Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit f99de73

Browse files
committed
Merge pull request #109 from guybedford/master
Use when.js polyfill
2 parents 42354d1 + 9aeaea3 commit f99de73

5 files changed

Lines changed: 946 additions & 156 deletions

File tree

Gruntfile.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,40 @@ module.exports = function (grunt) {
2323
concat: {
2424
dist: {
2525
src: [
26-
'lib/promise.js',
27-
'lib/module.js',
28-
'lib/loader.js',
29-
'lib/system.js'
26+
'lib/promise.js',
27+
'lib/module.js',
28+
'lib/loader.js',
29+
'lib/system.js'
3030
],
3131
dest: 'tmp/<%= pkg.name %>.js'
32+
},
33+
polyfillOnly: {
34+
src: [
35+
'lib/module.js',
36+
'lib/loader.js',
37+
'lib/system.js'
38+
],
39+
dest: 'tmp/<%= pkg.name %>-sans-promises.js'
3240
}
3341
},
3442
uglify: {
3543
options: {
3644
banner: '<%= meta.banner %>'
3745
},
3846
dist: {
39-
src: 'tmp/<%= pkg.name %>.js',
40-
dest: 'dist/<%= pkg.name %>.js'
47+
src: 'tmp/<%= pkg.name %>.js',
48+
dest: 'dist/<%= pkg.name %>.js'
4149
},
4250
traceur: {
43-
options: {
44-
banner: '/*\n Traceur Compiler 0.0.25 - https://github.com/google/traceur-compiler \n*/\n'
45-
},
46-
src: 'lib/traceur.js',
47-
dest: 'dist/traceur.js'
51+
options: {
52+
banner: '/*\n Traceur Compiler 0.0.25 - https://github.com/google/traceur-compiler \n*/\n'
53+
},
54+
src: 'lib/traceur.js',
55+
dest: 'dist/traceur.js'
56+
},
57+
polyfillOnly: {
58+
src: 'tmp/<%= pkg.name %>-sans-promises.js',
59+
dest: 'dist/<%= pkg.name %>-sans-promises.js'
4860
}
4961
}
5062
});

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
Dynamically loads ES6 modules in NodeJS and current browsers.
44

5-
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.
6-
75
* Provides an asynchronous loader (`System.import`) to [dynamically load ES6 modules](#getting-started) in all modern browsers including IE9+.
86
* Uses [Traceur](https://github.com/google/traceur-compiler) for compiling ES6 modules and syntax into ES5 in the browser with source map support
97
* Adds support for the `<script type="module">` tag allowing inline module loading.
108
* Loader hooks can be used to [extend the System loader with custom functionality](#creating-a-custom-loader)
119
* [Compatible with NodeJS](#nodejs-support) allowing for server-side module loading
10+
* Polyfills ES6 Promises in the browser with a bundled [when.js](https://github.com/cujojs/when/blob/master/docs/es6-promise-shim.md) implementation.
11+
12+
The complete combined polyfill comes to 22KB 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.
1213

1314
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.
1415

@@ -351,10 +352,9 @@ function locate(load) {
351352

352353
function fetch(load) {
353354
// return a promise. Alternatively, just use the system fetch
354-
// promise -return System.fetch(load)
355-
var defer = MyPromiseLibrary.createDeferred();
356-
myXhr.get(load.address, defer.resolve, defer.reject);
357-
return defer.promise;
355+
return new Promise(function(resolve, reject) {
356+
myXhr.get(load.address, resolve, reject);
357+
});
358358
}
359359

360360
function translate(load) {
@@ -414,7 +414,7 @@ _Also, please don't edit files in the "dist" subdirectory as they are generated
414414
## Credit
415415
Copyright (c) 2014 Luke Hoban, Addy Osmani, Guy Bedford
416416

417-
Promises Integration from [Promiscuous](https://github.com/RubenVerborgh/promiscuous/), Copyright (c) 2013-2014 Ruben Verborgh, MIT License
417+
ES6 Promises integration from [when.js](https://github.com/cujojs/when/blob/master/docs/es6-promise-shim.md), Copyright (c) 2010-2014 Brian Cavalier, John Hann, MIT License
418418

419419
## License
420420
Licensed under the MIT license.

dist/es6-module-loader-sans-promises.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)