es-module-shims 1.3.3 → 1.3.4

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.3.4 (2021/12/02)
2
+ * Support source mapping normalization with trailing comments (https://github.com/guybedford/es-module-shims/pull/229)
3
+
1
4
  ES Module Shims 1.3.3 (2021/11/30))
2
5
  * Remove use of document.write (https://github.com/guybedford/es-module-shims/pull/227, @lewisl9029)
3
6
 
@@ -1,4 +1,4 @@
1
- /* ES Module Shims 1.3.3 */
1
+ /* ES Module Shims 1.3.4 */
2
2
  (function () {
3
3
 
4
4
  const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
@@ -529,9 +529,9 @@
529
529
  resolvedSource += source.slice(lastIndex);
530
530
  }
531
531
 
532
- resolvedSource = resolvedSource.replace(/\n\/\/# sourceMappingURL=([^\n]+)\s*$/, (match, url) => match.replace(url, () => new URL(url, load.r)));
532
+ // ; and // trailer support added for Ruby 7 source maps compatibility
533
533
  let hasSourceURL = false;
534
- resolvedSource = resolvedSource.replace(/\n\/\/# sourceURL=([^\n]+)\s*$/, (match, url) => (hasSourceURL = true, match.replace(url, () => new URL(url, load.r))));
534
+ resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
535
535
  if (!hasSourceURL)
536
536
  resolvedSource += '\n//# sourceURL=' + load.r;
537
537
 
@@ -539,6 +539,8 @@
539
539
  load.S = undefined;
540
540
  }
541
541
 
542
+ const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]+)\s*)*$/;
543
+
542
544
  const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
543
545
  const jsonContentType = /^(text|application)\/json(;|$)/;
544
546
  const cssContentType = /^(text|application)\/css(;|$)/;
@@ -1,4 +1,4 @@
1
- /* ES Module Shims Wasm 1.3.3 */
1
+ /* ES Module Shims Wasm 1.3.4 */
2
2
  (function () {
3
3
 
4
4
  const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
@@ -527,9 +527,9 @@
527
527
  resolvedSource += source.slice(lastIndex);
528
528
  }
529
529
 
530
- resolvedSource = resolvedSource.replace(/\n\/\/# sourceMappingURL=([^\n]+)\s*$/, (match, url) => match.replace(url, () => new URL(url, load.r)));
530
+ // ; and // trailer support added for Ruby 7 source maps compatibility
531
531
  let hasSourceURL = false;
532
- resolvedSource = resolvedSource.replace(/\n\/\/# sourceURL=([^\n]+)\s*$/, (match, url) => (hasSourceURL = true, match.replace(url, () => new URL(url, load.r))));
532
+ resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
533
533
  if (!hasSourceURL)
534
534
  resolvedSource += '\n//# sourceURL=' + load.r;
535
535
 
@@ -537,6 +537,8 @@
537
537
  load.S = undefined;
538
538
  }
539
539
 
540
+ const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]+)\s*)*$/;
541
+
540
542
  const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
541
543
  const jsonContentType = /^(text|application)\/json(;|$)/;
542
544
  const cssContentType = /^(text|application)\/css(;|$)/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-module-shims",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Shims for the latest ES module features",
5
5
  "main": "dist/es-module-shims.js",
6
6
  "exports": {
@@ -11,10 +11,10 @@
11
11
  "build": "rollup -c",
12
12
  "bench": "bash bench/bench.sh",
13
13
  "bench:clear": "rm -rf bench/results",
14
- "footprint": "npm run build && cat dist/es-module-shims.js | brotli | wc -c",
15
- "footprint:csp": "npm run build && cat dist/es-module-shims.csp.js | brotli | wc -c",
14
+ "footprint": "npm run build ; cat dist/es-module-shims.js | brotli | wc -c",
15
+ "footprint:csp": "npm run build ; cat dist/es-module-shims.csp.js | brotli | wc -c",
16
16
  "prepublishOnly": "npm run build",
17
- "test": "npm run test:test-base-href && npm run test:test-csp && npm run test:test-dom-order && npm run test:test-early-module-load && npm run test:test-polyfill && npm run test:test-polyfill-wasm && npm run test:test-preload-case && npm run test:test-revoke-blob-urls && npm run test:test-shim",
17
+ "test": "npm run test:test-base-href ; npm run test:test-csp ; npm run test:test-dom-order ; npm run test:test-early-module-load ; npm run test:test-polyfill ; npm run test:test-polyfill-wasm ; npm run test:test-preload-case ; npm run test:test-revoke-blob-urls ; npm run test:test-shim",
18
18
  "test:test-base-href": "cross-env TEST_NAME=test-base-href node test/server.mjs",
19
19
  "test:test-csp": "cross-env TEST_NAME=test-csp node test/server.mjs",
20
20
  "test:test-dom-order": "cross-env TEST_NAME=test-dom-order node test/server.mjs",