es-module-loader-0.17.11/ 0000775 0000000 0000000 00000000000 12656641603 0015030 5 ustar 00root root 0000000 0000000 es-module-loader-0.17.11/.agignore 0000664 0000000 0000000 00000000006 12656641603 0016620 0 ustar 00root root 0000000 0000000 dist/
es-module-loader-0.17.11/.gitignore 0000664 0000000 0000000 00000000073 12656641603 0017020 0 ustar 00root root 0000000 0000000 node_modules
bower_components
tmp
coverage
.DS_Store
*.sw?
es-module-loader-0.17.11/.jshintrc 0000664 0000000 0000000 00000000257 12656641603 0016661 0 ustar 00root root 0000000 0000000 {
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true
}
es-module-loader-0.17.11/.travis.yml 0000664 0000000 0000000 00000001575 12656641603 0017151 0 ustar 00root root 0000000 0000000 ---
git:
depth: 1
language: node_js
node_js:
- '0.10'
- '0.11'
- '0.12'
- 'iojs'
- 'stable'
env:
global:
- SAUCE_LABS=false PARSER=false OPTIONS=""
matrix:
- PARSER="traceur"
- PARSER="babel"
- PARSER="typescript"
matrix:
include:
- node_js: "0.10"
env: SAUCE_LABS=true PARSER="traceur"
- node_js: "0.10"
env: SAUCE_LABS=true PARSER="babel"
- node_js: "0.10"
env: SAUCE_LABS=true PARSER="typescript"
#- node_js: "0.10"
# env: SAUCE_LABS=true PARSER="traceur" OPTIONS="--ie8"
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm update -g
- npm install -g karma-cli grunt-cli
before_script:
- grunt
script:
- npm run test:node
- npm run test:browser-$PARSER
- "[ $SAUCE_LABS == false ] || npm run test:browser-$PARSER -- --saucelabs $OPTIONS"
es-module-loader-0.17.11/Gruntfile.js 0000664 0000000 0000000 00000004210 12656641603 0017322 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*\n * <%= pkg.name %> v<%= pkg.version %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */'
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
dist: [
'lib/index.js'
]
},
concat: {
dist: {
files: {
'dist/<%= pkg.name %>.src.js': [
'src/url-polyfill.js',
'src/wrapper-start.js',
'src/loader.js',
'src/dynamic-only.js',
'src/system.js',
'src/system-resolve.js',
'src/system-fetch.js',
'src/wrapper-end.js'
],
'dist/<%= pkg.name %>-dev.src.js': [
'src/url-polyfill.js',
'src/wrapper-start.js',
'src/loader.js',
'src/declarative.js',
'src/transpiler.js',
'src/system.js',
'src/system-resolve.js',
'src/system-fetch.js',
'src/module-tag.js',
'src/wrapper-end.js'
]
}
}
},
uglify: {
options: {
banner: '<%= meta.banner %>\n',
compress: {
drop_console: true
},
sourceMap: true
},
dist: {
options: {
banner: '<%= meta.banner %>\n'
},
src: 'dist/<%= pkg.name %>.src.js',
dest: 'dist/<%= pkg.name %>.js'
},
devDist: {
options: {
banner: '<%= meta.banner %>\n'
},
src: 'dist/<%= pkg.name %>-dev.src.js',
dest: 'dist/<%= pkg.name %>-dev.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('lint', ['jshint']);
grunt.registerTask('compile', ['concat']);
grunt.registerTask('default', [/*'jshint', */'concat', 'uglify']);
};
es-module-loader-0.17.11/LICENSE-MIT 0000664 0000000 0000000 00000002075 12656641603 0016470 0 ustar 00root root 0000000 0000000 Copyright (c) 2013-2016 Guy Bedford, Luke Hoban, Addy Osmani
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
es-module-loader-0.17.11/README.md 0000664 0000000 0000000 00000016413 12656641603 0016314 0 ustar 00root root 0000000 0000000 # ES6 Module Loader Polyfill [![Build Status][travis-image]][travis-url]
_For upgrading to ES6 Module Loader 0.17, [read the release notes here](https://github.com/ModuleLoader/es6-module-loader/releases/tag/v0.17.0)._
Dynamically loads ES6 modules in browsers and [NodeJS](#nodejs-use) with support for loading existing and custom module formats through loader hooks.
This project implements dynamic module loading through `System` exactly to the previous ES6-specified loader API at [2014-08-24 ES6 Specification Draft Rev 27, Section 15](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27). The specification for the module loader was removed from the ES6/ES2015 specification in 2014, and a new loader implementing the new draft [WhatWG loader spec](https://github.com/whatwg/loader) is pending alpha release on the [1.0 branch](https://github.com/ModuleLoader/es6-module-loader/tree/1.0).
* Provides an asynchronous loader (`System.import`) to [dynamically load ES6 modules](#getting-started).
* Supports [Traceur](https://github.com/google/traceur-compiler), [Babel](http://babeljs.io/) and [TypeScript](https://github.com/Microsoft/TypeScript/) for compiling ES6 modules and syntax into ES5 in the browser with source map support.
* Fully supports [ES6 circular references and live bindings](docs/circular-references-bindings.md).
* Includes [`paths` implementation](docs/loader-config.md).
* Can be used as a [tracing tool](docs/tracing-api.md) for static analysis of modules.
* Supports IE8+, with IE9+ support for ES6 development without pre-compilation.
* The minified production loader is under 5KB minified and gzipped, making it suitable for production use, provided that modules are [built into ES5 making them independent of Traceur](docs/production-workflows.md).
* Supports declaring modules with `
```
To use Babel, load Babel's `browser.js` instead and set the transpiler to `babel` with the loader configuration:
```html
```
To use TypeScript, set the transpiler to `typescript` in the loader configuration:
```html
```
Then we can write any ES6 module:
mymodule.js:
```javascript
export class q {
constructor() {
console.log('this is an es6 class!');
}
}
```
and load the module dynamically in the browser
```html
```
The dynamic loader returns a `Module` object, which contains getters for the named exports (in this case, `q`).
See the [demo folder](https://github.com/ModuleLoader/es6-module-loader/blob/master/demo/index.html) in this repo for a working example demonstrating module loading in the browser both with `System.import` and with the module-type script tag.
Although `System.import()` does not support the import of multiple modules defined in an array, because `System.import()` returns a Promise, this can be achieved by creating an array of `System.import`s and using `Promise.all()`.
#### Setting transpilation options
If using Traceur, these can be set with:
```javascript
System.traceurOptions = {...};
```
With Babel:
```javascript
System.babelOptions = {...};
```
With TypeScript:
```javascript
System.typescriptOptions = {...};
```
#### Module Tag
The module tag is specified to provide a new entry point for using module syntax in browsers. This is because normal `
```
Because it is only possible to load ES6 modules with this tag, it is not suitable for production use in this way.
#### NodeJS Use
```
npm install es6-module-loader babel traceur typescript
```
It is important that Babel, Traceur or TypeScript is installed into the path in order to be found, since these are no longer project dependencies.
For use in NodeJS, the `Loader` and `System` globals are provided as exports:
index.js:
```javascript
var System = require('es6-module-loader').System;
/*
* Include:
* System.transpiler = 'babel';
* to use Babel instead of Traceur or
* System.transpiler = 'typescript';
* to use TypeScript
*/
System.import('some-module').then(function(m) {
console.log(m.p);
});
```
some-module.js:
```javascript
export var p = 'NodeJS test';
```
Running the application:
```
> node index.js
NodeJS test
```
## Contributing
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).
_Also, please don't edit files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "lib" subdirectory!_
## Testing
- `npm run test:node` will use node to to run the tests
- `npm run test:browser` will run `npm run test:browser-babel`, `npm run test:browser-traceur` and `npm run test:browser-typescript`
- `npm run test:browser-[transpiler]` use karma to run the tests with Traceur, Babel or TypeScript.
- `npm run test:browser:perf` will use karma to run benchmarks
`npm run test:browser-[transpiler]` supports options after a double dash (`--`) :
- You can use the `--polyfill` option to test the code with polyfill.
- You can use the `--coverage` option to test and extract coverage info.
- You can use the `--ie8` option to test the code in the ie8 scope only.
- You can use the `--saucelabs` option to use karma and saucelabs to run the tests in various browsers.
Note: you will need to export your username and key to launch it.
```sh
export SAUCE_USERNAME={your user name} && export SAUCE_ACCESS_KEY={the access key that you see once logged in}
npm run test:browsers -- --saucelabs
```
## Credit
Copyright (c) 2015 Luke Hoban, Addy Osmani, Guy Bedford
## License
Licensed under the MIT license.
[travis-url]: https://travis-ci.org/ModuleLoader/es6-module-loader
[travis-image]: https://travis-ci.org/ModuleLoader/es6-module-loader.svg?branch=master
[saucelabs-url]: https://saucelabs.com/u/guybedford
[saucelabs-image]: https://saucelabs.com/buildstatus/guybedford
es-module-loader-0.17.11/demo/ 0000775 0000000 0000000 00000000000 12656641603 0015754 5 ustar 00root root 0000000 0000000 es-module-loader-0.17.11/demo/index.html 0000664 0000000 0000000 00000003234 12656641603 0017753 0 ustar 00root root 0000000 0000000
Module Loader Polyfill
Check the console in your browser developer tools! This code is currently loaded in the page:
<script src="../node_modules/traceur/bin/traceur.js"></script>
<script src="../dist/es6-module-loader-dev.js"></script>
<script type="module">
import { hello } from 'test1.js';
console.log(hello); // -> world
// es6 syntax
var a, b;
[a, b] = [1, 2];
console.log(a); // 1
</script>
Click on the button below and this function will be run:
<script>
function buttonClick() {
// dynamic loading API
System.import('test2.js').then(function(module) {
new module.Foo();
});
}
</script>
Note that if you click on the button again, a new Foo module will be created, but 'test2' will not be reloaded.