Socket
Socket
Sign inDemoInstall

es6-module-loader

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-module-loader - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

9

package.json
{
"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"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc