es-module-shims 2.6.0 → 2.6.2
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 +6 -5
- package/dist/es-module-shims.debug.js +227 -212
- package/dist/es-module-shims.js +226 -211
- package/dist/es-module-shims.wasm.js +226 -211
- package/package.json +4 -3
|
@@ -1,168 +1,176 @@
|
|
|
1
|
-
/** ES Module Shims Wasm @version 2.6.
|
|
1
|
+
/** ES Module Shims Wasm @version 2.6.2 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
hotState
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
hotState.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
hotState.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
undefined,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
4
|
+
const self_ = typeof globalThis !== 'undefined' ? globalThis : self;
|
|
5
|
+
|
|
6
|
+
let invalidate;
|
|
7
|
+
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
8
|
+
const initHotReload = (topLevelLoad, importShim) => {
|
|
9
|
+
let _importHook = importHook,
|
|
10
|
+
_resolveHook = resolveHook,
|
|
11
|
+
_metaHook = metaHook;
|
|
12
|
+
|
|
13
|
+
let defaultResolve;
|
|
14
|
+
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
15
|
+
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
16
|
+
const originalParent = stripVersion(parent);
|
|
17
|
+
const url = stripVersion(defaultResolve(id, originalParent));
|
|
18
|
+
const hotState = getHotState(url);
|
|
19
|
+
const parents = hotState.p;
|
|
20
|
+
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
21
|
+
return toVersioned(url, hotState);
|
|
22
|
+
};
|
|
23
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
24
|
+
const hotState = getHotState(url);
|
|
25
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
26
|
+
hotState.t = sourceType;
|
|
27
|
+
};
|
|
28
|
+
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
29
|
+
|
|
30
|
+
const Hot = class Hot {
|
|
31
|
+
constructor(url) {
|
|
32
|
+
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
33
|
+
}
|
|
34
|
+
accept(deps, cb) {
|
|
35
|
+
if (typeof deps === 'function') {
|
|
36
|
+
cb = deps;
|
|
37
|
+
deps = null;
|
|
38
|
+
}
|
|
39
|
+
const hotState = getHotState(this.url);
|
|
40
|
+
if (!hotState.A) return;
|
|
41
|
+
(hotState.a = hotState.a || []).push([
|
|
42
|
+
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
43
|
+
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
44
|
+
: null,
|
|
45
|
+
cb
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
dispose(cb) {
|
|
49
|
+
getHotState(this.url).u = cb;
|
|
50
|
+
}
|
|
51
|
+
invalidate() {
|
|
52
|
+
const hotState = getHotState(this.url);
|
|
53
|
+
hotState.a = hotState.A = null;
|
|
54
|
+
const seen = [this.url];
|
|
55
|
+
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const versionedRegEx = /\?v=\d+$/;
|
|
60
|
+
const stripVersion = url => {
|
|
61
|
+
const versionMatch = url.match(versionedRegEx);
|
|
62
|
+
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const toVersioned = (url, hotState) => {
|
|
66
|
+
const { v } = hotState;
|
|
67
|
+
return url + (v ? '?v=' + v : '');
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
let hotRegistry = {},
|
|
71
|
+
curInvalidationRoots = new Set(),
|
|
72
|
+
curInvalidationInterval;
|
|
73
|
+
const getHotState = url =>
|
|
74
|
+
hotRegistry[url] ||
|
|
75
|
+
(hotRegistry[url] = {
|
|
76
|
+
// version
|
|
77
|
+
v: 0,
|
|
78
|
+
// accept list ([deps, cb] pairs)
|
|
79
|
+
a: null,
|
|
80
|
+
// accepting acceptors
|
|
81
|
+
A: true,
|
|
82
|
+
// unload callback
|
|
83
|
+
u: null,
|
|
84
|
+
// entry point or inline script source
|
|
85
|
+
e: false,
|
|
86
|
+
// hot data
|
|
87
|
+
d: {},
|
|
88
|
+
// parents
|
|
89
|
+
p: [],
|
|
90
|
+
// source type
|
|
91
|
+
t: undefined
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
invalidate = (url, fromUrl, seen = []) => {
|
|
95
|
+
const hotState = hotRegistry[url];
|
|
96
|
+
if (!hotState || seen.includes(url)) return false;
|
|
97
|
+
seen.push(url);
|
|
98
|
+
hotState.A = false;
|
|
99
|
+
if (
|
|
100
|
+
fromUrl &&
|
|
101
|
+
hotState.a &&
|
|
102
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
103
|
+
) {
|
|
104
|
+
curInvalidationRoots.add(fromUrl);
|
|
105
|
+
} else {
|
|
106
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
107
|
+
hotState.v++;
|
|
108
|
+
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
109
|
+
}
|
|
110
|
+
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const handleInvalidations = () => {
|
|
115
|
+
curInvalidationInterval = null;
|
|
116
|
+
const earlyRoots = new Set();
|
|
117
|
+
for (const root of curInvalidationRoots) {
|
|
118
|
+
const hotState = hotRegistry[root];
|
|
119
|
+
topLevelLoad(
|
|
120
|
+
toVersioned(root, hotState),
|
|
121
|
+
baseUrl,
|
|
122
|
+
defaultFetchOpts,
|
|
123
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
124
|
+
false,
|
|
125
|
+
undefined,
|
|
126
|
+
hotState.t
|
|
127
|
+
).then(m => {
|
|
128
|
+
if (hotState.a) {
|
|
129
|
+
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
130
|
+
// unload should be the latest unload handler from the just loaded module
|
|
131
|
+
if (hotState.u) {
|
|
132
|
+
hotState.u(hotState.d);
|
|
133
|
+
hotState.u = null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
hotState.p.forEach(p => {
|
|
137
|
+
const hotState = hotRegistry[p];
|
|
138
|
+
if (hotState && hotState.a)
|
|
139
|
+
hotState.a.forEach(
|
|
140
|
+
async ([d, c]) =>
|
|
141
|
+
d &&
|
|
142
|
+
!earlyRoots.has(c) &&
|
|
143
|
+
(typeof d === 'string' ?
|
|
144
|
+
d === root && c(m)
|
|
145
|
+
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
}, throwError);
|
|
149
|
+
}
|
|
150
|
+
curInvalidationRoots = new Set();
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
setHooks(
|
|
154
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
155
|
+
_resolveHook ?
|
|
156
|
+
(id, parent, defaultResolve) =>
|
|
157
|
+
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
158
|
+
: hotResolveHook,
|
|
159
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
160
|
+
);
|
|
159
161
|
};
|
|
160
162
|
|
|
161
163
|
const hasDocument = typeof document !== 'undefined';
|
|
162
164
|
|
|
163
165
|
const noop = () => {};
|
|
164
166
|
|
|
165
|
-
const
|
|
167
|
+
const chain = (a, b) =>
|
|
168
|
+
function () {
|
|
169
|
+
a.apply(this, arguments);
|
|
170
|
+
b.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const dynamicImport = (u, _errUrl) => import(u);
|
|
166
174
|
|
|
167
175
|
const defineValue = (obj, prop, value) =>
|
|
168
176
|
Object.defineProperty(obj, prop, { writable: false, configurable: false, value });
|
|
@@ -170,21 +178,23 @@
|
|
|
170
178
|
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
171
179
|
|
|
172
180
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
173
|
-
Object.assign(esmsInitOptions,
|
|
181
|
+
Object.assign(esmsInitOptions, self_.esmsInitOptions || {});
|
|
174
182
|
|
|
175
|
-
const version = "2.6.
|
|
183
|
+
const version = "2.6.2";
|
|
176
184
|
|
|
177
185
|
const r = esmsInitOptions.version;
|
|
178
|
-
if (
|
|
186
|
+
if (self_.importShim || (r && r !== version)) {
|
|
179
187
|
return;
|
|
180
188
|
}
|
|
181
189
|
|
|
182
190
|
// shim mode is determined on initialization, no late shim mode
|
|
183
191
|
const shimMode =
|
|
184
192
|
esmsInitOptions.shimMode ||
|
|
185
|
-
(hasDocument
|
|
193
|
+
(hasDocument ?
|
|
186
194
|
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
187
|
-
.length > 0
|
|
195
|
+
.length > 0
|
|
196
|
+
// Without a document, shim mode is always true as we cannot polyfill
|
|
197
|
+
: true);
|
|
188
198
|
|
|
189
199
|
let importHook,
|
|
190
200
|
resolveHook,
|
|
@@ -198,7 +208,7 @@
|
|
|
198
208
|
|
|
199
209
|
const defaultFetchOpts = { credentials: 'same-origin' };
|
|
200
210
|
|
|
201
|
-
const globalHook = name => (typeof name === 'string' ?
|
|
211
|
+
const globalHook = name => (typeof name === 'string' ? self_[name] : name);
|
|
202
212
|
|
|
203
213
|
if (esmsInitOptions.onimport) importHook = globalHook(esmsInitOptions.onimport);
|
|
204
214
|
if (esmsInitOptions.resolve) resolveHook = globalHook(esmsInitOptions.resolve);
|
|
@@ -216,7 +226,11 @@
|
|
|
216
226
|
nativePassthrough = !hasCustomizationHooks && !hotReload
|
|
217
227
|
} = esmsInitOptions;
|
|
218
228
|
|
|
219
|
-
|
|
229
|
+
const setHooks = (importHook_, resolveHook_, metaHook_) => (
|
|
230
|
+
(importHook = importHook_),
|
|
231
|
+
(resolveHook = resolveHook_),
|
|
232
|
+
(metaHook = metaHook_)
|
|
233
|
+
);
|
|
220
234
|
|
|
221
235
|
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
222
236
|
|
|
@@ -248,13 +262,14 @@
|
|
|
248
262
|
};
|
|
249
263
|
|
|
250
264
|
const baseUrl =
|
|
251
|
-
hasDocument ?
|
|
252
|
-
|
|
253
|
-
|
|
265
|
+
hasDocument ? document.baseURI
|
|
266
|
+
: typeof location !== 'undefined' ?
|
|
267
|
+
`${location.protocol}//${location.host}${
|
|
254
268
|
location.pathname.includes('/') ?
|
|
255
269
|
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
256
270
|
: location.pathname
|
|
257
|
-
}
|
|
271
|
+
}`
|
|
272
|
+
: 'about:blank';
|
|
258
273
|
|
|
259
274
|
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
260
275
|
let { skip } = esmsInitOptions;
|
|
@@ -268,10 +283,11 @@
|
|
|
268
283
|
skip = s => skip.test(s);
|
|
269
284
|
}
|
|
270
285
|
|
|
271
|
-
const dispatchError = error =>
|
|
286
|
+
const dispatchError = error => self_.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
272
287
|
|
|
273
288
|
const throwError = err => {
|
|
274
|
-
(
|
|
289
|
+
(self_.reportError || dispatchError)(err);
|
|
290
|
+
onerror(err);
|
|
275
291
|
};
|
|
276
292
|
|
|
277
293
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
@@ -619,7 +635,7 @@
|
|
|
619
635
|
};
|
|
620
636
|
|
|
621
637
|
// import()
|
|
622
|
-
async function importShim
|
|
638
|
+
async function importShim(id, opts, parentUrl) {
|
|
623
639
|
if (typeof opts === 'string') {
|
|
624
640
|
parentUrl = opts;
|
|
625
641
|
opts = undefined;
|
|
@@ -642,7 +658,7 @@
|
|
|
642
658
|
// import.source()
|
|
643
659
|
// (opts not currently supported as no use cases yet)
|
|
644
660
|
if (shimMode || wasmSourcePhaseEnabled)
|
|
645
|
-
importShim
|
|
661
|
+
importShim.source = async (id, opts, parentUrl) => {
|
|
646
662
|
if (typeof opts === 'string') {
|
|
647
663
|
parentUrl = opts;
|
|
648
664
|
opts = undefined;
|
|
@@ -655,18 +671,17 @@
|
|
|
655
671
|
await importMapPromise;
|
|
656
672
|
const url = resolve(id, parentUrl || baseUrl).r;
|
|
657
673
|
const load = getOrCreateLoad(url, defaultFetchOpts, undefined, undefined);
|
|
658
|
-
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
659
|
-
onpolyfill();
|
|
660
|
-
firstPolyfillLoad = false;
|
|
661
|
-
}
|
|
662
674
|
await load.f;
|
|
663
|
-
return importShim
|
|
675
|
+
return importShim._s[load.r];
|
|
664
676
|
};
|
|
665
677
|
|
|
666
678
|
// import.defer() is just a proxy for import(), since we can't actually defer
|
|
667
|
-
if (shimMode || deferPhaseEnabled) importShim
|
|
679
|
+
if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
|
|
668
680
|
|
|
669
|
-
if (hotReload)
|
|
681
|
+
if (hotReload) {
|
|
682
|
+
initHotReload(topLevelLoad, importShim);
|
|
683
|
+
importShim.hotReload = hotReload$1;
|
|
684
|
+
}
|
|
670
685
|
|
|
671
686
|
const defaultResolve = (id, parentUrl) => {
|
|
672
687
|
return (
|
|
@@ -683,24 +698,24 @@
|
|
|
683
698
|
return resolve(id, `${parentUrl}`).r;
|
|
684
699
|
};
|
|
685
700
|
|
|
686
|
-
importShim
|
|
687
|
-
importShim
|
|
688
|
-
importShim
|
|
701
|
+
importShim.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
|
|
702
|
+
importShim.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
|
|
703
|
+
importShim.addImportMap = importMapIn => {
|
|
689
704
|
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
690
705
|
composedImportMap = resolveAndComposeImportMap(importMapIn, baseUrl, composedImportMap);
|
|
691
706
|
};
|
|
692
|
-
importShim
|
|
707
|
+
importShim.version = version;
|
|
693
708
|
|
|
694
|
-
const registry = (importShim
|
|
709
|
+
const registry = (importShim._r = {});
|
|
695
710
|
// Wasm caches
|
|
696
|
-
const sourceCache = (importShim
|
|
697
|
-
|
|
711
|
+
const sourceCache = (importShim._s = {});
|
|
712
|
+
/* const instanceCache = */ importShim._i = new WeakMap();
|
|
698
713
|
|
|
699
714
|
// Ensure this version is the only version
|
|
700
|
-
defineValue(
|
|
715
|
+
defineValue(self_, 'importShim', Object.freeze(importShim));
|
|
701
716
|
const shimModeOptions = { ...esmsInitOptions, shimMode: true };
|
|
702
717
|
if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
|
|
703
|
-
|
|
718
|
+
self_.esmsInitOptions = shimModeOptions;
|
|
704
719
|
|
|
705
720
|
const loadAll = async (load, seen) => {
|
|
706
721
|
seen[load.u] = 1;
|
|
@@ -803,7 +818,7 @@
|
|
|
803
818
|
let firstPolyfillLoad = true;
|
|
804
819
|
let legacyAcceptingImportMaps = true;
|
|
805
820
|
|
|
806
|
-
|
|
821
|
+
async function topLevelLoad(
|
|
807
822
|
url,
|
|
808
823
|
parentUrl,
|
|
809
824
|
fetchOpts,
|
|
@@ -811,7 +826,7 @@
|
|
|
811
826
|
nativelyLoaded,
|
|
812
827
|
lastStaticLoadPromise,
|
|
813
828
|
sourceType
|
|
814
|
-
)
|
|
829
|
+
) {
|
|
815
830
|
await initPromise;
|
|
816
831
|
await importMapPromise;
|
|
817
832
|
url = (await resolve(url, parentUrl)).r;
|
|
@@ -857,11 +872,11 @@
|
|
|
857
872
|
if (load.s) (await dynamicImport(load.s, load.u)).u$_(module);
|
|
858
873
|
revokeObjectURLs(Object.keys(seen));
|
|
859
874
|
return module;
|
|
860
|
-
}
|
|
875
|
+
}
|
|
861
876
|
|
|
862
877
|
const revokeObjectURLs = registryKeys => {
|
|
863
878
|
let curIdx = 0;
|
|
864
|
-
const handler =
|
|
879
|
+
const handler = self_.requestIdleCallback || self_.requestAnimationFrame || (fn => setTimeout(fn, 0));
|
|
865
880
|
handler(cleanup);
|
|
866
881
|
function cleanup() {
|
|
867
882
|
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
@@ -926,7 +941,8 @@
|
|
|
926
941
|
|
|
927
942
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
928
943
|
// and define this blob
|
|
929
|
-
|
|
944
|
+
resolvedSource = '';
|
|
945
|
+
lastIndex = 0;
|
|
930
946
|
|
|
931
947
|
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
932
948
|
// source phase
|
|
@@ -1055,10 +1071,11 @@
|
|
|
1055
1071
|
|
|
1056
1072
|
const doFetch = async (url, fetchOpts, parent) => {
|
|
1057
1073
|
if (enforceIntegrity && !fetchOpts.integrity) throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
1058
|
-
|
|
1074
|
+
let res,
|
|
1075
|
+
poolQueue = pushFetchPool();
|
|
1059
1076
|
if (poolQueue) await poolQueue;
|
|
1060
1077
|
try {
|
|
1061
|
-
|
|
1078
|
+
res = await fetchHook(url, fetchOpts);
|
|
1062
1079
|
} catch (e) {
|
|
1063
1080
|
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
|
1064
1081
|
throw e;
|
|
@@ -1080,24 +1097,22 @@
|
|
|
1080
1097
|
if (!esmsTsTransform) esmsTsTransform = m.transform;
|
|
1081
1098
|
};
|
|
1082
1099
|
|
|
1083
|
-
const contentTypeRegEx = /^(text|application)\/((x-)?javascript|wasm|json|css|typescript)(;|$)/;
|
|
1084
1100
|
async function defaultSourceHook(url, fetchOpts, parent) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1101
|
+
let res = await doFetch(url, fetchOpts, parent),
|
|
1102
|
+
contentType,
|
|
1103
|
+
[, json, type, jsts] =
|
|
1104
|
+
(contentType = res.headers.get('content-type') || '').match(
|
|
1105
|
+
/^(?:[^/;]+\/(?:[^/+;]+\+)?(json)|(?:text|application)\/(?:x-)?((java|type)script|wasm|css))(?:;|$)/
|
|
1106
|
+
) || [];
|
|
1107
|
+
if (!(type = json || (jsts ? jsts[0] + 's' : type || (/\.m?ts(\?|#|$)/.test(url) && 'ts')))) {
|
|
1108
|
+
throw Error(
|
|
1109
|
+
`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
|
|
1110
|
+
);
|
|
1093
1111
|
}
|
|
1094
1112
|
return {
|
|
1095
1113
|
url: res.url,
|
|
1096
|
-
source:
|
|
1097
|
-
type
|
|
1098
|
-
t[0] === 'x' || (t[0] === 'j' && t[1] === 'a') ? 'js'
|
|
1099
|
-
: t[0] === 't' ? 'ts'
|
|
1100
|
-
: t
|
|
1114
|
+
source: await (type > 'v' ? WebAssembly.compileStreaming(res) : res.text()),
|
|
1115
|
+
type
|
|
1101
1116
|
};
|
|
1102
1117
|
}
|
|
1103
1118
|
|
|
@@ -1131,7 +1146,7 @@
|
|
|
1131
1146
|
}
|
|
1132
1147
|
source += `if(h)h.accept(m=>({${obj}}=m))`;
|
|
1133
1148
|
} else if (type === 'json') {
|
|
1134
|
-
source = `${hotPrefix}j
|
|
1149
|
+
source = `${hotPrefix}j=JSON.parse(${JSON.stringify(source)});export{j as default};if(h)h.accept(m=>j=m.default)`;
|
|
1135
1150
|
} else if (type === 'css') {
|
|
1136
1151
|
source = `${hotPrefix}s=h&&h.data.s||new CSSStyleSheet();s.replaceSync(${JSON.stringify(
|
|
1137
1152
|
source.replace(
|
|
@@ -1219,7 +1234,7 @@
|
|
|
1219
1234
|
|
|
1220
1235
|
const linkLoad = (load, fetchOpts) => {
|
|
1221
1236
|
if (load.L) return;
|
|
1222
|
-
load.L = load.f.then(
|
|
1237
|
+
load.L = load.f.then(() => {
|
|
1223
1238
|
let childFetchOpts = fetchOpts;
|
|
1224
1239
|
load.d = load.a[0]
|
|
1225
1240
|
.map(({ n, d, t, a, se }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-module-shims",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Shims for the latest ES module features",
|
|
5
5
|
"main": "dist/es-module-shims.js",
|
|
6
6
|
"exports": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@rollup/plugin-replace": "^2.4.2",
|
|
34
34
|
"amaro": "0.5.3",
|
|
35
|
+
"chomp": "^0.2.23",
|
|
35
36
|
"es-module-lexer": "1.7.0",
|
|
36
37
|
"kleur": "^4.1.4",
|
|
37
38
|
"mime-types": "^2.1.33",
|
|
@@ -50,8 +51,8 @@
|
|
|
50
51
|
"test": "test"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
|
-
"build": "
|
|
54
|
-
"test": "
|
|
54
|
+
"build": "chomp build",
|
|
55
|
+
"test": "chomp test"
|
|
55
56
|
},
|
|
56
57
|
"repository": {
|
|
57
58
|
"type": "git",
|