es-module-shims 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/es-module-shims.debug.js +156 -140
- package/dist/es-module-shims.js +153 -137
- package/dist/es-module-shims.wasm.js +153 -137
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Because we are still using the native module loader the edge cases work out comp
|
|
|
30
30
|
Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
|
|
31
31
|
|
|
32
32
|
```html
|
|
33
|
-
<script async src="https://ga.jspm.io/npm:es-module-shims@2.3.
|
|
33
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@2.3.1/dist/es-module-shims.js"></script>
|
|
34
34
|
|
|
35
35
|
<!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
|
|
36
36
|
<script type="importmap">
|
|
@@ -738,7 +738,7 @@ window.esmsInitOptions = {
|
|
|
738
738
|
// Hook import.meta construction
|
|
739
739
|
meta: (meta, url) => void // default is noop
|
|
740
740
|
// Hook top-level imports
|
|
741
|
-
onimport: (url, options, parentUrl) => void // default is noop
|
|
741
|
+
onimport: (url, options, parentUrl, source) => void // default is noop
|
|
742
742
|
}
|
|
743
743
|
</script>
|
|
744
744
|
<script async src="es-module-shims.js"></script>
|
|
@@ -998,8 +998,11 @@ The import hook is supported for both shim and polyfill modes and provides an as
|
|
|
998
998
|
```js
|
|
999
999
|
<script>
|
|
1000
1000
|
window.esmsInitOptions = {
|
|
1001
|
-
onimport: function (url, options, parentUrl) {
|
|
1002
|
-
|
|
1001
|
+
onimport: function (url, options, parentUrl, source) {
|
|
1002
|
+
if (source !== undefined)
|
|
1003
|
+
console.log(`Top-level inline script with source: ${source}`);
|
|
1004
|
+
else
|
|
1005
|
+
console.log(`Top-level URL import (static or dynamic) for ${url}`);
|
|
1003
1006
|
}
|
|
1004
1007
|
}
|
|
1005
1008
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** ES Module Shims 2.3.
|
|
2
|
-
(function () {
|
|
1
|
+
/** ES Module Shims 2.3.1 */
|
|
2
|
+
(function (exports) {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
5
5
|
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
18
18
|
return toVersioned(url);
|
|
19
19
|
};
|
|
20
|
-
const hotImportHook = url => {
|
|
21
|
-
getHotState(url)
|
|
20
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
21
|
+
const hotState = getHotState(url);
|
|
22
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
23
|
+
hotState.t = sourceType;
|
|
22
24
|
};
|
|
23
25
|
const hotMetaHook = (metaObj, url) => {
|
|
24
26
|
metaObj.hot = new Hot(url);
|
|
@@ -79,12 +81,14 @@
|
|
|
79
81
|
A: true,
|
|
80
82
|
// unload callback
|
|
81
83
|
u: null,
|
|
82
|
-
// entry point
|
|
84
|
+
// entry point or inline script source
|
|
83
85
|
e: false,
|
|
84
86
|
// hot data
|
|
85
87
|
d: {},
|
|
86
88
|
// parents
|
|
87
|
-
p: []
|
|
89
|
+
p: [],
|
|
90
|
+
// source type
|
|
91
|
+
t: undefined
|
|
88
92
|
});
|
|
89
93
|
|
|
90
94
|
invalidate = (url, fromUrl, seen = []) => {
|
|
@@ -112,7 +116,15 @@
|
|
|
112
116
|
const earlyRoots = new Set();
|
|
113
117
|
for (const root of curInvalidationRoots) {
|
|
114
118
|
const hotState = hotRegistry[root];
|
|
115
|
-
|
|
119
|
+
topLevelLoad(
|
|
120
|
+
toVersioned(root),
|
|
121
|
+
baseUrl,
|
|
122
|
+
defaultFetchOpts,
|
|
123
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
124
|
+
false,
|
|
125
|
+
undefined,
|
|
126
|
+
hotState.t
|
|
127
|
+
).then(m => {
|
|
116
128
|
if (hotState.a) {
|
|
117
129
|
hotState.a.every(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
118
130
|
// unload should be the latest unload handler from the just loaded module
|
|
@@ -134,136 +146,134 @@
|
|
|
134
146
|
);
|
|
135
147
|
});
|
|
136
148
|
}
|
|
137
|
-
},
|
|
149
|
+
}, throwError);
|
|
138
150
|
}
|
|
139
151
|
curInvalidationRoots = new Set();
|
|
140
152
|
}, hotReloadInterval);
|
|
141
153
|
};
|
|
142
154
|
|
|
143
155
|
return [
|
|
144
|
-
_importHook ?
|
|
145
|
-
(url, opts, parentUrl) => {
|
|
146
|
-
_importHook(url, opts, parentUrl);
|
|
147
|
-
hotImportHook(url);
|
|
148
|
-
}
|
|
149
|
-
: hotImportHook,
|
|
156
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
150
157
|
_resolveHook ?
|
|
151
158
|
(id, parent, defaultResolve) =>
|
|
152
159
|
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
153
160
|
: hotResolveHook,
|
|
154
|
-
_metaHook ?
|
|
155
|
-
(metaObj, url) => {
|
|
156
|
-
_metaHook(metaObj, url);
|
|
157
|
-
hotMetaHook(metaObj, url);
|
|
158
|
-
}
|
|
159
|
-
: hotMetaHook
|
|
161
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
160
162
|
];
|
|
161
163
|
};
|
|
162
164
|
|
|
163
|
-
if (self.importShim) {
|
|
164
|
-
console.info(
|
|
165
|
-
`es-module-shims: skipping initialization as importShim was already registered by another polyfill instance`
|
|
166
|
-
);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const hasDocument = typeof document !== 'undefined';
|
|
171
|
-
|
|
172
|
-
const noop = () => {};
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
165
|
+
if (self.importShim) {
|
|
166
|
+
console.info(
|
|
167
|
+
`es-module-shims: skipping initialization as importShim was already registered by another polyfill instance`
|
|
168
|
+
);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const hasDocument = typeof document !== 'undefined';
|
|
173
|
+
|
|
174
|
+
const noop = () => {};
|
|
175
|
+
|
|
176
|
+
const chain = (a, b) =>
|
|
177
|
+
function () {
|
|
178
|
+
a.apply(this, arguments);
|
|
179
|
+
b.apply(this, arguments);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
183
|
+
|
|
184
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
185
|
+
|
|
186
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
187
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
188
|
+
|
|
189
|
+
// shim mode is determined on initialization, no late shim mode
|
|
190
|
+
const shimMode =
|
|
191
|
+
esmsInitOptions.shimMode ||
|
|
192
|
+
(hasDocument &&
|
|
193
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
194
|
+
.length > 0);
|
|
195
|
+
|
|
196
|
+
let importHook,
|
|
197
|
+
resolveHook,
|
|
198
|
+
fetchHook = fetch,
|
|
199
|
+
metaHook,
|
|
200
|
+
tsTransform =
|
|
201
|
+
esmsInitOptions.tsTransform ||
|
|
202
|
+
(hasDocument && document.currentScript && document.currentScript.src.replace(/(\.\w+)?\.js$/, '-typescript.js')) ||
|
|
203
|
+
'./es-module-shims-typescript.js';
|
|
204
|
+
|
|
205
|
+
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
206
|
+
|
|
207
|
+
const {
|
|
208
|
+
revokeBlobURLs,
|
|
209
|
+
noLoadEventRetriggers,
|
|
210
|
+
enforceIntegrity,
|
|
211
|
+
hotReload,
|
|
212
|
+
hotReloadInterval = 100,
|
|
213
|
+
nativePassthrough = !hotReload
|
|
214
|
+
} = esmsInitOptions;
|
|
215
|
+
|
|
216
|
+
const globalHook = name => (typeof name === 'string' ? self[name] : name);
|
|
217
|
+
|
|
218
|
+
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
219
|
+
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
220
|
+
if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
|
|
221
|
+
if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
|
|
222
|
+
|
|
223
|
+
if (hotReload) [importHook, resolveHook, metaHook] = initHotReload();
|
|
224
|
+
|
|
225
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
226
|
+
|
|
227
|
+
let nonce = esmsInitOptions.nonce;
|
|
228
|
+
if (!nonce && hasDocument) {
|
|
229
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
230
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
|
|
234
|
+
|
|
235
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
236
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
237
|
+
const wasmInstancePhaseEnabled =
|
|
238
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
|
|
239
|
+
const wasmSourcePhaseEnabled =
|
|
240
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
|
|
241
|
+
const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
|
|
242
|
+
|
|
243
|
+
const onpolyfill =
|
|
244
|
+
esmsInitOptions.onpolyfill ?
|
|
245
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
246
|
+
: () => {
|
|
247
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const baseUrl =
|
|
251
|
+
hasDocument ?
|
|
252
|
+
document.baseURI
|
|
253
|
+
: `${location.protocol}//${location.host}${
|
|
254
|
+
location.pathname.includes('/') ?
|
|
255
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
256
|
+
: location.pathname
|
|
257
|
+
}`;
|
|
258
|
+
|
|
259
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
260
|
+
let { skip } = esmsInitOptions;
|
|
261
|
+
if (Array.isArray(skip)) {
|
|
262
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
263
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
264
|
+
} else if (typeof skip === 'string') {
|
|
265
|
+
const r = new RegExp(skip);
|
|
266
|
+
skip = s => r.test(s);
|
|
267
|
+
} else if (skip instanceof RegExp) {
|
|
268
|
+
skip = s => skip.test(s);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
272
|
+
|
|
273
|
+
const throwError = err => {
|
|
274
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
275
|
+
};
|
|
276
|
+
|
|
267
277
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
268
278
|
|
|
269
279
|
const backslashRegEx = /\\/g;
|
|
@@ -630,15 +640,7 @@
|
|
|
630
640
|
sourceType = opts.with.type;
|
|
631
641
|
}
|
|
632
642
|
}
|
|
633
|
-
return topLevelLoad(
|
|
634
|
-
id,
|
|
635
|
-
parentUrl || baseUrl,
|
|
636
|
-
{ credentials: 'same-origin' },
|
|
637
|
-
undefined,
|
|
638
|
-
undefined,
|
|
639
|
-
undefined,
|
|
640
|
-
sourceType
|
|
641
|
-
);
|
|
643
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
642
644
|
}
|
|
643
645
|
|
|
644
646
|
// import.source()
|
|
@@ -657,7 +659,7 @@
|
|
|
657
659
|
}
|
|
658
660
|
await importMapPromise;
|
|
659
661
|
const url = resolve(id, parentUrl || baseUrl).r;
|
|
660
|
-
const load = getOrCreateLoad(url,
|
|
662
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
661
663
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
662
664
|
onpolyfill();
|
|
663
665
|
firstPolyfillLoad = false;
|
|
@@ -802,7 +804,15 @@
|
|
|
802
804
|
let firstPolyfillLoad = true;
|
|
803
805
|
let legacyAcceptingImportMaps = true;
|
|
804
806
|
|
|
805
|
-
const topLevelLoad = async (
|
|
807
|
+
const topLevelLoad = async (
|
|
808
|
+
url,
|
|
809
|
+
parentUrl,
|
|
810
|
+
fetchOpts,
|
|
811
|
+
source,
|
|
812
|
+
nativelyLoaded,
|
|
813
|
+
lastStaticLoadPromise,
|
|
814
|
+
sourceType
|
|
815
|
+
) => {
|
|
806
816
|
await initPromise;
|
|
807
817
|
await importMapPromise;
|
|
808
818
|
url = (await resolve(url, parentUrl)).r;
|
|
@@ -814,7 +824,7 @@
|
|
|
814
824
|
url += '?entry';
|
|
815
825
|
}
|
|
816
826
|
|
|
817
|
-
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl);
|
|
827
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
818
828
|
// early analysis opt-out - no need to even fetch if we have feature support
|
|
819
829
|
if (!shimMode && baselinePassthrough && nativePassthrough && sourceType !== 'ts') {
|
|
820
830
|
console.info(`es-module-shims: early exit for ${url} due to baseline modules support`);
|
|
@@ -1155,8 +1165,8 @@
|
|
|
1155
1165
|
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1156
1166
|
if (source && registry[url]) {
|
|
1157
1167
|
let i = 0;
|
|
1158
|
-
while (registry[url + '
|
|
1159
|
-
url += '
|
|
1168
|
+
while (registry[url + '#' + ++i]);
|
|
1169
|
+
url += '#' + i;
|
|
1160
1170
|
}
|
|
1161
1171
|
let load = registry[url];
|
|
1162
1172
|
if (load) return load;
|
|
@@ -1421,7 +1431,7 @@
|
|
|
1421
1431
|
!script.src ? script.innerHTML : undefined,
|
|
1422
1432
|
!shimMode,
|
|
1423
1433
|
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1424
|
-
'ts'
|
|
1434
|
+
ts ? 'ts' : undefined
|
|
1425
1435
|
).catch(throwError);
|
|
1426
1436
|
}
|
|
1427
1437
|
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
@@ -1439,4 +1449,10 @@
|
|
|
1439
1449
|
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1440
1450
|
};
|
|
1441
1451
|
|
|
1442
|
-
|
|
1452
|
+
exports.topLevelLoad = topLevelLoad;
|
|
1453
|
+
|
|
1454
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1455
|
+
|
|
1456
|
+
return exports;
|
|
1457
|
+
|
|
1458
|
+
})({});
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** ES Module Shims 2.3.
|
|
2
|
-
(function () {
|
|
1
|
+
/** ES Module Shims 2.3.1 */
|
|
2
|
+
(function (exports) {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
5
5
|
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
18
18
|
return toVersioned(url);
|
|
19
19
|
};
|
|
20
|
-
const hotImportHook = url => {
|
|
21
|
-
getHotState(url)
|
|
20
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
21
|
+
const hotState = getHotState(url);
|
|
22
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
23
|
+
hotState.t = sourceType;
|
|
22
24
|
};
|
|
23
25
|
const hotMetaHook = (metaObj, url) => {
|
|
24
26
|
metaObj.hot = new Hot(url);
|
|
@@ -79,12 +81,14 @@
|
|
|
79
81
|
A: true,
|
|
80
82
|
// unload callback
|
|
81
83
|
u: null,
|
|
82
|
-
// entry point
|
|
84
|
+
// entry point or inline script source
|
|
83
85
|
e: false,
|
|
84
86
|
// hot data
|
|
85
87
|
d: {},
|
|
86
88
|
// parents
|
|
87
|
-
p: []
|
|
89
|
+
p: [],
|
|
90
|
+
// source type
|
|
91
|
+
t: undefined
|
|
88
92
|
});
|
|
89
93
|
|
|
90
94
|
invalidate = (url, fromUrl, seen = []) => {
|
|
@@ -111,7 +115,15 @@
|
|
|
111
115
|
const earlyRoots = new Set();
|
|
112
116
|
for (const root of curInvalidationRoots) {
|
|
113
117
|
const hotState = hotRegistry[root];
|
|
114
|
-
|
|
118
|
+
topLevelLoad(
|
|
119
|
+
toVersioned(root),
|
|
120
|
+
baseUrl,
|
|
121
|
+
defaultFetchOpts,
|
|
122
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
123
|
+
false,
|
|
124
|
+
undefined,
|
|
125
|
+
hotState.t
|
|
126
|
+
).then(m => {
|
|
115
127
|
if (hotState.a) {
|
|
116
128
|
hotState.a.every(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
117
129
|
// unload should be the latest unload handler from the just loaded module
|
|
@@ -133,133 +145,131 @@
|
|
|
133
145
|
);
|
|
134
146
|
});
|
|
135
147
|
}
|
|
136
|
-
},
|
|
148
|
+
}, throwError);
|
|
137
149
|
}
|
|
138
150
|
curInvalidationRoots = new Set();
|
|
139
151
|
}, hotReloadInterval);
|
|
140
152
|
};
|
|
141
153
|
|
|
142
154
|
return [
|
|
143
|
-
_importHook ?
|
|
144
|
-
(url, opts, parentUrl) => {
|
|
145
|
-
_importHook(url, opts, parentUrl);
|
|
146
|
-
hotImportHook(url);
|
|
147
|
-
}
|
|
148
|
-
: hotImportHook,
|
|
155
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
149
156
|
_resolveHook ?
|
|
150
157
|
(id, parent, defaultResolve) =>
|
|
151
158
|
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
152
159
|
: hotResolveHook,
|
|
153
|
-
_metaHook ?
|
|
154
|
-
(metaObj, url) => {
|
|
155
|
-
_metaHook(metaObj, url);
|
|
156
|
-
hotMetaHook(metaObj, url);
|
|
157
|
-
}
|
|
158
|
-
: hotMetaHook
|
|
160
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
159
161
|
];
|
|
160
162
|
};
|
|
161
163
|
|
|
162
|
-
if (self.importShim) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const hasDocument = typeof document !== 'undefined';
|
|
167
|
-
|
|
168
|
-
const noop = () => {};
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
164
|
+
if (self.importShim) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const hasDocument = typeof document !== 'undefined';
|
|
169
|
+
|
|
170
|
+
const noop = () => {};
|
|
171
|
+
|
|
172
|
+
const chain = (a, b) =>
|
|
173
|
+
function () {
|
|
174
|
+
a.apply(this, arguments);
|
|
175
|
+
b.apply(this, arguments);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
179
|
+
|
|
180
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
181
|
+
|
|
182
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
183
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
184
|
+
|
|
185
|
+
// shim mode is determined on initialization, no late shim mode
|
|
186
|
+
const shimMode =
|
|
187
|
+
esmsInitOptions.shimMode ||
|
|
188
|
+
(hasDocument &&
|
|
189
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
190
|
+
.length > 0);
|
|
191
|
+
|
|
192
|
+
let importHook,
|
|
193
|
+
resolveHook,
|
|
194
|
+
fetchHook = fetch,
|
|
195
|
+
metaHook,
|
|
196
|
+
tsTransform =
|
|
197
|
+
esmsInitOptions.tsTransform ||
|
|
198
|
+
(hasDocument && document.currentScript && document.currentScript.src.replace(/(\.\w+)?\.js$/, '-typescript.js')) ||
|
|
199
|
+
'./es-module-shims-typescript.js';
|
|
200
|
+
|
|
201
|
+
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
202
|
+
|
|
203
|
+
const {
|
|
204
|
+
revokeBlobURLs,
|
|
205
|
+
noLoadEventRetriggers,
|
|
206
|
+
enforceIntegrity,
|
|
207
|
+
hotReload,
|
|
208
|
+
hotReloadInterval = 100,
|
|
209
|
+
nativePassthrough = !hotReload
|
|
210
|
+
} = esmsInitOptions;
|
|
211
|
+
|
|
212
|
+
const globalHook = name => (typeof name === 'string' ? self[name] : name);
|
|
213
|
+
|
|
214
|
+
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
215
|
+
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
216
|
+
if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
|
|
217
|
+
if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
|
|
218
|
+
|
|
219
|
+
if (hotReload) [importHook, resolveHook, metaHook] = initHotReload();
|
|
220
|
+
|
|
221
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
222
|
+
|
|
223
|
+
let nonce = esmsInitOptions.nonce;
|
|
224
|
+
if (!nonce && hasDocument) {
|
|
225
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
226
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
|
|
230
|
+
|
|
231
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
232
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
233
|
+
const wasmInstancePhaseEnabled =
|
|
234
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
|
|
235
|
+
const wasmSourcePhaseEnabled =
|
|
236
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
|
|
237
|
+
const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
|
|
238
|
+
|
|
239
|
+
const onpolyfill =
|
|
240
|
+
esmsInitOptions.onpolyfill ?
|
|
241
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
242
|
+
: () => {
|
|
243
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const baseUrl =
|
|
247
|
+
hasDocument ?
|
|
248
|
+
document.baseURI
|
|
249
|
+
: `${location.protocol}//${location.host}${
|
|
250
|
+
location.pathname.includes('/') ?
|
|
251
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
252
|
+
: location.pathname
|
|
253
|
+
}`;
|
|
254
|
+
|
|
255
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
256
|
+
let { skip } = esmsInitOptions;
|
|
257
|
+
if (Array.isArray(skip)) {
|
|
258
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
259
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
260
|
+
} else if (typeof skip === 'string') {
|
|
261
|
+
const r = new RegExp(skip);
|
|
262
|
+
skip = s => r.test(s);
|
|
263
|
+
} else if (skip instanceof RegExp) {
|
|
264
|
+
skip = s => skip.test(s);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
268
|
+
|
|
269
|
+
const throwError = err => {
|
|
270
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
271
|
+
};
|
|
272
|
+
|
|
263
273
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
264
274
|
|
|
265
275
|
const backslashRegEx = /\\/g;
|
|
@@ -619,15 +629,7 @@
|
|
|
619
629
|
sourceType = opts.with.type;
|
|
620
630
|
}
|
|
621
631
|
}
|
|
622
|
-
return topLevelLoad(
|
|
623
|
-
id,
|
|
624
|
-
parentUrl || baseUrl,
|
|
625
|
-
{ credentials: 'same-origin' },
|
|
626
|
-
undefined,
|
|
627
|
-
undefined,
|
|
628
|
-
undefined,
|
|
629
|
-
sourceType
|
|
630
|
-
);
|
|
632
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
631
633
|
}
|
|
632
634
|
|
|
633
635
|
// import.source()
|
|
@@ -645,7 +647,7 @@
|
|
|
645
647
|
}
|
|
646
648
|
await importMapPromise;
|
|
647
649
|
const url = resolve(id, parentUrl || baseUrl).r;
|
|
648
|
-
const load = getOrCreateLoad(url,
|
|
650
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
649
651
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
650
652
|
onpolyfill();
|
|
651
653
|
firstPolyfillLoad = false;
|
|
@@ -790,7 +792,15 @@
|
|
|
790
792
|
let firstPolyfillLoad = true;
|
|
791
793
|
let legacyAcceptingImportMaps = true;
|
|
792
794
|
|
|
793
|
-
const topLevelLoad = async (
|
|
795
|
+
const topLevelLoad = async (
|
|
796
|
+
url,
|
|
797
|
+
parentUrl,
|
|
798
|
+
fetchOpts,
|
|
799
|
+
source,
|
|
800
|
+
nativelyLoaded,
|
|
801
|
+
lastStaticLoadPromise,
|
|
802
|
+
sourceType
|
|
803
|
+
) => {
|
|
794
804
|
await initPromise;
|
|
795
805
|
await importMapPromise;
|
|
796
806
|
url = (await resolve(url, parentUrl)).r;
|
|
@@ -802,7 +812,7 @@
|
|
|
802
812
|
url += '?entry';
|
|
803
813
|
}
|
|
804
814
|
|
|
805
|
-
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl);
|
|
815
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
806
816
|
// early analysis opt-out - no need to even fetch if we have feature support
|
|
807
817
|
if (!shimMode && baselinePassthrough && nativePassthrough && sourceType !== 'ts') {
|
|
808
818
|
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
@@ -1137,8 +1147,8 @@
|
|
|
1137
1147
|
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1138
1148
|
if (source && registry[url]) {
|
|
1139
1149
|
let i = 0;
|
|
1140
|
-
while (registry[url + '
|
|
1141
|
-
url += '
|
|
1150
|
+
while (registry[url + '#' + ++i]);
|
|
1151
|
+
url += '#' + i;
|
|
1142
1152
|
}
|
|
1143
1153
|
let load = registry[url];
|
|
1144
1154
|
if (load) return load;
|
|
@@ -1397,7 +1407,7 @@
|
|
|
1397
1407
|
!script.src ? script.innerHTML : undefined,
|
|
1398
1408
|
!shimMode,
|
|
1399
1409
|
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1400
|
-
'ts'
|
|
1410
|
+
ts ? 'ts' : undefined
|
|
1401
1411
|
).catch(throwError);
|
|
1402
1412
|
}
|
|
1403
1413
|
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
@@ -1415,4 +1425,10 @@
|
|
|
1415
1425
|
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1416
1426
|
};
|
|
1417
1427
|
|
|
1418
|
-
|
|
1428
|
+
exports.topLevelLoad = topLevelLoad;
|
|
1429
|
+
|
|
1430
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1431
|
+
|
|
1432
|
+
return exports;
|
|
1433
|
+
|
|
1434
|
+
})({});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** ES Module Shims Wasm 2.3.
|
|
2
|
-
(function () {
|
|
1
|
+
/** ES Module Shims Wasm 2.3.1 */
|
|
2
|
+
(function (exports) {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
5
5
|
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
18
18
|
return toVersioned(url);
|
|
19
19
|
};
|
|
20
|
-
const hotImportHook = url => {
|
|
21
|
-
getHotState(url)
|
|
20
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
21
|
+
const hotState = getHotState(url);
|
|
22
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
23
|
+
hotState.t = sourceType;
|
|
22
24
|
};
|
|
23
25
|
const hotMetaHook = (metaObj, url) => {
|
|
24
26
|
metaObj.hot = new Hot(url);
|
|
@@ -79,12 +81,14 @@
|
|
|
79
81
|
A: true,
|
|
80
82
|
// unload callback
|
|
81
83
|
u: null,
|
|
82
|
-
// entry point
|
|
84
|
+
// entry point or inline script source
|
|
83
85
|
e: false,
|
|
84
86
|
// hot data
|
|
85
87
|
d: {},
|
|
86
88
|
// parents
|
|
87
|
-
p: []
|
|
89
|
+
p: [],
|
|
90
|
+
// source type
|
|
91
|
+
t: undefined
|
|
88
92
|
});
|
|
89
93
|
|
|
90
94
|
invalidate = (url, fromUrl, seen = []) => {
|
|
@@ -111,7 +115,15 @@
|
|
|
111
115
|
const earlyRoots = new Set();
|
|
112
116
|
for (const root of curInvalidationRoots) {
|
|
113
117
|
const hotState = hotRegistry[root];
|
|
114
|
-
|
|
118
|
+
topLevelLoad(
|
|
119
|
+
toVersioned(root),
|
|
120
|
+
baseUrl,
|
|
121
|
+
defaultFetchOpts,
|
|
122
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
123
|
+
false,
|
|
124
|
+
undefined,
|
|
125
|
+
hotState.t
|
|
126
|
+
).then(m => {
|
|
115
127
|
if (hotState.a) {
|
|
116
128
|
hotState.a.every(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
117
129
|
// unload should be the latest unload handler from the just loaded module
|
|
@@ -133,133 +145,131 @@
|
|
|
133
145
|
);
|
|
134
146
|
});
|
|
135
147
|
}
|
|
136
|
-
},
|
|
148
|
+
}, throwError);
|
|
137
149
|
}
|
|
138
150
|
curInvalidationRoots = new Set();
|
|
139
151
|
}, hotReloadInterval);
|
|
140
152
|
};
|
|
141
153
|
|
|
142
154
|
return [
|
|
143
|
-
_importHook ?
|
|
144
|
-
(url, opts, parentUrl) => {
|
|
145
|
-
_importHook(url, opts, parentUrl);
|
|
146
|
-
hotImportHook(url);
|
|
147
|
-
}
|
|
148
|
-
: hotImportHook,
|
|
155
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
149
156
|
_resolveHook ?
|
|
150
157
|
(id, parent, defaultResolve) =>
|
|
151
158
|
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
152
159
|
: hotResolveHook,
|
|
153
|
-
_metaHook ?
|
|
154
|
-
(metaObj, url) => {
|
|
155
|
-
_metaHook(metaObj, url);
|
|
156
|
-
hotMetaHook(metaObj, url);
|
|
157
|
-
}
|
|
158
|
-
: hotMetaHook
|
|
160
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
159
161
|
];
|
|
160
162
|
};
|
|
161
163
|
|
|
162
|
-
if (self.importShim) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const hasDocument = typeof document !== 'undefined';
|
|
167
|
-
|
|
168
|
-
const noop = () => {};
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
164
|
+
if (self.importShim) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const hasDocument = typeof document !== 'undefined';
|
|
169
|
+
|
|
170
|
+
const noop = () => {};
|
|
171
|
+
|
|
172
|
+
const chain = (a, b) =>
|
|
173
|
+
function () {
|
|
174
|
+
a.apply(this, arguments);
|
|
175
|
+
b.apply(this, arguments);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
179
|
+
|
|
180
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
181
|
+
|
|
182
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
183
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
184
|
+
|
|
185
|
+
// shim mode is determined on initialization, no late shim mode
|
|
186
|
+
const shimMode =
|
|
187
|
+
esmsInitOptions.shimMode ||
|
|
188
|
+
(hasDocument &&
|
|
189
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
190
|
+
.length > 0);
|
|
191
|
+
|
|
192
|
+
let importHook,
|
|
193
|
+
resolveHook,
|
|
194
|
+
fetchHook = fetch,
|
|
195
|
+
metaHook,
|
|
196
|
+
tsTransform =
|
|
197
|
+
esmsInitOptions.tsTransform ||
|
|
198
|
+
(hasDocument && document.currentScript && document.currentScript.src.replace(/(\.\w+)?\.js$/, '-typescript.js')) ||
|
|
199
|
+
'./es-module-shims-typescript.js';
|
|
200
|
+
|
|
201
|
+
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
202
|
+
|
|
203
|
+
const {
|
|
204
|
+
revokeBlobURLs,
|
|
205
|
+
noLoadEventRetriggers,
|
|
206
|
+
enforceIntegrity,
|
|
207
|
+
hotReload,
|
|
208
|
+
hotReloadInterval = 100,
|
|
209
|
+
nativePassthrough = !hotReload
|
|
210
|
+
} = esmsInitOptions;
|
|
211
|
+
|
|
212
|
+
const globalHook = name => (typeof name === 'string' ? self[name] : name);
|
|
213
|
+
|
|
214
|
+
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
215
|
+
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
216
|
+
if (esmsInitOptions.fetch) fetchHook = globalHook(esmsInitOptions.fetch);
|
|
217
|
+
if (esmsInitOptions.meta) metaHook = globalHook(esmsInitOptions.meta);
|
|
218
|
+
|
|
219
|
+
if (hotReload) [importHook, resolveHook, metaHook] = initHotReload();
|
|
220
|
+
|
|
221
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
222
|
+
|
|
223
|
+
let nonce = esmsInitOptions.nonce;
|
|
224
|
+
if (!nonce && hasDocument) {
|
|
225
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
226
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const onerror = globalHook(esmsInitOptions.onerror || console.error.bind(console));
|
|
230
|
+
|
|
231
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
232
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
233
|
+
const wasmInstancePhaseEnabled =
|
|
234
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-instances') || enableAll;
|
|
235
|
+
const wasmSourcePhaseEnabled =
|
|
236
|
+
enable.includes('wasm-modules') || enable.includes('wasm-module-sources') || enableAll;
|
|
237
|
+
const deferPhaseEnabled = enable.includes('import-defer') || enableAll;
|
|
238
|
+
|
|
239
|
+
const onpolyfill =
|
|
240
|
+
esmsInitOptions.onpolyfill ?
|
|
241
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
242
|
+
: () => {
|
|
243
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const baseUrl =
|
|
247
|
+
hasDocument ?
|
|
248
|
+
document.baseURI
|
|
249
|
+
: `${location.protocol}//${location.host}${
|
|
250
|
+
location.pathname.includes('/') ?
|
|
251
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
252
|
+
: location.pathname
|
|
253
|
+
}`;
|
|
254
|
+
|
|
255
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
256
|
+
let { skip } = esmsInitOptions;
|
|
257
|
+
if (Array.isArray(skip)) {
|
|
258
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
259
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
260
|
+
} else if (typeof skip === 'string') {
|
|
261
|
+
const r = new RegExp(skip);
|
|
262
|
+
skip = s => r.test(s);
|
|
263
|
+
} else if (skip instanceof RegExp) {
|
|
264
|
+
skip = s => skip.test(s);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
268
|
+
|
|
269
|
+
const throwError = err => {
|
|
270
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
271
|
+
};
|
|
272
|
+
|
|
263
273
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
264
274
|
|
|
265
275
|
const backslashRegEx = /\\/g;
|
|
@@ -619,15 +629,7 @@
|
|
|
619
629
|
sourceType = opts.with.type;
|
|
620
630
|
}
|
|
621
631
|
}
|
|
622
|
-
return topLevelLoad(
|
|
623
|
-
id,
|
|
624
|
-
parentUrl || baseUrl,
|
|
625
|
-
{ credentials: 'same-origin' },
|
|
626
|
-
undefined,
|
|
627
|
-
undefined,
|
|
628
|
-
undefined,
|
|
629
|
-
sourceType
|
|
630
|
-
);
|
|
632
|
+
return topLevelLoad(id, parentUrl || baseUrl, defaultFetchOpts, undefined, undefined, undefined, sourceType);
|
|
631
633
|
}
|
|
632
634
|
|
|
633
635
|
// import.source()
|
|
@@ -645,7 +647,7 @@
|
|
|
645
647
|
}
|
|
646
648
|
await importMapPromise;
|
|
647
649
|
const url = resolve(id, parentUrl || baseUrl).r;
|
|
648
|
-
const load = getOrCreateLoad(url,
|
|
650
|
+
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
649
651
|
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
650
652
|
onpolyfill();
|
|
651
653
|
firstPolyfillLoad = false;
|
|
@@ -790,7 +792,15 @@
|
|
|
790
792
|
let firstPolyfillLoad = true;
|
|
791
793
|
let legacyAcceptingImportMaps = true;
|
|
792
794
|
|
|
793
|
-
const topLevelLoad = async (
|
|
795
|
+
const topLevelLoad = async (
|
|
796
|
+
url,
|
|
797
|
+
parentUrl,
|
|
798
|
+
fetchOpts,
|
|
799
|
+
source,
|
|
800
|
+
nativelyLoaded,
|
|
801
|
+
lastStaticLoadPromise,
|
|
802
|
+
sourceType
|
|
803
|
+
) => {
|
|
794
804
|
await initPromise;
|
|
795
805
|
await importMapPromise;
|
|
796
806
|
url = (await resolve(url, parentUrl)).r;
|
|
@@ -802,7 +812,7 @@
|
|
|
802
812
|
url += '?entry';
|
|
803
813
|
}
|
|
804
814
|
|
|
805
|
-
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl);
|
|
815
|
+
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, parentUrl, source, sourceType);
|
|
806
816
|
// early analysis opt-out - no need to even fetch if we have feature support
|
|
807
817
|
if (!shimMode && baselinePassthrough && nativePassthrough && sourceType !== 'ts') {
|
|
808
818
|
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
@@ -1137,8 +1147,8 @@
|
|
|
1137
1147
|
const getOrCreateLoad = (url, fetchOpts, parent, source) => {
|
|
1138
1148
|
if (source && registry[url]) {
|
|
1139
1149
|
let i = 0;
|
|
1140
|
-
while (registry[url + '
|
|
1141
|
-
url += '
|
|
1150
|
+
while (registry[url + '#' + ++i]);
|
|
1151
|
+
url += '#' + i;
|
|
1142
1152
|
}
|
|
1143
1153
|
let load = registry[url];
|
|
1144
1154
|
if (load) return load;
|
|
@@ -1397,7 +1407,7 @@
|
|
|
1397
1407
|
!script.src ? script.innerHTML : undefined,
|
|
1398
1408
|
!shimMode,
|
|
1399
1409
|
isBlockingReadyScript && lastStaticLoadPromise,
|
|
1400
|
-
'ts'
|
|
1410
|
+
ts ? 'ts' : undefined
|
|
1401
1411
|
).catch(throwError);
|
|
1402
1412
|
}
|
|
1403
1413
|
if (!noLoadEventRetriggers) loadPromise.then(() => script.dispatchEvent(new Event('load')));
|
|
@@ -1415,4 +1425,10 @@
|
|
|
1415
1425
|
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
1416
1426
|
};
|
|
1417
1427
|
|
|
1418
|
-
|
|
1428
|
+
exports.topLevelLoad = topLevelLoad;
|
|
1429
|
+
|
|
1430
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1431
|
+
|
|
1432
|
+
return exports;
|
|
1433
|
+
|
|
1434
|
+
})({});
|