es-module-shims 1.5.18 → 1.6.0

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.18/dist/es-module-shims.js"></script>
32
+ <script async src="https://ga.jspm.io/npm:es-module-shims@1.6.0/dist/es-module-shims.js"></script>
33
33
 
34
34
  <!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
35
35
  <script type="importmap">
@@ -626,12 +626,23 @@ In such a case, this double event firing can be disabled with the `noLoadEventRe
626
626
 
627
627
  When loading modules that you know will only use baseline modules features, it is possible to set a rule to explicitly opt-out modules from rewriting. This improves performance because those modules then do not need to be processed or transformed at all, so that only local application code is handled and not library code.
628
628
 
629
- This can be configured by providing a URL regular expression for the `skip` option:
629
+ The `skip` option supports a string regular expression or array of exact module URLs to check:
630
630
 
631
631
  ```js
632
632
  <script type="esms-options">
633
633
  {
634
- "skip": "/^https?:\/\/(cdn\.skypack\.dev|jspm\.dev)\//"
634
+ "skip": "^https?:\/\/(cdn\.skypack\.dev|jspm\.dev)\/"
635
+ }
636
+ </script>
637
+ <script async src="es-module-shims.js"></script>
638
+ ```
639
+
640
+ When passing an array, relative URLs or paths ending in `/` can be provided:
641
+
642
+ ```js
643
+ <script type="esms-options">
644
+ {
645
+ "skip": ["./app.js", "https://jspm.dev/"]
635
646
  }
636
647
  </script>
637
648
  <script async src="es-module-shims.js"></script>
@@ -1,4 +1,4 @@
1
- /* ES Module Shims 1.5.18 */
1
+ /* ES Module Shims 1.6.0 */
2
2
  (function () {
3
3
 
4
4
  const hasWindow = typeof window !== 'undefined';
@@ -18,8 +18,6 @@
18
18
  let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
19
19
  const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
20
20
 
21
- const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
22
-
23
21
  const mapOverrides = esmsInitOptions.mapOverrides;
24
22
 
25
23
  let nonce = esmsInitOptions.nonce;
@@ -53,6 +51,15 @@
53
51
  : location.pathname}`;
54
52
 
55
53
  const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
54
+ let { skip } = esmsInitOptions;
55
+ if (Array.isArray(skip)) {
56
+ const l = skip.map(s => new URL(s, baseUrl).href);
57
+ skip = s => l.some(i => i[i.length - 1] === '/' && s.startsWith(i) || s === i);
58
+ }
59
+ else if (typeof skip === 'string') {
60
+ const r = new RegExp(skip);
61
+ skip = s => s.test(r);
62
+ }
56
63
 
57
64
  const eoop = err => setTimeout(() => { throw err });
58
65
 
@@ -778,6 +785,7 @@
778
785
  const { r, b } = await resolve(n, load.r || load.u);
779
786
  if (b && (!supportsImportMaps || importMapSrcOrLazy))
780
787
  load.n = true;
788
+ if (d !== -1) return;
781
789
  if (skip && skip.test(r)) return { b: r };
782
790
  if (childFetchOpts.integrity)
783
791
  childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
@@ -1,4 +1,4 @@
1
- /* ES Module Shims Wasm 1.5.18 */
1
+ /* ES Module Shims Wasm 1.6.0 */
2
2
  (function () {
3
3
 
4
4
  const hasWindow = typeof window !== 'undefined';
@@ -18,8 +18,6 @@
18
18
  let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
19
19
  const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
20
20
 
21
- const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
22
-
23
21
  const mapOverrides = esmsInitOptions.mapOverrides;
24
22
 
25
23
  let nonce = esmsInitOptions.nonce;
@@ -53,6 +51,15 @@
53
51
  : location.pathname}`;
54
52
 
55
53
  const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
54
+ let { skip } = esmsInitOptions;
55
+ if (Array.isArray(skip)) {
56
+ const l = skip.map(s => new URL(s, baseUrl).href);
57
+ skip = s => l.some(i => i[i.length - 1] === '/' && s.startsWith(i) || s === i);
58
+ }
59
+ else if (typeof skip === 'string') {
60
+ const r = new RegExp(skip);
61
+ skip = s => s.test(r);
62
+ }
56
63
 
57
64
  const eoop = err => setTimeout(() => { throw err });
58
65
 
@@ -778,6 +785,7 @@
778
785
  const { r, b } = await resolve(n, load.r || load.u);
779
786
  if (b && (!supportsImportMaps || importMapSrcOrLazy))
780
787
  load.n = true;
788
+ if (d !== -1) return;
781
789
  if (skip && skip.test(r)) return { b: r };
782
790
  if (childFetchOpts.integrity)
783
791
  childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-module-shims",
3
- "version": "1.5.18",
3
+ "version": "1.6.0",
4
4
  "description": "Shims for the latest ES module features",
5
5
  "main": "dist/es-module-shims.js",
6
6
  "exports": {
@@ -36,8 +36,8 @@
36
36
  "test": "test"
37
37
  },
38
38
  "scripts": {
39
- "build": "cargo install chompbuild ; chomp build",
40
- "test": "cargo install chompbuild ; chomp test"
39
+ "build": "npm install -g chomp ; chomp build",
40
+ "test": "npm install -g chomp ; chomp test"
41
41
  },
42
42
  "repository": {
43
43
  "type": "git",