@jsenv/core 36.0.1 → 36.0.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/dist/js/ribbon.js +4 -0
- package/dist/jsenv_core.js +117 -107
- package/package.json +1 -1
- package/src/build/build.js +32 -24
- package/src/dev/file_service.js +4 -4
- package/src/dev/start_dev_server.js +4 -4
- package/src/kitchen/kitchen.js +13 -8
- package/src/kitchen/url_graph/url_graph_report.js +1 -1
- package/src/kitchen/url_graph.js +1 -1
- package/src/plugins/plugin_controller.js +2 -2
- package/src/plugins/plugins.js +9 -11
- package/src/plugins/{file_urls/jsenv_plugin_file_urls.js → protocol_file/jsenv_plugin_protocol_file.js} +9 -9
- package/src/plugins/{http_urls/jsenv_plugin_http_urls.js → protocol_http/jsenv_plugin_protocol_http.js} +3 -3
- package/src/plugins/reference_analysis/jsenv_plugin_reference_analysis.js +25 -6
- 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/src/plugins/{url_type_from_reference.js → resolution_node_esm/url_type_from_reference.js} +0 -0
package/dist/js/ribbon.js
CHANGED
|
@@ -47,6 +47,10 @@ const injectRibbon = ({
|
|
|
47
47
|
</div>`;
|
|
48
48
|
const node = document.createElement("div");
|
|
49
49
|
node.innerHTML = html;
|
|
50
|
+
const toolbarStateInLocalStorage = localStorage.hasOwnProperty("jsenv_toolbar") ? JSON.parse(localStorage.getItem("jsenv_toolbar")) : {};
|
|
51
|
+
if (toolbarStateInLocalStorage.ribbonDisplayed === false) {
|
|
52
|
+
node.querySelector("#jsenv_ribbon_container").style.display = "none";
|
|
53
|
+
}
|
|
50
54
|
document.body.appendChild(node.firstChild);
|
|
51
55
|
};
|
|
52
56
|
|
package/dist/jsenv_core.js
CHANGED
|
@@ -7806,7 +7806,7 @@ const createUrlInfo = url => {
|
|
|
7806
7806
|
originalUrl: undefined,
|
|
7807
7807
|
filename: "",
|
|
7808
7808
|
isEntryPoint: false,
|
|
7809
|
-
|
|
7809
|
+
mustIgnore: undefined,
|
|
7810
7810
|
originalContent: undefined,
|
|
7811
7811
|
content: undefined,
|
|
7812
7812
|
sourcemap: null,
|
|
@@ -8126,11 +8126,11 @@ const returnValueAssertions = [{
|
|
|
8126
8126
|
}
|
|
8127
8127
|
if (typeof valueReturned === "object") {
|
|
8128
8128
|
const {
|
|
8129
|
-
|
|
8129
|
+
mustIgnore,
|
|
8130
8130
|
content,
|
|
8131
8131
|
body
|
|
8132
8132
|
} = valueReturned;
|
|
8133
|
-
if (
|
|
8133
|
+
if (mustIgnore) {
|
|
8134
8134
|
return undefined;
|
|
8135
8135
|
}
|
|
8136
8136
|
if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) {
|
|
@@ -9192,7 +9192,7 @@ const createKitchen = ({
|
|
|
9192
9192
|
specifierColumn,
|
|
9193
9193
|
baseUrl,
|
|
9194
9194
|
isOriginalPosition,
|
|
9195
|
-
|
|
9195
|
+
mustIgnore,
|
|
9196
9196
|
isEntryPoint = false,
|
|
9197
9197
|
isResourceHint = false,
|
|
9198
9198
|
isImplicit = false,
|
|
@@ -9241,7 +9241,7 @@ const createKitchen = ({
|
|
|
9241
9241
|
specifierColumn,
|
|
9242
9242
|
isOriginalPosition,
|
|
9243
9243
|
baseUrl,
|
|
9244
|
-
|
|
9244
|
+
mustIgnore,
|
|
9245
9245
|
isEntryPoint,
|
|
9246
9246
|
isResourceHint,
|
|
9247
9247
|
isImplicit,
|
|
@@ -9333,8 +9333,13 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
9333
9333
|
reference.generatedUrl = normalizeUrl(referencedUrlObject.href);
|
|
9334
9334
|
});
|
|
9335
9335
|
const returnValue = pluginController.callHooksUntil("formatReference", reference, referenceContext);
|
|
9336
|
-
reference.
|
|
9337
|
-
|
|
9336
|
+
if (reference.mustIgnore) {
|
|
9337
|
+
reference.generatedSpecifier = reference.specifier;
|
|
9338
|
+
reference.generatedSpecifier = urlSpecifierEncoding.encode(reference);
|
|
9339
|
+
} else {
|
|
9340
|
+
reference.generatedSpecifier = returnValue || reference.generatedUrl;
|
|
9341
|
+
reference.generatedSpecifier = urlSpecifierEncoding.encode(reference);
|
|
9342
|
+
}
|
|
9338
9343
|
return [reference, urlInfo];
|
|
9339
9344
|
} catch (error) {
|
|
9340
9345
|
throw createResolveUrlError({
|
|
@@ -9504,7 +9509,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
9504
9509
|
contextDuringFetch: context
|
|
9505
9510
|
});
|
|
9506
9511
|
};
|
|
9507
|
-
if (urlInfo.
|
|
9512
|
+
if (!urlInfo.mustIgnore) {
|
|
9508
9513
|
// references
|
|
9509
9514
|
const references = [];
|
|
9510
9515
|
context.referenceUtils = {
|
|
@@ -9834,10 +9839,10 @@ const traceFromUrlSite = urlSite => {
|
|
|
9834
9839
|
};
|
|
9835
9840
|
};
|
|
9836
9841
|
const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
|
|
9837
|
-
if (reference.
|
|
9838
|
-
urlInfo.
|
|
9842
|
+
if (reference.mustIgnore) {
|
|
9843
|
+
urlInfo.mustIgnore = true;
|
|
9839
9844
|
} else {
|
|
9840
|
-
urlInfo.
|
|
9845
|
+
urlInfo.mustIgnore = false;
|
|
9841
9846
|
}
|
|
9842
9847
|
urlInfo.originalUrl = urlInfo.originalUrl || reference.url;
|
|
9843
9848
|
if (reference.isEntryPoint || isWebWorkerEntryPointReference(reference)) {
|
|
@@ -10076,7 +10081,7 @@ const createUrlGraphReport = urlGraph => {
|
|
|
10076
10081
|
// ignore:
|
|
10077
10082
|
// - inline files: they are already taken into account in the file where they appear
|
|
10078
10083
|
// - ignored files: we don't know their content
|
|
10079
|
-
if (urlInfo.isInline ||
|
|
10084
|
+
if (urlInfo.isInline || urlInfo.mustIgnore) {
|
|
10080
10085
|
return;
|
|
10081
10086
|
}
|
|
10082
10087
|
// file loaded via import assertion are already inside the graph
|
|
@@ -11108,6 +11113,7 @@ const parseAndTransformJsReferences = async (urlInfo, context, {
|
|
|
11108
11113
|
const jsenvPluginReferenceAnalysis = ({
|
|
11109
11114
|
include,
|
|
11110
11115
|
supportedProtocols = ["file:", "data:", "virtual:", "http:", "https:"],
|
|
11116
|
+
ignoreProtocol = "remove",
|
|
11111
11117
|
inlineContent = true,
|
|
11112
11118
|
inlineConvertedScript = false,
|
|
11113
11119
|
fetchInlineUrls = true,
|
|
@@ -11115,7 +11121,8 @@ const jsenvPluginReferenceAnalysis = ({
|
|
|
11115
11121
|
}) => {
|
|
11116
11122
|
return [jsenvPluginReferenceAnalysisInclude({
|
|
11117
11123
|
include,
|
|
11118
|
-
supportedProtocols
|
|
11124
|
+
supportedProtocols,
|
|
11125
|
+
ignoreProtocol
|
|
11119
11126
|
}), jsenvPluginDirectoryReferenceAnalysis(), jsenvPluginHtmlReferenceAnalysis({
|
|
11120
11127
|
inlineContent,
|
|
11121
11128
|
inlineConvertedScript
|
|
@@ -11126,7 +11133,8 @@ const jsenvPluginReferenceAnalysis = ({
|
|
|
11126
11133
|
};
|
|
11127
11134
|
const jsenvPluginReferenceAnalysisInclude = ({
|
|
11128
11135
|
include,
|
|
11129
|
-
supportedProtocols
|
|
11136
|
+
supportedProtocols,
|
|
11137
|
+
ignoreProtocol
|
|
11130
11138
|
}) => {
|
|
11131
11139
|
// eslint-disable-next-line no-unused-vars
|
|
11132
11140
|
let getIncludeInfo = url => undefined;
|
|
@@ -11152,7 +11160,7 @@ const jsenvPluginReferenceAnalysisInclude = ({
|
|
|
11152
11160
|
}
|
|
11153
11161
|
},
|
|
11154
11162
|
redirectReference: reference => {
|
|
11155
|
-
if (reference.
|
|
11163
|
+
if (reference.mustIgnore !== undefined) {
|
|
11156
11164
|
return;
|
|
11157
11165
|
}
|
|
11158
11166
|
if (reference.specifier[0] === "#" &&
|
|
@@ -11161,24 +11169,36 @@ const jsenvPluginReferenceAnalysisInclude = ({
|
|
|
11161
11169
|
// However for js import specifiers they have a different meaning and we want
|
|
11162
11170
|
// to resolve them (https://nodejs.org/api/packages.html#imports for instance)
|
|
11163
11171
|
reference.type !== "js_import") {
|
|
11164
|
-
reference.
|
|
11172
|
+
reference.mustIgnore = true;
|
|
11173
|
+
return;
|
|
11174
|
+
}
|
|
11175
|
+
if (reference.url.startsWith("ignore:")) {
|
|
11176
|
+
reference.mustIgnore = true;
|
|
11177
|
+
if (ignoreProtocol === "remove") {
|
|
11178
|
+
reference.specifier = reference.specifier.slice("ignore:".length);
|
|
11179
|
+
}
|
|
11165
11180
|
return;
|
|
11166
11181
|
}
|
|
11167
11182
|
const includeInfo = getIncludeInfo(reference.url);
|
|
11168
11183
|
if (includeInfo === true) {
|
|
11169
|
-
reference.
|
|
11184
|
+
reference.mustIgnore = false;
|
|
11170
11185
|
return;
|
|
11171
11186
|
}
|
|
11172
11187
|
if (includeInfo === false) {
|
|
11173
|
-
reference.
|
|
11188
|
+
reference.mustIgnore = true;
|
|
11174
11189
|
return;
|
|
11175
11190
|
}
|
|
11176
11191
|
const {
|
|
11177
11192
|
protocol
|
|
11178
11193
|
} = new URL(reference.url);
|
|
11179
11194
|
const protocolIsSupported = supportedProtocols.some(supportedProtocol => protocol === supportedProtocol);
|
|
11180
|
-
if (protocolIsSupported) {
|
|
11181
|
-
reference.
|
|
11195
|
+
if (!protocolIsSupported) {
|
|
11196
|
+
reference.mustIgnore = true;
|
|
11197
|
+
}
|
|
11198
|
+
},
|
|
11199
|
+
formatReference: reference => {
|
|
11200
|
+
if (ignoreProtocol === "inject" && reference.mustIgnore && !reference.url.startsWith("ignore:")) {
|
|
11201
|
+
reference.specifier = `ignore:${reference.specifier}`;
|
|
11182
11202
|
}
|
|
11183
11203
|
}
|
|
11184
11204
|
};
|
|
@@ -17435,10 +17455,10 @@ const jsenvPluginNodeEsmResolution = (resolutionConfig = {}) => {
|
|
|
17435
17455
|
runtimeCompat,
|
|
17436
17456
|
preservesSymlink: true
|
|
17437
17457
|
});
|
|
17438
|
-
if (
|
|
17458
|
+
if (resolvers.js_module === undefined) {
|
|
17439
17459
|
resolvers.js_module = nodeEsmResolverDefault;
|
|
17440
17460
|
}
|
|
17441
|
-
if (
|
|
17461
|
+
if (resolvers.js_classic === undefined) {
|
|
17442
17462
|
resolvers.js_classic = (reference, context) => {
|
|
17443
17463
|
if (reference.subtype === "self_import_scripts_arg") {
|
|
17444
17464
|
return nodeEsmResolverDefault(reference, context);
|
|
@@ -17467,41 +17487,25 @@ const jsenvPluginNodeEsmResolution = (resolutionConfig = {}) => {
|
|
|
17467
17487
|
};
|
|
17468
17488
|
};
|
|
17469
17489
|
|
|
17470
|
-
const jsenvPluginWebResolution = (
|
|
17471
|
-
const resolvers = {};
|
|
17472
|
-
const resolveUsingWebResolution = (reference, context) => {
|
|
17473
|
-
if (reference.specifier === "/") {
|
|
17474
|
-
const {
|
|
17475
|
-
mainFilePath,
|
|
17476
|
-
rootDirectoryUrl
|
|
17477
|
-
} = context;
|
|
17478
|
-
return String(new URL(mainFilePath, rootDirectoryUrl));
|
|
17479
|
-
}
|
|
17480
|
-
if (reference.specifier[0] === "/") {
|
|
17481
|
-
return new URL(reference.specifier.slice(1), context.rootDirectoryUrl).href;
|
|
17482
|
-
}
|
|
17483
|
-
return new URL(reference.specifier,
|
|
17484
|
-
// baseUrl happens second argument to new URL() is different from
|
|
17485
|
-
// import.meta.url or document.currentScript.src
|
|
17486
|
-
reference.baseUrl || reference.parentUrl).href;
|
|
17487
|
-
};
|
|
17488
|
-
Object.keys(resolutionConfig).forEach(urlType => {
|
|
17489
|
-
const config = resolutionConfig[urlType];
|
|
17490
|
-
if (config === true) {
|
|
17491
|
-
resolvers[urlType] = resolveUsingWebResolution;
|
|
17492
|
-
} else if (config === false) {
|
|
17493
|
-
resolvers[urlType] = () => null;
|
|
17494
|
-
} else {
|
|
17495
|
-
throw new TypeError(`config must be true or false, got ${config} on "${urlType}"`);
|
|
17496
|
-
}
|
|
17497
|
-
});
|
|
17490
|
+
const jsenvPluginWebResolution = () => {
|
|
17498
17491
|
return {
|
|
17499
17492
|
name: "jsenv:web_resolution",
|
|
17500
17493
|
appliesDuring: "*",
|
|
17501
17494
|
resolveReference: (reference, context) => {
|
|
17502
|
-
|
|
17503
|
-
|
|
17504
|
-
|
|
17495
|
+
if (reference.specifier === "/") {
|
|
17496
|
+
const {
|
|
17497
|
+
mainFilePath,
|
|
17498
|
+
rootDirectoryUrl
|
|
17499
|
+
} = context;
|
|
17500
|
+
return String(new URL(mainFilePath, rootDirectoryUrl));
|
|
17501
|
+
}
|
|
17502
|
+
if (reference.specifier[0] === "/") {
|
|
17503
|
+
return new URL(reference.specifier.slice(1), context.rootDirectoryUrl).href;
|
|
17504
|
+
}
|
|
17505
|
+
return new URL(reference.specifier,
|
|
17506
|
+
// baseUrl happens second argument to new URL() is different from
|
|
17507
|
+
// import.meta.url or document.currentScript.src
|
|
17508
|
+
reference.baseUrl || reference.parentUrl).href;
|
|
17505
17509
|
}
|
|
17506
17510
|
};
|
|
17507
17511
|
};
|
|
@@ -17540,14 +17544,14 @@ const jsenvPluginVersionSearchParam = () => {
|
|
|
17540
17544
|
};
|
|
17541
17545
|
};
|
|
17542
17546
|
|
|
17543
|
-
const
|
|
17547
|
+
const jsenvPluginProtocolFile = ({
|
|
17544
17548
|
magicExtensions = ["inherit", ".js"],
|
|
17545
17549
|
magicDirectoryIndex = true,
|
|
17546
17550
|
preserveSymlinks = false,
|
|
17547
17551
|
directoryReferenceAllowed = false
|
|
17548
17552
|
}) => {
|
|
17549
17553
|
return [{
|
|
17550
|
-
name: "jsenv:
|
|
17554
|
+
name: "jsenv:fs_redirection",
|
|
17551
17555
|
appliesDuring: "*",
|
|
17552
17556
|
redirectReference: reference => {
|
|
17553
17557
|
// http, https, data, about, ...
|
|
@@ -17588,13 +17592,13 @@ const jsenvPluginFileUrls = ({
|
|
|
17588
17592
|
urlObject.pathname = pathname.slice(0, -1);
|
|
17589
17593
|
}
|
|
17590
17594
|
let url = urlObject.href;
|
|
17591
|
-
const
|
|
17595
|
+
const mustIgnore = stat && stat.isDirectory() && (
|
|
17592
17596
|
// ignore new URL second arg
|
|
17593
17597
|
reference.subtype === "new_url_second_arg" ||
|
|
17594
17598
|
// ignore root file url
|
|
17595
17599
|
reference.url === "file:///" || reference.subtype === "new_url_first_arg" && reference.specifier === "./");
|
|
17596
|
-
if (
|
|
17597
|
-
reference.
|
|
17600
|
+
if (mustIgnore) {
|
|
17601
|
+
reference.mustIgnore = true;
|
|
17598
17602
|
} else {
|
|
17599
17603
|
const shouldApplyDilesystemMagicResolution = reference.type === "js_import";
|
|
17600
17604
|
if (shouldApplyDilesystemMagicResolution) {
|
|
@@ -17626,7 +17630,7 @@ const jsenvPluginFileUrls = ({
|
|
|
17626
17630
|
return null;
|
|
17627
17631
|
}
|
|
17628
17632
|
}, {
|
|
17629
|
-
name: "jsenv:
|
|
17633
|
+
name: "jsenv:fs_resolution",
|
|
17630
17634
|
appliesDuring: "*",
|
|
17631
17635
|
resolveReference: {
|
|
17632
17636
|
filesystem: (reference, context) => {
|
|
@@ -17639,10 +17643,10 @@ const jsenvPluginFileUrls = ({
|
|
|
17639
17643
|
}
|
|
17640
17644
|
}
|
|
17641
17645
|
}, {
|
|
17642
|
-
name: "jsenv:@
|
|
17643
|
-
// during
|
|
17646
|
+
name: "jsenv:@fs",
|
|
17647
|
+
// during build it's fine to use "file://"" urls
|
|
17648
|
+
// but during dev it's a browser running the code
|
|
17644
17649
|
// so absolute file urls needs to be relativized
|
|
17645
|
-
// during build it's fine to use file:// urls
|
|
17646
17650
|
appliesDuring: "dev",
|
|
17647
17651
|
resolveReference: reference => {
|
|
17648
17652
|
if (reference.specifier.startsWith("/@fs/")) {
|
|
@@ -17697,13 +17701,13 @@ const resolveSymlink = fileUrl => {
|
|
|
17697
17701
|
return pathToFileURL(realpathSync(new URL(fileUrl))).href;
|
|
17698
17702
|
};
|
|
17699
17703
|
|
|
17700
|
-
const
|
|
17704
|
+
const jsenvPluginProtocolHttp = () => {
|
|
17701
17705
|
return {
|
|
17702
|
-
name: "jsenv:
|
|
17706
|
+
name: "jsenv:protocol_http",
|
|
17703
17707
|
appliesDuring: "*",
|
|
17704
17708
|
redirectReference: reference => {
|
|
17705
17709
|
if (reference.url.startsWith("http:") || reference.url.startsWith("https:")) {
|
|
17706
|
-
reference.
|
|
17710
|
+
reference.mustIgnore = true;
|
|
17707
17711
|
}
|
|
17708
17712
|
// TODO: according to some pattern matching jsenv could be allowed
|
|
17709
17713
|
// to fetch and transform http urls
|
|
@@ -20893,8 +20897,8 @@ const getCorePlugins = ({
|
|
|
20893
20897
|
runtimeCompat,
|
|
20894
20898
|
referenceAnalysis = {},
|
|
20895
20899
|
nodeEsmResolution = {},
|
|
20896
|
-
|
|
20897
|
-
|
|
20900
|
+
magicExtensions,
|
|
20901
|
+
magicDirectoryIndex,
|
|
20898
20902
|
directoryReferenceAllowed,
|
|
20899
20903
|
supervisor,
|
|
20900
20904
|
transpilation = true,
|
|
@@ -20912,9 +20916,6 @@ const getCorePlugins = ({
|
|
|
20912
20916
|
if (supervisor === true) {
|
|
20913
20917
|
supervisor = {};
|
|
20914
20918
|
}
|
|
20915
|
-
if (fileSystemMagicRedirection === true) {
|
|
20916
|
-
fileSystemMagicRedirection = {};
|
|
20917
|
-
}
|
|
20918
20919
|
if (clientAutoreload === true) {
|
|
20919
20920
|
clientAutoreload = {};
|
|
20920
20921
|
}
|
|
@@ -20930,10 +20931,11 @@ const getCorePlugins = ({
|
|
|
20930
20931
|
- reference inside a js module -> resolved by node esm
|
|
20931
20932
|
- All the rest uses web standard url resolution
|
|
20932
20933
|
*/
|
|
20933
|
-
|
|
20934
|
+
jsenvPluginProtocolFile({
|
|
20934
20935
|
directoryReferenceAllowed,
|
|
20935
|
-
|
|
20936
|
-
|
|
20936
|
+
magicExtensions,
|
|
20937
|
+
magicDirectoryIndex
|
|
20938
|
+
}), jsenvPluginProtocolHttp(), ...(nodeEsmResolution ? [jsenvPluginNodeEsmResolution(nodeEsmResolution)] : []), jsenvPluginWebResolution(), jsenvPluginVersionSearchParam(), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), ...(scenarioPlaceholders ? [jsenvPluginGlobalScenarios()] : []), jsenvPluginNodeRuntime({
|
|
20937
20939
|
runtimeCompat
|
|
20938
20940
|
}), jsenvPluginImportMetaHot(), ...(clientAutoreload ? [jsenvPluginAutoreload({
|
|
20939
20941
|
...clientAutoreload,
|
|
@@ -21335,8 +21337,8 @@ const build = async ({
|
|
|
21335
21337
|
plugins = [],
|
|
21336
21338
|
referenceAnalysis = {},
|
|
21337
21339
|
nodeEsmResolution,
|
|
21338
|
-
|
|
21339
|
-
|
|
21340
|
+
magicExtensions,
|
|
21341
|
+
magicDirectoryIndex,
|
|
21340
21342
|
directoryReferenceAllowed,
|
|
21341
21343
|
scenarioPlaceholders,
|
|
21342
21344
|
transpilation = {},
|
|
@@ -21473,12 +21475,6 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21473
21475
|
...contextSharedDuringBuild,
|
|
21474
21476
|
plugins: [...plugins, {
|
|
21475
21477
|
appliesDuring: "build",
|
|
21476
|
-
formatReference: reference => {
|
|
21477
|
-
if (!reference.shouldHandle) {
|
|
21478
|
-
return `ignore:${reference.specifier}`;
|
|
21479
|
-
}
|
|
21480
|
-
return null;
|
|
21481
|
-
},
|
|
21482
21478
|
fetchUrlContent: (urlInfo, context) => {
|
|
21483
21479
|
if (context.reference.original) {
|
|
21484
21480
|
rawRedirections.set(context.reference.original.url, context.reference.url);
|
|
@@ -21488,10 +21484,15 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21488
21484
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
21489
21485
|
urlGraph: rawGraph,
|
|
21490
21486
|
runtimeCompat,
|
|
21491
|
-
referenceAnalysis
|
|
21487
|
+
referenceAnalysis: {
|
|
21488
|
+
...referenceAnalysis,
|
|
21489
|
+
// during first pass (craft) we inject "ignore:" when a reference must be ignored
|
|
21490
|
+
// so that the second pass (shape) properly ignore those urls
|
|
21491
|
+
ignoreProtocol: "inject"
|
|
21492
|
+
},
|
|
21492
21493
|
nodeEsmResolution,
|
|
21493
|
-
|
|
21494
|
-
|
|
21494
|
+
magicExtensions,
|
|
21495
|
+
magicDirectoryIndex,
|
|
21495
21496
|
directoryReferenceAllowed,
|
|
21496
21497
|
transpilation: {
|
|
21497
21498
|
...transpilation,
|
|
@@ -21533,7 +21534,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21533
21534
|
...contextSharedDuringBuild,
|
|
21534
21535
|
plugins: [jsenvPluginReferenceAnalysis({
|
|
21535
21536
|
...referenceAnalysis,
|
|
21536
|
-
|
|
21537
|
+
// here most plugins are not there
|
|
21538
|
+
// - no external plugin
|
|
21539
|
+
// - no plugin putting reference.mustIgnore on https urls
|
|
21540
|
+
// At this stage it's only about redirecting urls to the build directory
|
|
21541
|
+
// consequently only a subset or urls are supported
|
|
21542
|
+
supportedProtocols: ["file:", "data:", "virtual:", "ignore:"],
|
|
21543
|
+
fetchInlineUrls: false,
|
|
21544
|
+
ignoreProtocol: versioning ? "keep" : "remove"
|
|
21537
21545
|
}), ...(lineBreakNormalization ? [jsenvPluginLineBreakNormalization()] : []), jsenvPluginJsModuleFallback({
|
|
21538
21546
|
systemJsInjection: true
|
|
21539
21547
|
}), jsenvPluginInlining(), {
|
|
@@ -21685,9 +21693,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21685
21693
|
},
|
|
21686
21694
|
formatReference: reference => {
|
|
21687
21695
|
if (!reference.generatedUrl.startsWith("file:")) {
|
|
21688
|
-
if (!versioning && reference.generatedUrl.startsWith("ignore:")) {
|
|
21689
|
-
return reference.generatedUrl.slice("ignore:".length);
|
|
21690
|
-
}
|
|
21691
21696
|
return null;
|
|
21692
21697
|
}
|
|
21693
21698
|
if (reference.isResourceHint) {
|
|
@@ -22123,7 +22128,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22123
22128
|
if (urlInfo.isInline) {
|
|
22124
22129
|
return;
|
|
22125
22130
|
}
|
|
22126
|
-
if (
|
|
22131
|
+
if (urlInfo.mustIgnore) {
|
|
22127
22132
|
return;
|
|
22128
22133
|
}
|
|
22129
22134
|
if (urlInfo.dependents.size === 0 && !urlInfo.isEntryPoint) {
|
|
@@ -22149,7 +22154,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22149
22154
|
const dependencyContentVersion = contentVersionMap.get(reference.url);
|
|
22150
22155
|
if (!dependencyContentVersion) {
|
|
22151
22156
|
// no content generated for this dependency
|
|
22152
|
-
// (inline, data:, sourcemap,
|
|
22157
|
+
// (inline, data:, sourcemap, mustIgnore is true, ...)
|
|
22153
22158
|
return null;
|
|
22154
22159
|
}
|
|
22155
22160
|
if (preferWithoutVersioning(reference)) {
|
|
@@ -22212,8 +22217,16 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22212
22217
|
build: true,
|
|
22213
22218
|
runtimeCompat,
|
|
22214
22219
|
...contextSharedDuringBuild,
|
|
22215
|
-
plugins: [
|
|
22220
|
+
plugins: [
|
|
22221
|
+
// here most plugins are not there
|
|
22222
|
+
// - no external plugin
|
|
22223
|
+
// - no plugin putting reference.mustIgnore on https urls
|
|
22224
|
+
// At this stage it's only about versioning urls
|
|
22225
|
+
// consequently only a subset or urls are supported
|
|
22226
|
+
jsenvPluginReferenceAnalysis({
|
|
22216
22227
|
...referenceAnalysis,
|
|
22228
|
+
supportedProtocols: ["file:", "data:", "virtual:"],
|
|
22229
|
+
ignoreProtocol: "remove",
|
|
22217
22230
|
fetchInlineUrls: false,
|
|
22218
22231
|
inlineConvertedScript: true,
|
|
22219
22232
|
// to be able to version their urls
|
|
@@ -22247,10 +22260,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22247
22260
|
return url;
|
|
22248
22261
|
},
|
|
22249
22262
|
formatReference: reference => {
|
|
22250
|
-
if (
|
|
22251
|
-
if (reference.generatedUrl.startsWith("ignore:")) {
|
|
22252
|
-
return reference.generatedUrl.slice("ignore:".length);
|
|
22253
|
-
}
|
|
22263
|
+
if (reference.mustIgnore) {
|
|
22254
22264
|
return null;
|
|
22255
22265
|
}
|
|
22256
22266
|
if (reference.isInline || reference.url.startsWith("data:")) {
|
|
@@ -22265,7 +22275,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22265
22275
|
if (!canUseVersionedUrl(referencedUrlInfo)) {
|
|
22266
22276
|
return reference.specifier;
|
|
22267
22277
|
}
|
|
22268
|
-
if (
|
|
22278
|
+
if (referencedUrlInfo.mustIgnore) {
|
|
22269
22279
|
return null;
|
|
22270
22280
|
}
|
|
22271
22281
|
const versionedUrl = versionedUrlMap.get(reference.url);
|
|
@@ -22375,7 +22385,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22375
22385
|
}
|
|
22376
22386
|
{
|
|
22377
22387
|
GRAPH.forEach(finalGraph, urlInfo => {
|
|
22378
|
-
if (
|
|
22388
|
+
if (urlInfo.mustIgnore) {
|
|
22379
22389
|
return;
|
|
22380
22390
|
}
|
|
22381
22391
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -22524,7 +22534,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22524
22534
|
if (serviceWorkerEntryUrlInfos.length > 0) {
|
|
22525
22535
|
const serviceWorkerResources = {};
|
|
22526
22536
|
GRAPH.forEach(finalGraph, urlInfo => {
|
|
22527
|
-
if (urlInfo.isInline ||
|
|
22537
|
+
if (urlInfo.isInline || urlInfo.mustIgnore) {
|
|
22528
22538
|
return;
|
|
22529
22539
|
}
|
|
22530
22540
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -22583,7 +22593,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22583
22593
|
return buildRelativeUrl;
|
|
22584
22594
|
};
|
|
22585
22595
|
GRAPH.forEach(finalGraph, urlInfo => {
|
|
22586
|
-
if (
|
|
22596
|
+
if (urlInfo.mustIgnore) {
|
|
22587
22597
|
return;
|
|
22588
22598
|
}
|
|
22589
22599
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -22855,8 +22865,8 @@ const createFileService = ({
|
|
|
22855
22865
|
plugins,
|
|
22856
22866
|
referenceAnalysis,
|
|
22857
22867
|
nodeEsmResolution,
|
|
22858
|
-
|
|
22859
|
-
|
|
22868
|
+
magicExtensions,
|
|
22869
|
+
magicDirectoryIndex,
|
|
22860
22870
|
supervisor,
|
|
22861
22871
|
transpilation,
|
|
22862
22872
|
clientAutoreload,
|
|
@@ -22932,8 +22942,8 @@ const createFileService = ({
|
|
|
22932
22942
|
runtimeCompat,
|
|
22933
22943
|
referenceAnalysis,
|
|
22934
22944
|
nodeEsmResolution,
|
|
22935
|
-
|
|
22936
|
-
|
|
22945
|
+
magicExtensions,
|
|
22946
|
+
magicDirectoryIndex,
|
|
22937
22947
|
supervisor,
|
|
22938
22948
|
transpilation,
|
|
22939
22949
|
clientAutoreload,
|
|
@@ -23271,9 +23281,9 @@ const startDevServer = async ({
|
|
|
23271
23281
|
plugins = [],
|
|
23272
23282
|
referenceAnalysis = {},
|
|
23273
23283
|
nodeEsmResolution,
|
|
23274
|
-
webResolution,
|
|
23275
23284
|
supervisor = true,
|
|
23276
|
-
|
|
23285
|
+
magicExtensions,
|
|
23286
|
+
magicDirectoryIndex,
|
|
23277
23287
|
transpilation,
|
|
23278
23288
|
cacheControl = true,
|
|
23279
23289
|
ribbon = true,
|
|
@@ -23390,8 +23400,8 @@ const startDevServer = async ({
|
|
|
23390
23400
|
plugins,
|
|
23391
23401
|
referenceAnalysis,
|
|
23392
23402
|
nodeEsmResolution,
|
|
23393
|
-
|
|
23394
|
-
|
|
23403
|
+
magicExtensions,
|
|
23404
|
+
magicDirectoryIndex,
|
|
23395
23405
|
supervisor,
|
|
23396
23406
|
transpilation,
|
|
23397
23407
|
clientAutoreload,
|
package/package.json
CHANGED
package/src/build/build.js
CHANGED
|
@@ -136,8 +136,8 @@ export const build = async ({
|
|
|
136
136
|
plugins = [],
|
|
137
137
|
referenceAnalysis = {},
|
|
138
138
|
nodeEsmResolution,
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
magicExtensions,
|
|
140
|
+
magicDirectoryIndex,
|
|
141
141
|
directoryReferenceAllowed,
|
|
142
142
|
scenarioPlaceholders,
|
|
143
143
|
transpilation = {},
|
|
@@ -319,12 +319,6 @@ build ${entryPointKeys.length} entry points`);
|
|
|
319
319
|
...plugins,
|
|
320
320
|
{
|
|
321
321
|
appliesDuring: "build",
|
|
322
|
-
formatReference: (reference) => {
|
|
323
|
-
if (!reference.shouldHandle) {
|
|
324
|
-
return `ignore:${reference.specifier}`;
|
|
325
|
-
}
|
|
326
|
-
return null;
|
|
327
|
-
},
|
|
328
322
|
fetchUrlContent: (urlInfo, context) => {
|
|
329
323
|
if (context.reference.original) {
|
|
330
324
|
rawRedirections.set(
|
|
@@ -339,16 +333,22 @@ build ${entryPointKeys.length} entry points`);
|
|
|
339
333
|
urlGraph: rawGraph,
|
|
340
334
|
runtimeCompat,
|
|
341
335
|
|
|
342
|
-
referenceAnalysis
|
|
336
|
+
referenceAnalysis: {
|
|
337
|
+
...referenceAnalysis,
|
|
338
|
+
// during first pass (craft) we inject "ignore:" when a reference must be ignored
|
|
339
|
+
// so that the second pass (shape) properly ignore those urls
|
|
340
|
+
ignoreProtocol: "inject",
|
|
341
|
+
},
|
|
343
342
|
nodeEsmResolution,
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
magicExtensions,
|
|
344
|
+
magicDirectoryIndex,
|
|
346
345
|
directoryReferenceAllowed,
|
|
347
346
|
transpilation: {
|
|
348
347
|
...transpilation,
|
|
349
348
|
babelHelpersAsImport: !explicitJsModuleFallback,
|
|
350
349
|
jsModuleFallbackOnJsClassic: false,
|
|
351
350
|
},
|
|
351
|
+
|
|
352
352
|
inlining: false,
|
|
353
353
|
scenarioPlaceholders,
|
|
354
354
|
}),
|
|
@@ -390,7 +390,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
390
390
|
plugins: [
|
|
391
391
|
jsenvPluginReferenceAnalysis({
|
|
392
392
|
...referenceAnalysis,
|
|
393
|
+
// here most plugins are not there
|
|
394
|
+
// - no external plugin
|
|
395
|
+
// - no plugin putting reference.mustIgnore on https urls
|
|
396
|
+
// At this stage it's only about redirecting urls to the build directory
|
|
397
|
+
// consequently only a subset or urls are supported
|
|
398
|
+
supportedProtocols: ["file:", "data:", "virtual:", "ignore:"],
|
|
393
399
|
fetchInlineUrls: false,
|
|
400
|
+
ignoreProtocol: versioning ? "keep" : "remove",
|
|
394
401
|
}),
|
|
395
402
|
...(lineBreakNormalization
|
|
396
403
|
? [jsenvPluginLineBreakNormalization()]
|
|
@@ -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) {
|
|
@@ -1078,7 +1082,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1078
1082
|
if (urlInfo.isInline) {
|
|
1079
1083
|
return;
|
|
1080
1084
|
}
|
|
1081
|
-
if (
|
|
1085
|
+
if (urlInfo.mustIgnore) {
|
|
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:, sourcemap, mustIgnore is true, ...)
|
|
1116
1120
|
return null;
|
|
1117
1121
|
}
|
|
1118
1122
|
if (preferWithoutVersioning(reference)) {
|
|
@@ -1183,8 +1187,15 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1183
1187
|
runtimeCompat,
|
|
1184
1188
|
...contextSharedDuringBuild,
|
|
1185
1189
|
plugins: [
|
|
1190
|
+
// here most plugins are not there
|
|
1191
|
+
// - no external plugin
|
|
1192
|
+
// - no plugin putting reference.mustIgnore on https urls
|
|
1193
|
+
// At this stage it's only about versioning urls
|
|
1194
|
+
// consequently only a subset or urls are supported
|
|
1186
1195
|
jsenvPluginReferenceAnalysis({
|
|
1187
1196
|
...referenceAnalysis,
|
|
1197
|
+
supportedProtocols: ["file:", "data:", "virtual:"],
|
|
1198
|
+
ignoreProtocol: "remove",
|
|
1188
1199
|
fetchInlineUrls: false,
|
|
1189
1200
|
inlineConvertedScript: true, // to be able to version their urls
|
|
1190
1201
|
allowEscapeForVersioning: true,
|
|
@@ -1227,10 +1238,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1227
1238
|
return url;
|
|
1228
1239
|
},
|
|
1229
1240
|
formatReference: (reference) => {
|
|
1230
|
-
if (
|
|
1231
|
-
if (reference.generatedUrl.startsWith("ignore:")) {
|
|
1232
|
-
return reference.generatedUrl.slice("ignore:".length);
|
|
1233
|
-
}
|
|
1241
|
+
if (reference.mustIgnore) {
|
|
1234
1242
|
return null;
|
|
1235
1243
|
}
|
|
1236
1244
|
if (reference.isInline || reference.url.startsWith("data:")) {
|
|
@@ -1247,7 +1255,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1247
1255
|
if (!canUseVersionedUrl(referencedUrlInfo)) {
|
|
1248
1256
|
return reference.specifier;
|
|
1249
1257
|
}
|
|
1250
|
-
if (
|
|
1258
|
+
if (referencedUrlInfo.mustIgnore) {
|
|
1251
1259
|
return null;
|
|
1252
1260
|
}
|
|
1253
1261
|
const versionedUrl = versionedUrlMap.get(reference.url);
|
|
@@ -1376,7 +1384,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1376
1384
|
}
|
|
1377
1385
|
cleanup_jsenv_attributes_from_html: {
|
|
1378
1386
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1379
|
-
if (
|
|
1387
|
+
if (urlInfo.mustIgnore) {
|
|
1380
1388
|
return;
|
|
1381
1389
|
}
|
|
1382
1390
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -1561,7 +1569,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1561
1569
|
if (serviceWorkerEntryUrlInfos.length > 0) {
|
|
1562
1570
|
const serviceWorkerResources = {};
|
|
1563
1571
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1564
|
-
if (urlInfo.isInline ||
|
|
1572
|
+
if (urlInfo.isInline || urlInfo.mustIgnore) {
|
|
1565
1573
|
return;
|
|
1566
1574
|
}
|
|
1567
1575
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -1634,7 +1642,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1634
1642
|
return buildRelativeUrl;
|
|
1635
1643
|
};
|
|
1636
1644
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1637
|
-
if (
|
|
1645
|
+
if (urlInfo.mustIgnore) {
|
|
1638
1646
|
return;
|
|
1639
1647
|
}
|
|
1640
1648
|
if (!urlInfo.url.startsWith("file:")) {
|
package/src/dev/file_service.js
CHANGED
|
@@ -28,8 +28,8 @@ export const createFileService = ({
|
|
|
28
28
|
plugins,
|
|
29
29
|
referenceAnalysis,
|
|
30
30
|
nodeEsmResolution,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
magicExtensions,
|
|
32
|
+
magicDirectoryIndex,
|
|
33
33
|
supervisor,
|
|
34
34
|
transpilation,
|
|
35
35
|
clientAutoreload,
|
|
@@ -116,8 +116,8 @@ export const createFileService = ({
|
|
|
116
116
|
|
|
117
117
|
referenceAnalysis,
|
|
118
118
|
nodeEsmResolution,
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
magicExtensions,
|
|
120
|
+
magicDirectoryIndex,
|
|
121
121
|
supervisor,
|
|
122
122
|
transpilation,
|
|
123
123
|
|
|
@@ -52,9 +52,9 @@ export const startDevServer = async ({
|
|
|
52
52
|
plugins = [],
|
|
53
53
|
referenceAnalysis = {},
|
|
54
54
|
nodeEsmResolution,
|
|
55
|
-
webResolution,
|
|
56
55
|
supervisor = true,
|
|
57
|
-
|
|
56
|
+
magicExtensions,
|
|
57
|
+
magicDirectoryIndex,
|
|
58
58
|
transpilation,
|
|
59
59
|
cacheControl = true,
|
|
60
60
|
ribbon = true,
|
|
@@ -192,8 +192,8 @@ export const startDevServer = async ({
|
|
|
192
192
|
plugins,
|
|
193
193
|
referenceAnalysis,
|
|
194
194
|
nodeEsmResolution,
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
magicExtensions,
|
|
196
|
+
magicDirectoryIndex,
|
|
197
197
|
supervisor,
|
|
198
198
|
transpilation,
|
|
199
199
|
clientAutoreload,
|
package/src/kitchen/kitchen.js
CHANGED
|
@@ -116,7 +116,7 @@ export const createKitchen = ({
|
|
|
116
116
|
specifierColumn,
|
|
117
117
|
baseUrl,
|
|
118
118
|
isOriginalPosition,
|
|
119
|
-
|
|
119
|
+
mustIgnore,
|
|
120
120
|
isEntryPoint = false,
|
|
121
121
|
isResourceHint = false,
|
|
122
122
|
isImplicit = false,
|
|
@@ -165,7 +165,7 @@ export const createKitchen = ({
|
|
|
165
165
|
specifierColumn,
|
|
166
166
|
isOriginalPosition,
|
|
167
167
|
baseUrl,
|
|
168
|
-
|
|
168
|
+
mustIgnore,
|
|
169
169
|
isEntryPoint,
|
|
170
170
|
isResourceHint,
|
|
171
171
|
isImplicit,
|
|
@@ -281,8 +281,13 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
281
281
|
reference,
|
|
282
282
|
referenceContext,
|
|
283
283
|
);
|
|
284
|
-
reference.
|
|
285
|
-
|
|
284
|
+
if (reference.mustIgnore) {
|
|
285
|
+
reference.generatedSpecifier = reference.specifier;
|
|
286
|
+
reference.generatedSpecifier = urlSpecifierEncoding.encode(reference);
|
|
287
|
+
} else {
|
|
288
|
+
reference.generatedSpecifier = returnValue || reference.generatedUrl;
|
|
289
|
+
reference.generatedSpecifier = urlSpecifierEncoding.encode(reference);
|
|
290
|
+
}
|
|
286
291
|
return [reference, urlInfo];
|
|
287
292
|
} catch (error) {
|
|
288
293
|
throw createResolveUrlError({
|
|
@@ -464,7 +469,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
464
469
|
});
|
|
465
470
|
};
|
|
466
471
|
|
|
467
|
-
if (urlInfo.
|
|
472
|
+
if (!urlInfo.mustIgnore) {
|
|
468
473
|
// references
|
|
469
474
|
const references = [];
|
|
470
475
|
context.referenceUtils = {
|
|
@@ -849,10 +854,10 @@ const traceFromUrlSite = (urlSite) => {
|
|
|
849
854
|
};
|
|
850
855
|
|
|
851
856
|
const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
|
|
852
|
-
if (reference.
|
|
853
|
-
urlInfo.
|
|
857
|
+
if (reference.mustIgnore) {
|
|
858
|
+
urlInfo.mustIgnore = true;
|
|
854
859
|
} else {
|
|
855
|
-
urlInfo.
|
|
860
|
+
urlInfo.mustIgnore = false;
|
|
856
861
|
}
|
|
857
862
|
urlInfo.originalUrl = urlInfo.originalUrl || reference.url;
|
|
858
863
|
|
|
@@ -36,7 +36,7 @@ const createUrlGraphReport = (urlGraph) => {
|
|
|
36
36
|
// ignore:
|
|
37
37
|
// - inline files: they are already taken into account in the file where they appear
|
|
38
38
|
// - ignored files: we don't know their content
|
|
39
|
-
if (urlInfo.isInline ||
|
|
39
|
+
if (urlInfo.isInline || urlInfo.mustIgnore) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
// file loaded via import assertion are already inside the graph
|
package/src/kitchen/url_graph.js
CHANGED
|
@@ -325,8 +325,8 @@ const returnValueAssertions = [
|
|
|
325
325
|
return { content: valueReturned };
|
|
326
326
|
}
|
|
327
327
|
if (typeof valueReturned === "object") {
|
|
328
|
-
const {
|
|
329
|
-
if (
|
|
328
|
+
const { mustIgnore, content, body } = valueReturned;
|
|
329
|
+
if (mustIgnore) {
|
|
330
330
|
return undefined;
|
|
331
331
|
}
|
|
332
332
|
if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) {
|
package/src/plugins/plugins.js
CHANGED
|
@@ -3,8 +3,8 @@ import { jsenvPluginImportmap } from "./importmap/jsenv_plugin_importmap.js";
|
|
|
3
3
|
import { jsenvPluginNodeEsmResolution } from "./resolution_node_esm/jsenv_plugin_node_esm_resolution.js";
|
|
4
4
|
import { jsenvPluginWebResolution } from "./resolution_web/jsenv_plugin_web_resolution.js";
|
|
5
5
|
import { jsenvPluginVersionSearchParam } from "./version_search_param/jsenv_plugin_version_search_param.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { jsenvPluginProtocolFile } from "./protocol_file/jsenv_plugin_protocol_file.js";
|
|
7
|
+
import { jsenvPluginProtocolHttp } from "./protocol_http/jsenv_plugin_protocol_http.js";
|
|
8
8
|
import { jsenvPluginInlining } from "./inlining/jsenv_plugin_inlining.js";
|
|
9
9
|
import { jsenvPluginSupervisor } from "./supervisor/jsenv_plugin_supervisor.js";
|
|
10
10
|
import { jsenvPluginCommonJsGlobals } from "./commonjs_globals/jsenv_plugin_commonjs_globals.js";
|
|
@@ -25,8 +25,8 @@ export const getCorePlugins = ({
|
|
|
25
25
|
|
|
26
26
|
referenceAnalysis = {},
|
|
27
27
|
nodeEsmResolution = {},
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
magicExtensions,
|
|
29
|
+
magicDirectoryIndex,
|
|
30
30
|
directoryReferenceAllowed,
|
|
31
31
|
supervisor,
|
|
32
32
|
transpilation = true,
|
|
@@ -45,9 +45,6 @@ export const getCorePlugins = ({
|
|
|
45
45
|
if (supervisor === true) {
|
|
46
46
|
supervisor = {};
|
|
47
47
|
}
|
|
48
|
-
if (fileSystemMagicRedirection === true) {
|
|
49
|
-
fileSystemMagicRedirection = {};
|
|
50
|
-
}
|
|
51
48
|
if (clientAutoreload === true) {
|
|
52
49
|
clientAutoreload = {};
|
|
53
50
|
}
|
|
@@ -68,15 +65,16 @@ export const getCorePlugins = ({
|
|
|
68
65
|
- reference inside a js module -> resolved by node esm
|
|
69
66
|
- All the rest uses web standard url resolution
|
|
70
67
|
*/
|
|
71
|
-
|
|
68
|
+
jsenvPluginProtocolFile({
|
|
72
69
|
directoryReferenceAllowed,
|
|
73
|
-
|
|
70
|
+
magicExtensions,
|
|
71
|
+
magicDirectoryIndex,
|
|
74
72
|
}),
|
|
75
|
-
|
|
73
|
+
jsenvPluginProtocolHttp(),
|
|
76
74
|
...(nodeEsmResolution
|
|
77
75
|
? [jsenvPluginNodeEsmResolution(nodeEsmResolution)]
|
|
78
76
|
: []),
|
|
79
|
-
jsenvPluginWebResolution(
|
|
77
|
+
jsenvPluginWebResolution(),
|
|
80
78
|
|
|
81
79
|
jsenvPluginVersionSearchParam(),
|
|
82
80
|
jsenvPluginCommonJsGlobals(),
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "@jsenv/node-esm-resolution";
|
|
13
13
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const jsenvPluginProtocolFile = ({
|
|
16
16
|
magicExtensions = ["inherit", ".js"],
|
|
17
17
|
magicDirectoryIndex = true,
|
|
18
18
|
preserveSymlinks = false,
|
|
@@ -20,7 +20,7 @@ export const jsenvPluginFileUrls = ({
|
|
|
20
20
|
}) => {
|
|
21
21
|
return [
|
|
22
22
|
{
|
|
23
|
-
name: "jsenv:
|
|
23
|
+
name: "jsenv:fs_redirection",
|
|
24
24
|
appliesDuring: "*",
|
|
25
25
|
redirectReference: (reference) => {
|
|
26
26
|
// http, https, data, about, ...
|
|
@@ -57,7 +57,7 @@ export const jsenvPluginFileUrls = ({
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
let url = urlObject.href;
|
|
60
|
-
const
|
|
60
|
+
const mustIgnore =
|
|
61
61
|
stat &&
|
|
62
62
|
stat.isDirectory() &&
|
|
63
63
|
// ignore new URL second arg
|
|
@@ -67,8 +67,8 @@ export const jsenvPluginFileUrls = ({
|
|
|
67
67
|
(reference.subtype === "new_url_first_arg" &&
|
|
68
68
|
reference.specifier === "./"));
|
|
69
69
|
|
|
70
|
-
if (
|
|
71
|
-
reference.
|
|
70
|
+
if (mustIgnore) {
|
|
71
|
+
reference.mustIgnore = true;
|
|
72
72
|
} else {
|
|
73
73
|
const shouldApplyDilesystemMagicResolution =
|
|
74
74
|
reference.type === "js_import";
|
|
@@ -109,7 +109,7 @@ export const jsenvPluginFileUrls = ({
|
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
|
-
name: "jsenv:
|
|
112
|
+
name: "jsenv:fs_resolution",
|
|
113
113
|
appliesDuring: "*",
|
|
114
114
|
resolveReference: {
|
|
115
115
|
filesystem: (reference, context) => {
|
|
@@ -124,10 +124,10 @@ export const jsenvPluginFileUrls = ({
|
|
|
124
124
|
},
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
|
-
name: "jsenv:@
|
|
128
|
-
// during
|
|
127
|
+
name: "jsenv:@fs",
|
|
128
|
+
// during build it's fine to use "file://"" urls
|
|
129
|
+
// but during dev it's a browser running the code
|
|
129
130
|
// so absolute file urls needs to be relativized
|
|
130
|
-
// during build it's fine to use file:// urls
|
|
131
131
|
appliesDuring: "dev",
|
|
132
132
|
resolveReference: (reference) => {
|
|
133
133
|
if (reference.specifier.startsWith("/@fs/")) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const jsenvPluginProtocolHttp = () => {
|
|
2
2
|
return {
|
|
3
|
-
name: "jsenv:
|
|
3
|
+
name: "jsenv:protocol_http",
|
|
4
4
|
appliesDuring: "*",
|
|
5
5
|
redirectReference: (reference) => {
|
|
6
6
|
if (
|
|
7
7
|
reference.url.startsWith("http:") ||
|
|
8
8
|
reference.url.startsWith("https:")
|
|
9
9
|
) {
|
|
10
|
-
reference.
|
|
10
|
+
reference.mustIgnore = true;
|
|
11
11
|
}
|
|
12
12
|
// TODO: according to some pattern matching jsenv could be allowed
|
|
13
13
|
// to fetch and transform http urls
|
|
@@ -12,6 +12,7 @@ export const jsenvPluginReferenceAnalysis = ({
|
|
|
12
12
|
include,
|
|
13
13
|
supportedProtocols = ["file:", "data:", "virtual:", "http:", "https:"],
|
|
14
14
|
|
|
15
|
+
ignoreProtocol = "remove",
|
|
15
16
|
inlineContent = true,
|
|
16
17
|
inlineConvertedScript = false,
|
|
17
18
|
fetchInlineUrls = true,
|
|
@@ -21,6 +22,7 @@ export const jsenvPluginReferenceAnalysis = ({
|
|
|
21
22
|
jsenvPluginReferenceAnalysisInclude({
|
|
22
23
|
include,
|
|
23
24
|
supportedProtocols,
|
|
25
|
+
ignoreProtocol,
|
|
24
26
|
}),
|
|
25
27
|
jsenvPluginDirectoryReferenceAnalysis(),
|
|
26
28
|
jsenvPluginHtmlReferenceAnalysis({
|
|
@@ -44,6 +46,7 @@ export const jsenvPluginReferenceAnalysis = ({
|
|
|
44
46
|
const jsenvPluginReferenceAnalysisInclude = ({
|
|
45
47
|
include,
|
|
46
48
|
supportedProtocols,
|
|
49
|
+
ignoreProtocol,
|
|
47
50
|
}) => {
|
|
48
51
|
// eslint-disable-next-line no-unused-vars
|
|
49
52
|
let getIncludeInfo = (url) => undefined;
|
|
@@ -67,7 +70,7 @@ const jsenvPluginReferenceAnalysisInclude = ({
|
|
|
67
70
|
}
|
|
68
71
|
},
|
|
69
72
|
redirectReference: (reference) => {
|
|
70
|
-
if (reference.
|
|
73
|
+
if (reference.mustIgnore !== undefined) {
|
|
71
74
|
return;
|
|
72
75
|
}
|
|
73
76
|
if (
|
|
@@ -78,24 +81,40 @@ const jsenvPluginReferenceAnalysisInclude = ({
|
|
|
78
81
|
// to resolve them (https://nodejs.org/api/packages.html#imports for instance)
|
|
79
82
|
reference.type !== "js_import"
|
|
80
83
|
) {
|
|
81
|
-
reference.
|
|
84
|
+
reference.mustIgnore = true;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (reference.url.startsWith("ignore:")) {
|
|
88
|
+
reference.mustIgnore = true;
|
|
89
|
+
if (ignoreProtocol === "remove") {
|
|
90
|
+
reference.specifier = reference.specifier.slice("ignore:".length);
|
|
91
|
+
}
|
|
82
92
|
return;
|
|
83
93
|
}
|
|
84
94
|
const includeInfo = getIncludeInfo(reference.url);
|
|
85
95
|
if (includeInfo === true) {
|
|
86
|
-
reference.
|
|
96
|
+
reference.mustIgnore = false;
|
|
87
97
|
return;
|
|
88
98
|
}
|
|
89
99
|
if (includeInfo === false) {
|
|
90
|
-
reference.
|
|
100
|
+
reference.mustIgnore = true;
|
|
91
101
|
return;
|
|
92
102
|
}
|
|
93
103
|
const { protocol } = new URL(reference.url);
|
|
94
104
|
const protocolIsSupported = supportedProtocols.some(
|
|
95
105
|
(supportedProtocol) => protocol === supportedProtocol,
|
|
96
106
|
);
|
|
97
|
-
if (protocolIsSupported) {
|
|
98
|
-
reference.
|
|
107
|
+
if (!protocolIsSupported) {
|
|
108
|
+
reference.mustIgnore = true;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
formatReference: (reference) => {
|
|
112
|
+
if (
|
|
113
|
+
ignoreProtocol === "inject" &&
|
|
114
|
+
reference.mustIgnore &&
|
|
115
|
+
!reference.url.startsWith("ignore:")
|
|
116
|
+
) {
|
|
117
|
+
reference.specifier = `ignore:${reference.specifier}`;
|
|
99
118
|
}
|
|
100
119
|
},
|
|
101
120
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { urlTypeFromReference } from "
|
|
1
|
+
import { urlTypeFromReference } from "./url_type_from_reference.js";
|
|
2
2
|
import { createNodeEsmResolver } from "./node_esm_resolver.js";
|
|
3
3
|
|
|
4
4
|
export const jsenvPluginNodeEsmResolution = (resolutionConfig = {}) => {
|
|
@@ -41,10 +41,10 @@ export const jsenvPluginNodeEsmResolution = (resolutionConfig = {}) => {
|
|
|
41
41
|
runtimeCompat,
|
|
42
42
|
preservesSymlink: true,
|
|
43
43
|
});
|
|
44
|
-
if (
|
|
44
|
+
if (resolvers.js_module === undefined) {
|
|
45
45
|
resolvers.js_module = nodeEsmResolverDefault;
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
47
|
+
if (resolvers.js_classic === undefined) {
|
|
48
48
|
resolvers.js_classic = (reference, context) => {
|
|
49
49
|
if (reference.subtype === "self_import_scripts_arg") {
|
|
50
50
|
return nodeEsmResolverDefault(reference, context);
|
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const jsenvPluginWebResolution = (resolutionConfig = {}) => {
|
|
4
|
-
const resolvers = {};
|
|
5
|
-
const resolveUsingWebResolution = (reference, context) => {
|
|
6
|
-
if (reference.specifier === "/") {
|
|
7
|
-
const { mainFilePath, rootDirectoryUrl } = context;
|
|
8
|
-
return String(new URL(mainFilePath, rootDirectoryUrl));
|
|
9
|
-
}
|
|
10
|
-
if (reference.specifier[0] === "/") {
|
|
11
|
-
return new URL(reference.specifier.slice(1), context.rootDirectoryUrl)
|
|
12
|
-
.href;
|
|
13
|
-
}
|
|
14
|
-
return new URL(
|
|
15
|
-
reference.specifier,
|
|
16
|
-
// baseUrl happens second argument to new URL() is different from
|
|
17
|
-
// import.meta.url or document.currentScript.src
|
|
18
|
-
reference.baseUrl || reference.parentUrl,
|
|
19
|
-
).href;
|
|
20
|
-
};
|
|
21
|
-
Object.keys(resolutionConfig).forEach((urlType) => {
|
|
22
|
-
const config = resolutionConfig[urlType];
|
|
23
|
-
if (config === true) {
|
|
24
|
-
resolvers[urlType] = resolveUsingWebResolution;
|
|
25
|
-
} else if (config === false) {
|
|
26
|
-
resolvers[urlType] = () => null;
|
|
27
|
-
} else {
|
|
28
|
-
throw new TypeError(
|
|
29
|
-
`config must be true or false, got ${config} on "${urlType}"`,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
1
|
+
export const jsenvPluginWebResolution = () => {
|
|
34
2
|
return {
|
|
35
3
|
name: "jsenv:web_resolution",
|
|
36
4
|
appliesDuring: "*",
|
|
37
5
|
resolveReference: (reference, context) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
6
|
+
if (reference.specifier === "/") {
|
|
7
|
+
const { mainFilePath, rootDirectoryUrl } = context;
|
|
8
|
+
return String(new URL(mainFilePath, rootDirectoryUrl));
|
|
9
|
+
}
|
|
10
|
+
if (reference.specifier[0] === "/") {
|
|
11
|
+
return new URL(reference.specifier.slice(1), context.rootDirectoryUrl)
|
|
12
|
+
.href;
|
|
13
|
+
}
|
|
14
|
+
return new URL(
|
|
15
|
+
reference.specifier,
|
|
16
|
+
// baseUrl happens second argument to new URL() is different from
|
|
17
|
+
// import.meta.url or document.currentScript.src
|
|
18
|
+
reference.baseUrl || reference.parentUrl,
|
|
19
|
+
).href;
|
|
43
20
|
},
|
|
44
21
|
};
|
|
45
22
|
};
|
|
@@ -47,5 +47,14 @@ export const injectRibbon = ({ text }) => {
|
|
|
47
47
|
|
|
48
48
|
const node = document.createElement("div");
|
|
49
49
|
node.innerHTML = html;
|
|
50
|
+
|
|
51
|
+
const toolbarStateInLocalStorage = localStorage.hasOwnProperty(
|
|
52
|
+
"jsenv_toolbar",
|
|
53
|
+
)
|
|
54
|
+
? JSON.parse(localStorage.getItem("jsenv_toolbar"))
|
|
55
|
+
: {};
|
|
56
|
+
if (toolbarStateInLocalStorage.ribbonDisplayed === false) {
|
|
57
|
+
node.querySelector("#jsenv_ribbon_container").style.display = "none";
|
|
58
|
+
}
|
|
50
59
|
document.body.appendChild(node.firstChild);
|
|
51
60
|
};
|
/package/src/plugins/{url_type_from_reference.js → resolution_node_esm/url_type_from_reference.js}
RENAMED
|
File without changes
|