es-module-shims 2.3.1 → 2.4.0
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 +12 -1
- package/dist/es-module-shims.debug.js +214 -206
- package/dist/es-module-shims.js +211 -203
- package/dist/es-module-shims.wasm.js +211 -203
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** ES Module Shims Wasm 2.
|
|
1
|
+
/** ES Module Shims Wasm @version 2.4.0 */
|
|
2
2
|
(function (exports) {
|
|
3
3
|
|
|
4
4
|
let invalidate;
|
|
@@ -161,10 +161,6 @@
|
|
|
161
161
|
];
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
if (self.importShim) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
164
|
const hasDocument = typeof document !== 'undefined';
|
|
169
165
|
|
|
170
166
|
const noop = () => {};
|
|
@@ -177,11 +173,19 @@
|
|
|
177
173
|
|
|
178
174
|
const dynamicImport = (u, errUrl) => import(u);
|
|
179
175
|
|
|
176
|
+
const defineValue = (obj, prop, value) =>
|
|
177
|
+
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
178
|
+
|
|
180
179
|
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
181
180
|
|
|
182
181
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
183
182
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
184
183
|
|
|
184
|
+
const r = esmsInitOptions.version;
|
|
185
|
+
if (self.importShim || (r && r !== "2.4.0")) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
185
189
|
// shim mode is determined on initialization, no late shim mode
|
|
186
190
|
const shimMode =
|
|
187
191
|
esmsInitOptions.shimMode ||
|
|
@@ -272,198 +276,198 @@
|
|
|
272
276
|
|
|
273
277
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
274
278
|
|
|
275
|
-
const backslashRegEx = /\\/g;
|
|
276
|
-
|
|
277
|
-
const asURL = url => {
|
|
278
|
-
try {
|
|
279
|
-
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
280
|
-
} catch (_) {}
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
const resolveUrl = (relUrl, parentUrl) =>
|
|
284
|
-
resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
|
|
285
|
-
|
|
286
|
-
const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
|
|
287
|
-
const hIdx = parentUrl.indexOf('#'),
|
|
288
|
-
qIdx = parentUrl.indexOf('?');
|
|
289
|
-
if (hIdx + qIdx > -2)
|
|
290
|
-
parentUrl = parentUrl.slice(
|
|
291
|
-
0,
|
|
292
|
-
hIdx === -1 ? qIdx
|
|
293
|
-
: qIdx === -1 || qIdx > hIdx ? hIdx
|
|
294
|
-
: qIdx
|
|
295
|
-
);
|
|
296
|
-
if (relUrl.indexOf('\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
|
|
297
|
-
// protocol-relative
|
|
298
|
-
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
299
|
-
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
300
|
-
}
|
|
301
|
-
// relative-url
|
|
302
|
-
else if (
|
|
303
|
-
(relUrl[0] === '.' &&
|
|
304
|
-
(relUrl[1] === '/' ||
|
|
305
|
-
(relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
|
|
306
|
-
(relUrl.length === 1 && (relUrl += '/')))) ||
|
|
307
|
-
relUrl[0] === '/'
|
|
308
|
-
) {
|
|
309
|
-
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
310
|
-
if (parentProtocol === 'blob:') {
|
|
311
|
-
throw new TypeError(
|
|
312
|
-
`Failed to resolve module specifier "${relUrl}". Invalid relative url or base scheme isn't hierarchical.`
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
316
|
-
//if (parentUrl[parentProtocol.length] !== '/')
|
|
317
|
-
// throw new Error('Cannot resolve');
|
|
318
|
-
// read pathname from parent URL
|
|
319
|
-
// pathname taken to be part after leading "/"
|
|
320
|
-
let pathname;
|
|
321
|
-
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
322
|
-
// resolving to a :// so we need to read out the auth and host
|
|
323
|
-
if (parentProtocol !== 'file:') {
|
|
324
|
-
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
325
|
-
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
326
|
-
} else {
|
|
327
|
-
pathname = parentUrl.slice(8);
|
|
328
|
-
}
|
|
329
|
-
} else {
|
|
330
|
-
// resolving to :/ so pathname is the /... part
|
|
331
|
-
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
335
|
-
|
|
336
|
-
// join together and split for removal of .. and . segments
|
|
337
|
-
// looping the string instead of anything fancy for perf reasons
|
|
338
|
-
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
339
|
-
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
340
|
-
|
|
341
|
-
const output = [];
|
|
342
|
-
let segmentIndex = -1;
|
|
343
|
-
for (let i = 0; i < segmented.length; i++) {
|
|
344
|
-
// busy reading a segment - only terminate on '/'
|
|
345
|
-
if (segmentIndex !== -1) {
|
|
346
|
-
if (segmented[i] === '/') {
|
|
347
|
-
output.push(segmented.slice(segmentIndex, i + 1));
|
|
348
|
-
segmentIndex = -1;
|
|
349
|
-
}
|
|
350
|
-
continue;
|
|
351
|
-
}
|
|
352
|
-
// new segment - check if it is relative
|
|
353
|
-
else if (segmented[i] === '.') {
|
|
354
|
-
// ../ segment
|
|
355
|
-
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
356
|
-
output.pop();
|
|
357
|
-
i += 2;
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
// ./ segment
|
|
361
|
-
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
362
|
-
i += 1;
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
// it is the start of a new segment
|
|
367
|
-
while (segmented[i] === '/') i++;
|
|
368
|
-
segmentIndex = i;
|
|
369
|
-
}
|
|
370
|
-
// finish reading out the last segment
|
|
371
|
-
if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
|
|
372
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
377
|
-
const outMap = {
|
|
378
|
-
imports:
|
|
379
|
-
scopes:
|
|
380
|
-
integrity:
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
384
|
-
|
|
385
|
-
if (json.scopes)
|
|
386
|
-
for (let s in json.scopes) {
|
|
387
|
-
const resolvedScope = resolveUrl(s, baseUrl);
|
|
388
|
-
resolveAndComposePackages(
|
|
389
|
-
json.scopes[s],
|
|
390
|
-
outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
|
|
391
|
-
baseUrl,
|
|
392
|
-
parentMap
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
|
|
397
|
-
|
|
398
|
-
return outMap;
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
const getMatch = (path, matchObj) => {
|
|
402
|
-
if (matchObj[path]) return path;
|
|
403
|
-
let sepIndex = path.length;
|
|
404
|
-
do {
|
|
405
|
-
const segment = path.slice(0, sepIndex + 1);
|
|
406
|
-
if (segment in matchObj) return segment;
|
|
407
|
-
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
const applyPackages = (id, packages) => {
|
|
411
|
-
const pkgName = getMatch(id, packages);
|
|
412
|
-
if (pkgName) {
|
|
413
|
-
const pkg = packages[pkgName];
|
|
414
|
-
if (pkg === null) return;
|
|
415
|
-
return pkg + id.slice(pkgName.length);
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
|
|
420
|
-
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
421
|
-
while (scopeUrl) {
|
|
422
|
-
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
423
|
-
if (packageResolution) return packageResolution;
|
|
424
|
-
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
425
|
-
}
|
|
426
|
-
return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
|
|
430
|
-
for (let p in packages) {
|
|
431
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
432
|
-
if (
|
|
433
|
-
(!shimMode || !mapOverrides) &&
|
|
434
|
-
outPackages[resolvedLhs] &&
|
|
435
|
-
outPackages[resolvedLhs] !== packages[resolvedLhs]
|
|
436
|
-
) {
|
|
437
|
-
console.warn(
|
|
438
|
-
`es-module-shims: Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`
|
|
439
|
-
);
|
|
440
|
-
continue;
|
|
441
|
-
}
|
|
442
|
-
let target = packages[p];
|
|
443
|
-
if (typeof target !== 'string') continue;
|
|
444
|
-
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
445
|
-
if (mapped) {
|
|
446
|
-
outPackages[resolvedLhs] = mapped;
|
|
447
|
-
continue;
|
|
448
|
-
}
|
|
449
|
-
console.warn(`es-module-shims: Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
|
|
454
|
-
for (let p in integrity) {
|
|
455
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
456
|
-
if (
|
|
457
|
-
(!shimMode || !mapOverrides) &&
|
|
458
|
-
outIntegrity[resolvedLhs] &&
|
|
459
|
-
outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
|
|
460
|
-
) {
|
|
461
|
-
console.warn(
|
|
462
|
-
`es-module-shims: Rejected map integrity override "${resolvedLhs}" from ${outIntegrity[resolvedLhs]} to ${integrity[resolvedLhs]}.`
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
outIntegrity[resolvedLhs] = integrity[p];
|
|
466
|
-
}
|
|
279
|
+
const backslashRegEx = /\\/g;
|
|
280
|
+
|
|
281
|
+
const asURL = url => {
|
|
282
|
+
try {
|
|
283
|
+
if (url.indexOf(':') !== -1) return new URL(url).href;
|
|
284
|
+
} catch (_) {}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const resolveUrl = (relUrl, parentUrl) =>
|
|
288
|
+
resolveIfNotPlainOrUrl(relUrl, parentUrl) || asURL(relUrl) || resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
|
|
289
|
+
|
|
290
|
+
const resolveIfNotPlainOrUrl = (relUrl, parentUrl) => {
|
|
291
|
+
const hIdx = parentUrl.indexOf('#'),
|
|
292
|
+
qIdx = parentUrl.indexOf('?');
|
|
293
|
+
if (hIdx + qIdx > -2)
|
|
294
|
+
parentUrl = parentUrl.slice(
|
|
295
|
+
0,
|
|
296
|
+
hIdx === -1 ? qIdx
|
|
297
|
+
: qIdx === -1 || qIdx > hIdx ? hIdx
|
|
298
|
+
: qIdx
|
|
299
|
+
);
|
|
300
|
+
if (relUrl.indexOf('\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
|
|
301
|
+
// protocol-relative
|
|
302
|
+
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
303
|
+
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
304
|
+
}
|
|
305
|
+
// relative-url
|
|
306
|
+
else if (
|
|
307
|
+
(relUrl[0] === '.' &&
|
|
308
|
+
(relUrl[1] === '/' ||
|
|
309
|
+
(relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
|
|
310
|
+
(relUrl.length === 1 && (relUrl += '/')))) ||
|
|
311
|
+
relUrl[0] === '/'
|
|
312
|
+
) {
|
|
313
|
+
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
314
|
+
if (parentProtocol === 'blob:') {
|
|
315
|
+
throw new TypeError(
|
|
316
|
+
`Failed to resolve module specifier "${relUrl}". Invalid relative url or base scheme isn't hierarchical.`
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
320
|
+
//if (parentUrl[parentProtocol.length] !== '/')
|
|
321
|
+
// throw new Error('Cannot resolve');
|
|
322
|
+
// read pathname from parent URL
|
|
323
|
+
// pathname taken to be part after leading "/"
|
|
324
|
+
let pathname;
|
|
325
|
+
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
326
|
+
// resolving to a :// so we need to read out the auth and host
|
|
327
|
+
if (parentProtocol !== 'file:') {
|
|
328
|
+
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
329
|
+
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
330
|
+
} else {
|
|
331
|
+
pathname = parentUrl.slice(8);
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
// resolving to :/ so pathname is the /... part
|
|
335
|
+
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
339
|
+
|
|
340
|
+
// join together and split for removal of .. and . segments
|
|
341
|
+
// looping the string instead of anything fancy for perf reasons
|
|
342
|
+
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
343
|
+
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
344
|
+
|
|
345
|
+
const output = [];
|
|
346
|
+
let segmentIndex = -1;
|
|
347
|
+
for (let i = 0; i < segmented.length; i++) {
|
|
348
|
+
// busy reading a segment - only terminate on '/'
|
|
349
|
+
if (segmentIndex !== -1) {
|
|
350
|
+
if (segmented[i] === '/') {
|
|
351
|
+
output.push(segmented.slice(segmentIndex, i + 1));
|
|
352
|
+
segmentIndex = -1;
|
|
353
|
+
}
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
// new segment - check if it is relative
|
|
357
|
+
else if (segmented[i] === '.') {
|
|
358
|
+
// ../ segment
|
|
359
|
+
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
360
|
+
output.pop();
|
|
361
|
+
i += 2;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
// ./ segment
|
|
365
|
+
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
366
|
+
i += 1;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
// it is the start of a new segment
|
|
371
|
+
while (segmented[i] === '/') i++;
|
|
372
|
+
segmentIndex = i;
|
|
373
|
+
}
|
|
374
|
+
// finish reading out the last segment
|
|
375
|
+
if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
|
|
376
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
const resolveAndComposeImportMap = (json, baseUrl, parentMap) => {
|
|
381
|
+
const outMap = {
|
|
382
|
+
imports: { ...parentMap.imports },
|
|
383
|
+
scopes: { ...parentMap.scopes },
|
|
384
|
+
integrity: { ...parentMap.integrity }
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
if (json.imports) resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
388
|
+
|
|
389
|
+
if (json.scopes)
|
|
390
|
+
for (let s in json.scopes) {
|
|
391
|
+
const resolvedScope = resolveUrl(s, baseUrl);
|
|
392
|
+
resolveAndComposePackages(
|
|
393
|
+
json.scopes[s],
|
|
394
|
+
outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
|
|
395
|
+
baseUrl,
|
|
396
|
+
parentMap
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (json.integrity) resolveAndComposeIntegrity(json.integrity, outMap.integrity, baseUrl);
|
|
401
|
+
|
|
402
|
+
return outMap;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
const getMatch = (path, matchObj) => {
|
|
406
|
+
if (matchObj[path]) return path;
|
|
407
|
+
let sepIndex = path.length;
|
|
408
|
+
do {
|
|
409
|
+
const segment = path.slice(0, sepIndex + 1);
|
|
410
|
+
if (segment in matchObj) return segment;
|
|
411
|
+
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const applyPackages = (id, packages) => {
|
|
415
|
+
const pkgName = getMatch(id, packages);
|
|
416
|
+
if (pkgName) {
|
|
417
|
+
const pkg = packages[pkgName];
|
|
418
|
+
if (pkg === null) return;
|
|
419
|
+
return pkg + id.slice(pkgName.length);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const resolveImportMap = (importMap, resolvedOrPlain, parentUrl) => {
|
|
424
|
+
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
425
|
+
while (scopeUrl) {
|
|
426
|
+
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
427
|
+
if (packageResolution) return packageResolution;
|
|
428
|
+
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
429
|
+
}
|
|
430
|
+
return applyPackages(resolvedOrPlain, importMap.imports) || (resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
const resolveAndComposePackages = (packages, outPackages, baseUrl, parentMap) => {
|
|
434
|
+
for (let p in packages) {
|
|
435
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
436
|
+
if (
|
|
437
|
+
(!shimMode || !mapOverrides) &&
|
|
438
|
+
outPackages[resolvedLhs] &&
|
|
439
|
+
outPackages[resolvedLhs] !== packages[resolvedLhs]
|
|
440
|
+
) {
|
|
441
|
+
console.warn(
|
|
442
|
+
`es-module-shims: Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`
|
|
443
|
+
);
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
let target = packages[p];
|
|
447
|
+
if (typeof target !== 'string') continue;
|
|
448
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
449
|
+
if (mapped) {
|
|
450
|
+
outPackages[resolvedLhs] = mapped;
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
console.warn(`es-module-shims: Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
const resolveAndComposeIntegrity = (integrity, outIntegrity, baseUrl) => {
|
|
458
|
+
for (let p in integrity) {
|
|
459
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
460
|
+
if (
|
|
461
|
+
(!shimMode || !mapOverrides) &&
|
|
462
|
+
outIntegrity[resolvedLhs] &&
|
|
463
|
+
outIntegrity[resolvedLhs] !== integrity[resolvedLhs]
|
|
464
|
+
) {
|
|
465
|
+
console.warn(
|
|
466
|
+
`es-module-shims: Rejected map integrity override "${resolvedLhs}" from ${outIntegrity[resolvedLhs]} to ${integrity[resolvedLhs]}.`
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
outIntegrity[resolvedLhs] = integrity[p];
|
|
470
|
+
}
|
|
467
471
|
};
|
|
468
472
|
|
|
469
473
|
// support browsers without dynamic import support (eg Firefox 6x)
|
|
@@ -661,8 +665,6 @@
|
|
|
661
665
|
|
|
662
666
|
if (hotReload) importShim$1.hotReload = hotReload$1;
|
|
663
667
|
|
|
664
|
-
self.importShim = importShim$1;
|
|
665
|
-
|
|
666
668
|
const defaultResolve = (id, parentUrl) => {
|
|
667
669
|
return (
|
|
668
670
|
resolveImportMap(composedImportMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) ||
|
|
@@ -690,6 +692,13 @@
|
|
|
690
692
|
const sourceCache = (importShim$1._s = {});
|
|
691
693
|
(importShim$1._i = new WeakMap());
|
|
692
694
|
|
|
695
|
+
// Ensure this version is the only version
|
|
696
|
+
defineValue(self, 'importShim', Object.freeze(importShim$1));
|
|
697
|
+
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
698
|
+
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
699
|
+
self.esmsInitOptions = shimModeOptions;
|
|
700
|
+
defineValue(self, '_d', undefined);
|
|
701
|
+
|
|
693
702
|
const loadAll = async (load, seen) => {
|
|
694
703
|
seen[load.u] = 1;
|
|
695
704
|
await load.L;
|
|
@@ -723,8 +732,7 @@
|
|
|
723
732
|
if (!shimMode && typeof WebAssembly !== 'undefined') {
|
|
724
733
|
if (wasmSourcePhaseEnabled && !Object.getPrototypeOf(WebAssembly.Module).name) {
|
|
725
734
|
const s = Symbol();
|
|
726
|
-
const brand = m =>
|
|
727
|
-
Object.defineProperty(m, s, { writable: false, configurable: false, value: 'WebAssembly.Module' });
|
|
735
|
+
const brand = m => defineValue(m, s, 'WebAssembly.Module');
|
|
728
736
|
class AbstractModuleSource {
|
|
729
737
|
get [Symbol.toStringTag]() {
|
|
730
738
|
if (this[s]) return this[s];
|
|
@@ -1080,7 +1088,7 @@
|
|
|
1080
1088
|
const mapIntegrity = composedImportMap.integrity[url];
|
|
1081
1089
|
const res = await doFetch(
|
|
1082
1090
|
url,
|
|
1083
|
-
mapIntegrity && !fetchOpts.integrity ?
|
|
1091
|
+
mapIntegrity && !fetchOpts.integrity ? { ...fetchOpts, integrity: mapIntegrity } : fetchOpts,
|
|
1084
1092
|
parent
|
|
1085
1093
|
);
|
|
1086
1094
|
const r = res.url;
|
|
@@ -1235,7 +1243,7 @@
|
|
|
1235
1243
|
if (d >= 0 || resolved.N) load.N = true;
|
|
1236
1244
|
if (d !== -1) return;
|
|
1237
1245
|
if (skip && skip(resolved.r) && !sourcePhase) return { l: { b: resolved.r }, s: false };
|
|
1238
|
-
if (childFetchOpts.integrity) childFetchOpts =
|
|
1246
|
+
if (childFetchOpts.integrity) childFetchOpts = { ...childFetchOpts, integrity: undefined };
|
|
1239
1247
|
const child = { l: getOrCreateLoad(resolved.r, childFetchOpts, load.r, source), s: sourcePhase };
|
|
1240
1248
|
// assertion case -> inline the CSS / JSON URL directly
|
|
1241
1249
|
if (source === '') child.l.b = child.l.u;
|