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.
@@ -1,168 +1,176 @@
1
- /** ES Module Shims @version 2.6.0 */
1
+ /** ES Module Shims @version 2.6.2 */
2
2
  (function () {
3
3
 
4
- let invalidate;
5
- const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
6
- const initHotReload = () => {
7
- let _importHook = importHook,
8
- _resolveHook = resolveHook,
9
- _metaHook = metaHook;
10
-
11
- let defaultResolve;
12
- let hotResolveHook = (id, parent, _defaultResolve) => {
13
- if (!defaultResolve) defaultResolve = _defaultResolve;
14
- const originalParent = stripVersion(parent);
15
- const url = stripVersion(defaultResolve(id, originalParent));
16
- const hotState = getHotState(url);
17
- const parents = hotState.p;
18
- if (!parents.includes(originalParent)) parents.push(originalParent);
19
- return toVersioned(url, hotState);
20
- };
21
- const hotImportHook = (url, _, __, source, sourceType) => {
22
- const hotState = getHotState(url);
23
- hotState.e = typeof source === 'string' ? source : true;
24
- hotState.t = sourceType;
25
- };
26
- const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
27
-
28
- const Hot = class Hot {
29
- constructor(url) {
30
- this.data = getHotState((this.url = stripVersion(url))).d;
31
- }
32
- accept(deps, cb) {
33
- if (typeof deps === 'function') {
34
- cb = deps;
35
- deps = null;
36
- }
37
- const hotState = getHotState(this.url);
38
- if (!hotState.A) return;
39
- (hotState.a = hotState.a || []).push([
40
- typeof deps === 'string' ? defaultResolve(deps, this.url)
41
- : deps ? deps.map(d => defaultResolve(d, this.url))
42
- : null,
43
- cb
44
- ]);
45
- }
46
- dispose(cb) {
47
- getHotState(this.url).u = cb;
48
- }
49
- invalidate() {
50
- const hotState = getHotState(this.url);
51
- hotState.a = hotState.A = null;
52
- const seen = [this.url];
53
- hotState.p.forEach(p => invalidate(p, this.url, seen));
54
- }
55
- };
56
-
57
- const versionedRegEx = /\?v=\d+$/;
58
- const stripVersion = url => {
59
- const versionMatch = url.match(versionedRegEx);
60
- return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
61
- };
62
-
63
- const toVersioned = (url, hotState) => {
64
- const { v } = hotState;
65
- return url + (v ? '?v=' + v : '');
66
- };
67
-
68
- let hotRegistry = {},
69
- curInvalidationRoots = new Set(),
70
- curInvalidationInterval;
71
- const getHotState = url =>
72
- hotRegistry[url] ||
73
- (hotRegistry[url] = {
74
- // version
75
- v: 0,
76
- // accept list ([deps, cb] pairs)
77
- a: null,
78
- // accepting acceptors
79
- A: true,
80
- // unload callback
81
- u: null,
82
- // entry point or inline script source
83
- e: false,
84
- // hot data
85
- d: {},
86
- // parents
87
- p: [],
88
- // source type
89
- t: undefined
90
- });
91
-
92
- invalidate = (url, fromUrl, seen = []) => {
93
- const hotState = hotRegistry[url];
94
- if (!hotState || seen.includes(url)) return false;
95
- seen.push(url);
96
- hotState.A = false;
97
- if (
98
- fromUrl &&
99
- hotState.a &&
100
- hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
101
- ) {
102
- curInvalidationRoots.add(fromUrl);
103
- } else {
104
- if (hotState.e || hotState.a) curInvalidationRoots.add(url);
105
- hotState.v++;
106
- if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
107
- }
108
- if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
109
- return true;
110
- };
111
-
112
- const handleInvalidations = () => {
113
- curInvalidationInterval = null;
114
- const earlyRoots = new Set();
115
- for (const root of curInvalidationRoots) {
116
- const hotState = hotRegistry[root];
117
- topLevelLoad(
118
- toVersioned(root, hotState),
119
- baseUrl,
120
- defaultFetchOpts,
121
- typeof hotState.e === 'string' ? hotState.e : undefined,
122
- false,
123
- undefined,
124
- hotState.t
125
- ).then(m => {
126
- if (hotState.a) {
127
- hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
128
- // unload should be the latest unload handler from the just loaded module
129
- if (hotState.u) {
130
- hotState.u(hotState.d);
131
- hotState.u = null;
132
- }
133
- }
134
- hotState.p.forEach(p => {
135
- const hotState = hotRegistry[p];
136
- if (hotState && hotState.a)
137
- hotState.a.forEach(
138
- async ([d, c]) =>
139
- d &&
140
- !earlyRoots.has(c) &&
141
- (typeof d === 'string' ?
142
- d === root && c(m)
143
- : c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
144
- );
145
- });
146
- }, throwError);
147
- }
148
- curInvalidationRoots = new Set();
149
- };
150
-
151
- return [
152
- _importHook ? chain(_importHook, hotImportHook) : hotImportHook,
153
- _resolveHook ?
154
- (id, parent, defaultResolve) =>
155
- hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
156
- : hotResolveHook,
157
- _metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
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 dynamicImport = (u, errUrl) => import(u);
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, self.esmsInitOptions || {});
181
+ Object.assign(esmsInitOptions, self_.esmsInitOptions || {});
174
182
 
175
- const version = "2.6.0";
183
+ const version = "2.6.2";
176
184
 
177
185
  const r$1 = esmsInitOptions.version;
178
- if (self.importShim || (r$1 && r$1 !== version)) {
186
+ if (self_.importShim || (r$1 && r$1 !== 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' ? self[name] : name);
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
- if (hotReload) [importHook, resolveHook, metaHook] = initHotReload();
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
- document.baseURI
253
- : `${location.protocol}//${location.host}${
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 => self.dispatchEvent(Object.assign(new Event('error'), { error }));
286
+ const dispatchError = error => self_.dispatchEvent(Object.assign(new Event('error'), { error }));
272
287
 
273
288
  const throwError = err => {
274
- (self.reportError || dispatchError)(err), void onerror(err);
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$1(id, opts, parentUrl) {
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$1.source = async (id, opts, parentUrl) => {
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$1._s[load.r];
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$1.defer = importShim$1;
679
+ if (shimMode || deferPhaseEnabled) importShim.defer = importShim;
668
680
 
669
- if (hotReload) importShim$1.hotReload = hotReload$1;
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$1.resolve = (id, parentUrl) => resolve(id, parentUrl).r;
687
- importShim$1.getImportMap = () => JSON.parse(JSON.stringify(composedImportMap));
688
- importShim$1.addImportMap = importMapIn => {
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$1.version = version;
707
+ importShim.version = version;
693
708
 
694
- const registry = (importShim$1._r = {});
709
+ const registry = (importShim._r = {});
695
710
  // Wasm caches
696
- const sourceCache = (importShim$1._s = {});
697
- (importShim$1._i = new WeakMap());
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(self, 'importShim', Object.freeze(importShim$1));
715
+ defineValue(self_, 'importShim', Object.freeze(importShim));
701
716
  const shimModeOptions = { ...esmsInitOptions, shimMode: true };
702
717
  if (optionsScript) optionsScript.innerHTML = JSON.stringify(shimModeOptions);
703
- self.esmsInitOptions = shimModeOptions;
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
- const topLevelLoad = async (
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 = self.requestIdleCallback || self.requestAnimationFrame;
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
- (resolvedSource = ''), (lastIndex = 0);
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
- const poolQueue = pushFetchPool();
1074
+ let res,
1075
+ poolQueue = pushFetchPool();
1059
1076
  if (poolQueue) await poolQueue;
1060
1077
  try {
1061
- var res = await fetchHook(url, fetchOpts);
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
- const res = await doFetch(url, fetchOpts, parent);
1086
- let [, , t] = (res.headers.get('content-type') || '').match(contentTypeRegEx) || [];
1087
- if (!t) {
1088
- if (url.endsWith('.ts') || url.endsWith('.mts')) t = 'ts';
1089
- else
1090
- throw Error(
1091
- `Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
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: t === 'wasm' ? await WebAssembly.compileStreaming(res) : await res.text(),
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=${source};export{j as default};if(h)h.accept(m=>j=m.default)`;
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(async () => {
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 }) => {