es6-module-loader
Advanced tools
Comparing version 0.4.3 to 0.5.0
{ | ||
"name": "es6-module-loader", | ||
"description": "An ES6 Module Loader shim", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/ModuleLoader/es6-module-loader", | ||
@@ -27,3 +27,4 @@ "author": { | ||
"grunt-contrib-uglify": "~0.2.2", | ||
"grunt-contrib-jshint": "~0.6.0" | ||
"grunt-contrib-jshint": "~0.6.0", | ||
"grunt-contrib-concat": "~0.3.0" | ||
}, | ||
@@ -41,3 +42,3 @@ "keywords": [ | ||
"scripts": { | ||
"test": "grunt test" | ||
"test": "node test/test" | ||
}, | ||
@@ -48,4 +49,4 @@ "files": [ | ||
"dependencies": { | ||
"traceur": "0.0.13" | ||
"traceur": "0.0.25" | ||
} | ||
} |
103
README.md
@@ -5,12 +5,14 @@ # ES6 Module Loader Polyfill | ||
The complete combined polyfill comes to 16KB minified, making it suitable for production use, provided that modules are built into ES5 making them independent of Traceur. Build workflows are currently in progress. | ||
The complete combined polyfill comes to 15KB minified, making it suitable for production use, provided that modules are built into ES5 making them independent of Traceur. Build workflows are currently in progress. | ||
* Provides an asynchronous loader (`System.import`) to [dynamically load ES6 modules](#getting-started) in all modern browsers including IE8+ | ||
* Provides an asynchronous loader (`System.import`) to [dynamically load ES6 modules](#getting-started) in all modern browsers including IE9+. | ||
* Uses [Traceur](https://github.com/google/traceur-compiler) for compiling ES6 modules and syntax into ES5 in the browser with source map support | ||
* Adds support for the `<script type="module">` tag allowing inline module loading. | ||
* Uses [Traceur](https://github.com/google/traceur-compiler) for compiling ES6 modules and syntax into ES5 in the browser with source map support | ||
* Loader hooks can be used to [extend the System loader with custom functionality](#creating-a-custom-loader) | ||
* Fully compatible with NodeJS allowing for spec-compliant server-side module loading | ||
* [Compatible with NodeJS](#nodejs-support) allowing for server-side module loading | ||
See the [demo folder](https://github.com/ModuleLoader/es6-module-loader/blob/master/demo/index.html) in this repo for a working example demonstrating both module loading the module tag. | ||
See the [demo folder](https://github.com/ModuleLoader/es6-module-loader/blob/master/demo/index.html) in this repo for a working example demonstrating both module loading the module tag in the browser. | ||
For an example of a universal module loader based on this polyfill for loading AMD, CommonJS and globals, see [SystemJS](https://github.com/systemjs/systemjs). | ||
_Note that while the specification draft has been written, it is still subject to change._ | ||
@@ -30,10 +32,14 @@ | ||
Then include the `es6-module-loader.js` file on its own in the page: | ||
If using ES6 syntax (optional), include Traceur in the page first: | ||
```html | ||
<script src="traceur.js"></script> | ||
``` | ||
Then include `es6-module-loader.js`: | ||
```html | ||
<script src="es6-module-loader.js"></script> | ||
``` | ||
Traceur will be downloaded only when needed for ES6 syntax parsing, detected as the existence of module syntax, or as specified by the `metadata.es6 = true` property. | ||
Write an ES6 module: | ||
@@ -98,3 +104,3 @@ | ||
Module code is treated differently to scripts due to the nature of exports and imports. This is why the `<script type="module">` tag (which will become the `<module>` tag in modern browsers) is introduced to distinguish script code from module code. Scripts cannot export or import, but are able to use the dynamic loader `System.import(...)`. | ||
Module code is treated differently to scripts due to the nature of exports and imports. This is why the `<script type="module">` tag is introduced to distinguish script code from module code. Scripts cannot export or import, but are able to use the dynamic loader `System.import(...)`. | ||
@@ -129,3 +135,3 @@ ### Module Names and baseURL | ||
} | ||
}; | ||
@@ -279,24 +285,28 @@ exports.another = {}; | ||
``` | ||
npm install es6-module-loader | ||
``` | ||
For use in NodeJS, the `Module`, `Loader` and `System` globals are provided as exports: | ||
index.js: | ||
```javascript | ||
var System = require('es6-module-loader').System; | ||
System.import('some-module').then(callback); | ||
System.import('some-module').then(function(m) { | ||
console.log(m.p); | ||
}); | ||
``` | ||
Traceur support requires `npm install traceur`, allowing ES6 syntax in NodeJS: | ||
some-module.js: | ||
```javascript | ||
var System = require('es6-module-loader').System; | ||
export var p = 'NodeJS test'; | ||
``` | ||
System.import('es6-file').then(function(module) { | ||
module.classMethod(); | ||
}); | ||
Running the application: | ||
``` | ||
> node index.js | ||
NodeJS test | ||
``` | ||
### Custom Traceur Location | ||
To set a custom path to the Traceur parser, specify the `data-traceur-src` attribute on the `<script>` tag used to include the module loader. | ||
## Creating a Custom Loader | ||
@@ -387,54 +397,6 @@ | ||
Notes on the exact specification implementation differences are included below. | ||
See the source of https://github.com/ModuleLoader/es6-module-loader/blob/master/lib/es6-module-loader.js, which contains comments detailing the exact specification notes and design decisions. | ||
### Loader Polyfill | ||
* Implemented exactly to the 2013-12-02 Specification Draft - | ||
https://github.com/jorendorff/js-loaders/blob/e60d3651/specs/es6-modules-2013-12-02.pdf | ||
with the only exceptions as described here | ||
* Abstract functions have been combined where possible, and their associated functions | ||
commented | ||
* Declarative Module Support is entirely disabled, and an error will be thrown if | ||
the instantiate loader hook returns undefined | ||
* With this assumption, instead of Link, LinkDynamicModules is run directly | ||
* ES6 support is thus provided through the instantiate function of the System loader | ||
* EnsureEvaluated is removed, but may in future implement dynamic execution pending | ||
issue - https://github.com/jorendorff/js-loaders/issues/63 | ||
* Realm implementation is entirely omitted. As such, Loader.global and Loader.realm | ||
accessors will throw errors, as well as Loader.eval | ||
* Loader module table iteration currently not yet implemented | ||
### System Loader Implementation | ||
* Implemented to https://github.com/jorendorff/js-loaders/blob/master/browser-loader.js, | ||
except for Instantiate function | ||
* Instantiate function determines if ES6 module syntax is being used, if so parses with | ||
Traceur and returns a dynamic InstantiateResult for loading ES6 module syntax in ES5. | ||
* Custom loaders thus can be implemented by using this System.instantiate function as | ||
the fallback loading scenario, after other module format detections. | ||
* Traceur is loaded dynamically when module syntax is detected by a regex (with over- | ||
classification), either from require('traceur') on the server, or the | ||
'data-traceur-src' property on the current script in the browser, or if not set, | ||
'traceur.js' in the same URL path as the current script in the browser. | ||
* The `<script type="module">` tag is supported, but the `<module>` tag is not | ||
* The implemented ondemand / paths functionality is provisional and subject to change | ||
To follow the current the specification changes, see the marked issues https://github.com/ModuleLoader/es6-module-loader/issues?labels=specification&page=1&state=open. | ||
## Projects using us | ||
* [SystemJS](https://github.com/systemjs/systemjs) provides the `System` loader with AMD, CommonJS and global module support, as well as semver version management and a RequireJS-style plugin system and map configuration. | ||
## Contributing | ||
@@ -446,2 +408,3 @@ In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt). | ||
## Release History | ||
* 0.5.0 Traceur update and separation, deferred execution pipeline, IE9 compatibility fixes, code separation | ||
* 0.4.3 ES6 detection fix, Traceur runtime inclusion | ||
@@ -448,0 +411,0 @@ * 0.4.2 promises fixes, __moduleName support, btoa language fixes, instantiation using normalized names as arguments |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
15785
4
2
0
420
2
+ Addedtraceur@0.0.25(transitive)
- Removedtraceur@0.0.13(transitive)
Updatedtraceur@0.0.25