aboutsummaryrefslogtreecommitdiff
path: root/node_modules/systemjs/README.md
blob: afe998a27674b8b5d0d55b37b4f670715fc39f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
SystemJS
========

[![Build Status][travis-image]][travis-url]
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/systemjs/systemjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 
[![Support](https://supporterhq.com/api/b/33df4abbec4d39260f49015d2457eafe/SystemJS)](https://supporterhq.com/support/33df4abbec4d39260f49015d2457eafe/SystemJS)

Universal dynamic module loader - loads ES6 modules, AMD, CommonJS and global scripts in the browser and NodeJS.

* [Loads any module format](docs/module-formats.md) with [exact circular reference and binding support](https://github.com/ModuleLoader/es6-module-loader/blob/v0.17.0/docs/circular-references-bindings.md).
* Loads [ES6 modules compiled into the `System.register` bundle format for production](docs/production-workflows.md), maintaining circular references support.
* Supports RequireJS-style [map](docs/overview.md#map-config), [paths](https://github.com/ModuleLoader/es6-module-loader/blob/master/docs/loader-config.md#paths-implementation), [bundles](docs/production-workflows.md#bundle-extension) and [global shims](docs/module-formats.md#shim-dependencies).
* [Loader plugins](docs/overview.md#plugin-loaders) allow custom transpilation or asset loading.

Built to the format ES6-specified loader API from [ES6 Specification Draft Rev 27, Section 15](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27),
and will be updated to the [WhatWG loader API](https://whatwg.github.io/loader/) as soon as it can be considered stable for implementation.

~19KB minified and gzipped, runs in IE8+ and NodeJS.

For discussion, join the [Gitter Room](https://gitter.im/systemjs/systemjs).

Documentation
---

* [ES6 Modules Overview](docs/es6-modules-overview.md)
* [SystemJS Overview](docs/overview.md)
* [Config API](docs/config-api.md)
* [Module Formats](docs/module-formats.md)
* [Production Workflows](docs/production-workflows.md)
* [System API](docs/system-api.md)
* [Creating Plugins](docs/creating-plugins.md)

Basic Use
---

### Browser

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

  // loads /js/main.js
  SystemJS.import('main.js');
</script>
```

The above will support loading all module formats, including ES Modules transpiled into the System.register format.

To load ES6 code with in-browser transpilation, configure one of the following transpiler plugins:

* [Babel](https://github.com/systemjs/plugin-babel)
* [TypeScript](https://github.com/frankwallis/plugin-typescript)
* [Traceur](http://github.com/systemjs/plugin-traceur)

### Promise Polyfill

SystemJS relies on `Promise` being present in the environment.

For the best performance in IE and older browsers, it is advisable to load a polyfill like [Bluebird](https://github.com/petkaantonov/bluebird) or [es6-promise](https://github.com/stefanpenner/es6-promise) before SystemJS.

Otherwise, when Promise is not available, SystemJS will attempt to load the `system-polyfills.js` file located in the dist folder which contains the when.js Promise polyfill.

### NodeJS

To load modules in NodeJS, install SystemJS with:

```
  npm install systemjs
```

If transpiling ES6, also install the transpiler plugin, following the instructions from the transpiler project page.

We can then load modules equivalently in NodeJS as we do in the browser:

```javascript
var SystemJS = require('systemjs');

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

If you are using jspm as a package manager you will also need to load the generated configuration.
The best way to do this in node is to get your `System` instance through jspm, which will automatically load your config correctly for you:

```js
var Loader = require('jspm').Loader;
var SystemJS = new Loader();

SystemJS.import('lodash').then(function (_) {
 console.log(_);
});
```

### Plugins

Supported loader plugins:

* [CSS](https://github.com/systemjs/plugin-css)
* [LESS](https://github.com/systemjs/plugin-less)
* [Image](https://github.com/systemjs/plugin-image)
* [JSON](https://github.com/systemjs/plugin-json)
* [Text](https://github.com/systemjs/plugin-text)
* [Node Binary](https://github.com/systemjs/plugin-node-binary)

Additional Plugins:

* [Audio](https://github.com/ozsay/plugin-audio)
* [CoffeeScript](https://github.com/forresto/plugin-coffee)
* [Ember Handlebars](https://github.com/n-fuse/plugin-ember-hbs)
* [Handlebars](https://github.com/davis/plugin-hbs)
* [HTML](https://github.com/Hypercubed/systemjs-plugin-html/)
* [Image (lazy)](https://github.com/laurentgoudet/plugin-lazyimage)
* [Jade](https://github.com/johnsoftek/plugin-jade)
* [Jade VirtualDOM](https://github.com/WorldMaker/system-jade-virtualdom)
* [jst](https://github.com/podio/plugin-jst)
* [JSX](https://github.com/floatdrop/plugin-jsx)
* [Markdown](https://github.com/guybedford/plugin-md)
* [raw](https://github.com/matthewbauer/plugin-raw)
* [SASS](https://github.com/screendriver/plugin-sass)
* [SCSS](https://github.com/kevcjones/plugin-scss)
* [sofe](https://github.com/CanopyTax/sofe)
* [SVG](https://github.com/vuzonp/systemjs-plugin-svg)
* [WebFont](https://github.com/guybedford/plugin-font)
* [WebWorkers](https://github.com/casperlamboo/plugin-worker)
* [YAML](https://github.com/tb/plugin-yaml)

Guides:

* [Using plugins](docs/overview.md#plugin-loaders)
* [Creating plugins](docs/creating-plugins.md)

#### 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

[travis-url]: https://travis-ci.org/systemjs/systemjs
[travis-image]: https://travis-ci.org/systemjs/systemjs.svg?branch=master