mirror of
https://github.com/systemjs/systemjs.git
synced 2026-02-01 15:59:54 +00:00
named register to define into plain
This commit is contained in:
parent
47f7429ea2
commit
bc63fbb04d
@ -2,8 +2,8 @@
|
||||
* SystemJS named register extension
|
||||
* Supports System.register('name', [..deps..], function (_export, _context) { ... })
|
||||
*
|
||||
* Names are resolved origin-relative, so
|
||||
* System.register(['x']) must be imported as System.import('/x')
|
||||
* Names are written to the registry as-is
|
||||
* System.register('x', ...) can be imported as System.import('x')
|
||||
*/
|
||||
(function () {
|
||||
const systemJSPrototype = System.constructor.prototype;
|
||||
@ -15,7 +15,15 @@
|
||||
if (typeof name !== 'string')
|
||||
return register.apply(this, arguments);
|
||||
|
||||
registerRegistry['bundle:' + name] = [deps, declare];
|
||||
registerRegistry[name] = [deps, declare];
|
||||
};
|
||||
|
||||
const resolve = systemJSPrototype.resolve;
|
||||
systemJSPrototype.resolve = function (id, parentURL) {
|
||||
if (id[0] === '/' || id[0] === '.' && (id[1] === '/' || id[1] === '.' && id[2] === '/'))
|
||||
return resolve.call(this, id, parentURL);
|
||||
if (registerRegistry[id])
|
||||
return id;
|
||||
};
|
||||
|
||||
const instantiate = systemJSPrototype.instantiate;
|
||||
|
||||
@ -2,7 +2,7 @@ suite('Named System.register', function() {
|
||||
test('Loading a named System.register bundle', function () {
|
||||
return System.import('./fixtures/browser/named-bundle.js').then(function (m) {
|
||||
assert.equal(Object.keys(m).length, 0);
|
||||
return System.import('bundle:a');
|
||||
return System.import('a');
|
||||
})
|
||||
.then(function (m) {
|
||||
assert.equal(m.a, 'b');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user