@jsenv/core 29.5.0 → 29.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/script_type_module_supervisor.js +3 -2
- package/dist/js/supervisor.js +3 -2
- package/dist/main.js +72 -43
- package/package.json +2 -2
- package/src/build/build.js +42 -1
- package/src/plugins/bundling/css/bundle_css.js +1 -1
- package/src/plugins/bundling/js_module/bundle_js_modules.js +1 -1
- package/src/plugins/importmap/jsenv_plugin_importmap.js +2 -4
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +13 -11
- package/src/plugins/supervisor/client/script_type_module_supervisor.js +3 -2
- package/src/plugins/supervisor/client/supervisor.js +3 -2
- package/src/plugins/supervisor/jsenv_plugin_supervisor.js +7 -9
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_conversion.js +1 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_library.js +1 -0
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +3 -0
- package/src/plugins/url_analysis/html/html_urls.js +4 -5
|
@@ -42,8 +42,9 @@ const createExecuteWithScript = ({
|
|
|
42
42
|
nodeToReplace = currentScriptClone;
|
|
43
43
|
currentScriptClone.src = urlObject.href;
|
|
44
44
|
} else {
|
|
45
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
46
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
45
|
+
currentScriptClone.removeAttribute("jsenv-cooked-by");
|
|
46
|
+
currentScriptClone.removeAttribute("jsenv-inlined-by");
|
|
47
|
+
currentScriptClone.removeAttribute("jsenv-injected-by");
|
|
47
48
|
currentScriptClone.removeAttribute("inlined-from-src");
|
|
48
49
|
currentScriptClone.removeAttribute("original-position");
|
|
49
50
|
currentScriptClone.removeAttribute("original-src-position");
|
package/dist/js/supervisor.js
CHANGED
|
@@ -885,8 +885,9 @@ window.__supervisor__ = (() => {
|
|
|
885
885
|
nodeToReplace = currentScriptClone;
|
|
886
886
|
currentScriptClone.src = urlObject.href;
|
|
887
887
|
} else {
|
|
888
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
889
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
888
|
+
currentScriptClone.removeAttribute("jsenv-cooked-by");
|
|
889
|
+
currentScriptClone.removeAttribute("jsenv-inlined-by");
|
|
890
|
+
currentScriptClone.removeAttribute("jsenv-injected-by");
|
|
890
891
|
currentScriptClone.removeAttribute("inlined-from-src");
|
|
891
892
|
currentScriptClone.removeAttribute("original-position");
|
|
892
893
|
currentScriptClone.removeAttribute("original-src-position");
|
package/dist/main.js
CHANGED
|
@@ -7574,8 +7574,9 @@ const stringifyHtmlAst = (htmlAst, {
|
|
|
7574
7574
|
"original-href-position": undefined,
|
|
7575
7575
|
"inlined-from-src": undefined,
|
|
7576
7576
|
"inlined-from-href": undefined,
|
|
7577
|
-
"jsenv-
|
|
7578
|
-
"jsenv-
|
|
7577
|
+
"jsenv-cooked-by": undefined,
|
|
7578
|
+
"jsenv-inlined-by": undefined,
|
|
7579
|
+
"jsenv-injected-by": undefined,
|
|
7579
7580
|
"jsenv-debug": undefined
|
|
7580
7581
|
});
|
|
7581
7582
|
}
|
|
@@ -7693,17 +7694,15 @@ const createHtmlNode = ({
|
|
|
7693
7694
|
};
|
|
7694
7695
|
const injectHtmlNode = (htmlAst, node, jsenvPluginName = "jsenv") => {
|
|
7695
7696
|
setHtmlNodeAttributes(node, {
|
|
7696
|
-
"jsenv-
|
|
7697
|
-
"jsenv-plugin-action": "injected"
|
|
7697
|
+
"jsenv-injected-by": jsenvPluginName
|
|
7698
7698
|
});
|
|
7699
7699
|
const htmlHtmlNode = findChild(htmlAst, node => node.nodeName === "html");
|
|
7700
7700
|
const bodyNode = findChild(htmlHtmlNode, node => node.nodeName === "body");
|
|
7701
|
-
return
|
|
7701
|
+
return insertHtmlNodeAfter(node, bodyNode);
|
|
7702
7702
|
};
|
|
7703
7703
|
const injectScriptNodeAsEarlyAsPossible = (htmlAst, scriptNode, jsenvPluginName = "jsenv") => {
|
|
7704
7704
|
setHtmlNodeAttributes(scriptNode, {
|
|
7705
|
-
"jsenv-
|
|
7706
|
-
"jsenv-plugin-action": "injected"
|
|
7705
|
+
"jsenv-injected-by": jsenvPluginName
|
|
7707
7706
|
});
|
|
7708
7707
|
const isJsModule = analyzeScriptNode(scriptNode).type === "js_module";
|
|
7709
7708
|
if (isJsModule) {
|
|
@@ -7717,35 +7716,35 @@ const injectScriptNodeAsEarlyAsPossible = (htmlAst, scriptNode, jsenvPluginName
|
|
|
7717
7716
|
let after = firstImportmapScript;
|
|
7718
7717
|
for (const nextSibling of nextSiblings) {
|
|
7719
7718
|
if (nextSibling.nodeName === "script") {
|
|
7720
|
-
return
|
|
7719
|
+
return insertHtmlNodeBefore(scriptNode, importmapParent, nextSibling);
|
|
7721
7720
|
}
|
|
7722
7721
|
if (nextSibling.nodeName === "link") {
|
|
7723
7722
|
after = nextSibling;
|
|
7724
7723
|
}
|
|
7725
7724
|
}
|
|
7726
|
-
return
|
|
7725
|
+
return insertHtmlNodeAfter(scriptNode, importmapParent, after);
|
|
7727
7726
|
}
|
|
7728
7727
|
}
|
|
7729
7728
|
const headNode = findChild(htmlAst, node => node.nodeName === "html").childNodes[0];
|
|
7730
7729
|
let after = headNode.childNodes[0];
|
|
7731
7730
|
for (const child of headNode.childNodes) {
|
|
7732
7731
|
if (child.nodeName === "script") {
|
|
7733
|
-
return
|
|
7732
|
+
return insertHtmlNodeBefore(scriptNode, headNode, child);
|
|
7734
7733
|
}
|
|
7735
7734
|
if (child.nodeName === "link") {
|
|
7736
7735
|
after = child;
|
|
7737
7736
|
}
|
|
7738
7737
|
}
|
|
7739
|
-
return
|
|
7738
|
+
return insertHtmlNodeAfter(scriptNode, headNode, after);
|
|
7740
7739
|
};
|
|
7741
|
-
const
|
|
7740
|
+
const insertHtmlNodeBefore = (nodeToInsert, futureParentNode, futureNextSibling) => {
|
|
7742
7741
|
const {
|
|
7743
7742
|
childNodes = []
|
|
7744
7743
|
} = futureParentNode;
|
|
7745
7744
|
const futureIndex = futureNextSibling ? childNodes.indexOf(futureNextSibling) : 0;
|
|
7746
7745
|
injectWithWhitespaces(nodeToInsert, futureParentNode, futureIndex);
|
|
7747
7746
|
};
|
|
7748
|
-
const
|
|
7747
|
+
const insertHtmlNodeAfter = (nodeToInsert, futureParentNode, futurePrevSibling) => {
|
|
7749
7748
|
const {
|
|
7750
7749
|
childNodes = []
|
|
7751
7750
|
} = futureParentNode;
|
|
@@ -7788,7 +7787,14 @@ const findChild = ({
|
|
|
7788
7787
|
childNodes = []
|
|
7789
7788
|
}, predicate) => childNodes.find(predicate);
|
|
7790
7789
|
const stringifyAttributes = object => {
|
|
7791
|
-
|
|
7790
|
+
let string = "";
|
|
7791
|
+
Object.keys(object).forEach(key => {
|
|
7792
|
+
const value = object[key];
|
|
7793
|
+
if (value === undefined) return;
|
|
7794
|
+
if (string !== "") string += " ";
|
|
7795
|
+
string += `${key}=${valueToHtmlAttributeValue(value)}`;
|
|
7796
|
+
});
|
|
7797
|
+
return string;
|
|
7792
7798
|
};
|
|
7793
7799
|
const valueToHtmlAttributeValue = value => {
|
|
7794
7800
|
if (typeof value === "string") {
|
|
@@ -11639,9 +11645,8 @@ const visitHtmlUrls = ({
|
|
|
11639
11645
|
attributeName,
|
|
11640
11646
|
specifier
|
|
11641
11647
|
}) => {
|
|
11642
|
-
const isContentCooked = getHtmlNodeAttribute(node, "jsenv-plugin-action") === "content_cooked";
|
|
11643
11648
|
let position;
|
|
11644
|
-
if (
|
|
11649
|
+
if (getHtmlNodeAttribute(node, "jsenv-cooked-by")) {
|
|
11645
11650
|
// when generated from inline content,
|
|
11646
11651
|
// line, column is not "src" nor "inlined-from-src" but "original-position"
|
|
11647
11652
|
position = getHtmlNodePosition(node);
|
|
@@ -11676,8 +11681,7 @@ const visitHtmlUrls = ({
|
|
|
11676
11681
|
}) => {
|
|
11677
11682
|
const value = getHtmlNodeAttribute(node, attributeName);
|
|
11678
11683
|
if (value) {
|
|
11679
|
-
|
|
11680
|
-
if (jsenvPluginOwner === "jsenv:importmap") {
|
|
11684
|
+
if (getHtmlNodeAttribute(node, "jsenv-inlined-by") === "jsenv:importmap") {
|
|
11681
11685
|
// during build the importmap is inlined
|
|
11682
11686
|
// and shoud not be considered as a dependency anymore
|
|
11683
11687
|
return null;
|
|
@@ -12127,8 +12131,7 @@ const jsenvPluginHtmlInlineContent = ({
|
|
|
12127
12131
|
mutations.push(() => {
|
|
12128
12132
|
setHtmlNodeText(styleNode, inlineStyleUrlInfo.content);
|
|
12129
12133
|
setHtmlNodeAttributes(styleNode, {
|
|
12130
|
-
"jsenv-
|
|
12131
|
-
"jsenv-plugin-action": "content_cooked"
|
|
12134
|
+
"jsenv-cooked-by": "jsenv:html_inline_content"
|
|
12132
12135
|
});
|
|
12133
12136
|
});
|
|
12134
12137
|
},
|
|
@@ -12140,11 +12143,10 @@ const jsenvPluginHtmlInlineContent = ({
|
|
|
12140
12143
|
// If the inline script was already handled by an other plugin, ignore it
|
|
12141
12144
|
// - we want to preserve inline scripts generated by html supervisor during dev
|
|
12142
12145
|
// - we want to avoid cooking twice a script during build
|
|
12143
|
-
|
|
12144
|
-
if (jsenvPluginOwner === "jsenv:as_js_classic_html" && !analyzeConvertedScripts) {
|
|
12146
|
+
if (!analyzeConvertedScripts && getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") === "jsenv:as_js_classic_html") {
|
|
12145
12147
|
return;
|
|
12146
12148
|
}
|
|
12147
|
-
if (
|
|
12149
|
+
if (getHtmlNodeAttribute(scriptNode, "jsenv-cooked-by") === "jsenv:supervisor" || getHtmlNodeAttribute(scriptNode, "jsenv-inlined-by") === "jsenv:supervisor" || getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") === "jsenv:supervisor") {
|
|
12148
12150
|
return;
|
|
12149
12151
|
}
|
|
12150
12152
|
const {
|
|
@@ -12193,8 +12195,7 @@ const jsenvPluginHtmlInlineContent = ({
|
|
|
12193
12195
|
mutations.push(() => {
|
|
12194
12196
|
setHtmlNodeText(scriptNode, inlineScriptUrlInfo.content);
|
|
12195
12197
|
setHtmlNodeAttributes(scriptNode, {
|
|
12196
|
-
"jsenv-
|
|
12197
|
-
"jsenv-plugin-action": "content_cooked",
|
|
12198
|
+
"jsenv-cooked-by": "jsenv:html_inline_content",
|
|
12198
12199
|
...(extension ? {
|
|
12199
12200
|
type: type === "js_module" ? "module" : undefined
|
|
12200
12201
|
} : {})
|
|
@@ -16504,7 +16505,8 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
16504
16505
|
type: "js_classic",
|
|
16505
16506
|
originalUrl: jsModuleUrlInfo.originalUrl,
|
|
16506
16507
|
originalContent: jsModuleUrlInfo.originalContent,
|
|
16507
|
-
sourcemap
|
|
16508
|
+
sourcemap,
|
|
16509
|
+
data: jsModuleUrlInfo.data
|
|
16508
16510
|
};
|
|
16509
16511
|
}
|
|
16510
16512
|
};
|
|
@@ -16936,7 +16938,7 @@ const rollupPluginJsenv = ({
|
|
|
16936
16938
|
originalUrl,
|
|
16937
16939
|
type: format === "esm" ? "js_module" : "common_js",
|
|
16938
16940
|
data: {
|
|
16939
|
-
|
|
16941
|
+
bundlerName: "rollup",
|
|
16940
16942
|
bundleRelativeUrl: rollupFileInfo.fileName,
|
|
16941
16943
|
usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0,
|
|
16942
16944
|
isDynamicEntry: rollupFileInfo.isDynamicEntry
|
|
@@ -17278,7 +17280,8 @@ const jsenvPluginAsJsClassicLibrary = ({
|
|
|
17278
17280
|
type: "js_classic",
|
|
17279
17281
|
originalUrl: urlInfo.originalUrl,
|
|
17280
17282
|
originalContent: jsModuleUrlInfo.originalContent,
|
|
17281
|
-
sourcemap
|
|
17283
|
+
sourcemap,
|
|
17284
|
+
data: jsModuleUrlInfo.data
|
|
17282
17285
|
};
|
|
17283
17286
|
}
|
|
17284
17287
|
};
|
|
@@ -18045,8 +18048,7 @@ const jsenvPluginImportmap = () => {
|
|
|
18045
18048
|
});
|
|
18046
18049
|
setHtmlNodeText(importmap, inlineImportmapUrlInfo.content);
|
|
18047
18050
|
setHtmlNodeAttributes(importmap, {
|
|
18048
|
-
"jsenv-
|
|
18049
|
-
"jsenv-plugin-action": "content_cooked"
|
|
18051
|
+
"jsenv-cooked-by": "jsenv:importmap"
|
|
18050
18052
|
});
|
|
18051
18053
|
onHtmlImportmapParsed(JSON.parse(inlineImportmapUrlInfo.content), htmlUrlInfo.url);
|
|
18052
18054
|
};
|
|
@@ -18065,8 +18067,7 @@ const jsenvPluginImportmap = () => {
|
|
|
18065
18067
|
setHtmlNodeText(importmap, importmapUrlInfo.content);
|
|
18066
18068
|
setHtmlNodeAttributes(importmap, {
|
|
18067
18069
|
"src": undefined,
|
|
18068
|
-
"jsenv-
|
|
18069
|
-
"jsenv-plugin-action": "inlined",
|
|
18070
|
+
"jsenv-inlined-by": "jsenv:importmap",
|
|
18070
18071
|
"inlined-from-src": src
|
|
18071
18072
|
});
|
|
18072
18073
|
const {
|
|
@@ -19740,8 +19741,7 @@ const jsenvPluginSupervisor = ({
|
|
|
19740
19741
|
if (type !== "js_classic" && type !== "js_module") {
|
|
19741
19742
|
return;
|
|
19742
19743
|
}
|
|
19743
|
-
|
|
19744
|
-
if (jsenvPluginOwner !== undefined) {
|
|
19744
|
+
if (getHtmlNodeAttribute(node, "jsenv-cooked-by") || getHtmlNodeAttribute(node, "jsenv-inlined-by") || getHtmlNodeAttribute(node, "jsenv-injected-by")) {
|
|
19745
19745
|
return;
|
|
19746
19746
|
}
|
|
19747
19747
|
const noSupervisor = getHtmlNodeAttribute(node, "no-supervisor");
|
|
@@ -19817,15 +19817,13 @@ const jsenvPluginSupervisor = ({
|
|
|
19817
19817
|
}
|
|
19818
19818
|
if (src) {
|
|
19819
19819
|
setHtmlNodeAttributes(node, {
|
|
19820
|
-
"jsenv-
|
|
19821
|
-
"jsenv-plugin-action": "inlined",
|
|
19820
|
+
"jsenv-inlined-by": "jsenv:supervisor",
|
|
19822
19821
|
"src": undefined,
|
|
19823
19822
|
"inlined-from-src": src
|
|
19824
19823
|
});
|
|
19825
19824
|
} else {
|
|
19826
19825
|
setHtmlNodeAttributes(node, {
|
|
19827
|
-
"jsenv-
|
|
19828
|
-
"jsenv-plugin-action": "content_cooked"
|
|
19826
|
+
"jsenv-cooked-by": "jsenv:supervisor"
|
|
19829
19827
|
});
|
|
19830
19828
|
}
|
|
19831
19829
|
});
|
|
@@ -20244,7 +20242,8 @@ const jsenvPluginAsModules = () => {
|
|
|
20244
20242
|
contentType: "text/javascript",
|
|
20245
20243
|
type: "js_module",
|
|
20246
20244
|
originalUrl: jsonUrlInfo.originalUrl,
|
|
20247
|
-
originalContent: jsonUrlInfo.originalContent
|
|
20245
|
+
originalContent: jsonUrlInfo.originalContent,
|
|
20246
|
+
data: jsonUrlInfo.data
|
|
20248
20247
|
};
|
|
20249
20248
|
}
|
|
20250
20249
|
};
|
|
@@ -20290,7 +20289,8 @@ const jsenvPluginAsModules = () => {
|
|
|
20290
20289
|
contentType: "text/javascript",
|
|
20291
20290
|
type: "js_module",
|
|
20292
20291
|
originalUrl: cssUrlInfo.originalUrl,
|
|
20293
|
-
originalContent: cssUrlInfo.originalContent
|
|
20292
|
+
originalContent: cssUrlInfo.originalContent,
|
|
20293
|
+
data: cssUrlInfo.data
|
|
20294
20294
|
};
|
|
20295
20295
|
}
|
|
20296
20296
|
};
|
|
@@ -20334,7 +20334,8 @@ export default inlineContent.text`,
|
|
|
20334
20334
|
contentType: "text/javascript",
|
|
20335
20335
|
type: "js_module",
|
|
20336
20336
|
originalUrl: textUrlInfo.originalUrl,
|
|
20337
|
-
originalContent: textUrlInfo.originalContent
|
|
20337
|
+
originalContent: textUrlInfo.originalContent,
|
|
20338
|
+
data: textUrlInfo.data
|
|
20338
20339
|
};
|
|
20339
20340
|
}
|
|
20340
20341
|
};
|
|
@@ -21426,7 +21427,7 @@ const bundleCss = async ({
|
|
|
21426
21427
|
cssUrlInfos.forEach(cssUrlInfo => {
|
|
21427
21428
|
bundledCssUrlInfos[cssUrlInfo.url] = {
|
|
21428
21429
|
data: {
|
|
21429
|
-
|
|
21430
|
+
bundlerName: "parcel"
|
|
21430
21431
|
},
|
|
21431
21432
|
contentType: "text/css",
|
|
21432
21433
|
content: cssBundleInfos[cssUrlInfo.url].bundleContent
|
|
@@ -23548,7 +23549,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
23548
23549
|
bundleRedirections.set(bundlerGeneratedUrlInfo.originalUrl, buildUrl);
|
|
23549
23550
|
associateBuildUrlAndRawUrl(buildUrl, bundlerGeneratedUrlInfo.originalUrl, "bundle");
|
|
23550
23551
|
} else {
|
|
23551
|
-
|
|
23552
|
+
bundleUrlInfo.data.generatedToShareCode = true;
|
|
23552
23553
|
}
|
|
23553
23554
|
} else {
|
|
23554
23555
|
associateBuildUrlAndRawUrl(buildUrl, url, "bundle");
|
|
@@ -23897,6 +23898,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
23897
23898
|
storeOriginalPositions: false
|
|
23898
23899
|
});
|
|
23899
23900
|
const mutations = [];
|
|
23901
|
+
const hintsToInject = {};
|
|
23900
23902
|
visitHtmlNodes(htmlAst, {
|
|
23901
23903
|
link: node => {
|
|
23902
23904
|
const href = getHtmlNodeAttribute(node, "href");
|
|
@@ -23931,6 +23933,12 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
23931
23933
|
href: buildSpecifierBeforeRedirect
|
|
23932
23934
|
});
|
|
23933
23935
|
});
|
|
23936
|
+
for (const dependencyUrl of buildUrlInfo.dependencies) {
|
|
23937
|
+
const dependencyUrlInfo = finalGraph.urlInfoMap.get(dependencyUrl);
|
|
23938
|
+
if (dependencyUrlInfo.data.generatedToShareCode) {
|
|
23939
|
+
hintsToInject[dependencyUrl] = node;
|
|
23940
|
+
}
|
|
23941
|
+
}
|
|
23934
23942
|
};
|
|
23935
23943
|
if (href.startsWith("file:")) {
|
|
23936
23944
|
let url = href;
|
|
@@ -23953,6 +23961,27 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
23953
23961
|
}
|
|
23954
23962
|
}
|
|
23955
23963
|
});
|
|
23964
|
+
Object.keys(hintsToInject).forEach(urlToHint => {
|
|
23965
|
+
const hintNode = hintsToInject[urlToHint];
|
|
23966
|
+
const urlFormatted = versioningRedirections.get(urlToHint) || urlToHint;
|
|
23967
|
+
const specifierBeforeRedirect = findKey(buildUrls, urlFormatted);
|
|
23968
|
+
const found = findHtmlNode(htmlAst, htmlNode => {
|
|
23969
|
+
return htmlNode.nodeName === "link" && getHtmlNodeAttribute(htmlNode, "href") === specifierBeforeRedirect;
|
|
23970
|
+
});
|
|
23971
|
+
if (!found) {
|
|
23972
|
+
mutations.push(() => {
|
|
23973
|
+
const nodeToInsert = createHtmlNode({
|
|
23974
|
+
tagName: "link",
|
|
23975
|
+
href: specifierBeforeRedirect,
|
|
23976
|
+
rel: getHtmlNodeAttribute(hintNode, "rel"),
|
|
23977
|
+
as: getHtmlNodeAttribute(hintNode, "as"),
|
|
23978
|
+
type: getHtmlNodeAttribute(hintNode, "type"),
|
|
23979
|
+
crossorigin: getHtmlNodeAttribute(hintNode, "crossorigin")
|
|
23980
|
+
});
|
|
23981
|
+
insertHtmlNodeAfter(nodeToInsert, hintNode.parentNode, hintNode);
|
|
23982
|
+
});
|
|
23983
|
+
}
|
|
23984
|
+
});
|
|
23956
23985
|
if (mutations.length > 0) {
|
|
23957
23986
|
mutations.forEach(mutation => mutation());
|
|
23958
23987
|
await finalGraphKitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.6.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@c88/v8-coverage": "0.1.1",
|
|
68
68
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
69
69
|
"@jsenv/abort": "4.2.4",
|
|
70
|
-
"@jsenv/ast": "1.4.
|
|
70
|
+
"@jsenv/ast": "1.4.4",
|
|
71
71
|
"@jsenv/babel-plugins": "1.0.9",
|
|
72
72
|
"@jsenv/filesystem": "4.1.5",
|
|
73
73
|
"@jsenv/importmap": "1.2.1",
|
package/src/build/build.js
CHANGED
|
@@ -48,6 +48,9 @@ import {
|
|
|
48
48
|
getHtmlNodeAttribute,
|
|
49
49
|
setHtmlNodeAttributes,
|
|
50
50
|
removeHtmlNode,
|
|
51
|
+
createHtmlNode,
|
|
52
|
+
insertHtmlNodeAfter,
|
|
53
|
+
findHtmlNode,
|
|
51
54
|
} from "@jsenv/ast"
|
|
52
55
|
|
|
53
56
|
import { createUrlGraph } from "../kitchen/url_graph.js"
|
|
@@ -805,7 +808,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
805
808
|
"bundle",
|
|
806
809
|
)
|
|
807
810
|
} else {
|
|
808
|
-
|
|
811
|
+
bundleUrlInfo.data.generatedToShareCode = true
|
|
809
812
|
}
|
|
810
813
|
} else {
|
|
811
814
|
associateBuildUrlAndRawUrl(buildUrl, url, "bundle")
|
|
@@ -1213,6 +1216,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1213
1216
|
storeOriginalPositions: false,
|
|
1214
1217
|
})
|
|
1215
1218
|
const mutations = []
|
|
1219
|
+
const hintsToInject = {}
|
|
1216
1220
|
visitHtmlNodes(htmlAst, {
|
|
1217
1221
|
link: (node) => {
|
|
1218
1222
|
const href = getHtmlNodeAttribute(node, "href")
|
|
@@ -1264,6 +1268,13 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1264
1268
|
href: buildSpecifierBeforeRedirect,
|
|
1265
1269
|
})
|
|
1266
1270
|
})
|
|
1271
|
+
for (const dependencyUrl of buildUrlInfo.dependencies) {
|
|
1272
|
+
const dependencyUrlInfo =
|
|
1273
|
+
finalGraph.urlInfoMap.get(dependencyUrl)
|
|
1274
|
+
if (dependencyUrlInfo.data.generatedToShareCode) {
|
|
1275
|
+
hintsToInject[dependencyUrl] = node
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1267
1278
|
}
|
|
1268
1279
|
if (href.startsWith("file:")) {
|
|
1269
1280
|
let url = href
|
|
@@ -1288,6 +1299,36 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
1288
1299
|
}
|
|
1289
1300
|
},
|
|
1290
1301
|
})
|
|
1302
|
+
Object.keys(hintsToInject).forEach((urlToHint) => {
|
|
1303
|
+
const hintNode = hintsToInject[urlToHint]
|
|
1304
|
+
const urlFormatted =
|
|
1305
|
+
versioningRedirections.get(urlToHint) || urlToHint
|
|
1306
|
+
const specifierBeforeRedirect = findKey(buildUrls, urlFormatted)
|
|
1307
|
+
const found = findHtmlNode(htmlAst, (htmlNode) => {
|
|
1308
|
+
return (
|
|
1309
|
+
htmlNode.nodeName === "link" &&
|
|
1310
|
+
getHtmlNodeAttribute(htmlNode, "href") ===
|
|
1311
|
+
specifierBeforeRedirect
|
|
1312
|
+
)
|
|
1313
|
+
})
|
|
1314
|
+
if (!found) {
|
|
1315
|
+
mutations.push(() => {
|
|
1316
|
+
const nodeToInsert = createHtmlNode({
|
|
1317
|
+
tagName: "link",
|
|
1318
|
+
href: specifierBeforeRedirect,
|
|
1319
|
+
rel: getHtmlNodeAttribute(hintNode, "rel"),
|
|
1320
|
+
as: getHtmlNodeAttribute(hintNode, "as"),
|
|
1321
|
+
type: getHtmlNodeAttribute(hintNode, "type"),
|
|
1322
|
+
crossorigin: getHtmlNodeAttribute(hintNode, "crossorigin"),
|
|
1323
|
+
})
|
|
1324
|
+
insertHtmlNodeAfter(
|
|
1325
|
+
nodeToInsert,
|
|
1326
|
+
hintNode.parentNode,
|
|
1327
|
+
hintNode,
|
|
1328
|
+
)
|
|
1329
|
+
})
|
|
1330
|
+
}
|
|
1331
|
+
})
|
|
1291
1332
|
if (mutations.length > 0) {
|
|
1292
1333
|
mutations.forEach((mutation) => mutation())
|
|
1293
1334
|
await finalGraphKitchen.urlInfoTransformer.applyFinalTransformations(
|
|
@@ -21,7 +21,7 @@ export const bundleCss = async ({ cssUrlInfos, context }) => {
|
|
|
21
21
|
cssUrlInfos.forEach((cssUrlInfo) => {
|
|
22
22
|
bundledCssUrlInfos[cssUrlInfo.url] = {
|
|
23
23
|
data: {
|
|
24
|
-
|
|
24
|
+
bundlerName: "parcel",
|
|
25
25
|
},
|
|
26
26
|
contentType: "text/css",
|
|
27
27
|
content: cssBundleInfos[cssUrlInfo.url].bundleContent,
|
|
@@ -162,7 +162,7 @@ const rollupPluginJsenv = ({
|
|
|
162
162
|
originalUrl,
|
|
163
163
|
type: format === "esm" ? "js_module" : "common_js",
|
|
164
164
|
data: {
|
|
165
|
-
|
|
165
|
+
bundlerName: "rollup",
|
|
166
166
|
bundleRelativeUrl: rollupFileInfo.fileName,
|
|
167
167
|
usesImport:
|
|
168
168
|
rollupFileInfo.imports.length > 0 ||
|
|
@@ -134,8 +134,7 @@ export const jsenvPluginImportmap = () => {
|
|
|
134
134
|
})
|
|
135
135
|
setHtmlNodeText(importmap, inlineImportmapUrlInfo.content)
|
|
136
136
|
setHtmlNodeAttributes(importmap, {
|
|
137
|
-
"jsenv-
|
|
138
|
-
"jsenv-plugin-action": "content_cooked",
|
|
137
|
+
"jsenv-cooked-by": "jsenv:importmap",
|
|
139
138
|
})
|
|
140
139
|
onHtmlImportmapParsed(
|
|
141
140
|
JSON.parse(inlineImportmapUrlInfo.content),
|
|
@@ -164,8 +163,7 @@ export const jsenvPluginImportmap = () => {
|
|
|
164
163
|
setHtmlNodeText(importmap, importmapUrlInfo.content)
|
|
165
164
|
setHtmlNodeAttributes(importmap, {
|
|
166
165
|
"src": undefined,
|
|
167
|
-
"jsenv-
|
|
168
|
-
"jsenv-plugin-action": "inlined",
|
|
166
|
+
"jsenv-inlined-by": "jsenv:importmap",
|
|
169
167
|
"inlined-from-src": src,
|
|
170
168
|
})
|
|
171
169
|
|
|
@@ -65,8 +65,7 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
65
65
|
mutations.push(() => {
|
|
66
66
|
setHtmlNodeText(styleNode, inlineStyleUrlInfo.content)
|
|
67
67
|
setHtmlNodeAttributes(styleNode, {
|
|
68
|
-
"jsenv-
|
|
69
|
-
"jsenv-plugin-action": "content_cooked",
|
|
68
|
+
"jsenv-cooked-by": "jsenv:html_inline_content",
|
|
70
69
|
})
|
|
71
70
|
})
|
|
72
71
|
},
|
|
@@ -78,17 +77,21 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
78
77
|
// If the inline script was already handled by an other plugin, ignore it
|
|
79
78
|
// - we want to preserve inline scripts generated by html supervisor during dev
|
|
80
79
|
// - we want to avoid cooking twice a script during build
|
|
81
|
-
const jsenvPluginOwner = getHtmlNodeAttribute(
|
|
82
|
-
scriptNode,
|
|
83
|
-
"jsenv-plugin-owner",
|
|
84
|
-
)
|
|
85
80
|
if (
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
!analyzeConvertedScripts &&
|
|
82
|
+
getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") ===
|
|
83
|
+
"jsenv:as_js_classic_html"
|
|
88
84
|
) {
|
|
89
85
|
return
|
|
90
86
|
}
|
|
91
|
-
if (
|
|
87
|
+
if (
|
|
88
|
+
getHtmlNodeAttribute(scriptNode, "jsenv-cooked-by") ===
|
|
89
|
+
"jsenv:supervisor" ||
|
|
90
|
+
getHtmlNodeAttribute(scriptNode, "jsenv-inlined-by") ===
|
|
91
|
+
"jsenv:supervisor" ||
|
|
92
|
+
getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") ===
|
|
93
|
+
"jsenv:supervisor"
|
|
94
|
+
) {
|
|
92
95
|
return
|
|
93
96
|
}
|
|
94
97
|
const { type, contentType, extension } =
|
|
@@ -131,8 +134,7 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
|
131
134
|
mutations.push(() => {
|
|
132
135
|
setHtmlNodeText(scriptNode, inlineScriptUrlInfo.content)
|
|
133
136
|
setHtmlNodeAttributes(scriptNode, {
|
|
134
|
-
"jsenv-
|
|
135
|
-
"jsenv-plugin-action": "content_cooked",
|
|
137
|
+
"jsenv-cooked-by": "jsenv:html_inline_content",
|
|
136
138
|
...(extension
|
|
137
139
|
? { type: type === "js_module" ? "module" : undefined }
|
|
138
140
|
: {}),
|
|
@@ -36,8 +36,9 @@ const createExecuteWithScript = ({ currentScript, src }) => {
|
|
|
36
36
|
nodeToReplace = currentScriptClone
|
|
37
37
|
currentScriptClone.src = urlObject.href
|
|
38
38
|
} else {
|
|
39
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
40
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
39
|
+
currentScriptClone.removeAttribute("jsenv-cooked-by")
|
|
40
|
+
currentScriptClone.removeAttribute("jsenv-inlined-by")
|
|
41
|
+
currentScriptClone.removeAttribute("jsenv-injected-by")
|
|
41
42
|
currentScriptClone.removeAttribute("inlined-from-src")
|
|
42
43
|
currentScriptClone.removeAttribute("original-position")
|
|
43
44
|
currentScriptClone.removeAttribute("original-src-position")
|
|
@@ -885,8 +885,9 @@ window.__supervisor__ = (() => {
|
|
|
885
885
|
nodeToReplace = currentScriptClone
|
|
886
886
|
currentScriptClone.src = urlObject.href
|
|
887
887
|
} else {
|
|
888
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
889
|
-
currentScriptClone.removeAttribute("jsenv-
|
|
888
|
+
currentScriptClone.removeAttribute("jsenv-cooked-by")
|
|
889
|
+
currentScriptClone.removeAttribute("jsenv-inlined-by")
|
|
890
|
+
currentScriptClone.removeAttribute("jsenv-injected-by")
|
|
890
891
|
currentScriptClone.removeAttribute("inlined-from-src")
|
|
891
892
|
currentScriptClone.removeAttribute("original-position")
|
|
892
893
|
currentScriptClone.removeAttribute("original-src-position")
|
|
@@ -277,11 +277,11 @@ export const jsenvPluginSupervisor = ({
|
|
|
277
277
|
if (type !== "js_classic" && type !== "js_module") {
|
|
278
278
|
return
|
|
279
279
|
}
|
|
280
|
-
|
|
281
|
-
node,
|
|
282
|
-
"jsenv-
|
|
283
|
-
|
|
284
|
-
|
|
280
|
+
if (
|
|
281
|
+
getHtmlNodeAttribute(node, "jsenv-cooked-by") ||
|
|
282
|
+
getHtmlNodeAttribute(node, "jsenv-inlined-by") ||
|
|
283
|
+
getHtmlNodeAttribute(node, "jsenv-injected-by")
|
|
284
|
+
) {
|
|
285
285
|
return
|
|
286
286
|
}
|
|
287
287
|
const noSupervisor = getHtmlNodeAttribute(node, "no-supervisor")
|
|
@@ -378,15 +378,13 @@ export const jsenvPluginSupervisor = ({
|
|
|
378
378
|
}
|
|
379
379
|
if (src) {
|
|
380
380
|
setHtmlNodeAttributes(node, {
|
|
381
|
-
"jsenv-
|
|
382
|
-
"jsenv-plugin-action": "inlined",
|
|
381
|
+
"jsenv-inlined-by": "jsenv:supervisor",
|
|
383
382
|
"src": undefined,
|
|
384
383
|
"inlined-from-src": src,
|
|
385
384
|
})
|
|
386
385
|
} else {
|
|
387
386
|
setHtmlNodeAttributes(node, {
|
|
388
|
-
"jsenv-
|
|
389
|
-
"jsenv-plugin-action": "content_cooked",
|
|
387
|
+
"jsenv-cooked-by": "jsenv:supervisor",
|
|
390
388
|
})
|
|
391
389
|
}
|
|
392
390
|
},
|
|
@@ -130,6 +130,7 @@ const jsenvPluginAsModules = () => {
|
|
|
130
130
|
type: "js_module",
|
|
131
131
|
originalUrl: jsonUrlInfo.originalUrl,
|
|
132
132
|
originalContent: jsonUrlInfo.originalContent,
|
|
133
|
+
data: jsonUrlInfo.data,
|
|
133
134
|
}
|
|
134
135
|
},
|
|
135
136
|
}
|
|
@@ -179,6 +180,7 @@ const jsenvPluginAsModules = () => {
|
|
|
179
180
|
type: "js_module",
|
|
180
181
|
originalUrl: cssUrlInfo.originalUrl,
|
|
181
182
|
originalContent: cssUrlInfo.originalContent,
|
|
183
|
+
data: cssUrlInfo.data,
|
|
182
184
|
}
|
|
183
185
|
},
|
|
184
186
|
}
|
|
@@ -226,6 +228,7 @@ export default inlineContent.text`,
|
|
|
226
228
|
type: "js_module",
|
|
227
229
|
originalUrl: textUrlInfo.originalUrl,
|
|
228
230
|
originalContent: textUrlInfo.originalContent,
|
|
231
|
+
data: textUrlInfo.data,
|
|
229
232
|
}
|
|
230
233
|
},
|
|
231
234
|
}
|
|
@@ -104,10 +104,8 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
|
|
|
104
104
|
attributeName,
|
|
105
105
|
specifier,
|
|
106
106
|
}) => {
|
|
107
|
-
const isContentCooked =
|
|
108
|
-
getHtmlNodeAttribute(node, "jsenv-plugin-action") === "content_cooked"
|
|
109
107
|
let position
|
|
110
|
-
if (
|
|
108
|
+
if (getHtmlNodeAttribute(node, "jsenv-cooked-by")) {
|
|
111
109
|
// when generated from inline content,
|
|
112
110
|
// line, column is not "src" nor "inlined-from-src" but "original-position"
|
|
113
111
|
position = getHtmlNodePosition(node)
|
|
@@ -138,8 +136,9 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
|
|
|
138
136
|
const visitAttributeAsUrlSpecifier = ({ node, attributeName, ...rest }) => {
|
|
139
137
|
const value = getHtmlNodeAttribute(node, attributeName)
|
|
140
138
|
if (value) {
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
if (
|
|
140
|
+
getHtmlNodeAttribute(node, "jsenv-inlined-by") === "jsenv:importmap"
|
|
141
|
+
) {
|
|
143
142
|
// during build the importmap is inlined
|
|
144
143
|
// and shoud not be considered as a dependency anymore
|
|
145
144
|
return null
|