es-module-shims 1.4.2 → 1.4.3

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,7 @@
1
+ ES Module Shims 1.4.3 (2022/01/25)
2
+ * Feature: Support import map overrides when existing resolution matches new resolution (https://github.com/guybedford/es-module-shims/pull/249, @vovacodes)
3
+ * Fix: Import assertions support with dynamic imports (https://github.com/guybedford/es-module-shims/pull/248)
4
+
1
5
  ES Module Shims 1.4.2 (2022/01/24)
2
6
  * Fix: optional catch binding in `isUrl` function (@thepassle, https://github.com/guybedford/es-module-shims/pull/246)
3
7
 
package/README.md CHANGED
@@ -27,7 +27,7 @@ Because we are still using the native module loader the edge cases work out comp
27
27
  Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
28
28
 
29
29
  ```html
30
- <script async src="https://ga.jspm.io/npm:es-module-shims@1.4.2/dist/es-module-shims.js"></script>
30
+ <script async src="https://ga.jspm.io/npm:es-module-shims@1.4.3/dist/es-module-shims.js"></script>
31
31
 
32
32
  <!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
33
33
  <script type="importmap">
@@ -1,4 +1,4 @@
1
- /* ES Module Shims 1.4.2 */
1
+ /* ES Module Shims 1.4.3 */
2
2
  (function () {
3
3
 
4
4
  const uaMatch = navigator.userAgent.match(/(Edge|Safari)\/\d+\.\d+/);
@@ -131,7 +131,7 @@
131
131
  function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
132
132
  for (let p in packages) {
133
133
  const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
134
- if (outPackages[resolvedLhs]) {
134
+ if (outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
135
135
  throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
136
136
  }
137
137
  let target = packages[p];
@@ -486,7 +486,7 @@
486
486
  // once all deps have loaded we can inline the dependency resolution blobs
487
487
  // and define this blob
488
488
  let lastIndex = 0, depIndex = 0;
489
- for (const { s: start, se: end, d: dynamicImportIndex } of imports) {
489
+ for (const { s: start, e: end, se: statementEnd, d: dynamicImportIndex } of imports) {
490
490
  // dependency source replacements
491
491
  if (dynamicImportIndex === -1) {
492
492
  const depLoad = load.d[depIndex++];
@@ -507,24 +507,24 @@
507
507
  }
508
508
  // circular shell execution
509
509
  else if (depLoad.s) {
510
- resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)};import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
511
- lastIndex = end;
510
+ resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)};import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
511
+ lastIndex = statementEnd;
512
512
  depLoad.s = undefined;
513
513
  continue;
514
514
  }
515
- resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)}`;
516
- lastIndex = end;
515
+ resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
516
+ lastIndex = statementEnd;
517
517
  }
518
518
  // import.meta
519
519
  else if (dynamicImportIndex === -2) {
520
520
  meta[load.r] = { url: load.r, resolve: importMetaResolve };
521
521
  resolvedSource += `${source.slice(lastIndex, start)}self._esmsm[${urlJsString(load.r)}]`;
522
- lastIndex = end;
522
+ lastIndex = statementEnd;
523
523
  }
524
524
  // dynamic import
525
525
  else {
526
- resolvedSource += `${source.slice(lastIndex, dynamicImportIndex + 6)}Shim(${source.slice(start, end)}, ${load.r && urlJsString(load.r)}`;
527
- lastIndex = end;
526
+ resolvedSource += `${source.slice(lastIndex, dynamicImportIndex + 6)}Shim(${source.slice(start, end)}, ${load.r && urlJsString(load.r)}${source.slice(end, statementEnd)}`;
527
+ lastIndex = statementEnd;
528
528
  }
529
529
  }
530
530
 
@@ -1,4 +1,4 @@
1
- /* ES Module Shims Wasm 1.4.2 */
1
+ /* ES Module Shims Wasm 1.4.3 */
2
2
  (function () {
3
3
 
4
4
  const uaMatch = navigator.userAgent.match(/(Edge|Safari)\/\d+\.\d+/);
@@ -131,7 +131,7 @@
131
131
  function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
132
132
  for (let p in packages) {
133
133
  const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
134
- if (outPackages[resolvedLhs]) {
134
+ if (outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
135
135
  throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
136
136
  }
137
137
  let target = packages[p];
@@ -484,7 +484,7 @@
484
484
  // once all deps have loaded we can inline the dependency resolution blobs
485
485
  // and define this blob
486
486
  let lastIndex = 0, depIndex = 0;
487
- for (const { s: start, se: end, d: dynamicImportIndex } of imports) {
487
+ for (const { s: start, e: end, se: statementEnd, d: dynamicImportIndex } of imports) {
488
488
  // dependency source replacements
489
489
  if (dynamicImportIndex === -1) {
490
490
  const depLoad = load.d[depIndex++];
@@ -505,24 +505,24 @@
505
505
  }
506
506
  // circular shell execution
507
507
  else if (depLoad.s) {
508
- resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)};import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
509
- lastIndex = end;
508
+ resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)};import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
509
+ lastIndex = statementEnd;
510
510
  depLoad.s = undefined;
511
511
  continue;
512
512
  }
513
- resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, end)}*/${urlJsString(blobUrl)}`;
514
- lastIndex = end;
513
+ resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
514
+ lastIndex = statementEnd;
515
515
  }
516
516
  // import.meta
517
517
  else if (dynamicImportIndex === -2) {
518
518
  meta[load.r] = { url: load.r, resolve: importMetaResolve };
519
519
  resolvedSource += `${source.slice(lastIndex, start)}self._esmsm[${urlJsString(load.r)}]`;
520
- lastIndex = end;
520
+ lastIndex = statementEnd;
521
521
  }
522
522
  // dynamic import
523
523
  else {
524
- resolvedSource += `${source.slice(lastIndex, dynamicImportIndex + 6)}Shim(${source.slice(start, end)}, ${load.r && urlJsString(load.r)}`;
525
- lastIndex = end;
524
+ resolvedSource += `${source.slice(lastIndex, dynamicImportIndex + 6)}Shim(${source.slice(start, end)}, ${load.r && urlJsString(load.r)}${source.slice(end, statementEnd)}`;
525
+ lastIndex = statementEnd;
526
526
  }
527
527
  }
528
528
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-module-shims",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Shims for the latest ES module features",
5
5
  "main": "dist/es-module-shims.js",
6
6
  "exports": {