A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/guybedford/cjs below:

guybedford/cjs: CommonJS loader plugin for RequireJS

CommonJS Loader Plugin for RequireJS

Load CommonJS modules without needing to convert them to AMD.

AMD and CommonJS are actually incredibly similar formats so this plugin is only 10 lines long.

To load a CommonJS module in RequireJS simply do -

  require(['cjs!my-commonjs-module'], function(mymodule) {
  });

If your module looks like:

  var someDep = require('a-dependency');
  exports.out = 'asdf';

Then it is dynamically converted into:

  define(function(require, exports, module) {
    (function() {
      var define = undefined; // ensures any amd detection is disabled
      var someDep = require('cjs!a-dependency');
      exports.out = 'asdf';
    })();
  });

which is the AMD module format.

Dependencies are naturally handled by referring back to the plugin.

Supports:

Built with the AMD-Loader plugin helper.

If not using package management, ensure that the AMD-Loader plugin is installed.

If using bower, include the map or paths configurations:

  paths: {
    cjs: 'cjs/cjs',
    'amd-loader': 'amd-loader/amd-loader'
  }

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4