es-module-shims 1.4.0 → 1.4.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ES Module Shims 1.4.1 (2021/12/15)
2
+ * Fix: Firefox parse error stacks (https://github.com/guybedford/es-module-shims/pull/239)
3
+
1
4
  ES Module Shims 1.4.0 (2021/12/14)
2
5
  * Feature: "enforceIntegrity" option and "modulepreload-shim" support for secure shim mode with integrity (https://github.com/guybedford/es-module-shims/pull/236)
3
6
  * Fix: Safari parse error stacks (https://github.com/guybedford/es-module-shims/pull/238)
@@ -1,7 +1,9 @@
1
- /* ES Module Shims 1.4.0 */
1
+ /* ES Module Shims 1.4.1 */
2
2
  (function () {
3
3
 
4
- const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
4
+ const uaMatch = navigator.userAgent.match(/(Edge|Safari)\/\d+\.\d+/);
5
+ const edge = uaMatch && uaMatch[1] === 'Edge';
6
+ const safari = uaMatch && uaMatch[1] === 'Safari';
5
7
 
6
8
  let baseUrl;
7
9
 
@@ -762,8 +764,12 @@
762
764
  if (isDomContentLoadedScript) domContentLoadedCnt++;
763
765
  const blocks = script.getAttribute('async') === null && isReadyScript;
764
766
  const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, blocks && lastStaticLoadPromise).catch(e => {
765
- // This used to be a setTimeout(() => { throw e }) but this breaks Safari stacks
766
- console.error(e);
767
+ // Safari only gives error via console.error
768
+ if (safari)
769
+ console.error(e);
770
+ // Firefox only gives error stack via setTimeout
771
+ else
772
+ setTimeout(() => { throw e});
767
773
  onerror(e);
768
774
  });
769
775
  if (blocks)
@@ -1,7 +1,9 @@
1
- /* ES Module Shims Wasm 1.4.0 */
1
+ /* ES Module Shims Wasm 1.4.1 */
2
2
  (function () {
3
3
 
4
- const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
4
+ const uaMatch = navigator.userAgent.match(/(Edge|Safari)\/\d+\.\d+/);
5
+ const edge = uaMatch && uaMatch[1] === 'Edge';
6
+ const safari = uaMatch && uaMatch[1] === 'Safari';
5
7
 
6
8
  let baseUrl;
7
9
 
@@ -760,8 +762,12 @@
760
762
  if (isDomContentLoadedScript) domContentLoadedCnt++;
761
763
  const blocks = script.getAttribute('async') === null && isReadyScript;
762
764
  const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, blocks && lastStaticLoadPromise).catch(e => {
763
- // This used to be a setTimeout(() => { throw e }) but this breaks Safari stacks
764
- console.error(e);
765
+ // Safari only gives error via console.error
766
+ if (safari)
767
+ console.error(e);
768
+ // Firefox only gives error stack via setTimeout
769
+ else
770
+ setTimeout(() => { throw e});
765
771
  onerror(e);
766
772
  });
767
773
  if (blocks)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-module-shims",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Shims for the latest ES module features",
5
5
  "main": "dist/es-module-shims.js",
6
6
  "exports": {