@jsenv/core 37.0.5 → 37.1.1
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/dist/js/autoreload.js +23 -20
- package/dist/js/import_meta_hot.js +0 -1
- package/dist/jsenv_core.js +691 -591
- package/package.json +2 -2
- package/src/build/build.js +141 -154
- package/src/build/build_versions_manager.js +53 -56
- package/src/dev/file_service.js +68 -77
- package/src/dev/start_dev_server.js +2 -4
- package/src/helpers/event_emitter.js +18 -0
- package/src/kitchen/kitchen.js +4 -6
- package/src/kitchen/url_graph/references.js +29 -8
- package/src/kitchen/url_graph/url_content.js +9 -0
- package/src/kitchen/url_graph/url_graph.js +50 -57
- package/src/kitchen/url_graph/url_graph_report.js +62 -59
- package/src/kitchen/url_graph/url_graph_visitor.js +30 -0
- package/src/kitchen/url_graph/url_info_transformations.js +26 -26
- package/src/plugins/autoreload/client/autoreload.js +7 -7
- package/src/plugins/autoreload/client/reload.js +16 -13
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +4 -4
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +138 -96
- package/src/plugins/autoreload/jsenv_plugin_hot_search_param.js +43 -25
- package/src/plugins/import_meta_hot/client/import_meta_hot.js +0 -1
- package/src/plugins/plugins.js +3 -14
- package/src/plugins/resolution_node_esm/jsenv_plugin_node_esm_resolution.js +4 -0
package/dist/js/autoreload.js
CHANGED
|
@@ -51,20 +51,20 @@ const getDOMNodesUsingUrl = (urlToReload) => {
|
|
|
51
51
|
}
|
|
52
52
|
nodes.push({
|
|
53
53
|
node,
|
|
54
|
-
reload: () => {
|
|
54
|
+
reload: (hot) => {
|
|
55
55
|
if (node.nodeName === "SCRIPT") {
|
|
56
56
|
const copy = document.createElement("script");
|
|
57
57
|
Array.from(node.attributes).forEach((attribute) => {
|
|
58
58
|
copy.setAttribute(attribute.nodeName, attribute.nodeValue);
|
|
59
59
|
});
|
|
60
|
-
copy.src = injectQuery(node.src, { hot
|
|
60
|
+
copy.src = injectQuery(node.src, { hot });
|
|
61
61
|
if (node.parentNode) {
|
|
62
62
|
node.parentNode.replaceChild(copy, node);
|
|
63
63
|
} else {
|
|
64
64
|
document.body.appendChild(copy);
|
|
65
65
|
}
|
|
66
66
|
} else {
|
|
67
|
-
node[attributeName] = injectQuery(attribute, { hot
|
|
67
|
+
node[attributeName] = injectQuery(attribute, { hot });
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
});
|
|
@@ -108,16 +108,19 @@ const getDOMNodesUsingUrl = (urlToReload) => {
|
|
|
108
108
|
visitNodeAttributeAsUrl(img, "src");
|
|
109
109
|
const srcset = img.srcset;
|
|
110
110
|
if (srcset) {
|
|
111
|
-
const srcCandidates = parseSrcSet(srcset);
|
|
112
|
-
srcCandidates.forEach((srcCandidate) => {
|
|
113
|
-
const url = new URL(srcCandidate.specifier, `${window.location.href}`);
|
|
114
|
-
if (shouldReloadUrl(url)) {
|
|
115
|
-
srcCandidate.specifier = injectQuery(url, { hot: Date.now() });
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
111
|
nodes.push({
|
|
119
112
|
node: img,
|
|
120
|
-
reload: () => {
|
|
113
|
+
reload: (hot) => {
|
|
114
|
+
const srcCandidates = parseSrcSet(srcset);
|
|
115
|
+
srcCandidates.forEach((srcCandidate) => {
|
|
116
|
+
const url = new URL(
|
|
117
|
+
srcCandidate.specifier,
|
|
118
|
+
`${window.location.href}`,
|
|
119
|
+
);
|
|
120
|
+
if (shouldReloadUrl(url)) {
|
|
121
|
+
srcCandidate.specifier = injectQuery(url, { hot });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
121
124
|
img.srcset = stringifySrcSet(srcCandidates);
|
|
122
125
|
},
|
|
123
126
|
});
|
|
@@ -137,8 +140,8 @@ const getDOMNodesUsingUrl = (urlToReload) => {
|
|
|
137
140
|
return nodes;
|
|
138
141
|
};
|
|
139
142
|
|
|
140
|
-
const reloadJsImport = async (url) => {
|
|
141
|
-
const urlWithHotSearchParam = injectQuery(url, { hot
|
|
143
|
+
const reloadJsImport = async (url, hot) => {
|
|
144
|
+
const urlWithHotSearchParam = injectQuery(url, { hot });
|
|
142
145
|
const namespace = await import(urlWithHotSearchParam);
|
|
143
146
|
return namespace;
|
|
144
147
|
};
|
|
@@ -264,7 +267,7 @@ const dequeue = async () => {
|
|
|
264
267
|
}
|
|
265
268
|
};
|
|
266
269
|
|
|
267
|
-
const applyHotReload = async ({ hotInstructions }) => {
|
|
270
|
+
const applyHotReload = async ({ cause, hot, hotInstructions }) => {
|
|
268
271
|
await hotInstructions.reduce(
|
|
269
272
|
async (previous, { type, boundary, acceptedBy }) => {
|
|
270
273
|
await previous;
|
|
@@ -280,7 +283,7 @@ const applyHotReload = async ({ hotInstructions }) => {
|
|
|
280
283
|
delete urlHotMetas[urlToFetch];
|
|
281
284
|
if (urlHotMeta.disposeCallback) {
|
|
282
285
|
console.groupCollapsed(
|
|
283
|
-
`[jsenv] cleanup ${boundary} (
|
|
286
|
+
`[jsenv] cleanup ${boundary} (no longer referenced by ${acceptedBy})`,
|
|
284
287
|
);
|
|
285
288
|
console.log(`call dispose callback`);
|
|
286
289
|
await urlHotMeta.disposeCallback();
|
|
@@ -291,10 +294,10 @@ const applyHotReload = async ({ hotInstructions }) => {
|
|
|
291
294
|
}
|
|
292
295
|
|
|
293
296
|
if (acceptedBy === boundary) {
|
|
294
|
-
console.groupCollapsed(`[jsenv] hot reloading ${boundary}`);
|
|
297
|
+
console.groupCollapsed(`[jsenv] hot reloading ${boundary} (${cause})`);
|
|
295
298
|
} else {
|
|
296
299
|
console.groupCollapsed(
|
|
297
|
-
`[jsenv] hot reloading ${acceptedBy} usage in ${boundary}`,
|
|
300
|
+
`[jsenv] hot reloading ${acceptedBy} usage in ${boundary} (${cause})`,
|
|
298
301
|
);
|
|
299
302
|
}
|
|
300
303
|
if (type === "js_module") {
|
|
@@ -311,7 +314,7 @@ const applyHotReload = async ({ hotInstructions }) => {
|
|
|
311
314
|
type: "dynamic_import",
|
|
312
315
|
url: urlToFetch,
|
|
313
316
|
};
|
|
314
|
-
const namespace = await reloadJsImport(urlToFetch);
|
|
317
|
+
const namespace = await reloadJsImport(urlToFetch, hot);
|
|
315
318
|
if (urlHotMeta.acceptCallback) {
|
|
316
319
|
await urlHotMeta.acceptCallback(namespace);
|
|
317
320
|
}
|
|
@@ -338,11 +341,11 @@ const applyHotReload = async ({ hotInstructions }) => {
|
|
|
338
341
|
console.log(`no dom node using ${acceptedBy}`);
|
|
339
342
|
} else if (domNodesCount === 1) {
|
|
340
343
|
console.log(`reloading`, domNodesUsingUrl[0].node);
|
|
341
|
-
domNodesUsingUrl[0].reload();
|
|
344
|
+
domNodesUsingUrl[0].reload(hot);
|
|
342
345
|
} else {
|
|
343
346
|
console.log(`reloading ${domNodesCount} nodes using ${acceptedBy}`);
|
|
344
347
|
domNodesUsingUrl.forEach((domNodesUsingUrl) => {
|
|
345
|
-
domNodesUsingUrl.reload();
|
|
348
|
+
domNodesUsingUrl.reload(hot);
|
|
346
349
|
});
|
|
347
350
|
}
|
|
348
351
|
console.groupEnd();
|