es-module-shims 1.7.3 → 1.8.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 +1 -1
- package/dist/es-module-shims.debug.js +18 -1
- package/dist/es-module-shims.js +18 -1
- package/dist/es-module-shims.wasm.js +18 -1
- package/package.json +1 -1
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.
|
|
32
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@1.8.0/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.
|
|
1
|
+
/* ES Module Shims DEBUG BUILD 1.8.0 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -463,6 +463,7 @@
|
|
|
463
463
|
};
|
|
464
464
|
|
|
465
465
|
const registry = importShim._r = {};
|
|
466
|
+
importShim._w = {};
|
|
466
467
|
|
|
467
468
|
async function loadAll (load, seen) {
|
|
468
469
|
if (load.b || seen[load.u])
|
|
@@ -708,6 +709,7 @@
|
|
|
708
709
|
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
709
710
|
|
|
710
711
|
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
712
|
+
const wasmContentType = /^(application)\/wasm(;|$)/;
|
|
711
713
|
const jsonContentType = /^(text|application)\/json(;|$)/;
|
|
712
714
|
const cssContentType = /^(text|application)\/css(;|$)/;
|
|
713
715
|
|
|
@@ -751,6 +753,21 @@
|
|
|
751
753
|
const contentType = res.headers.get('content-type');
|
|
752
754
|
if (jsContentType.test(contentType))
|
|
753
755
|
return { r: res.url, s: await res.text(), t: 'js' };
|
|
756
|
+
else if (wasmContentType.test(contentType)) {
|
|
757
|
+
const module = importShim._w[url] = await WebAssembly.compileStreaming(res);
|
|
758
|
+
let s = '', i = 0, importObj = '';
|
|
759
|
+
for (const impt of WebAssembly.Module.imports(module)) {
|
|
760
|
+
s += `import * as impt${i} from '${impt.module}';\n`;
|
|
761
|
+
importObj += `'${impt.module}':impt${i++},`;
|
|
762
|
+
}
|
|
763
|
+
i = 0;
|
|
764
|
+
s += `const instance = await WebAssembly.instantiate(importShim._w['${url}'], {${importObj}});\n`;
|
|
765
|
+
for (const expt of WebAssembly.Module.exports(module)) {
|
|
766
|
+
s += `const expt${i} = instance['${expt.name}'];\n`;
|
|
767
|
+
s += `export { expt${i++} as "${expt.name}" };\n`;
|
|
768
|
+
}
|
|
769
|
+
return { r: res.url, s, t: 'wasm' };
|
|
770
|
+
}
|
|
754
771
|
else if (jsonContentType.test(contentType))
|
|
755
772
|
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
|
|
756
773
|
else if (cssContentType.test(contentType)) {
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims 1.
|
|
1
|
+
/* ES Module Shims 1.8.0 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -458,6 +458,7 @@
|
|
|
458
458
|
};
|
|
459
459
|
|
|
460
460
|
const registry = importShim._r = {};
|
|
461
|
+
importShim._w = {};
|
|
461
462
|
|
|
462
463
|
async function loadAll (load, seen) {
|
|
463
464
|
if (load.b || seen[load.u])
|
|
@@ -701,6 +702,7 @@
|
|
|
701
702
|
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
702
703
|
|
|
703
704
|
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
705
|
+
const wasmContentType = /^(application)\/wasm(;|$)/;
|
|
704
706
|
const jsonContentType = /^(text|application)\/json(;|$)/;
|
|
705
707
|
const cssContentType = /^(text|application)\/css(;|$)/;
|
|
706
708
|
|
|
@@ -744,6 +746,21 @@
|
|
|
744
746
|
const contentType = res.headers.get('content-type');
|
|
745
747
|
if (jsContentType.test(contentType))
|
|
746
748
|
return { r: res.url, s: await res.text(), t: 'js' };
|
|
749
|
+
else if (wasmContentType.test(contentType)) {
|
|
750
|
+
const module = importShim._w[url] = await WebAssembly.compileStreaming(res);
|
|
751
|
+
let s = '', i = 0, importObj = '';
|
|
752
|
+
for (const impt of WebAssembly.Module.imports(module)) {
|
|
753
|
+
s += `import * as impt${i} from '${impt.module}';\n`;
|
|
754
|
+
importObj += `'${impt.module}':impt${i++},`;
|
|
755
|
+
}
|
|
756
|
+
i = 0;
|
|
757
|
+
s += `const instance = await WebAssembly.instantiate(importShim._w['${url}'], {${importObj}});\n`;
|
|
758
|
+
for (const expt of WebAssembly.Module.exports(module)) {
|
|
759
|
+
s += `const expt${i} = instance['${expt.name}'];\n`;
|
|
760
|
+
s += `export { expt${i++} as "${expt.name}" };\n`;
|
|
761
|
+
}
|
|
762
|
+
return { r: res.url, s, t: 'wasm' };
|
|
763
|
+
}
|
|
747
764
|
else if (jsonContentType.test(contentType))
|
|
748
765
|
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
|
|
749
766
|
else if (cssContentType.test(contentType)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims Wasm 1.
|
|
1
|
+
/* ES Module Shims Wasm 1.8.0 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -458,6 +458,7 @@
|
|
|
458
458
|
};
|
|
459
459
|
|
|
460
460
|
const registry = importShim._r = {};
|
|
461
|
+
importShim._w = {};
|
|
461
462
|
|
|
462
463
|
async function loadAll (load, seen) {
|
|
463
464
|
if (load.b || seen[load.u])
|
|
@@ -701,6 +702,7 @@
|
|
|
701
702
|
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
|
702
703
|
|
|
703
704
|
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
705
|
+
const wasmContentType = /^(application)\/wasm(;|$)/;
|
|
704
706
|
const jsonContentType = /^(text|application)\/json(;|$)/;
|
|
705
707
|
const cssContentType = /^(text|application)\/css(;|$)/;
|
|
706
708
|
|
|
@@ -744,6 +746,21 @@
|
|
|
744
746
|
const contentType = res.headers.get('content-type');
|
|
745
747
|
if (jsContentType.test(contentType))
|
|
746
748
|
return { r: res.url, s: await res.text(), t: 'js' };
|
|
749
|
+
else if (wasmContentType.test(contentType)) {
|
|
750
|
+
const module = importShim._w[url] = await WebAssembly.compileStreaming(res);
|
|
751
|
+
let s = '', i = 0, importObj = '';
|
|
752
|
+
for (const impt of WebAssembly.Module.imports(module)) {
|
|
753
|
+
s += `import * as impt${i} from '${impt.module}';\n`;
|
|
754
|
+
importObj += `'${impt.module}':impt${i++},`;
|
|
755
|
+
}
|
|
756
|
+
i = 0;
|
|
757
|
+
s += `const instance = await WebAssembly.instantiate(importShim._w['${url}'], {${importObj}});\n`;
|
|
758
|
+
for (const expt of WebAssembly.Module.exports(module)) {
|
|
759
|
+
s += `const expt${i} = instance['${expt.name}'];\n`;
|
|
760
|
+
s += `export { expt${i++} as "${expt.name}" };\n`;
|
|
761
|
+
}
|
|
762
|
+
return { r: res.url, s, t: 'wasm' };
|
|
763
|
+
}
|
|
747
764
|
else if (jsonContentType.test(contentType))
|
|
748
765
|
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
|
|
749
766
|
else if (cssContentType.test(contentType)) {
|