@jsenv/core 36.0.1 → 36.1.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/dist/js/ribbon.js +4 -0
- package/dist/jsenv_core.js +188 -912
- package/package.json +4 -4
- package/src/build/build.js +33 -36
- package/src/dev/file_service.js +6 -4
- package/src/dev/start_dev_server.js +6 -4
- package/src/kitchen/kitchen.js +71 -13
- package/src/kitchen/url_graph/url_graph_report.js +9 -5
- package/src/kitchen/url_graph.js +0 -1
- package/src/plugins/plugin_controller.js +15 -7
- package/src/plugins/plugins.js +11 -12
- package/src/plugins/{file_urls/jsenv_plugin_file_urls.js → protocol_file/jsenv_plugin_protocol_file.js} +50 -45
- package/src/plugins/{http_urls/jsenv_plugin_http_urls.js → protocol_http/jsenv_plugin_protocol_http.js} +6 -5
- package/src/plugins/reference_analysis/jsenv_plugin_reference_analysis.js +0 -69
- package/src/plugins/resolution_node_esm/jsenv_plugin_node_esm_resolution.js +3 -3
- package/src/plugins/resolution_web/jsenv_plugin_web_resolution.js +15 -38
- package/src/plugins/ribbon/client/ribbon.js +9 -0
- package/dist/js/supervisor.js +0 -1175
- package/src/helpers/basic_fetch.js +0 -53
- package/src/helpers/ping_server.js +0 -30
- package/src/plugins/supervisor/client/supervisor.js +0 -1153
- package/src/plugins/supervisor/html_supervisor_injection.js +0 -281
- package/src/plugins/supervisor/js_supervisor_injection.js +0 -283
- package/src/plugins/supervisor/jsenv_plugin_supervisor.js +0 -218
- /package/src/plugins/{url_type_from_reference.js → resolution_node_esm/url_type_from_reference.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "36.0
|
|
3
|
+
"version": "36.1.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"@jsenv/integrity": "0.0.1",
|
|
70
70
|
"@jsenv/log": "3.3.5",
|
|
71
71
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
72
|
+
"@jsenv/plugin-supervisor": "1.0.0",
|
|
72
73
|
"@jsenv/server": "15.0.3",
|
|
73
74
|
"@jsenv/sourcemap": "1.0.10",
|
|
74
75
|
"@jsenv/url-meta": "8.1.0",
|
|
75
76
|
"@jsenv/urls": "2.0.0",
|
|
76
77
|
"@jsenv/utils": "2.0.1",
|
|
77
78
|
"construct-style-sheets-polyfill": "3.1.0",
|
|
78
|
-
"launch-editor": "2.6.0",
|
|
79
79
|
"lightningcss": "1.20.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
@@ -92,11 +92,11 @@
|
|
|
92
92
|
"@jsenv/plugin-placeholders": "./packages/jsenv-plugin-placeholders/",
|
|
93
93
|
"@jsenv/plugin-as-js-classic": "./packages/jsenv-plugin-as-js-classic/",
|
|
94
94
|
"@jsenv/test": "./packages/test/",
|
|
95
|
-
"eslint": "8.
|
|
95
|
+
"eslint": "8.41.0",
|
|
96
96
|
"eslint-plugin-html": "7.1.0",
|
|
97
97
|
"eslint-plugin-import": "2.27.5",
|
|
98
98
|
"eslint-plugin-react": "7.32.2",
|
|
99
|
-
"playwright": "1.
|
|
99
|
+
"playwright": "1.34.2",
|
|
100
100
|
"prettier": "2.8.8"
|
|
101
101
|
}
|
|
102
102
|
}
|
package/src/build/build.js
CHANGED
|
@@ -130,14 +130,15 @@ export const build = async ({
|
|
|
130
130
|
buildDirectoryUrl,
|
|
131
131
|
entryPoints = {},
|
|
132
132
|
assetsDirectory = "",
|
|
133
|
+
ignore,
|
|
133
134
|
|
|
134
135
|
runtimeCompat = defaultRuntimeCompat,
|
|
135
136
|
base = runtimeCompat.node ? "./" : "/",
|
|
136
137
|
plugins = [],
|
|
137
138
|
referenceAnalysis = {},
|
|
138
139
|
nodeEsmResolution,
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
magicExtensions,
|
|
141
|
+
magicDirectoryIndex,
|
|
141
142
|
directoryReferenceAllowed,
|
|
142
143
|
scenarioPlaceholders,
|
|
143
144
|
transpilation = {},
|
|
@@ -311,6 +312,10 @@ build ${entryPointKeys.length} entry points`);
|
|
|
311
312
|
signal,
|
|
312
313
|
logLevel,
|
|
313
314
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
315
|
+
ignore,
|
|
316
|
+
// during first pass (craft) we keep "ignore:" when a reference is ignored
|
|
317
|
+
// so that the second pass (shape) properly ignore those urls
|
|
318
|
+
ignoreProtocol: "keep",
|
|
314
319
|
urlGraph: rawGraph,
|
|
315
320
|
build: true,
|
|
316
321
|
runtimeCompat,
|
|
@@ -319,12 +324,6 @@ build ${entryPointKeys.length} entry points`);
|
|
|
319
324
|
...plugins,
|
|
320
325
|
{
|
|
321
326
|
appliesDuring: "build",
|
|
322
|
-
formatReference: (reference) => {
|
|
323
|
-
if (!reference.shouldHandle) {
|
|
324
|
-
return `ignore:${reference.specifier}`;
|
|
325
|
-
}
|
|
326
|
-
return null;
|
|
327
|
-
},
|
|
328
327
|
fetchUrlContent: (urlInfo, context) => {
|
|
329
328
|
if (context.reference.original) {
|
|
330
329
|
rawRedirections.set(
|
|
@@ -338,17 +337,17 @@ build ${entryPointKeys.length} entry points`);
|
|
|
338
337
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
339
338
|
urlGraph: rawGraph,
|
|
340
339
|
runtimeCompat,
|
|
341
|
-
|
|
342
340
|
referenceAnalysis,
|
|
343
341
|
nodeEsmResolution,
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
magicExtensions,
|
|
343
|
+
magicDirectoryIndex,
|
|
346
344
|
directoryReferenceAllowed,
|
|
347
345
|
transpilation: {
|
|
348
346
|
...transpilation,
|
|
349
347
|
babelHelpersAsImport: !explicitJsModuleFallback,
|
|
350
348
|
jsModuleFallbackOnJsClassic: false,
|
|
351
349
|
},
|
|
350
|
+
|
|
352
351
|
inlining: false,
|
|
353
352
|
scenarioPlaceholders,
|
|
354
353
|
}),
|
|
@@ -383,6 +382,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
383
382
|
const finalGraphKitchen = createKitchen({
|
|
384
383
|
logLevel,
|
|
385
384
|
rootDirectoryUrl: buildDirectoryUrl,
|
|
385
|
+
// here most plugins are not there
|
|
386
|
+
// - no external plugin
|
|
387
|
+
// - no plugin putting reference.mustIgnore on https urls
|
|
388
|
+
// At this stage it's only about redirecting urls to the build directory
|
|
389
|
+
// consequently only a subset or urls are supported
|
|
390
|
+
supportedProtocols: ["file:", "data:", "virtual:", "ignore:"],
|
|
391
|
+
ignore,
|
|
392
|
+
ignoreProtocol: versioning ? "keep" : "remove",
|
|
386
393
|
urlGraph: finalGraph,
|
|
387
394
|
build: true,
|
|
388
395
|
runtimeCompat,
|
|
@@ -578,9 +585,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
578
585
|
},
|
|
579
586
|
formatReference: (reference) => {
|
|
580
587
|
if (!reference.generatedUrl.startsWith("file:")) {
|
|
581
|
-
if (!versioning && reference.generatedUrl.startsWith("ignore:")) {
|
|
582
|
-
return reference.generatedUrl.slice("ignore:".length);
|
|
583
|
-
}
|
|
584
588
|
return null;
|
|
585
589
|
}
|
|
586
590
|
if (reference.isResourceHint) {
|
|
@@ -1059,14 +1063,11 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1059
1063
|
const contentVersionMap = new Map();
|
|
1060
1064
|
const hashCallbacks = [];
|
|
1061
1065
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1062
|
-
if (urlInfo.url.startsWith("data:")) {
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
1066
|
if (urlInfo.type === "sourcemap") {
|
|
1066
1067
|
return;
|
|
1067
1068
|
}
|
|
1068
1069
|
// ignore:
|
|
1069
|
-
// - inline files:
|
|
1070
|
+
// - inline files and data files:
|
|
1070
1071
|
// they are already taken into account in the file where they appear
|
|
1071
1072
|
// - ignored files:
|
|
1072
1073
|
// we don't know their content
|
|
@@ -1078,7 +1079,10 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1078
1079
|
if (urlInfo.isInline) {
|
|
1079
1080
|
return;
|
|
1080
1081
|
}
|
|
1081
|
-
if (
|
|
1082
|
+
if (urlInfo.url.startsWith("data:")) {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
if (urlInfo.url.startsWith("ignore:")) {
|
|
1082
1086
|
return;
|
|
1083
1087
|
}
|
|
1084
1088
|
if (urlInfo.dependents.size === 0 && !urlInfo.isEntryPoint) {
|
|
@@ -1112,7 +1116,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1112
1116
|
);
|
|
1113
1117
|
if (!dependencyContentVersion) {
|
|
1114
1118
|
// no content generated for this dependency
|
|
1115
|
-
// (inline, data:, sourcemap,
|
|
1119
|
+
// (inline, data:, ignore:, sourcemap, ...)
|
|
1116
1120
|
return null;
|
|
1117
1121
|
}
|
|
1118
1122
|
if (preferWithoutVersioning(reference)) {
|
|
@@ -1178,6 +1182,8 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1178
1182
|
const versioningKitchen = createKitchen({
|
|
1179
1183
|
logLevel: logger.level,
|
|
1180
1184
|
rootDirectoryUrl: buildDirectoryUrl,
|
|
1185
|
+
ignore,
|
|
1186
|
+
ignoreProtocol: "remove",
|
|
1181
1187
|
urlGraph: finalGraph,
|
|
1182
1188
|
build: true,
|
|
1183
1189
|
runtimeCompat,
|
|
@@ -1227,13 +1233,13 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1227
1233
|
return url;
|
|
1228
1234
|
},
|
|
1229
1235
|
formatReference: (reference) => {
|
|
1230
|
-
if (
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1236
|
+
if (reference.url.startsWith("ignore:")) {
|
|
1237
|
+
return null;
|
|
1238
|
+
}
|
|
1239
|
+
if (reference.isInline) {
|
|
1234
1240
|
return null;
|
|
1235
1241
|
}
|
|
1236
|
-
if (reference.
|
|
1242
|
+
if (reference.url.startsWith("data:")) {
|
|
1237
1243
|
return null;
|
|
1238
1244
|
}
|
|
1239
1245
|
if (reference.isResourceHint) {
|
|
@@ -1247,9 +1253,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1247
1253
|
if (!canUseVersionedUrl(referencedUrlInfo)) {
|
|
1248
1254
|
return reference.specifier;
|
|
1249
1255
|
}
|
|
1250
|
-
if (!referencedUrlInfo.shouldHandle) {
|
|
1251
|
-
return null;
|
|
1252
|
-
}
|
|
1253
1256
|
const versionedUrl = versionedUrlMap.get(reference.url);
|
|
1254
1257
|
if (!versionedUrl) {
|
|
1255
1258
|
// happens for sourcemap
|
|
@@ -1376,9 +1379,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1376
1379
|
}
|
|
1377
1380
|
cleanup_jsenv_attributes_from_html: {
|
|
1378
1381
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1379
|
-
if (!urlInfo.shouldHandle) {
|
|
1380
|
-
return;
|
|
1381
|
-
}
|
|
1382
1382
|
if (!urlInfo.url.startsWith("file:")) {
|
|
1383
1383
|
return;
|
|
1384
1384
|
}
|
|
@@ -1561,10 +1561,10 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1561
1561
|
if (serviceWorkerEntryUrlInfos.length > 0) {
|
|
1562
1562
|
const serviceWorkerResources = {};
|
|
1563
1563
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1564
|
-
if (
|
|
1564
|
+
if (!urlInfo.url.startsWith("file:")) {
|
|
1565
1565
|
return;
|
|
1566
1566
|
}
|
|
1567
|
-
if (
|
|
1567
|
+
if (urlInfo.isInline) {
|
|
1568
1568
|
return;
|
|
1569
1569
|
}
|
|
1570
1570
|
if (!canUseVersionedUrl(urlInfo)) {
|
|
@@ -1634,9 +1634,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1634
1634
|
return buildRelativeUrl;
|
|
1635
1635
|
};
|
|
1636
1636
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1637
|
-
if (!urlInfo.shouldHandle) {
|
|
1638
|
-
return;
|
|
1639
|
-
}
|
|
1640
1637
|
if (!urlInfo.url.startsWith("file:")) {
|
|
1641
1638
|
return;
|
|
1642
1639
|
}
|
package/src/dev/file_service.js
CHANGED
|
@@ -22,14 +22,15 @@ export const createFileService = ({
|
|
|
22
22
|
|
|
23
23
|
sourceDirectoryUrl,
|
|
24
24
|
sourceMainFilePath,
|
|
25
|
+
ignore,
|
|
25
26
|
sourceFilesConfig,
|
|
26
27
|
runtimeCompat,
|
|
27
28
|
|
|
28
29
|
plugins,
|
|
29
30
|
referenceAnalysis,
|
|
30
31
|
nodeEsmResolution,
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
magicExtensions,
|
|
33
|
+
magicDirectoryIndex,
|
|
33
34
|
supervisor,
|
|
34
35
|
transpilation,
|
|
35
36
|
clientAutoreload,
|
|
@@ -97,6 +98,7 @@ export const createFileService = ({
|
|
|
97
98
|
logLevel,
|
|
98
99
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
99
100
|
mainFilePath: sourceMainFilePath,
|
|
101
|
+
ignore,
|
|
100
102
|
urlGraph,
|
|
101
103
|
dev: true,
|
|
102
104
|
runtimeCompat,
|
|
@@ -116,8 +118,8 @@ export const createFileService = ({
|
|
|
116
118
|
|
|
117
119
|
referenceAnalysis,
|
|
118
120
|
nodeEsmResolution,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
magicExtensions,
|
|
122
|
+
magicDirectoryIndex,
|
|
121
123
|
supervisor,
|
|
122
124
|
transpilation,
|
|
123
125
|
|
|
@@ -25,6 +25,7 @@ import { createFileService } from "./file_service.js";
|
|
|
25
25
|
export const startDevServer = async ({
|
|
26
26
|
sourceDirectoryUrl,
|
|
27
27
|
sourceMainFilePath = "./index.html",
|
|
28
|
+
ignore,
|
|
28
29
|
port = 3456,
|
|
29
30
|
hostname,
|
|
30
31
|
acceptAnyIp,
|
|
@@ -52,9 +53,9 @@ export const startDevServer = async ({
|
|
|
52
53
|
plugins = [],
|
|
53
54
|
referenceAnalysis = {},
|
|
54
55
|
nodeEsmResolution,
|
|
55
|
-
webResolution,
|
|
56
56
|
supervisor = true,
|
|
57
|
-
|
|
57
|
+
magicExtensions,
|
|
58
|
+
magicDirectoryIndex,
|
|
58
59
|
transpilation,
|
|
59
60
|
cacheControl = true,
|
|
60
61
|
ribbon = true,
|
|
@@ -186,14 +187,15 @@ export const startDevServer = async ({
|
|
|
186
187
|
|
|
187
188
|
sourceDirectoryUrl,
|
|
188
189
|
sourceMainFilePath,
|
|
190
|
+
ignore,
|
|
189
191
|
sourceFilesConfig,
|
|
190
192
|
runtimeCompat,
|
|
191
193
|
|
|
192
194
|
plugins,
|
|
193
195
|
referenceAnalysis,
|
|
194
196
|
nodeEsmResolution,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
magicExtensions,
|
|
198
|
+
magicDirectoryIndex,
|
|
197
199
|
supervisor,
|
|
198
200
|
transpilation,
|
|
199
201
|
clientAutoreload,
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
normalizeUrl,
|
|
7
7
|
setUrlFilename,
|
|
8
8
|
} from "@jsenv/urls";
|
|
9
|
+
import { URL_META } from "@jsenv/url-meta";
|
|
9
10
|
import { writeFileSync, ensureWindowsDriveLetter } from "@jsenv/filesystem";
|
|
10
11
|
import { createLogger, createDetailedMessage, ANSI } from "@jsenv/log";
|
|
11
12
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
|
|
@@ -29,6 +30,9 @@ export const createKitchen = ({
|
|
|
29
30
|
|
|
30
31
|
rootDirectoryUrl,
|
|
31
32
|
mainFilePath,
|
|
33
|
+
ignore,
|
|
34
|
+
ignoreProtocol = "remove",
|
|
35
|
+
supportedProtocols = ["file:", "data:", "virtual:", "http:", "https:"],
|
|
32
36
|
urlGraph,
|
|
33
37
|
dev = false,
|
|
34
38
|
build = false,
|
|
@@ -72,6 +76,35 @@ export const createKitchen = ({
|
|
|
72
76
|
pluginController.pushPlugin(pluginEntry);
|
|
73
77
|
});
|
|
74
78
|
|
|
79
|
+
const isIgnoredByProtocol = (url) => {
|
|
80
|
+
const { protocol } = new URL(url);
|
|
81
|
+
const protocolIsSupported = supportedProtocols.some(
|
|
82
|
+
(supportedProtocol) => protocol === supportedProtocol,
|
|
83
|
+
);
|
|
84
|
+
return !protocolIsSupported;
|
|
85
|
+
};
|
|
86
|
+
let isIgnoredByParam = () => false;
|
|
87
|
+
if (ignore) {
|
|
88
|
+
const associations = URL_META.resolveAssociations(
|
|
89
|
+
{ ignore },
|
|
90
|
+
rootDirectoryUrl,
|
|
91
|
+
);
|
|
92
|
+
const cache = new Map();
|
|
93
|
+
isIgnoredByParam = (url) => {
|
|
94
|
+
const fromCache = cache.get(url);
|
|
95
|
+
if (fromCache) return fromCache;
|
|
96
|
+
const { ignore } = URL_META.applyAssociations({
|
|
97
|
+
url,
|
|
98
|
+
associations,
|
|
99
|
+
});
|
|
100
|
+
cache.set(url, ignore);
|
|
101
|
+
return ignore;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const isIgnored = (url) => {
|
|
105
|
+
return isIgnoredByProtocol(url) || isIgnoredByParam(url);
|
|
106
|
+
};
|
|
107
|
+
|
|
75
108
|
/*
|
|
76
109
|
* - "http_request"
|
|
77
110
|
* - "entry_point"
|
|
@@ -116,7 +149,6 @@ export const createKitchen = ({
|
|
|
116
149
|
specifierColumn,
|
|
117
150
|
baseUrl,
|
|
118
151
|
isOriginalPosition,
|
|
119
|
-
shouldHandle,
|
|
120
152
|
isEntryPoint = false,
|
|
121
153
|
isResourceHint = false,
|
|
122
154
|
isImplicit = false,
|
|
@@ -165,7 +197,6 @@ export const createKitchen = ({
|
|
|
165
197
|
specifierColumn,
|
|
166
198
|
isOriginalPosition,
|
|
167
199
|
baseUrl,
|
|
168
|
-
shouldHandle,
|
|
169
200
|
isEntryPoint,
|
|
170
201
|
isResourceHint,
|
|
171
202
|
isImplicit,
|
|
@@ -216,13 +247,36 @@ export const createKitchen = ({
|
|
|
216
247
|
url = normalizeUrl(url);
|
|
217
248
|
let referencedUrlObject;
|
|
218
249
|
let searchParams;
|
|
219
|
-
const
|
|
250
|
+
const setReferenceUrl = (referenceUrl) => {
|
|
251
|
+
// ignored urls are prefixed with "ignore:" so that reference are associated
|
|
252
|
+
// to a dedicated urlInfo that is ignored.
|
|
253
|
+
// this way it's only once a resource is referenced by reference that is not ignored
|
|
254
|
+
// that the resource is cooked
|
|
255
|
+
if (
|
|
256
|
+
reference.specifier[0] === "#" &&
|
|
257
|
+
// For Html, css and "#" refer to a resource in the page, reference must be preserved
|
|
258
|
+
// However for js import specifiers they have a different meaning and we want
|
|
259
|
+
// to resolve them (https://nodejs.org/api/packages.html#imports for instance)
|
|
260
|
+
reference.type !== "js_import"
|
|
261
|
+
) {
|
|
262
|
+
referenceUrl = `ignore:${referenceUrl}`;
|
|
263
|
+
} else if (isIgnored(referenceUrl)) {
|
|
264
|
+
referenceUrl = `ignore:${referenceUrl}`;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (
|
|
268
|
+
referenceUrl.startsWith("ignore:") &&
|
|
269
|
+
!reference.specifier.startsWith("ignore:")
|
|
270
|
+
) {
|
|
271
|
+
reference.specifier = `ignore:${reference.specifier}`;
|
|
272
|
+
}
|
|
273
|
+
|
|
220
274
|
referencedUrlObject = new URL(referenceUrl);
|
|
221
275
|
searchParams = referencedUrlObject.searchParams;
|
|
222
276
|
reference.url = referenceUrl;
|
|
223
277
|
reference.searchParams = searchParams;
|
|
224
278
|
};
|
|
225
|
-
|
|
279
|
+
setReferenceUrl(url);
|
|
226
280
|
|
|
227
281
|
if (reference.debug) {
|
|
228
282
|
logger.debug(`url resolved by "${
|
|
@@ -251,7 +305,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
251
305
|
}
|
|
252
306
|
const prevReference = { ...reference };
|
|
253
307
|
updateReference(prevReference, reference);
|
|
254
|
-
|
|
308
|
+
setReferenceUrl(normalizedReturnValue);
|
|
255
309
|
},
|
|
256
310
|
);
|
|
257
311
|
reference.generatedUrl = reference.url;
|
|
@@ -276,13 +330,22 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
276
330
|
reference.generatedUrl = normalizeUrl(referencedUrlObject.href);
|
|
277
331
|
},
|
|
278
332
|
);
|
|
333
|
+
|
|
279
334
|
const returnValue = pluginController.callHooksUntil(
|
|
280
335
|
"formatReference",
|
|
281
336
|
reference,
|
|
282
337
|
referenceContext,
|
|
283
338
|
);
|
|
284
|
-
reference.
|
|
285
|
-
|
|
339
|
+
if (reference.url.startsWith("ignore:")) {
|
|
340
|
+
if (ignoreProtocol === "remove") {
|
|
341
|
+
reference.specifier = reference.specifier.slice("ignore:".length);
|
|
342
|
+
}
|
|
343
|
+
reference.generatedSpecifier = reference.specifier;
|
|
344
|
+
reference.generatedSpecifier = urlSpecifierEncoding.encode(reference);
|
|
345
|
+
} else {
|
|
346
|
+
reference.generatedSpecifier = returnValue || reference.generatedUrl;
|
|
347
|
+
reference.generatedSpecifier = urlSpecifierEncoding.encode(reference);
|
|
348
|
+
}
|
|
286
349
|
return [reference, urlInfo];
|
|
287
350
|
} catch (error) {
|
|
288
351
|
throw createResolveUrlError({
|
|
@@ -464,7 +527,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
464
527
|
});
|
|
465
528
|
};
|
|
466
529
|
|
|
467
|
-
if (urlInfo.
|
|
530
|
+
if (!urlInfo.url.startsWith("ignore:")) {
|
|
468
531
|
// references
|
|
469
532
|
const references = [];
|
|
470
533
|
context.referenceUtils = {
|
|
@@ -849,11 +912,6 @@ const traceFromUrlSite = (urlSite) => {
|
|
|
849
912
|
};
|
|
850
913
|
|
|
851
914
|
const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
|
|
852
|
-
if (reference.shouldHandle) {
|
|
853
|
-
urlInfo.shouldHandle = true;
|
|
854
|
-
} else {
|
|
855
|
-
urlInfo.shouldHandle = false;
|
|
856
|
-
}
|
|
857
915
|
urlInfo.originalUrl = urlInfo.originalUrl || reference.url;
|
|
858
916
|
|
|
859
917
|
if (reference.isEntryPoint || isWebWorkerEntryPointReference(reference)) {
|
|
@@ -30,15 +30,19 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
30
30
|
total: 0,
|
|
31
31
|
};
|
|
32
32
|
urlGraph.urlInfoMap.forEach((urlInfo) => {
|
|
33
|
-
if (urlInfo.url.startsWith("data:")) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
33
|
// ignore:
|
|
37
|
-
// - inline files: they are already taken into account in the file where they appear
|
|
38
34
|
// - ignored files: we don't know their content
|
|
39
|
-
|
|
35
|
+
// - inline files and data files: they are already taken into account in the file where they appear
|
|
36
|
+
if (urlInfo.url.startsWith("ignore:")) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (urlInfo.isInline) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
+
if (urlInfo.url.startsWith("data:")) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
// file loaded via import assertion are already inside the graph
|
|
43
47
|
// their js module equivalent are ignored to avoid counting it twice
|
|
44
48
|
// in the build graph the file targeted by import assertion will likely be gone
|
package/src/kitchen/url_graph.js
CHANGED
|
@@ -153,7 +153,11 @@ export const createPluginController = (kitchenContext) => {
|
|
|
153
153
|
info.timing[`${hook.name}-${hook.plugin.name.replace("jsenv:", "")}`] =
|
|
154
154
|
performance.now() - startTimestamp;
|
|
155
155
|
}
|
|
156
|
-
valueReturned = assertAndNormalizeReturnValue(
|
|
156
|
+
valueReturned = assertAndNormalizeReturnValue(
|
|
157
|
+
hook.name,
|
|
158
|
+
valueReturned,
|
|
159
|
+
info,
|
|
160
|
+
);
|
|
157
161
|
return valueReturned;
|
|
158
162
|
};
|
|
159
163
|
const callAsyncHook = async (hook, info, context) => {
|
|
@@ -176,7 +180,11 @@ export const createPluginController = (kitchenContext) => {
|
|
|
176
180
|
info.timing[`${hook.name}-${hook.plugin.name.replace("jsenv:", "")}`] =
|
|
177
181
|
performance.now() - startTimestamp;
|
|
178
182
|
}
|
|
179
|
-
valueReturned = assertAndNormalizeReturnValue(
|
|
183
|
+
valueReturned = assertAndNormalizeReturnValue(
|
|
184
|
+
hook.name,
|
|
185
|
+
valueReturned,
|
|
186
|
+
info,
|
|
187
|
+
);
|
|
180
188
|
return valueReturned;
|
|
181
189
|
};
|
|
182
190
|
|
|
@@ -277,7 +285,7 @@ const getHookFunction = (
|
|
|
277
285
|
return hookValue;
|
|
278
286
|
};
|
|
279
287
|
|
|
280
|
-
const assertAndNormalizeReturnValue = (hookName, returnValue) => {
|
|
288
|
+
const assertAndNormalizeReturnValue = (hookName, returnValue, info) => {
|
|
281
289
|
// all hooks are allowed to return null/undefined as a signal of "I don't do anything"
|
|
282
290
|
if (returnValue === null || returnValue === undefined) {
|
|
283
291
|
return returnValue;
|
|
@@ -286,7 +294,7 @@ const assertAndNormalizeReturnValue = (hookName, returnValue) => {
|
|
|
286
294
|
if (!returnValueAssertion.appliesTo.includes(hookName)) {
|
|
287
295
|
continue;
|
|
288
296
|
}
|
|
289
|
-
const assertionResult = returnValueAssertion.assertion(returnValue);
|
|
297
|
+
const assertionResult = returnValueAssertion.assertion(returnValue, info);
|
|
290
298
|
if (assertionResult !== undefined) {
|
|
291
299
|
// normalization
|
|
292
300
|
returnValue = assertionResult;
|
|
@@ -320,13 +328,13 @@ const returnValueAssertions = [
|
|
|
320
328
|
"finalizeUrlContent",
|
|
321
329
|
"optimizeUrlContent",
|
|
322
330
|
],
|
|
323
|
-
assertion: (valueReturned) => {
|
|
331
|
+
assertion: (valueReturned, urlInfo) => {
|
|
324
332
|
if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) {
|
|
325
333
|
return { content: valueReturned };
|
|
326
334
|
}
|
|
327
335
|
if (typeof valueReturned === "object") {
|
|
328
|
-
const {
|
|
329
|
-
if (
|
|
336
|
+
const { content, body } = valueReturned;
|
|
337
|
+
if (urlInfo.url.startsWith("ignore:")) {
|
|
330
338
|
return undefined;
|
|
331
339
|
}
|
|
332
340
|
if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) {
|
package/src/plugins/plugins.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { jsenvPluginSupervisor } from "@jsenv/plugin-supervisor";
|
|
2
|
+
|
|
1
3
|
import { jsenvPluginReferenceAnalysis } from "./reference_analysis/jsenv_plugin_reference_analysis.js";
|
|
2
4
|
import { jsenvPluginImportmap } from "./importmap/jsenv_plugin_importmap.js";
|
|
3
5
|
import { jsenvPluginNodeEsmResolution } from "./resolution_node_esm/jsenv_plugin_node_esm_resolution.js";
|
|
4
6
|
import { jsenvPluginWebResolution } from "./resolution_web/jsenv_plugin_web_resolution.js";
|
|
5
7
|
import { jsenvPluginVersionSearchParam } from "./version_search_param/jsenv_plugin_version_search_param.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
+
import { jsenvPluginProtocolFile } from "./protocol_file/jsenv_plugin_protocol_file.js";
|
|
9
|
+
import { jsenvPluginProtocolHttp } from "./protocol_http/jsenv_plugin_protocol_http.js";
|
|
8
10
|
import { jsenvPluginInlining } from "./inlining/jsenv_plugin_inlining.js";
|
|
9
|
-
import { jsenvPluginSupervisor } from "./supervisor/jsenv_plugin_supervisor.js";
|
|
10
11
|
import { jsenvPluginCommonJsGlobals } from "./commonjs_globals/jsenv_plugin_commonjs_globals.js";
|
|
11
12
|
import { jsenvPluginImportMetaScenarios } from "./import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js";
|
|
12
13
|
import { jsenvPluginGlobalScenarios } from "./global_scenarios/jsenv_plugin_global_scenarios.js";
|
|
@@ -25,8 +26,8 @@ export const getCorePlugins = ({
|
|
|
25
26
|
|
|
26
27
|
referenceAnalysis = {},
|
|
27
28
|
nodeEsmResolution = {},
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
magicExtensions,
|
|
30
|
+
magicDirectoryIndex,
|
|
30
31
|
directoryReferenceAllowed,
|
|
31
32
|
supervisor,
|
|
32
33
|
transpilation = true,
|
|
@@ -45,9 +46,6 @@ export const getCorePlugins = ({
|
|
|
45
46
|
if (supervisor === true) {
|
|
46
47
|
supervisor = {};
|
|
47
48
|
}
|
|
48
|
-
if (fileSystemMagicRedirection === true) {
|
|
49
|
-
fileSystemMagicRedirection = {};
|
|
50
|
-
}
|
|
51
49
|
if (clientAutoreload === true) {
|
|
52
50
|
clientAutoreload = {};
|
|
53
51
|
}
|
|
@@ -68,15 +66,16 @@ export const getCorePlugins = ({
|
|
|
68
66
|
- reference inside a js module -> resolved by node esm
|
|
69
67
|
- All the rest uses web standard url resolution
|
|
70
68
|
*/
|
|
71
|
-
|
|
69
|
+
jsenvPluginProtocolFile({
|
|
72
70
|
directoryReferenceAllowed,
|
|
73
|
-
|
|
71
|
+
magicExtensions,
|
|
72
|
+
magicDirectoryIndex,
|
|
74
73
|
}),
|
|
75
|
-
|
|
74
|
+
jsenvPluginProtocolHttp(),
|
|
76
75
|
...(nodeEsmResolution
|
|
77
76
|
? [jsenvPluginNodeEsmResolution(nodeEsmResolution)]
|
|
78
77
|
: []),
|
|
79
|
-
jsenvPluginWebResolution(
|
|
78
|
+
jsenvPluginWebResolution(),
|
|
80
79
|
|
|
81
80
|
jsenvPluginVersionSearchParam(),
|
|
82
81
|
jsenvPluginCommonJsGlobals(),
|