es-module-shims 1.5.16 → 1.5.17
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.js +17 -3
- package/dist/es-module-shims.wasm.js +17 -3
- 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.5.
|
|
32
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.17/dist/es-module-shims.js"></script>
|
|
33
33
|
|
|
34
34
|
<!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
|
|
35
35
|
<script type="importmap">
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims 1.5.
|
|
1
|
+
/* ES Module Shims 1.5.17 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -342,9 +342,24 @@
|
|
|
342
342
|
}
|
|
343
343
|
window.addEventListener('message', cb, false);
|
|
344
344
|
|
|
345
|
-
const importMapTest = `<script nonce=${nonce}>
|
|
345
|
+
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([${
|
|
346
346
|
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
347
347
|
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>`;
|
|
348
|
+
|
|
349
|
+
iframe.onload = () => {
|
|
350
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
351
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
352
|
+
const doc = iframe.contentDocument;
|
|
353
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
354
|
+
const s = doc.createElement('script');
|
|
355
|
+
if (nonce)
|
|
356
|
+
s.setAttribute('nonce', nonce);
|
|
357
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
358
|
+
doc.head.appendChild(s);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
// WeChat browser requires append before setting srcdoc
|
|
362
|
+
document.head.appendChild(iframe);
|
|
348
363
|
// setting srcdoc is not supported in React native webviews on iOS
|
|
349
364
|
// setting src to a blob URL results in a navigation event in webviews
|
|
350
365
|
// document.write gives usability warnings
|
|
@@ -352,7 +367,6 @@
|
|
|
352
367
|
iframe.srcdoc = importMapTest;
|
|
353
368
|
else
|
|
354
369
|
iframe.contentDocument.write(importMapTest);
|
|
355
|
-
document.head.appendChild(iframe);
|
|
356
370
|
});
|
|
357
371
|
});
|
|
358
372
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims Wasm 1.5.
|
|
1
|
+
/* ES Module Shims Wasm 1.5.17 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -342,9 +342,24 @@
|
|
|
342
342
|
}
|
|
343
343
|
window.addEventListener('message', cb, false);
|
|
344
344
|
|
|
345
|
-
const importMapTest = `<script nonce=${nonce}>
|
|
345
|
+
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([${
|
|
346
346
|
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
347
347
|
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>`;
|
|
348
|
+
|
|
349
|
+
iframe.onload = () => {
|
|
350
|
+
// WeChat browser doesn't support setting srcdoc scripts
|
|
351
|
+
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
352
|
+
const doc = iframe.contentDocument;
|
|
353
|
+
if (doc && doc.head.childNodes.length === 0) {
|
|
354
|
+
const s = doc.createElement('script');
|
|
355
|
+
if (nonce)
|
|
356
|
+
s.setAttribute('nonce', nonce);
|
|
357
|
+
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
358
|
+
doc.head.appendChild(s);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
// WeChat browser requires append before setting srcdoc
|
|
362
|
+
document.head.appendChild(iframe);
|
|
348
363
|
// setting srcdoc is not supported in React native webviews on iOS
|
|
349
364
|
// setting src to a blob URL results in a navigation event in webviews
|
|
350
365
|
// document.write gives usability warnings
|
|
@@ -352,7 +367,6 @@
|
|
|
352
367
|
iframe.srcdoc = importMapTest;
|
|
353
368
|
else
|
|
354
369
|
iframe.contentDocument.write(importMapTest);
|
|
355
|
-
document.head.appendChild(iframe);
|
|
356
370
|
});
|
|
357
371
|
});
|
|
358
372
|
|