es-module-shims 1.7.1 → 1.7.3
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 +1 -1
- package/dist/es-module-shims.debug.js +97 -76
- package/dist/es-module-shims.js +97 -75
- package/dist/es-module-shims.wasm.js +97 -75
- package/package.json +2 -1
- package/dist/es-module-shims.wasm.debug.js +0 -898
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Because we are still using the native module loader the edge cases work out comp
|
|
|
29
29
|
Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
|
|
30
30
|
|
|
31
31
|
```html
|
|
32
|
-
<script async src="https://ga.jspm.io/npm:es-module-shims@1.7.
|
|
32
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@1.7.3/dist/es-module-shims.js"></script>
|
|
33
33
|
|
|
34
34
|
<!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
|
|
35
35
|
<script type="importmap">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims DEBUG BUILD 1.7.
|
|
1
|
+
/* ES Module Shims DEBUG BUILD 1.7.3 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -334,14 +334,14 @@
|
|
|
334
334
|
iframe.style.display = 'none';
|
|
335
335
|
iframe.setAttribute('nonce', nonce);
|
|
336
336
|
function cb ({ data }) {
|
|
337
|
-
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
supportsImportMeta = data[1];
|
|
341
|
-
supportsCssAssertions = data[2];
|
|
342
|
-
supportsJsonAssertions = data[3];
|
|
337
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
338
|
+
if (!isFeatureDetectionMessage) {
|
|
339
|
+
return;
|
|
343
340
|
}
|
|
344
|
-
|
|
341
|
+
supportsImportMaps = data[1];
|
|
342
|
+
supportsImportMeta = data[2];
|
|
343
|
+
supportsCssAssertions = data[3];
|
|
344
|
+
supportsJsonAssertions = data[4];
|
|
345
345
|
resolve();
|
|
346
346
|
document.head.removeChild(iframe);
|
|
347
347
|
window.removeEventListener('message', cb, false);
|
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
|
|
351
351
|
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
|
352
352
|
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
353
|
-
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(a,'*'))<${''}/script>`;
|
|
353
|
+
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
354
354
|
|
|
355
355
|
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
356
356
|
// path to trigger before setting srcdoc, therefore we track the timing
|
|
@@ -603,88 +603,109 @@
|
|
|
603
603
|
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
|
|
604
604
|
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
|
605
605
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
615
|
-
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
616
|
-
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
617
|
-
lastIndex = dynamicImportEnd;
|
|
618
|
-
}
|
|
619
|
-
resolvedSource += source.slice(lastIndex, originalIndex);
|
|
620
|
-
lastIndex = originalIndex;
|
|
606
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
|
607
|
+
// and define this blob
|
|
608
|
+
let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
|
|
609
|
+
function pushStringTo (originalIndex) {
|
|
610
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
611
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
612
|
+
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
613
|
+
lastIndex = dynamicImportEnd;
|
|
621
614
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
|
|
626
|
-
if (cycleShell) {
|
|
627
|
-
// circular shell creation
|
|
628
|
-
if (!(blobUrl = depLoad.s)) {
|
|
629
|
-
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
|
630
|
-
depLoad.a[1].map(({ s, e }, i) => {
|
|
631
|
-
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
632
|
-
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
633
|
-
}).join(',')
|
|
634
|
-
}}${
|
|
635
|
-
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
636
|
-
}export {${
|
|
637
|
-
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
|
|
638
|
-
}}\n//# sourceURL=${depLoad.r}?cycle`);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
pushStringTo(start - 1);
|
|
643
|
-
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
|
615
|
+
resolvedSource += source.slice(lastIndex, originalIndex);
|
|
616
|
+
lastIndex = originalIndex;
|
|
617
|
+
}
|
|
644
618
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
619
|
+
for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
|
|
620
|
+
// dependency source replacements
|
|
621
|
+
if (dynamicImportIndex === -1) {
|
|
622
|
+
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
|
|
623
|
+
if (cycleShell) {
|
|
624
|
+
// circular shell creation
|
|
625
|
+
if (!(blobUrl = depLoad.s)) {
|
|
626
|
+
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
|
627
|
+
depLoad.a[1].map(({ s, e }, i) => {
|
|
628
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
629
|
+
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
630
|
+
}).join(',')
|
|
631
|
+
}}${
|
|
632
|
+
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
633
|
+
}export {${
|
|
634
|
+
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
|
|
635
|
+
}}\n//# sourceURL=${depLoad.r}?cycle`);
|
|
649
636
|
}
|
|
650
|
-
lastIndex = statementEnd;
|
|
651
|
-
}
|
|
652
|
-
// import.meta
|
|
653
|
-
else if (dynamicImportIndex === -2) {
|
|
654
|
-
load.m = { url: load.r, resolve: metaResolve };
|
|
655
|
-
metaHook(load.m, load.u);
|
|
656
|
-
pushStringTo(start);
|
|
657
|
-
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
658
|
-
lastIndex = statementEnd;
|
|
659
637
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
638
|
+
|
|
639
|
+
pushStringTo(start - 1);
|
|
640
|
+
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
|
641
|
+
|
|
642
|
+
// circular shell execution
|
|
643
|
+
if (!cycleShell && depLoad.s) {
|
|
644
|
+
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
|
645
|
+
depLoad.s = undefined;
|
|
666
646
|
}
|
|
647
|
+
lastIndex = statementEnd;
|
|
648
|
+
}
|
|
649
|
+
// import.meta
|
|
650
|
+
else if (dynamicImportIndex === -2) {
|
|
651
|
+
load.m = { url: load.r, resolve: metaResolve };
|
|
652
|
+
metaHook(load.m, load.u);
|
|
653
|
+
pushStringTo(start);
|
|
654
|
+
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
655
|
+
lastIndex = statementEnd;
|
|
656
|
+
}
|
|
657
|
+
// dynamic import
|
|
658
|
+
else {
|
|
659
|
+
pushStringTo(statementStart + 6);
|
|
660
|
+
resolvedSource += `Shim(`;
|
|
661
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
|
662
|
+
lastIndex = start;
|
|
667
663
|
}
|
|
664
|
+
}
|
|
668
665
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
666
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
667
|
+
if (load.s)
|
|
668
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`).join(',')}})}catch(_){};\n`;
|
|
669
|
+
|
|
670
|
+
function pushSourceURL (commentPrefix, commentStart) {
|
|
671
|
+
const urlStart = commentStart + commentPrefix.length;
|
|
672
|
+
const commentEnd = source.indexOf('\n', urlStart);
|
|
673
|
+
const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
|
|
674
|
+
pushStringTo(urlStart);
|
|
675
|
+
resolvedSource += new URL(source.slice(urlStart, urlEnd), load.r).href;
|
|
676
|
+
lastIndex = urlEnd;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
680
|
+
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
681
|
+
|
|
682
|
+
// ignore sourceMap comments before already spliced code
|
|
683
|
+
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
684
|
+
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
672
685
|
|
|
673
|
-
|
|
686
|
+
// sourceURL first / only
|
|
687
|
+
if (sourceURLCommentStart !== -1 && (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)) {
|
|
688
|
+
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
674
689
|
}
|
|
690
|
+
// sourceMappingURL
|
|
691
|
+
if (sourceMapURLCommentStart !== -1) {
|
|
692
|
+
pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
|
|
693
|
+
// sourceURL last
|
|
694
|
+
if (sourceURLCommentStart !== -1 && (sourceURLCommentStart > sourceMapURLCommentStart))
|
|
695
|
+
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
pushStringTo(source.length);
|
|
675
699
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (!hasSourceURL)
|
|
679
|
-
resolvedSource += '\n//# sourceURL=' + load.r;
|
|
700
|
+
if (sourceURLCommentStart === -1)
|
|
701
|
+
resolvedSource += sourceURLCommentPrefix + load.r;
|
|
680
702
|
|
|
681
703
|
load.b = lastLoad = createBlob(resolvedSource);
|
|
682
704
|
load.S = undefined;
|
|
683
705
|
}
|
|
684
706
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
|
|
707
|
+
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
|
708
|
+
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
688
709
|
|
|
689
710
|
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
690
711
|
const jsonContentType = /^(text|application)\/json(;|$)/;
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims 1.7.
|
|
1
|
+
/* ES Module Shims 1.7.3 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -333,13 +333,14 @@
|
|
|
333
333
|
iframe.style.display = 'none';
|
|
334
334
|
iframe.setAttribute('nonce', nonce);
|
|
335
335
|
function cb ({ data }) {
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
|
|
339
|
-
supportsImportMeta = data[1];
|
|
340
|
-
supportsCssAssertions = data[2];
|
|
341
|
-
supportsJsonAssertions = data[3];
|
|
336
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
337
|
+
if (!isFeatureDetectionMessage) {
|
|
338
|
+
return;
|
|
342
339
|
}
|
|
340
|
+
supportsImportMaps = data[1];
|
|
341
|
+
supportsImportMeta = data[2];
|
|
342
|
+
supportsCssAssertions = data[3];
|
|
343
|
+
supportsJsonAssertions = data[4];
|
|
343
344
|
resolve();
|
|
344
345
|
document.head.removeChild(iframe);
|
|
345
346
|
window.removeEventListener('message', cb, false);
|
|
@@ -348,7 +349,7 @@
|
|
|
348
349
|
|
|
349
350
|
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
|
350
351
|
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
351
|
-
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(a,'*'))<${''}/script>`;
|
|
352
|
+
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
352
353
|
|
|
353
354
|
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
354
355
|
// path to trigger before setting srcdoc, therefore we track the timing
|
|
@@ -595,88 +596,109 @@
|
|
|
595
596
|
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
|
|
596
597
|
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
|
597
598
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
607
|
-
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
608
|
-
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
609
|
-
lastIndex = dynamicImportEnd;
|
|
610
|
-
}
|
|
611
|
-
resolvedSource += source.slice(lastIndex, originalIndex);
|
|
612
|
-
lastIndex = originalIndex;
|
|
599
|
+
// once all deps have loaded we can inline the dependency resolution blobs
|
|
600
|
+
// and define this blob
|
|
601
|
+
let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
|
|
602
|
+
function pushStringTo (originalIndex) {
|
|
603
|
+
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
604
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
605
|
+
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
606
|
+
lastIndex = dynamicImportEnd;
|
|
613
607
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
|
|
618
|
-
if (cycleShell) {
|
|
619
|
-
// circular shell creation
|
|
620
|
-
if (!(blobUrl = depLoad.s)) {
|
|
621
|
-
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
|
622
|
-
depLoad.a[1].map(({ s, e }, i) => {
|
|
623
|
-
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
624
|
-
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
625
|
-
}).join(',')
|
|
626
|
-
}}${
|
|
627
|
-
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
628
|
-
}export {${
|
|
629
|
-
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
|
|
630
|
-
}}\n//# sourceURL=${depLoad.r}?cycle`);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
pushStringTo(start - 1);
|
|
635
|
-
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
|
608
|
+
resolvedSource += source.slice(lastIndex, originalIndex);
|
|
609
|
+
lastIndex = originalIndex;
|
|
610
|
+
}
|
|
636
611
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
612
|
+
for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
|
|
613
|
+
// dependency source replacements
|
|
614
|
+
if (dynamicImportIndex === -1) {
|
|
615
|
+
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
|
|
616
|
+
if (cycleShell) {
|
|
617
|
+
// circular shell creation
|
|
618
|
+
if (!(blobUrl = depLoad.s)) {
|
|
619
|
+
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
|
620
|
+
depLoad.a[1].map(({ s, e }, i) => {
|
|
621
|
+
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
622
|
+
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
623
|
+
}).join(',')
|
|
624
|
+
}}${
|
|
625
|
+
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
626
|
+
}export {${
|
|
627
|
+
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
|
|
628
|
+
}}\n//# sourceURL=${depLoad.r}?cycle`);
|
|
641
629
|
}
|
|
642
|
-
lastIndex = statementEnd;
|
|
643
|
-
}
|
|
644
|
-
// import.meta
|
|
645
|
-
else if (dynamicImportIndex === -2) {
|
|
646
|
-
load.m = { url: load.r, resolve: metaResolve };
|
|
647
|
-
metaHook(load.m, load.u);
|
|
648
|
-
pushStringTo(start);
|
|
649
|
-
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
650
|
-
lastIndex = statementEnd;
|
|
651
630
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
631
|
+
|
|
632
|
+
pushStringTo(start - 1);
|
|
633
|
+
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
|
634
|
+
|
|
635
|
+
// circular shell execution
|
|
636
|
+
if (!cycleShell && depLoad.s) {
|
|
637
|
+
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
|
638
|
+
depLoad.s = undefined;
|
|
658
639
|
}
|
|
640
|
+
lastIndex = statementEnd;
|
|
641
|
+
}
|
|
642
|
+
// import.meta
|
|
643
|
+
else if (dynamicImportIndex === -2) {
|
|
644
|
+
load.m = { url: load.r, resolve: metaResolve };
|
|
645
|
+
metaHook(load.m, load.u);
|
|
646
|
+
pushStringTo(start);
|
|
647
|
+
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
648
|
+
lastIndex = statementEnd;
|
|
649
|
+
}
|
|
650
|
+
// dynamic import
|
|
651
|
+
else {
|
|
652
|
+
pushStringTo(statementStart + 6);
|
|
653
|
+
resolvedSource += `Shim(`;
|
|
654
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
|
655
|
+
lastIndex = start;
|
|
659
656
|
}
|
|
657
|
+
}
|
|
660
658
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
659
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
660
|
+
if (load.s)
|
|
661
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`).join(',')}})}catch(_){};\n`;
|
|
662
|
+
|
|
663
|
+
function pushSourceURL (commentPrefix, commentStart) {
|
|
664
|
+
const urlStart = commentStart + commentPrefix.length;
|
|
665
|
+
const commentEnd = source.indexOf('\n', urlStart);
|
|
666
|
+
const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
|
|
667
|
+
pushStringTo(urlStart);
|
|
668
|
+
resolvedSource += new URL(source.slice(urlStart, urlEnd), load.r).href;
|
|
669
|
+
lastIndex = urlEnd;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
|
673
|
+
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
|
674
|
+
|
|
675
|
+
// ignore sourceMap comments before already spliced code
|
|
676
|
+
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
|
677
|
+
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
|
664
678
|
|
|
665
|
-
|
|
679
|
+
// sourceURL first / only
|
|
680
|
+
if (sourceURLCommentStart !== -1 && (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)) {
|
|
681
|
+
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
666
682
|
}
|
|
683
|
+
// sourceMappingURL
|
|
684
|
+
if (sourceMapURLCommentStart !== -1) {
|
|
685
|
+
pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
|
|
686
|
+
// sourceURL last
|
|
687
|
+
if (sourceURLCommentStart !== -1 && (sourceURLCommentStart > sourceMapURLCommentStart))
|
|
688
|
+
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
pushStringTo(source.length);
|
|
667
692
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
if (!hasSourceURL)
|
|
671
|
-
resolvedSource += '\n//# sourceURL=' + load.r;
|
|
693
|
+
if (sourceURLCommentStart === -1)
|
|
694
|
+
resolvedSource += sourceURLCommentPrefix + load.r;
|
|
672
695
|
|
|
673
696
|
load.b = lastLoad = createBlob(resolvedSource);
|
|
674
697
|
load.S = undefined;
|
|
675
698
|
}
|
|
676
699
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
|
|
700
|
+
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
|
701
|
+
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
680
702
|
|
|
681
703
|
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
682
704
|
const jsonContentType = /^(text|application)\/json(;|$)/;
|