@@ -28,14 +28,22 @@ For an example of a universal module loader based on this polyfill for loading A
28
28
29
29
### Getting Started
30
30
31
- If using ES6 syntax (optional), include ` traceur.js ` in the page first then include ` es6-module-loader.js ` :
31
+ If using ES6 syntax (optional), include ` traceur.js ` or ` 6to5.js ` in the page first then include ` es6-module-loader.js ` :
32
32
33
33
``` html
34
34
<script src =" traceur.js" ></script >
35
35
<script src =" es6-module-loader.js" ></script >
36
36
```
37
37
38
- Write an ES6 module:
38
+ To use 6to5, set the parser to ` 6to5 ` with the loader configuration:
39
+
40
+ ``` html
41
+ <script >
42
+ System .parser = ' 6to5' ;
43
+ </script >
44
+ ```
45
+
46
+ Then we can write any ES6 module:
39
47
40
48
mymodule.js:
41
49
``` javascript
@@ -46,7 +54,7 @@ mymodule.js:
46
54
}
47
55
```
48
56
49
- We can then load the module with the dynamic loader:
57
+ and load the module dynamically in the browser
50
58
51
59
``` html
52
60
<script >
@@ -86,6 +94,11 @@ For use in NodeJS, the `Loader` and `System` globals are provided as exports:
86
94
index.js:
87
95
``` javascript
88
96
var System = require (' es6-module-loader' ).System ;
97
+ /*
98
+ * Include:
99
+ * System.parser = '6to5';
100
+ * to use 6to5 instead of Traceur
101
+ */
89
102
90
103
System .import (' some-module' ).then (function (m ) {
91
104
console .log (m .p );
@@ -132,7 +145,7 @@ Note: you will need to export your username and key to launch it.
132
145
```
133
146
134
147
## Credit
135
- Copyright (c) 2014 Luke Hoban, Addy Osmani, Guy Bedford
148
+ Copyright (c) 2015 Luke Hoban, Addy Osmani, Guy Bedford
136
149
137
150
## License
138
151
Licensed under the MIT license.
0 commit comments