es-module-shims 1.5.17 → 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 +14 -3
- package/dist/es-module-shims.js +16 -16
- package/dist/es-module-shims.wasm.js +16 -16
- package/package.json +3 -3
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.
|
|
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
|
-
|
|
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": "
|
|
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>
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims 1.
|
|
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
|
|
|
@@ -101,22 +108,14 @@
|
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
110
|
|
|
104
|
-
/*
|
|
105
|
-
* Import maps implementation
|
|
106
|
-
*
|
|
107
|
-
* To make lookups fast we pre-resolve the entire import map
|
|
108
|
-
* and then match based on backtracked hash lookups
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
111
|
function resolveUrl (relUrl, parentUrl) {
|
|
112
112
|
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
parentUrl = parentUrl.slice(0, queryHashIndex);
|
|
116
|
+
const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?');
|
|
117
|
+
if (hIdx + qIdx > -2)
|
|
118
|
+
parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
|
|
120
119
|
if (relUrl.indexOf('\\') !== -1)
|
|
121
120
|
relUrl = relUrl.replace(backslashRegEx, '/');
|
|
122
121
|
// protocol-relative
|
|
@@ -641,9 +640,9 @@
|
|
|
641
640
|
}
|
|
642
641
|
}
|
|
643
642
|
|
|
644
|
-
// support progressive cycle binding updates
|
|
643
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
645
644
|
if (load.s)
|
|
646
|
-
resolvedSource += `\n;import{u$_}from'${load.s}';u$_({
|
|
645
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}: ${ln}`).join(',')}})}catch(_){};\n`;
|
|
647
646
|
|
|
648
647
|
pushStringTo(source.length);
|
|
649
648
|
}
|
|
@@ -786,6 +785,7 @@
|
|
|
786
785
|
const { r, b } = await resolve(n, load.r || load.u);
|
|
787
786
|
if (b && (!supportsImportMaps || importMapSrcOrLazy))
|
|
788
787
|
load.n = true;
|
|
788
|
+
if (d !== -1) return;
|
|
789
789
|
if (skip && skip.test(r)) return { b: r };
|
|
790
790
|
if (childFetchOpts.integrity)
|
|
791
791
|
childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims Wasm 1.
|
|
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
|
|
|
@@ -101,22 +108,14 @@
|
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
110
|
|
|
104
|
-
/*
|
|
105
|
-
* Import maps implementation
|
|
106
|
-
*
|
|
107
|
-
* To make lookups fast we pre-resolve the entire import map
|
|
108
|
-
* and then match based on backtracked hash lookups
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
111
|
function resolveUrl (relUrl, parentUrl) {
|
|
112
112
|
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
parentUrl = parentUrl.slice(0, queryHashIndex);
|
|
116
|
+
const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?');
|
|
117
|
+
if (hIdx + qIdx > -2)
|
|
118
|
+
parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
|
|
120
119
|
if (relUrl.indexOf('\\') !== -1)
|
|
121
120
|
relUrl = relUrl.replace(backslashRegEx, '/');
|
|
122
121
|
// protocol-relative
|
|
@@ -641,9 +640,9 @@
|
|
|
641
640
|
}
|
|
642
641
|
}
|
|
643
642
|
|
|
644
|
-
// support progressive cycle binding updates
|
|
643
|
+
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
645
644
|
if (load.s)
|
|
646
|
-
resolvedSource += `\n;import{u$_}from'${load.s}';u$_({
|
|
645
|
+
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}: ${ln}`).join(',')}})}catch(_){};\n`;
|
|
647
646
|
|
|
648
647
|
pushStringTo(source.length);
|
|
649
648
|
}
|
|
@@ -786,6 +785,7 @@
|
|
|
786
785
|
const { r, b } = await resolve(n, load.r || load.u);
|
|
787
786
|
if (b && (!supportsImportMaps || importMapSrcOrLazy))
|
|
788
787
|
load.n = true;
|
|
788
|
+
if (d !== -1) return;
|
|
789
789
|
if (skip && skip.test(r)) return { b: r };
|
|
790
790
|
if (childFetchOpts.integrity)
|
|
791
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.
|
|
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": "
|
|
40
|
-
"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",
|