Skip to content

Commit fba60cb

Browse files
committed
update es6-module-loader 0.5, AMD compatibility layer fixes
1 parent 71c3d91 commit fba60cb

13 files changed

+194
-74
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Features include:
1313
* **[Plugins](#plugins):** A dynamic plugin system for modular loading rules.
1414
* **[Bundles](#production-bundles):** Dynamically link requires to bundle files.
1515

16-
Designed to work with the [ES6 Module Loader polyfill](https://github.com/ModuleLoader/es6-module-loader) (17KB minified) for a combined footprint of 27KB. In future, with native implementations, the polyfill should no longer be necessary. Like jQuery provides for the DOM, this library can smoothes over inconsistiencies or missing practical functionality provided by the native System loader.
16+
Designed to work with the [ES6 Module Loader polyfill](https://github.com/ModuleLoader/es6-module-loader) (15KB minified) for a combined footprint of 27KB. In future, with native implementations, the ES6 Module Loader polyfill should no longer be necessary. As jQuery provides for the DOM, this library can smooth over inconsistiencies and missing practical functionality provided by the native System loader.
1717

1818
Runs in the browser and NodeJS.
1919

dist/system-amd-production.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,39 @@ global.upgradeSystemLoader = function() {
1111
delete global.upgradeSystemLoader;
1212
/*
1313
SystemJS Core
14-
Adds normalization to the import function, as well as __defaultOnly support
14+
Adds normalization to the import function, as well as __useDefault support
1515
*/
1616
(function() {
1717
// check we have System
1818
if (typeof System == 'undefined')
1919
throw 'System not defined. Include the `es6-module-loader.js` polyfill before SystemJS.';
2020

2121
/*
22-
__defaultOnly
22+
__useDefault
2323
2424
When a module object looks like:
2525
new Module({
26-
__defaultOnly: true,
26+
__useDefault: true,
2727
default: 'some-module'
2828
})
2929
3030
Then the import of that module is taken to be the 'default' export and not the module object itself.
3131
3232
Useful for module.exports = function() {} handling
3333
*/
34-
var checkDefaultOnly = function(module) {
34+
var checkUseDefault = function(module) {
3535
if (!(module instanceof Module)) {
3636
var out = [];
3737
for (var i = 0; i < module.length; i++)
38-
out[i] = checkDefaultOnly(module[i]);
38+
out[i] = checkUseDefault(module[i]);
3939
return out;
4040
}
41-
return module.__defaultOnly ? module['default'] : module;
41+
return module.__useDefault ? module['default'] : module;
4242
}
4343

44-
// a variation on System.get that does the __defaultOnly check
44+
// a variation on System.get that does the __useDefault check
4545
System.getModule = function(key) {
46-
return checkDefaultOnly(System.get(key));
46+
return checkUseDefault(System.get(key));
4747
}
4848

4949
// support the empty module, as a concept
@@ -57,10 +57,10 @@ global.upgradeSystemLoader = function() {
5757
return new Promise(function(resolve) {
5858
resolve(System.normalize.call(this, name, options && options.name, options && options.address))
5959
})
60-
// add defaultOnly support
60+
// add useDefault support
6161
.then(function(name) {
6262
return Promise.resolve(systemImport.call(System, name, options)).then(function(module) {
63-
return checkDefaultOnly(module);
63+
return checkUseDefault(module);
6464
});
6565
});
6666
}
@@ -227,10 +227,10 @@ global.upgradeSystemLoader = function() {
227227
execute: function() {
228228
var args = [];
229229
for (var i = 0; i < arguments.length; i++)
230-
args.push(System.get(arguments[i]));
230+
args.push(System.getModule(arguments[i]));
231231

232232
var output = factory.apply(this, args);
233-
return new global.Module(output && output.__transpiledModule ? (delete output.__transpiledModule, output) : { __defaultOnly: true, 'default': output });
233+
return new global.Module(output && output.__esModule ? output : { __useDefault: true, 'default': output });
234234
}
235235
};
236236

@@ -244,6 +244,16 @@ global.upgradeSystemLoader = function() {
244244
// no translate at all
245245
System.translate = function() {}
246246

247+
// instantiate defaults to null
248+
System.instantiate = function() {
249+
return {
250+
deps: [],
251+
execute: function() {
252+
return new Module({});
253+
}
254+
};
255+
}
256+
247257

248258
/*
249259
AMD-compatible require
@@ -262,7 +272,7 @@ global.upgradeSystemLoader = function() {
262272

263273
// commonjs require
264274
else if (typeof names == 'string')
265-
return System.get(names);
275+
return System.getModule(names);
266276

267277
else
268278
throw 'Invalid require';

dist/system-amd-production.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)