guybedford e182da3249 docs
2015-06-04 14:50:09 +02:00
2015-06-04 14:50:07 +02:00
2015-06-04 14:50:09 +02:00
2015-06-04 14:49:54 +02:00
2015-06-02 22:59:36 +02:00
2015-04-09 12:27:13 +02:00
2015-02-12 16:24:38 +02:00
2015-05-31 18:19:13 +02:00
2015-06-04 14:50:09 +02:00

SystemJS

Gitter

For upgrading to SystemJS 0.17, see the SystemJS 0.17 release upgrade notes for more information, or read the updated SystemJS Overview guide.

Universal dynamic module loader - loads ES6 modules, AMD, CommonJS and global scripts in the browser and NodeJS. Works with both Traceur and Babel.

Built on top of the ES6 Module Loader polyfill coming to under 12KB minified and gzipped.

Runs in IE8+ and NodeJS.

For discussion, see the Google Group.

For a list of guides and tools, see the Third-Party Resources Wiki.

Documentation

Basic Use

Browser

<script src="system.js"></script>
<script>
  // set our baseURL reference path
  System.config({
    baseURL: '/app'
  });

  // loads /app/main.js
  System.import('main.js');
</script>

To load ES6, locate traceur.js (eg from https://github.com/jmcriffey/bower-traceur) in the baseURL path and it will be loaded when needed.

For use with Babel, locate the browser.js file at babel.js in the baseURL and set:

<script>
  System.transpiler = 'babel';
</script>

Alternatively a custom path to Babel or Traceur can also be set through paths:

System.config({
  paths: {
    traceur: 'path/to/traceur.js'
  }
});

NodeJS

To load modules in NodeJS, install SystemJS with:

  npm install systemjs traceur

(making sure to also install Traceur or Babel as needed, as they are not included as dependencies as of SystemJS 0.16)

We can then load modules equivalently to in the browser:

var System = require('systemjs');

/* 
 * Include
 *   System.transpiler = 'babel';
 * to use Babel instead of Traceur
 */

// loads './app.js' from the current directory
System.import('./app').then(function(m) {
  console.log(m);
});

Plugins

Supported loader plugins:

  • CSS System.import('my/file.css')
  • Image System.import('some/image.png!image')
  • JSON System.import('some/data.json')
  • Text System.import('some/text.txt!text')

Additional Plugins:

  • CoffeeScript System.import('./test.coffee')
  • Jade
  • JSX System.import('template.jsx')
  • Markdown System.import('app/some/project/README.md').then(function(html) {})
  • WebFont System.import('google Port Lligat Slab, Droid Sans !font')
  • Handlebars System.import('template.hbs!')
  • Ember Handlebars System.import('template.hbs!')

Read about using plugins here Read the guide here on creating plugins.

Running the tests

To install the dependencies correctly, run bower install from the root of the repo, then open test/test.html in a browser with a local server or file access flags enabled.

License

MIT

Description
Dynamic ES module loader
Readme MIT 18 MiB
Languages
JavaScript 96.4%
HTML 3.6%