es-module-shims 1.5.5 → 1.5.6

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 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.5/dist/es-module-shims.js"></script>
32
+ <script async src="https://ga.jspm.io/npm:es-module-shims@1.5.6/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 1.5.5 */
1
+ /* ES Module Shims 1.5.6 */
2
2
  (function () {
3
3
 
4
4
  const noop = () => {};
@@ -273,21 +273,20 @@
273
273
  let supportsJsonAssertions = false;
274
274
  let supportsCssAssertions = false;
275
275
 
276
- let supportsImportMeta = false;
277
- let supportsImportMaps = false;
278
-
276
+ let supportsImportMaps = HTMLScriptElement.supports ? HTMLScriptElement.supports('importmap') : false;
277
+ let supportsImportMeta = supportsImportMaps;
279
278
  let supportsDynamicImport = false;
280
279
 
281
- const featureDetectionPromise = Promise.resolve(supportsDynamicImportCheck).then(_supportsDynamicImport => {
280
+ const featureDetectionPromise = Promise.resolve(supportsImportMaps || supportsDynamicImportCheck).then(_supportsDynamicImport => {
282
281
  if (!_supportsDynamicImport)
283
282
  return;
284
283
  supportsDynamicImport = true;
285
284
 
286
285
  return Promise.all([
287
- dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
286
+ supportsImportMaps || dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
288
287
  cssModulesEnabled && dynamicImport(createBlob('import"data:text/css,{}"assert{type:"css"}')).then(() => supportsCssAssertions = true, noop),
289
288
  jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
290
- HTMLScriptElement.supports ? supportsImportMaps = HTMLScriptElement.supports('importmap') : new Promise(resolve => {
289
+ supportsImportMaps || new Promise(resolve => {
291
290
  self._$s = v => {
292
291
  document.head.removeChild(iframe);
293
292
  if (v) supportsImportMaps = true;
@@ -297,8 +296,11 @@
297
296
  const iframe = document.createElement('iframe');
298
297
  iframe.style.display = 'none';
299
298
  iframe.setAttribute('nonce', nonce);
300
- iframe.srcdoc = `<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`;
301
299
  document.head.appendChild(iframe);
300
+ // we use document.write here because eg Weixin built-in browser doesn't support setting srcdoc
301
+ // setting src to a blob URL results in a navigation event in webviews
302
+ // setting srcdoc is not supported in React native webviews on iOS
303
+ iframe.contentWindow.document.write(`<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`);
302
304
  })
303
305
  ]);
304
306
  });
@@ -720,7 +722,7 @@
720
722
  load.L = load.f.then(async () => {
721
723
  let childFetchOpts = fetchOpts;
722
724
  load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
723
- if (d >= 0 && !supportsDynamicImport || d === 2 && !supportsImportMeta)
725
+ if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
724
726
  load.n = true;
725
727
  if (d !== -1 || !n) return;
726
728
  const { r, b } = await resolve(n, load.r || load.u);
@@ -1,4 +1,4 @@
1
- /* ES Module Shims Wasm 1.5.5 */
1
+ /* ES Module Shims Wasm 1.5.6 */
2
2
  (function () {
3
3
 
4
4
  const noop = () => {};
@@ -271,21 +271,20 @@
271
271
  let supportsJsonAssertions = false;
272
272
  let supportsCssAssertions = false;
273
273
 
274
- let supportsImportMeta = false;
275
- let supportsImportMaps = false;
276
-
274
+ let supportsImportMaps = HTMLScriptElement.supports ? HTMLScriptElement.supports('importmap') : false;
275
+ let supportsImportMeta = supportsImportMaps;
277
276
  let supportsDynamicImport = false;
278
277
 
279
- const featureDetectionPromise = Promise.resolve(supportsDynamicImportCheck).then(_supportsDynamicImport => {
278
+ const featureDetectionPromise = Promise.resolve(supportsImportMaps || supportsDynamicImportCheck).then(_supportsDynamicImport => {
280
279
  if (!_supportsDynamicImport)
281
280
  return;
282
281
  supportsDynamicImport = true;
283
282
 
284
283
  return Promise.all([
285
- dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
284
+ supportsImportMaps || dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
286
285
  cssModulesEnabled && dynamicImport(createBlob('import"data:text/css,{}"assert{type:"css"}')).then(() => supportsCssAssertions = true, noop),
287
286
  jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
288
- HTMLScriptElement.supports ? supportsImportMaps = HTMLScriptElement.supports('importmap') : new Promise(resolve => {
287
+ supportsImportMaps || new Promise(resolve => {
289
288
  self._$s = v => {
290
289
  document.head.removeChild(iframe);
291
290
  if (v) supportsImportMaps = true;
@@ -295,8 +294,11 @@
295
294
  const iframe = document.createElement('iframe');
296
295
  iframe.style.display = 'none';
297
296
  iframe.setAttribute('nonce', nonce);
298
- iframe.srcdoc = `<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`;
299
297
  document.head.appendChild(iframe);
298
+ // we use document.write here because eg Weixin built-in browser doesn't support setting srcdoc
299
+ // setting src to a blob URL results in a navigation event in webviews
300
+ // setting srcdoc is not supported in React native webviews on iOS
301
+ iframe.contentWindow.document.write(`<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`);
300
302
  })
301
303
  ]);
302
304
  });
@@ -718,7 +720,7 @@
718
720
  load.L = load.f.then(async () => {
719
721
  let childFetchOpts = fetchOpts;
720
722
  load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
721
- if (d >= 0 && !supportsDynamicImport || d === 2 && !supportsImportMeta)
723
+ if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
722
724
  load.n = true;
723
725
  if (d !== -1 || !n) return;
724
726
  const { r, b } = await resolve(n, load.r || load.u);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-module-shims",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "Shims for the latest ES module features",
5
5
  "main": "dist/es-module-shims.js",
6
6
  "exports": {