Regenerate module loader after tool upgrades
This commit is contained in:
parent
e24b501c47
commit
4222d72bfe
File diff suppressed because one or more lines are too long
|
@ -1,74 +1,71 @@
|
|||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global.BrowserESModuleLoader = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
(global = global || self, global.BrowserESModuleLoader = factory());
|
||||
}(this, function () { 'use strict';
|
||||
|
||||
/*
|
||||
/*
|
||||
* Environment
|
||||
*/
|
||||
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
var isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
||||
var isWindows = typeof process !== 'undefined' && typeof process.platform === 'string' && process.platform.match(/^win/);
|
||||
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
var isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
||||
var isWindows = typeof process !== 'undefined' && typeof process.platform === 'string' && process.platform.match(/^win/);
|
||||
|
||||
var envGlobal = typeof self !== 'undefined' ? self : global;
|
||||
/*
|
||||
var envGlobal = typeof self !== 'undefined' ? self : global;
|
||||
|
||||
/*
|
||||
* Simple Symbol() shim
|
||||
*/
|
||||
var hasSymbol = typeof Symbol !== 'undefined';
|
||||
function createSymbol (name) {
|
||||
var hasSymbol = typeof Symbol !== 'undefined';
|
||||
function createSymbol (name) {
|
||||
return hasSymbol ? Symbol() : '@@' + name;
|
||||
}
|
||||
}
|
||||
|
||||
var toStringTag = hasSymbol && Symbol.toStringTag;
|
||||
var toStringTag = hasSymbol && Symbol.toStringTag;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
* Environment baseURI
|
||||
*/
|
||||
var baseURI;
|
||||
var baseURI;
|
||||
|
||||
// environent baseURI detection
|
||||
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||
// environent baseURI detection
|
||||
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||
baseURI = document.baseURI;
|
||||
|
||||
if (!baseURI) {
|
||||
var bases = document.getElementsByTagName('base');
|
||||
baseURI = bases[0] && bases[0].href || window.location.href;
|
||||
}
|
||||
}
|
||||
else if (typeof location != 'undefined') {
|
||||
}
|
||||
else if (typeof location != 'undefined') {
|
||||
baseURI = location.href;
|
||||
}
|
||||
}
|
||||
|
||||
// sanitize out the hash and querystring
|
||||
if (baseURI) {
|
||||
// sanitize out the hash and querystring
|
||||
if (baseURI) {
|
||||
baseURI = baseURI.split('#')[0].split('?')[0];
|
||||
var slashIndex = baseURI.lastIndexOf('/');
|
||||
if (slashIndex !== -1)
|
||||
baseURI = baseURI.substr(0, slashIndex + 1);
|
||||
}
|
||||
else if (typeof process !== 'undefined' && process.cwd) {
|
||||
}
|
||||
else if (typeof process !== 'undefined' && process.cwd) {
|
||||
baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd();
|
||||
if (isWindows)
|
||||
baseURI = baseURI.replace(/\\/g, '/');
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
throw new TypeError('No environment baseURI');
|
||||
}
|
||||
}
|
||||
|
||||
// ensure baseURI has trailing "/"
|
||||
if (baseURI[baseURI.length - 1] !== '/')
|
||||
// ensure baseURI has trailing "/"
|
||||
if (baseURI[baseURI.length - 1] !== '/')
|
||||
baseURI += '/';
|
||||
|
||||
/*
|
||||
/*
|
||||
* LoaderError with chaining for loader stacks
|
||||
*/
|
||||
var errArgs = new Error(0, '_').fileName == '_';
|
||||
function LoaderError__Check_error_message_for_loader_stack (childErr, newMessage) {
|
||||
var errArgs = new Error(0, '_').fileName == '_';
|
||||
function LoaderError__Check_error_message_for_loader_stack (childErr, newMessage) {
|
||||
// Convert file:/// URLs to paths in Node
|
||||
if (!isBrowser)
|
||||
newMessage = newMessage.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
|
||||
|
@ -93,14 +90,14 @@ function LoaderError__Check_error_message_for_loader_stack (childErr, newMessage
|
|||
err.originalErr = childErr.originalErr || childErr;
|
||||
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
var resolvedPromise$1 = Promise.resolve();
|
||||
var resolvedPromise = Promise.resolve();
|
||||
|
||||
/*
|
||||
/*
|
||||
* Simple Array values shim
|
||||
*/
|
||||
function arrayValues (arr) {
|
||||
function arrayValues (arr) {
|
||||
if (arr.values)
|
||||
return arr.values();
|
||||
|
||||
|
@ -127,35 +124,35 @@ function arrayValues (arr) {
|
|||
};
|
||||
};
|
||||
return iterable;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* 3. Reflect.Loader
|
||||
*
|
||||
* We skip the entire native internal pipeline, just providing the bare API
|
||||
*/
|
||||
// 3.1.1
|
||||
function Loader () {
|
||||
// 3.1.1
|
||||
function Loader () {
|
||||
this.registry = new Registry();
|
||||
}
|
||||
// 3.3.1
|
||||
Loader.prototype.constructor = Loader;
|
||||
}
|
||||
// 3.3.1
|
||||
Loader.prototype.constructor = Loader;
|
||||
|
||||
function ensureInstantiated (module) {
|
||||
function ensureInstantiated (module) {
|
||||
if (module === undefined)
|
||||
return;
|
||||
if (module instanceof ModuleNamespace === false && module[toStringTag] !== 'module')
|
||||
throw new TypeError('Module instantiation did not return a valid namespace object.');
|
||||
return module;
|
||||
}
|
||||
}
|
||||
|
||||
// 3.3.2
|
||||
Loader.prototype.import = function (key, parent) {
|
||||
// 3.3.2
|
||||
Loader.prototype.import = function (key, parent) {
|
||||
if (typeof key !== 'string')
|
||||
throw new TypeError('Loader import method must be passed a module key string');
|
||||
// custom resolveInstantiate combined hook for better perf
|
||||
var loader = this;
|
||||
return resolvedPromise$1
|
||||
return resolvedPromise
|
||||
.then(function () {
|
||||
return loader[RESOLVE_INSTANTIATE](key, parent);
|
||||
})
|
||||
|
@ -164,11 +161,11 @@ Loader.prototype.import = function (key, parent) {
|
|||
.catch(function (err) {
|
||||
throw LoaderError__Check_error_message_for_loader_stack(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
|
||||
});
|
||||
};
|
||||
// 3.3.3
|
||||
var RESOLVE = Loader.resolve = createSymbol('resolve');
|
||||
};
|
||||
// 3.3.3
|
||||
var RESOLVE = Loader.resolve = createSymbol('resolve');
|
||||
|
||||
/*
|
||||
/*
|
||||
* Combined resolve / instantiate hook
|
||||
*
|
||||
* Not in current reduced spec, but necessary to separate RESOLVE from RESOLVE + INSTANTIATE as described
|
||||
|
@ -177,27 +174,27 @@ var RESOLVE = Loader.resolve = createSymbol('resolve');
|
|||
* We implement RESOLVE_INSTANTIATE as a single hook instead of a separate INSTANTIATE in order to avoid
|
||||
* the need for double registry lookups as a performance optimization.
|
||||
*/
|
||||
var RESOLVE_INSTANTIATE = Loader.resolveInstantiate = createSymbol('resolveInstantiate');
|
||||
var RESOLVE_INSTANTIATE = Loader.resolveInstantiate = createSymbol('resolveInstantiate');
|
||||
|
||||
// default resolveInstantiate is just to call resolve and then get from the registry
|
||||
// this provides compatibility for the resolveInstantiate optimization
|
||||
Loader.prototype[RESOLVE_INSTANTIATE] = function (key, parent) {
|
||||
// default resolveInstantiate is just to call resolve and then get from the registry
|
||||
// this provides compatibility for the resolveInstantiate optimization
|
||||
Loader.prototype[RESOLVE_INSTANTIATE] = function (key, parent) {
|
||||
var loader = this;
|
||||
return loader.resolve(key, parent)
|
||||
.then(function (resolved) {
|
||||
return loader.registry.get(resolved);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function ensureResolution (resolvedKey) {
|
||||
function ensureResolution (resolvedKey) {
|
||||
if (resolvedKey === undefined)
|
||||
throw new RangeError('No resolution found.');
|
||||
return resolvedKey;
|
||||
}
|
||||
}
|
||||
|
||||
Loader.prototype.resolve = function (key, parent) {
|
||||
Loader.prototype.resolve = function (key, parent) {
|
||||
var loader = this;
|
||||
return resolvedPromise$1
|
||||
return resolvedPromise
|
||||
.then(function() {
|
||||
return loader[RESOLVE](key, parent);
|
||||
})
|
||||
|
@ -205,20 +202,20 @@ Loader.prototype.resolve = function (key, parent) {
|
|||
.catch(function (err) {
|
||||
throw LoaderError__Check_error_message_for_loader_stack(err, 'Resolving ' + key + (parent ? ' to ' + parent : ''));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
// 3.3.4 (import without evaluate)
|
||||
// this is not documented because the use of deferred evaluation as in Module.evaluate is not
|
||||
// documented, as it is not considered a stable feature to be encouraged
|
||||
// Loader.prototype.load may well be deprecated if this stays disabled
|
||||
/* Loader.prototype.load = function (key, parent) {
|
||||
// 3.3.4 (import without evaluate)
|
||||
// this is not documented because the use of deferred evaluation as in Module.evaluate is not
|
||||
// documented, as it is not considered a stable feature to be encouraged
|
||||
// Loader.prototype.load may well be deprecated if this stays disabled
|
||||
/* Loader.prototype.load = function (key, parent) {
|
||||
return Promise.resolve(this[RESOLVE_INSTANTIATE](key, parent || this.key))
|
||||
.catch(function (err) {
|
||||
throw addToError(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
|
||||
});
|
||||
}; */
|
||||
}; */
|
||||
|
||||
/*
|
||||
/*
|
||||
* 4. Registry
|
||||
*
|
||||
* Instead of structuring through a Map, just use a dictionary object
|
||||
|
@ -227,13 +224,13 @@ Loader.prototype.resolve = function (key, parent) {
|
|||
* Registry has been adjusted to use Namespace objects over ModuleStatus objects
|
||||
* as part of simplifying loader API implementation
|
||||
*/
|
||||
var iteratorSupport = typeof Symbol !== 'undefined' && Symbol.iterator;
|
||||
var REGISTRY = createSymbol('registry');
|
||||
function Registry() {
|
||||
var iteratorSupport = typeof Symbol !== 'undefined' && Symbol.iterator;
|
||||
var REGISTRY = createSymbol('registry');
|
||||
function Registry() {
|
||||
this[REGISTRY] = {};
|
||||
}
|
||||
// 4.4.1
|
||||
if (iteratorSupport) {
|
||||
}
|
||||
// 4.4.1
|
||||
if (iteratorSupport) {
|
||||
// 4.4.2
|
||||
Registry.prototype[Symbol.iterator] = function () {
|
||||
return this.entries()[Symbol.iterator]();
|
||||
|
@ -246,52 +243,52 @@ if (iteratorSupport) {
|
|||
return [key, registry[key]];
|
||||
}));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 4.4.4
|
||||
Registry.prototype.keys = function () {
|
||||
// 4.4.4
|
||||
Registry.prototype.keys = function () {
|
||||
return arrayValues(Object.keys(this[REGISTRY]));
|
||||
};
|
||||
// 4.4.5
|
||||
Registry.prototype.values = function () {
|
||||
};
|
||||
// 4.4.5
|
||||
Registry.prototype.values = function () {
|
||||
var registry = this[REGISTRY];
|
||||
return arrayValues(Object.keys(registry).map(function (key) {
|
||||
return registry[key];
|
||||
}));
|
||||
};
|
||||
// 4.4.6
|
||||
Registry.prototype.get = function (key) {
|
||||
};
|
||||
// 4.4.6
|
||||
Registry.prototype.get = function (key) {
|
||||
return this[REGISTRY][key];
|
||||
};
|
||||
// 4.4.7
|
||||
Registry.prototype.set = function (key, namespace) {
|
||||
};
|
||||
// 4.4.7
|
||||
Registry.prototype.set = function (key, namespace) {
|
||||
if (!(namespace instanceof ModuleNamespace || namespace[toStringTag] === 'module'))
|
||||
throw new Error('Registry must be set with an instance of Module Namespace');
|
||||
this[REGISTRY][key] = namespace;
|
||||
return this;
|
||||
};
|
||||
// 4.4.8
|
||||
Registry.prototype.has = function (key) {
|
||||
};
|
||||
// 4.4.8
|
||||
Registry.prototype.has = function (key) {
|
||||
return Object.hasOwnProperty.call(this[REGISTRY], key);
|
||||
};
|
||||
// 4.4.9
|
||||
Registry.prototype.delete = function (key) {
|
||||
};
|
||||
// 4.4.9
|
||||
Registry.prototype.delete = function (key) {
|
||||
if (Object.hasOwnProperty.call(this[REGISTRY], key)) {
|
||||
delete this[REGISTRY][key];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
/*
|
||||
* Simple ModuleNamespace Exotic object based on a baseObject
|
||||
* We export this for allowing a fast-path for module namespace creation over Module descriptors
|
||||
*/
|
||||
// var EVALUATE = createSymbol('evaluate');
|
||||
var BASE_OBJECT = createSymbol('baseObject');
|
||||
// var EVALUATE = createSymbol('evaluate');
|
||||
var BASE_OBJECT = createSymbol('baseObject');
|
||||
|
||||
// 8.3.1 Reflect.Module
|
||||
/*
|
||||
// 8.3.1 Reflect.Module
|
||||
/*
|
||||
* Best-effort simplified non-spec implementation based on
|
||||
* a baseObject referenced via getters.
|
||||
*
|
||||
|
@ -302,7 +299,7 @@ var BASE_OBJECT = createSymbol('baseObject');
|
|||
* Optional evaluation function provides experimental Module.evaluate
|
||||
* support for non-executed modules in registry.
|
||||
*/
|
||||
function ModuleNamespace (baseObject/*, evaluate*/) {
|
||||
function ModuleNamespace (baseObject/*, evaluate*/) {
|
||||
Object.defineProperty(this, BASE_OBJECT, {
|
||||
value: baseObject
|
||||
});
|
||||
|
@ -318,35 +315,34 @@ function ModuleNamespace (baseObject/*, evaluate*/) {
|
|||
else { */
|
||||
Object.keys(baseObject).forEach(extendNamespace, this);
|
||||
//}
|
||||
}
|
||||
// 8.4.2
|
||||
ModuleNamespace.prototype = Object.create(null);
|
||||
}// 8.4.2
|
||||
ModuleNamespace.prototype = Object.create(null);
|
||||
|
||||
if (toStringTag)
|
||||
if (toStringTag)
|
||||
Object.defineProperty(ModuleNamespace.prototype, toStringTag, {
|
||||
value: 'Module'
|
||||
});
|
||||
|
||||
function extendNamespace (key) {
|
||||
function extendNamespace (key) {
|
||||
Object.defineProperty(this, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return this[BASE_OBJECT][key];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* function doEvaluate (evaluate, context) {
|
||||
/* function doEvaluate (evaluate, context) {
|
||||
try {
|
||||
evaluate.call(context);
|
||||
}
|
||||
catch (e) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 8.4.1 Module.evaluate... not documented or used because this is potentially unstable
|
||||
Module.evaluate = function (ns) {
|
||||
// 8.4.1 Module.evaluate... not documented or used because this is potentially unstable
|
||||
Module.evaluate = function (ns) {
|
||||
var evaluate = ns[EVALUATE];
|
||||
if (evaluate) {
|
||||
ns[EVALUATE] = undefined;
|
||||
|
@ -362,16 +358,16 @@ Module.evaluate = function (ns) {
|
|||
}
|
||||
// make chainable
|
||||
return ns;
|
||||
}; */
|
||||
}; */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Optimized URL normalization assuming a syntax-valid URL parent
|
||||
*/
|
||||
function throwResolveError (relUrl, parentUrl) {
|
||||
function throwResolveError (relUrl, parentUrl) {
|
||||
throw new RangeError('Unable to resolve "' + relUrl + '" to ' + parentUrl);
|
||||
}
|
||||
var backslashRegEx = /\\/g;
|
||||
function resolveIfNotPlain (relUrl, parentUrl) {
|
||||
}
|
||||
var backslashRegEx = /\\/g;
|
||||
function resolveIfNotPlain (relUrl, parentUrl) {
|
||||
if (relUrl[0] === ' ' || relUrl[relUrl.length - 1] === ' ')
|
||||
relUrl = relUrl.trim();
|
||||
var parentProtocol = parentUrl && parentUrl.substr(0, parentUrl.indexOf(':') + 1);
|
||||
|
@ -489,10 +485,11 @@ function resolveIfNotPlain (relUrl, parentUrl) {
|
|||
}
|
||||
return relUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var resolvedPromise = Promise.resolve();
|
||||
/*
|
||||
var resolvedPromise$1 = Promise.resolve();
|
||||
|
||||
/*
|
||||
* Register Loader
|
||||
*
|
||||
* Builds directly on top of loader polyfill to provide:
|
||||
|
@ -503,9 +500,9 @@ var resolvedPromise = Promise.resolve();
|
|||
* - build tracing support by providing a .trace=true and .loads object format
|
||||
*/
|
||||
|
||||
var REGISTER_INTERNAL = createSymbol('register-internal');
|
||||
var REGISTER_INTERNAL = createSymbol('register-internal');
|
||||
|
||||
function RegisterLoader$1 () {
|
||||
function RegisterLoader () {
|
||||
Loader.call(this);
|
||||
|
||||
var registryDelete = this.registry.delete;
|
||||
|
@ -532,24 +529,24 @@ function RegisterLoader$1 () {
|
|||
|
||||
// tracing
|
||||
this.trace = false;
|
||||
}
|
||||
}
|
||||
|
||||
RegisterLoader$1.prototype = Object.create(Loader.prototype);
|
||||
RegisterLoader$1.prototype.constructor = RegisterLoader$1;
|
||||
RegisterLoader.prototype = Object.create(Loader.prototype);
|
||||
RegisterLoader.prototype.constructor = RegisterLoader;
|
||||
|
||||
var INSTANTIATE = RegisterLoader$1.instantiate = createSymbol('instantiate');
|
||||
var INSTANTIATE = RegisterLoader.instantiate = createSymbol('instantiate');
|
||||
|
||||
// default normalize is the WhatWG style normalizer
|
||||
RegisterLoader$1.prototype[RegisterLoader$1.resolve = Loader.resolve] = function (key, parentKey) {
|
||||
// default normalize is the WhatWG style normalizer
|
||||
RegisterLoader.prototype[RegisterLoader.resolve = Loader.resolve] = function (key, parentKey) {
|
||||
return resolveIfNotPlain(key, parentKey || baseURI);
|
||||
};
|
||||
};
|
||||
|
||||
RegisterLoader$1.prototype[INSTANTIATE] = function (key, processAnonRegister) {};
|
||||
RegisterLoader.prototype[INSTANTIATE] = function (key, processAnonRegister) {};
|
||||
|
||||
// once evaluated, the linkRecord is set to undefined leaving just the other load record properties
|
||||
// this allows tracking new binding listeners for es modules through importerSetters
|
||||
// for dynamic modules, the load record is removed entirely.
|
||||
function createLoadRecord (state, key, registration) {
|
||||
// once evaluated, the linkRecord is set to undefined leaving just the other load record properties
|
||||
// this allows tracking new binding listeners for es modules through importerSetters
|
||||
// for dynamic modules, the load record is removed entirely.
|
||||
function createLoadRecord (state, key, registration) {
|
||||
return state.records[key] = {
|
||||
key: key,
|
||||
|
||||
|
@ -597,9 +594,9 @@ function createLoadRecord (state, key, registration) {
|
|||
// hoisted: undefined
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
RegisterLoader$1.prototype[Loader.resolveInstantiate] = function (key, parentKey) {
|
||||
RegisterLoader.prototype[Loader.resolveInstantiate] = function (key, parentKey) {
|
||||
var loader = this;
|
||||
var state = this[REGISTER_INTERNAL];
|
||||
var registry = this.registry[REGISTRY];
|
||||
|
@ -624,9 +621,9 @@ RegisterLoader$1.prototype[Loader.resolveInstantiate] = function (key, parentKey
|
|||
return ensureEvaluate(loader, instantiated, link, registry, state);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function resolveInstantiate (loader, key, parentKey, registry, state) {
|
||||
function resolveInstantiate (loader, key, parentKey, registry, state) {
|
||||
// normalization shortpath for already-normalized key
|
||||
// could add a plain name filter, but doesn't yet seem necessary for perf
|
||||
var module = registry[key];
|
||||
|
@ -667,9 +664,9 @@ function resolveInstantiate (loader, key, parentKey, registry, state) {
|
|||
|
||||
return instantiate(loader, load, link, registry, state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function createProcessAnonRegister (loader, load, state) {
|
||||
function createProcessAnonRegister (loader, load, state) {
|
||||
return function () {
|
||||
var lastRegister = state.lastRegister;
|
||||
|
||||
|
@ -681,12 +678,12 @@ function createProcessAnonRegister (loader, load, state) {
|
|||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function instantiate (loader, load, link, registry, state) {
|
||||
function instantiate (loader, load, link, registry, state) {
|
||||
return link.instantiatePromise || (link.instantiatePromise =
|
||||
// if there is already an existing registration, skip running instantiate
|
||||
(load.registration ? resolvedPromise : resolvedPromise.then(function () {
|
||||
(load.registration ? resolvedPromise$1 : resolvedPromise$1.then(function () {
|
||||
state.lastRegister = undefined;
|
||||
return loader[INSTANTIATE](load.key, loader[INSTANTIATE].length > 1 && createProcessAnonRegister(loader, load, state));
|
||||
}))
|
||||
|
@ -733,10 +730,10 @@ function instantiate (loader, load, link, registry, state) {
|
|||
load.linkRecord = undefined;
|
||||
throw load.loadError = load.loadError || LoaderError__Check_error_message_for_loader_stack(err, 'Instantiating ' + load.key);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// like resolveInstantiate, but returning load records for linking
|
||||
function resolveInstantiateDep (loader, key, parentKey, registry, state, traceDepMap) {
|
||||
// like resolveInstantiate, but returning load records for linking
|
||||
function resolveInstantiateDep (loader, key, parentKey, registry, state, traceDepMap) {
|
||||
// normalization shortpaths for already-normalized key
|
||||
// DISABLED to prioritise consistent resolver calls
|
||||
// could add a plain name filter, but doesn't yet seem necessary for perf
|
||||
|
@ -789,9 +786,9 @@ function resolveInstantiateDep (loader, key, parentKey, registry, state, traceDe
|
|||
|
||||
return instantiate(loader, load, link, registry, state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function traceLoad (loader, load, link) {
|
||||
function traceLoad (loader, load, link) {
|
||||
loader.loads = loader.loads || {};
|
||||
loader.loads[load.key] = {
|
||||
key: load.key,
|
||||
|
@ -799,16 +796,16 @@ function traceLoad (loader, load, link) {
|
|||
dynamicDeps: [],
|
||||
depMap: link.depMap || {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Convert a CJS module.exports into a valid object for new Module:
|
||||
*
|
||||
* new Module(getEsModule(module.exports))
|
||||
*
|
||||
* Sets the default value to the module, while also reading off named exports carefully.
|
||||
*/
|
||||
function registerDeclarative (loader, load, link, declare) {
|
||||
function registerDeclarative (loader, load, link, declare) {
|
||||
var moduleObj = link.moduleObj;
|
||||
var importerSetters = load.importerSetters;
|
||||
|
||||
|
@ -846,9 +843,9 @@ function registerDeclarative (loader, load, link, declare) {
|
|||
link.moduleObj = moduleObj = declared.exports;
|
||||
definedExports = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function instantiateDeps (loader, load, link, registry, state) {
|
||||
function instantiateDeps (loader, load, link, registry, state) {
|
||||
if (link.depsInstantiatePromise)
|
||||
return link.depsInstantiatePromise;
|
||||
|
||||
|
@ -901,15 +898,15 @@ function instantiateDeps (loader, load, link, registry, state) {
|
|||
depsInstantiatePromise.catch(function () {});
|
||||
|
||||
return link.depsInstantiatePromise = depsInstantiatePromise;
|
||||
}
|
||||
}
|
||||
|
||||
function deepInstantiateDeps (loader, load, link, registry, state) {
|
||||
function deepInstantiateDeps (loader, load, link, registry, state) {
|
||||
var seen = [];
|
||||
function addDeps (load, link) {
|
||||
if (!link)
|
||||
return resolvedPromise;
|
||||
return resolvedPromise$1;
|
||||
if (seen.indexOf(load) !== -1)
|
||||
return resolvedPromise;
|
||||
return resolvedPromise$1;
|
||||
seen.push(load);
|
||||
|
||||
return instantiateDeps(loader, load, link, registry, state)
|
||||
|
@ -926,14 +923,13 @@ function deepInstantiateDeps (loader, load, link, registry, state) {
|
|||
return Promise.all(depPromises);
|
||||
});
|
||||
}
|
||||
|
||||
return addDeps(load, link);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* System.register
|
||||
*/
|
||||
RegisterLoader$1.prototype.register = function (key, deps, declare) {
|
||||
RegisterLoader.prototype.register = function (key, deps, declare) {
|
||||
var state = this[REGISTER_INTERNAL];
|
||||
|
||||
// anonymous modules get stored as lastAnon
|
||||
|
@ -946,12 +942,12 @@ RegisterLoader$1.prototype.register = function (key, deps, declare) {
|
|||
var load = state.records[key] || createLoadRecord(state, key, undefined);
|
||||
load.registration = [deps, declare, undefined];
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
/*
|
||||
* System.registerDyanmic
|
||||
*/
|
||||
RegisterLoader$1.prototype.registerDynamic = function (key, deps, executingRequire, execute) {
|
||||
RegisterLoader.prototype.registerDynamic = function (key, deps, executingRequire, execute) {
|
||||
var state = this[REGISTER_INTERNAL];
|
||||
|
||||
// anonymous modules get stored as lastAnon
|
||||
|
@ -964,31 +960,31 @@ RegisterLoader$1.prototype.registerDynamic = function (key, deps, executingRequi
|
|||
var load = state.records[key] || createLoadRecord(state, key, undefined);
|
||||
load.registration = [deps, executingRequire, execute];
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// ContextualLoader class
|
||||
// backwards-compatible with previous System.register context argument by exposing .id, .key
|
||||
function ContextualLoader (loader, key) {
|
||||
// ContextualLoader class
|
||||
// backwards-compatible with previous System.register context argument by exposing .id, .key
|
||||
function ContextualLoader (loader, key) {
|
||||
this.loader = loader;
|
||||
this.key = this.id = key;
|
||||
this.meta = {
|
||||
url: key
|
||||
// scriptElement: null
|
||||
};
|
||||
}
|
||||
/*ContextualLoader.prototype.constructor = function () {
|
||||
}
|
||||
/*ContextualLoader.prototype.constructor = function () {
|
||||
throw new TypeError('Cannot subclass the contextual loader only Reflect.Loader.');
|
||||
};*/
|
||||
ContextualLoader.prototype.import = function (key) {
|
||||
};*/
|
||||
ContextualLoader.prototype.import = function (key) {
|
||||
if (this.loader.trace)
|
||||
this.loader.loads[this.key].dynamicDeps.push(key);
|
||||
return this.loader.import(key, this.key);
|
||||
};
|
||||
/*ContextualLoader.prototype.resolve = function (key) {
|
||||
};
|
||||
/*ContextualLoader.prototype.resolve = function (key) {
|
||||
return this.loader.resolve(key, this.key);
|
||||
};*/
|
||||
};*/
|
||||
|
||||
function ensureEvaluate (loader, load, link, registry, state) {
|
||||
function ensureEvaluate (loader, load, link, registry, state) {
|
||||
if (load.module)
|
||||
return load.module;
|
||||
if (load.evalError)
|
||||
|
@ -1005,9 +1001,9 @@ function ensureEvaluate (loader, load, link, registry, state) {
|
|||
doEvaluateDynamic(loader, load, link, registry, state, [load]);
|
||||
}
|
||||
return load.module;
|
||||
}
|
||||
}
|
||||
|
||||
function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations, registry, state, seen) {
|
||||
function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations, registry, state, seen) {
|
||||
// we can only require from already-known dependencies
|
||||
return function (name) {
|
||||
for (var i = 0; i < dependencies.length; i++) {
|
||||
|
@ -1038,19 +1034,19 @@ function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations
|
|||
}
|
||||
throw new Error('Module ' + name + ' not declared as a System.registerDynamic dependency of ' + key);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function evalError (load, err) {
|
||||
function evalError (load, err) {
|
||||
load.linkRecord = undefined;
|
||||
var evalError = LoaderError__Check_error_message_for_loader_stack(err, 'Evaluating ' + load.key);
|
||||
if (load.evalError === undefined)
|
||||
load.evalError = evalError;
|
||||
throw evalError;
|
||||
}
|
||||
}
|
||||
|
||||
// es modules evaluate dependencies first
|
||||
// returns the error if any
|
||||
function doEvaluateDeclarative (loader, load, link, registry, state, seen) {
|
||||
// es modules evaluate dependencies first
|
||||
// returns the error if any
|
||||
function doEvaluateDeclarative (loader, load, link, registry, state, seen) {
|
||||
var depLoad, depLink;
|
||||
var depLoadPromises;
|
||||
for (var i = 0; i < link.dependencies.length; i++) {
|
||||
|
@ -1141,10 +1137,10 @@ function doEvaluateDeclarative (loader, load, link, registry, state, seen) {
|
|||
// dispose link record
|
||||
load.linkRecord = undefined;
|
||||
registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
|
||||
}
|
||||
}
|
||||
|
||||
// non es modules explicitly call moduleEvaluate through require
|
||||
function doEvaluateDynamic (loader, load, link, registry, state, seen) {
|
||||
// non es modules explicitly call moduleEvaluate through require
|
||||
function doEvaluateDynamic (loader, load, link, registry, state, seen) {
|
||||
// System.registerDynamic execute
|
||||
// "this" is "exports" in CJS
|
||||
var module = { id: load.key };
|
||||
|
@ -1200,18 +1196,18 @@ function doEvaluateDynamic (loader, load, link, registry, state, seen) {
|
|||
for (var i = 0; i < load.importerSetters.length; i++)
|
||||
load.importerSetters[i](load.module);
|
||||
load.importerSetters = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// the closest we can get to call(undefined)
|
||||
var nullContext = Object.create(null);
|
||||
if (Object.freeze)
|
||||
// the closest we can get to call(undefined)
|
||||
var nullContext = Object.create(null);
|
||||
if (Object.freeze)
|
||||
Object.freeze(nullContext);
|
||||
|
||||
var loader;
|
||||
var loader;
|
||||
|
||||
// <script type="module"> support
|
||||
var anonSources = {};
|
||||
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||
// <script type="module"> support
|
||||
var anonSources = {};
|
||||
if (typeof document != 'undefined' && document.getElementsByTagName) {
|
||||
var handleError = function(err) {
|
||||
// dispatch an error event so that we can display in errors in browsers
|
||||
// that don't yet support unhandledrejection
|
||||
|
@ -1273,13 +1269,13 @@ if (typeof document != 'undefined' && document.getElementsByTagName) {
|
|||
setTimeout(ready);
|
||||
else
|
||||
document.addEventListener('DOMContentLoaded', ready, false);
|
||||
}
|
||||
}
|
||||
|
||||
function BrowserESModuleLoader(baseKey) {
|
||||
function BrowserESModuleLoader(baseKey) {
|
||||
if (baseKey)
|
||||
this.baseKey = resolveIfNotPlain(baseKey, baseURI) || resolveIfNotPlain('./' + baseKey, baseURI);
|
||||
|
||||
RegisterLoader$1.call(this);
|
||||
RegisterLoader.call(this);
|
||||
|
||||
var loader = this;
|
||||
|
||||
|
@ -1292,19 +1288,19 @@ function BrowserESModuleLoader(baseKey) {
|
|||
if (prevRegister)
|
||||
prevRegister.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
BrowserESModuleLoader.prototype = Object.create(RegisterLoader$1.prototype);
|
||||
}
|
||||
BrowserESModuleLoader.prototype = Object.create(RegisterLoader.prototype);
|
||||
|
||||
// normalize is never given a relative name like "./x", that part is already handled
|
||||
BrowserESModuleLoader.prototype[RegisterLoader$1.resolve] = function(key, parent) {
|
||||
var resolved = RegisterLoader$1.prototype[RegisterLoader$1.resolve].call(this, key, parent || this.baseKey) || key;
|
||||
// normalize is never given a relative name like "./x", that part is already handled
|
||||
BrowserESModuleLoader.prototype[RegisterLoader.resolve] = function(key, parent) {
|
||||
var resolved = RegisterLoader.prototype[RegisterLoader.resolve].call(this, key, parent || this.baseKey) || key;
|
||||
if (!resolved)
|
||||
throw new RangeError('ES module loader does not resolve plain module names, resolving "' + key + '" to ' + parent);
|
||||
|
||||
return resolved;
|
||||
};
|
||||
};
|
||||
|
||||
function xhrFetch(url, resolve, reject) {
|
||||
function xhrFetch(url, resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
var load = function(source) {
|
||||
resolve(xhr.responseText);
|
||||
|
@ -1337,9 +1333,9 @@ function xhrFetch(url, resolve, reject) {
|
|||
};
|
||||
xhr.open("GET", url, true);
|
||||
xhr.send(null);
|
||||
}
|
||||
}
|
||||
|
||||
var WorkerPool = function (script, size) {
|
||||
var WorkerPool = function (script, size) {
|
||||
var current = document.currentScript;
|
||||
// IE doesn't support currentScript
|
||||
if (!current) {
|
||||
|
@ -1371,8 +1367,8 @@ var WorkerPool = function (script, size) {
|
|||
}
|
||||
|
||||
this._checkJobs();
|
||||
};
|
||||
WorkerPool.prototype = {
|
||||
};
|
||||
WorkerPool.prototype = {
|
||||
postMessage: function (msg) {
|
||||
if (this._stopTimeout !== undefined) {
|
||||
clearTimeout(this._stopTimeout);
|
||||
|
@ -1419,20 +1415,19 @@ WorkerPool.prototype = {
|
|||
wrkr.terminate();
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var promiseMap = new Map();
|
||||
var babelWorker = new WorkerPool('babel-worker.js', 3);
|
||||
babelWorker.onmessage = function (evt) {
|
||||
var promiseMap = new Map();
|
||||
var babelWorker = new WorkerPool('babel-worker.js', 3);
|
||||
babelWorker.onmessage = function (evt) {
|
||||
var promFuncs = promiseMap.get(evt.data.key);
|
||||
promFuncs.resolve(evt.data);
|
||||
promiseMap.delete(evt.data.key);
|
||||
};
|
||||
};
|
||||
|
||||
// instantiate just needs to run System.register
|
||||
// so we fetch the source, convert into the Babel System module format, then evaluate it
|
||||
BrowserESModuleLoader.prototype[RegisterLoader$1.instantiate] = function(key, processAnonRegister) {
|
||||
var loader = this;
|
||||
// instantiate just needs to run System.register
|
||||
// so we fetch the source, convert into the Babel System module format, then evaluate it
|
||||
BrowserESModuleLoader.prototype[RegisterLoader.instantiate] = function(key, processAnonRegister) {
|
||||
|
||||
// load as ES with Babel converting into System.register
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
@ -1474,13 +1469,13 @@ BrowserESModuleLoader.prototype[RegisterLoader$1.instantiate] = function(key, pr
|
|||
(0, eval)(data.code + '\n//# sourceURL=' + data.key + '!transpiled');
|
||||
processAnonRegister();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
// create a default loader instance in the browser
|
||||
if (isBrowser)
|
||||
// create a default loader instance in the browser
|
||||
if (isBrowser)
|
||||
loader = new BrowserESModuleLoader();
|
||||
|
||||
return BrowserESModuleLoader;
|
||||
return BrowserESModuleLoader;
|
||||
|
||||
})));
|
||||
}));
|
||||
//# sourceMappingURL=browser-es-module-loader.js.map
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue