@jsenv/core 36.0.0 → 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 +122 -113
- package/package.json +1 -1
- package/src/build/build.js +36 -26
- 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/transpilation/babel/jsenv_plugin_babel.js +1 -1
- package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js +3 -5
- /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
|
};
|
|
@@ -15425,11 +15445,10 @@ const jsenvPluginJsModuleFallbackInsideHtml = ({
|
|
|
15425
15445
|
});
|
|
15426
15446
|
}
|
|
15427
15447
|
}
|
|
15428
|
-
if (mutations.length === 0) {
|
|
15429
|
-
return null;
|
|
15430
|
-
}
|
|
15431
15448
|
await Promise.all(mutations.map(mutation => mutation()));
|
|
15432
|
-
return stringifyHtmlAst(htmlAst
|
|
15449
|
+
return stringifyHtmlAst(htmlAst, {
|
|
15450
|
+
cleanupPositionAttributes: context.dev
|
|
15451
|
+
});
|
|
15433
15452
|
}
|
|
15434
15453
|
}
|
|
15435
15454
|
};
|
|
@@ -17436,10 +17455,10 @@ const jsenvPluginNodeEsmResolution = (resolutionConfig = {}) => {
|
|
|
17436
17455
|
runtimeCompat,
|
|
17437
17456
|
preservesSymlink: true
|
|
17438
17457
|
});
|
|
17439
|
-
if (
|
|
17458
|
+
if (resolvers.js_module === undefined) {
|
|
17440
17459
|
resolvers.js_module = nodeEsmResolverDefault;
|
|
17441
17460
|
}
|
|
17442
|
-
if (
|
|
17461
|
+
if (resolvers.js_classic === undefined) {
|
|
17443
17462
|
resolvers.js_classic = (reference, context) => {
|
|
17444
17463
|
if (reference.subtype === "self_import_scripts_arg") {
|
|
17445
17464
|
return nodeEsmResolverDefault(reference, context);
|
|
@@ -17468,41 +17487,25 @@ const jsenvPluginNodeEsmResolution = (resolutionConfig = {}) => {
|
|
|
17468
17487
|
};
|
|
17469
17488
|
};
|
|
17470
17489
|
|
|
17471
|
-
const jsenvPluginWebResolution = (
|
|
17472
|
-
const resolvers = {};
|
|
17473
|
-
const resolveUsingWebResolution = (reference, context) => {
|
|
17474
|
-
if (reference.specifier === "/") {
|
|
17475
|
-
const {
|
|
17476
|
-
mainFilePath,
|
|
17477
|
-
rootDirectoryUrl
|
|
17478
|
-
} = context;
|
|
17479
|
-
return String(new URL(mainFilePath, rootDirectoryUrl));
|
|
17480
|
-
}
|
|
17481
|
-
if (reference.specifier[0] === "/") {
|
|
17482
|
-
return new URL(reference.specifier.slice(1), context.rootDirectoryUrl).href;
|
|
17483
|
-
}
|
|
17484
|
-
return new URL(reference.specifier,
|
|
17485
|
-
// baseUrl happens second argument to new URL() is different from
|
|
17486
|
-
// import.meta.url or document.currentScript.src
|
|
17487
|
-
reference.baseUrl || reference.parentUrl).href;
|
|
17488
|
-
};
|
|
17489
|
-
Object.keys(resolutionConfig).forEach(urlType => {
|
|
17490
|
-
const config = resolutionConfig[urlType];
|
|
17491
|
-
if (config === true) {
|
|
17492
|
-
resolvers[urlType] = resolveUsingWebResolution;
|
|
17493
|
-
} else if (config === false) {
|
|
17494
|
-
resolvers[urlType] = () => null;
|
|
17495
|
-
} else {
|
|
17496
|
-
throw new TypeError(`config must be true or false, got ${config} on "${urlType}"`);
|
|
17497
|
-
}
|
|
17498
|
-
});
|
|
17490
|
+
const jsenvPluginWebResolution = () => {
|
|
17499
17491
|
return {
|
|
17500
17492
|
name: "jsenv:web_resolution",
|
|
17501
17493
|
appliesDuring: "*",
|
|
17502
17494
|
resolveReference: (reference, context) => {
|
|
17503
|
-
|
|
17504
|
-
|
|
17505
|
-
|
|
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;
|
|
17506
17509
|
}
|
|
17507
17510
|
};
|
|
17508
17511
|
};
|
|
@@ -17541,14 +17544,14 @@ const jsenvPluginVersionSearchParam = () => {
|
|
|
17541
17544
|
};
|
|
17542
17545
|
};
|
|
17543
17546
|
|
|
17544
|
-
const
|
|
17547
|
+
const jsenvPluginProtocolFile = ({
|
|
17545
17548
|
magicExtensions = ["inherit", ".js"],
|
|
17546
17549
|
magicDirectoryIndex = true,
|
|
17547
17550
|
preserveSymlinks = false,
|
|
17548
17551
|
directoryReferenceAllowed = false
|
|
17549
17552
|
}) => {
|
|
17550
17553
|
return [{
|
|
17551
|
-
name: "jsenv:
|
|
17554
|
+
name: "jsenv:fs_redirection",
|
|
17552
17555
|
appliesDuring: "*",
|
|
17553
17556
|
redirectReference: reference => {
|
|
17554
17557
|
// http, https, data, about, ...
|
|
@@ -17589,13 +17592,13 @@ const jsenvPluginFileUrls = ({
|
|
|
17589
17592
|
urlObject.pathname = pathname.slice(0, -1);
|
|
17590
17593
|
}
|
|
17591
17594
|
let url = urlObject.href;
|
|
17592
|
-
const
|
|
17595
|
+
const mustIgnore = stat && stat.isDirectory() && (
|
|
17593
17596
|
// ignore new URL second arg
|
|
17594
17597
|
reference.subtype === "new_url_second_arg" ||
|
|
17595
17598
|
// ignore root file url
|
|
17596
17599
|
reference.url === "file:///" || reference.subtype === "new_url_first_arg" && reference.specifier === "./");
|
|
17597
|
-
if (
|
|
17598
|
-
reference.
|
|
17600
|
+
if (mustIgnore) {
|
|
17601
|
+
reference.mustIgnore = true;
|
|
17599
17602
|
} else {
|
|
17600
17603
|
const shouldApplyDilesystemMagicResolution = reference.type === "js_import";
|
|
17601
17604
|
if (shouldApplyDilesystemMagicResolution) {
|
|
@@ -17627,7 +17630,7 @@ const jsenvPluginFileUrls = ({
|
|
|
17627
17630
|
return null;
|
|
17628
17631
|
}
|
|
17629
17632
|
}, {
|
|
17630
|
-
name: "jsenv:
|
|
17633
|
+
name: "jsenv:fs_resolution",
|
|
17631
17634
|
appliesDuring: "*",
|
|
17632
17635
|
resolveReference: {
|
|
17633
17636
|
filesystem: (reference, context) => {
|
|
@@ -17640,10 +17643,10 @@ const jsenvPluginFileUrls = ({
|
|
|
17640
17643
|
}
|
|
17641
17644
|
}
|
|
17642
17645
|
}, {
|
|
17643
|
-
name: "jsenv:@
|
|
17644
|
-
// 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
|
|
17645
17649
|
// so absolute file urls needs to be relativized
|
|
17646
|
-
// during build it's fine to use file:// urls
|
|
17647
17650
|
appliesDuring: "dev",
|
|
17648
17651
|
resolveReference: reference => {
|
|
17649
17652
|
if (reference.specifier.startsWith("/@fs/")) {
|
|
@@ -17698,13 +17701,13 @@ const resolveSymlink = fileUrl => {
|
|
|
17698
17701
|
return pathToFileURL(realpathSync(new URL(fileUrl))).href;
|
|
17699
17702
|
};
|
|
17700
17703
|
|
|
17701
|
-
const
|
|
17704
|
+
const jsenvPluginProtocolHttp = () => {
|
|
17702
17705
|
return {
|
|
17703
|
-
name: "jsenv:
|
|
17706
|
+
name: "jsenv:protocol_http",
|
|
17704
17707
|
appliesDuring: "*",
|
|
17705
17708
|
redirectReference: reference => {
|
|
17706
17709
|
if (reference.url.startsWith("http:") || reference.url.startsWith("https:")) {
|
|
17707
|
-
reference.
|
|
17710
|
+
reference.mustIgnore = true;
|
|
17708
17711
|
}
|
|
17709
17712
|
// TODO: according to some pattern matching jsenv could be allowed
|
|
17710
17713
|
// to fetch and transform http urls
|
|
@@ -19986,7 +19989,7 @@ const jsenvPluginBabel = ({
|
|
|
19986
19989
|
return {
|
|
19987
19990
|
name: "jsenv:babel",
|
|
19988
19991
|
appliesDuring: "*",
|
|
19989
|
-
|
|
19992
|
+
transformUrlContent: {
|
|
19990
19993
|
js_classic: transformWithBabel,
|
|
19991
19994
|
js_module: transformWithBabel
|
|
19992
19995
|
}
|
|
@@ -20894,8 +20897,8 @@ const getCorePlugins = ({
|
|
|
20894
20897
|
runtimeCompat,
|
|
20895
20898
|
referenceAnalysis = {},
|
|
20896
20899
|
nodeEsmResolution = {},
|
|
20897
|
-
|
|
20898
|
-
|
|
20900
|
+
magicExtensions,
|
|
20901
|
+
magicDirectoryIndex,
|
|
20899
20902
|
directoryReferenceAllowed,
|
|
20900
20903
|
supervisor,
|
|
20901
20904
|
transpilation = true,
|
|
@@ -20913,9 +20916,6 @@ const getCorePlugins = ({
|
|
|
20913
20916
|
if (supervisor === true) {
|
|
20914
20917
|
supervisor = {};
|
|
20915
20918
|
}
|
|
20916
|
-
if (fileSystemMagicRedirection === true) {
|
|
20917
|
-
fileSystemMagicRedirection = {};
|
|
20918
|
-
}
|
|
20919
20919
|
if (clientAutoreload === true) {
|
|
20920
20920
|
clientAutoreload = {};
|
|
20921
20921
|
}
|
|
@@ -20931,10 +20931,11 @@ const getCorePlugins = ({
|
|
|
20931
20931
|
- reference inside a js module -> resolved by node esm
|
|
20932
20932
|
- All the rest uses web standard url resolution
|
|
20933
20933
|
*/
|
|
20934
|
-
|
|
20934
|
+
jsenvPluginProtocolFile({
|
|
20935
20935
|
directoryReferenceAllowed,
|
|
20936
|
-
|
|
20937
|
-
|
|
20936
|
+
magicExtensions,
|
|
20937
|
+
magicDirectoryIndex
|
|
20938
|
+
}), jsenvPluginProtocolHttp(), ...(nodeEsmResolution ? [jsenvPluginNodeEsmResolution(nodeEsmResolution)] : []), jsenvPluginWebResolution(), jsenvPluginVersionSearchParam(), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), ...(scenarioPlaceholders ? [jsenvPluginGlobalScenarios()] : []), jsenvPluginNodeRuntime({
|
|
20938
20939
|
runtimeCompat
|
|
20939
20940
|
}), jsenvPluginImportMetaHot(), ...(clientAutoreload ? [jsenvPluginAutoreload({
|
|
20940
20941
|
...clientAutoreload,
|
|
@@ -21336,8 +21337,8 @@ const build = async ({
|
|
|
21336
21337
|
plugins = [],
|
|
21337
21338
|
referenceAnalysis = {},
|
|
21338
21339
|
nodeEsmResolution,
|
|
21339
|
-
|
|
21340
|
-
|
|
21340
|
+
magicExtensions,
|
|
21341
|
+
magicDirectoryIndex,
|
|
21341
21342
|
directoryReferenceAllowed,
|
|
21342
21343
|
scenarioPlaceholders,
|
|
21343
21344
|
transpilation = {},
|
|
@@ -21474,12 +21475,6 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21474
21475
|
...contextSharedDuringBuild,
|
|
21475
21476
|
plugins: [...plugins, {
|
|
21476
21477
|
appliesDuring: "build",
|
|
21477
|
-
formatReference: reference => {
|
|
21478
|
-
if (!reference.shouldHandle) {
|
|
21479
|
-
return `ignore:${reference.specifier}`;
|
|
21480
|
-
}
|
|
21481
|
-
return null;
|
|
21482
|
-
},
|
|
21483
21478
|
fetchUrlContent: (urlInfo, context) => {
|
|
21484
21479
|
if (context.reference.original) {
|
|
21485
21480
|
rawRedirections.set(context.reference.original.url, context.reference.url);
|
|
@@ -21489,10 +21484,15 @@ build ${entryPointKeys.length} entry points`);
|
|
|
21489
21484
|
rootDirectoryUrl: sourceDirectoryUrl,
|
|
21490
21485
|
urlGraph: rawGraph,
|
|
21491
21486
|
runtimeCompat,
|
|
21492
|
-
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
|
+
},
|
|
21493
21493
|
nodeEsmResolution,
|
|
21494
|
-
|
|
21495
|
-
|
|
21494
|
+
magicExtensions,
|
|
21495
|
+
magicDirectoryIndex,
|
|
21496
21496
|
directoryReferenceAllowed,
|
|
21497
21497
|
transpilation: {
|
|
21498
21498
|
...transpilation,
|
|
@@ -21534,7 +21534,14 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21534
21534
|
...contextSharedDuringBuild,
|
|
21535
21535
|
plugins: [jsenvPluginReferenceAnalysis({
|
|
21536
21536
|
...referenceAnalysis,
|
|
21537
|
-
|
|
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"
|
|
21538
21545
|
}), ...(lineBreakNormalization ? [jsenvPluginLineBreakNormalization()] : []), jsenvPluginJsModuleFallback({
|
|
21539
21546
|
systemJsInjection: true
|
|
21540
21547
|
}), jsenvPluginInlining(), {
|
|
@@ -21686,9 +21693,6 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21686
21693
|
},
|
|
21687
21694
|
formatReference: reference => {
|
|
21688
21695
|
if (!reference.generatedUrl.startsWith("file:")) {
|
|
21689
|
-
if (!versioning && reference.generatedUrl.startsWith("ignore:")) {
|
|
21690
|
-
return reference.generatedUrl.slice("ignore:".length);
|
|
21691
|
-
}
|
|
21692
21696
|
return null;
|
|
21693
21697
|
}
|
|
21694
21698
|
if (reference.isResourceHint) {
|
|
@@ -21776,7 +21780,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21776
21780
|
}, {
|
|
21777
21781
|
name: "jsenv:optimize",
|
|
21778
21782
|
appliesDuring: "build",
|
|
21779
|
-
|
|
21783
|
+
transformUrlContent: async (urlInfo, context) => {
|
|
21780
21784
|
await rawGraphKitchen.pluginController.callAsyncHooks("optimizeUrlContent", urlInfo, context, async optimizeReturnValue => {
|
|
21781
21785
|
await finalGraphKitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, optimizeReturnValue);
|
|
21782
21786
|
});
|
|
@@ -22124,7 +22128,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22124
22128
|
if (urlInfo.isInline) {
|
|
22125
22129
|
return;
|
|
22126
22130
|
}
|
|
22127
|
-
if (
|
|
22131
|
+
if (urlInfo.mustIgnore) {
|
|
22128
22132
|
return;
|
|
22129
22133
|
}
|
|
22130
22134
|
if (urlInfo.dependents.size === 0 && !urlInfo.isEntryPoint) {
|
|
@@ -22150,7 +22154,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22150
22154
|
const dependencyContentVersion = contentVersionMap.get(reference.url);
|
|
22151
22155
|
if (!dependencyContentVersion) {
|
|
22152
22156
|
// no content generated for this dependency
|
|
22153
|
-
// (inline, data:, sourcemap,
|
|
22157
|
+
// (inline, data:, sourcemap, mustIgnore is true, ...)
|
|
22154
22158
|
return null;
|
|
22155
22159
|
}
|
|
22156
22160
|
if (preferWithoutVersioning(reference)) {
|
|
@@ -22213,8 +22217,16 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22213
22217
|
build: true,
|
|
22214
22218
|
runtimeCompat,
|
|
22215
22219
|
...contextSharedDuringBuild,
|
|
22216
|
-
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({
|
|
22217
22227
|
...referenceAnalysis,
|
|
22228
|
+
supportedProtocols: ["file:", "data:", "virtual:"],
|
|
22229
|
+
ignoreProtocol: "remove",
|
|
22218
22230
|
fetchInlineUrls: false,
|
|
22219
22231
|
inlineConvertedScript: true,
|
|
22220
22232
|
// to be able to version their urls
|
|
@@ -22248,10 +22260,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22248
22260
|
return url;
|
|
22249
22261
|
},
|
|
22250
22262
|
formatReference: reference => {
|
|
22251
|
-
if (
|
|
22252
|
-
if (reference.generatedUrl.startsWith("ignore:")) {
|
|
22253
|
-
return reference.generatedUrl.slice("ignore:".length);
|
|
22254
|
-
}
|
|
22263
|
+
if (reference.mustIgnore) {
|
|
22255
22264
|
return null;
|
|
22256
22265
|
}
|
|
22257
22266
|
if (reference.isInline || reference.url.startsWith("data:")) {
|
|
@@ -22266,7 +22275,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22266
22275
|
if (!canUseVersionedUrl(referencedUrlInfo)) {
|
|
22267
22276
|
return reference.specifier;
|
|
22268
22277
|
}
|
|
22269
|
-
if (
|
|
22278
|
+
if (referencedUrlInfo.mustIgnore) {
|
|
22270
22279
|
return null;
|
|
22271
22280
|
}
|
|
22272
22281
|
const versionedUrl = versionedUrlMap.get(reference.url);
|
|
@@ -22376,7 +22385,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22376
22385
|
}
|
|
22377
22386
|
{
|
|
22378
22387
|
GRAPH.forEach(finalGraph, urlInfo => {
|
|
22379
|
-
if (
|
|
22388
|
+
if (urlInfo.mustIgnore) {
|
|
22380
22389
|
return;
|
|
22381
22390
|
}
|
|
22382
22391
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -22525,7 +22534,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22525
22534
|
if (serviceWorkerEntryUrlInfos.length > 0) {
|
|
22526
22535
|
const serviceWorkerResources = {};
|
|
22527
22536
|
GRAPH.forEach(finalGraph, urlInfo => {
|
|
22528
|
-
if (urlInfo.isInline ||
|
|
22537
|
+
if (urlInfo.isInline || urlInfo.mustIgnore) {
|
|
22529
22538
|
return;
|
|
22530
22539
|
}
|
|
22531
22540
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -22584,7 +22593,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
22584
22593
|
return buildRelativeUrl;
|
|
22585
22594
|
};
|
|
22586
22595
|
GRAPH.forEach(finalGraph, urlInfo => {
|
|
22587
|
-
if (
|
|
22596
|
+
if (urlInfo.mustIgnore) {
|
|
22588
22597
|
return;
|
|
22589
22598
|
}
|
|
22590
22599
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -22856,8 +22865,8 @@ const createFileService = ({
|
|
|
22856
22865
|
plugins,
|
|
22857
22866
|
referenceAnalysis,
|
|
22858
22867
|
nodeEsmResolution,
|
|
22859
|
-
|
|
22860
|
-
|
|
22868
|
+
magicExtensions,
|
|
22869
|
+
magicDirectoryIndex,
|
|
22861
22870
|
supervisor,
|
|
22862
22871
|
transpilation,
|
|
22863
22872
|
clientAutoreload,
|
|
@@ -22933,8 +22942,8 @@ const createFileService = ({
|
|
|
22933
22942
|
runtimeCompat,
|
|
22934
22943
|
referenceAnalysis,
|
|
22935
22944
|
nodeEsmResolution,
|
|
22936
|
-
|
|
22937
|
-
|
|
22945
|
+
magicExtensions,
|
|
22946
|
+
magicDirectoryIndex,
|
|
22938
22947
|
supervisor,
|
|
22939
22948
|
transpilation,
|
|
22940
22949
|
clientAutoreload,
|
|
@@ -23272,9 +23281,9 @@ const startDevServer = async ({
|
|
|
23272
23281
|
plugins = [],
|
|
23273
23282
|
referenceAnalysis = {},
|
|
23274
23283
|
nodeEsmResolution,
|
|
23275
|
-
webResolution,
|
|
23276
23284
|
supervisor = true,
|
|
23277
|
-
|
|
23285
|
+
magicExtensions,
|
|
23286
|
+
magicDirectoryIndex,
|
|
23278
23287
|
transpilation,
|
|
23279
23288
|
cacheControl = true,
|
|
23280
23289
|
ribbon = true,
|
|
@@ -23391,8 +23400,8 @@ const startDevServer = async ({
|
|
|
23391
23400
|
plugins,
|
|
23392
23401
|
referenceAnalysis,
|
|
23393
23402
|
nodeEsmResolution,
|
|
23394
|
-
|
|
23395
|
-
|
|
23403
|
+
magicExtensions,
|
|
23404
|
+
magicDirectoryIndex,
|
|
23396
23405
|
supervisor,
|
|
23397
23406
|
transpilation,
|
|
23398
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) {
|
|
@@ -672,7 +676,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
672
676
|
{
|
|
673
677
|
name: "jsenv:optimize",
|
|
674
678
|
appliesDuring: "build",
|
|
675
|
-
|
|
679
|
+
transformUrlContent: async (urlInfo, context) => {
|
|
676
680
|
await rawGraphKitchen.pluginController.callAsyncHooks(
|
|
677
681
|
"optimizeUrlContent",
|
|
678
682
|
urlInfo,
|
|
@@ -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) {
|
|
@@ -1090,7 +1094,9 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1090
1094
|
parseHtmlString(urlInfo.content, {
|
|
1091
1095
|
storeOriginalPositions: false,
|
|
1092
1096
|
}),
|
|
1093
|
-
{
|
|
1097
|
+
{
|
|
1098
|
+
cleanupJsenvAttributes: true,
|
|
1099
|
+
},
|
|
1094
1100
|
)
|
|
1095
1101
|
: urlInfo.content;
|
|
1096
1102
|
const contentVersionGenerator = createVersionGenerator();
|
|
@@ -1110,7 +1116,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1110
1116
|
);
|
|
1111
1117
|
if (!dependencyContentVersion) {
|
|
1112
1118
|
// no content generated for this dependency
|
|
1113
|
-
// (inline, data:, sourcemap,
|
|
1119
|
+
// (inline, data:, sourcemap, mustIgnore is true, ...)
|
|
1114
1120
|
return null;
|
|
1115
1121
|
}
|
|
1116
1122
|
if (preferWithoutVersioning(reference)) {
|
|
@@ -1181,8 +1187,15 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1181
1187
|
runtimeCompat,
|
|
1182
1188
|
...contextSharedDuringBuild,
|
|
1183
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
|
|
1184
1195
|
jsenvPluginReferenceAnalysis({
|
|
1185
1196
|
...referenceAnalysis,
|
|
1197
|
+
supportedProtocols: ["file:", "data:", "virtual:"],
|
|
1198
|
+
ignoreProtocol: "remove",
|
|
1186
1199
|
fetchInlineUrls: false,
|
|
1187
1200
|
inlineConvertedScript: true, // to be able to version their urls
|
|
1188
1201
|
allowEscapeForVersioning: true,
|
|
@@ -1225,10 +1238,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1225
1238
|
return url;
|
|
1226
1239
|
},
|
|
1227
1240
|
formatReference: (reference) => {
|
|
1228
|
-
if (
|
|
1229
|
-
if (reference.generatedUrl.startsWith("ignore:")) {
|
|
1230
|
-
return reference.generatedUrl.slice("ignore:".length);
|
|
1231
|
-
}
|
|
1241
|
+
if (reference.mustIgnore) {
|
|
1232
1242
|
return null;
|
|
1233
1243
|
}
|
|
1234
1244
|
if (reference.isInline || reference.url.startsWith("data:")) {
|
|
@@ -1245,7 +1255,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1245
1255
|
if (!canUseVersionedUrl(referencedUrlInfo)) {
|
|
1246
1256
|
return reference.specifier;
|
|
1247
1257
|
}
|
|
1248
|
-
if (
|
|
1258
|
+
if (referencedUrlInfo.mustIgnore) {
|
|
1249
1259
|
return null;
|
|
1250
1260
|
}
|
|
1251
1261
|
const versionedUrl = versionedUrlMap.get(reference.url);
|
|
@@ -1374,7 +1384,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1374
1384
|
}
|
|
1375
1385
|
cleanup_jsenv_attributes_from_html: {
|
|
1376
1386
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1377
|
-
if (
|
|
1387
|
+
if (urlInfo.mustIgnore) {
|
|
1378
1388
|
return;
|
|
1379
1389
|
}
|
|
1380
1390
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -1559,7 +1569,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1559
1569
|
if (serviceWorkerEntryUrlInfos.length > 0) {
|
|
1560
1570
|
const serviceWorkerResources = {};
|
|
1561
1571
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1562
|
-
if (urlInfo.isInline ||
|
|
1572
|
+
if (urlInfo.isInline || urlInfo.mustIgnore) {
|
|
1563
1573
|
return;
|
|
1564
1574
|
}
|
|
1565
1575
|
if (!urlInfo.url.startsWith("file:")) {
|
|
@@ -1632,7 +1642,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1632
1642
|
return buildRelativeUrl;
|
|
1633
1643
|
};
|
|
1634
1644
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
1635
|
-
if (
|
|
1645
|
+
if (urlInfo.mustIgnore) {
|
|
1636
1646
|
return;
|
|
1637
1647
|
}
|
|
1638
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/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js
CHANGED
|
@@ -135,7 +135,6 @@ export const jsenvPluginJsModuleFallbackInsideHtml = ({
|
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
});
|
|
138
|
-
|
|
139
138
|
if (systemJsInjection) {
|
|
140
139
|
let needsSystemJs = false;
|
|
141
140
|
for (const reference of urlInfo.references) {
|
|
@@ -213,11 +212,10 @@ export const jsenvPluginJsModuleFallbackInsideHtml = ({
|
|
|
213
212
|
});
|
|
214
213
|
}
|
|
215
214
|
}
|
|
216
|
-
if (mutations.length === 0) {
|
|
217
|
-
return null;
|
|
218
|
-
}
|
|
219
215
|
await Promise.all(mutations.map((mutation) => mutation()));
|
|
220
|
-
return stringifyHtmlAst(htmlAst
|
|
216
|
+
return stringifyHtmlAst(htmlAst, {
|
|
217
|
+
cleanupPositionAttributes: context.dev,
|
|
218
|
+
});
|
|
221
219
|
},
|
|
222
220
|
},
|
|
223
221
|
};
|
/package/src/plugins/{url_type_from_reference.js → resolution_node_esm/url_type_from_reference.js}
RENAMED
|
File without changes
|