@jsenv/core 29.5.0 → 29.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,8 +42,9 @@ const createExecuteWithScript = ({
42
42
  nodeToReplace = currentScriptClone;
43
43
  currentScriptClone.src = urlObject.href;
44
44
  } else {
45
- currentScriptClone.removeAttribute("jsenv-plugin-owner");
46
- currentScriptClone.removeAttribute("jsenv-plugin-action");
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");
@@ -885,8 +885,9 @@ window.__supervisor__ = (() => {
885
885
  nodeToReplace = currentScriptClone;
886
886
  currentScriptClone.src = urlObject.href;
887
887
  } else {
888
- currentScriptClone.removeAttribute("jsenv-plugin-owner");
889
- currentScriptClone.removeAttribute("jsenv-plugin-action");
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-plugin-owner": undefined,
7578
- "jsenv-plugin-action": undefined,
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-plugin-owner": jsenvPluginName,
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 insertAfter(node, bodyNode);
7701
+ return insertHtmlNodeAfter(node, bodyNode);
7702
7702
  };
7703
7703
  const injectScriptNodeAsEarlyAsPossible = (htmlAst, scriptNode, jsenvPluginName = "jsenv") => {
7704
7704
  setHtmlNodeAttributes(scriptNode, {
7705
- "jsenv-plugin-owner": jsenvPluginName,
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 insertBefore(scriptNode, importmapParent, nextSibling);
7719
+ return insertHtmlNodeBefore(scriptNode, importmapParent, nextSibling);
7721
7720
  }
7722
7721
  if (nextSibling.nodeName === "link") {
7723
7722
  after = nextSibling;
7724
7723
  }
7725
7724
  }
7726
- return insertAfter(scriptNode, importmapParent, after);
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 insertBefore(scriptNode, headNode, child);
7732
+ return insertHtmlNodeBefore(scriptNode, headNode, child);
7734
7733
  }
7735
7734
  if (child.nodeName === "link") {
7736
7735
  after = child;
7737
7736
  }
7738
7737
  }
7739
- return insertAfter(scriptNode, headNode, after);
7738
+ return insertHtmlNodeAfter(scriptNode, headNode, after);
7740
7739
  };
7741
- const insertBefore = (nodeToInsert, futureParentNode, futureNextSibling) => {
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 insertAfter = (nodeToInsert, futureParentNode, futurePrevSibling) => {
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
- return Object.keys(object).map(key => `${key}=${valueToHtmlAttributeValue(object[key])}`).join(" ");
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") {
@@ -11676,8 +11682,8 @@ const visitHtmlUrls = ({
11676
11682
  }) => {
11677
11683
  const value = getHtmlNodeAttribute(node, attributeName);
11678
11684
  if (value) {
11679
- const jsenvPluginOwner = getHtmlNodeAttribute(node, "jsenv-plugin-owner");
11680
- if (jsenvPluginOwner === "jsenv:importmap") {
11685
+ const jsenvInlinedBy = getHtmlNodeAttribute(node, "jsenv-inlined-by");
11686
+ if (jsenvInlinedBy === "jsenv:importmap") {
11681
11687
  // during build the importmap is inlined
11682
11688
  // and shoud not be considered as a dependency anymore
11683
11689
  return null;
@@ -12127,8 +12133,7 @@ const jsenvPluginHtmlInlineContent = ({
12127
12133
  mutations.push(() => {
12128
12134
  setHtmlNodeText(styleNode, inlineStyleUrlInfo.content);
12129
12135
  setHtmlNodeAttributes(styleNode, {
12130
- "jsenv-plugin-owner": "jsenv:html_inline_content",
12131
- "jsenv-plugin-action": "content_cooked"
12136
+ "jsenv-cooked-by": "jsenv:html_inline_content"
12132
12137
  });
12133
12138
  });
12134
12139
  },
@@ -12140,11 +12145,10 @@ const jsenvPluginHtmlInlineContent = ({
12140
12145
  // If the inline script was already handled by an other plugin, ignore it
12141
12146
  // - we want to preserve inline scripts generated by html supervisor during dev
12142
12147
  // - we want to avoid cooking twice a script during build
12143
- const jsenvPluginOwner = getHtmlNodeAttribute(scriptNode, "jsenv-plugin-owner");
12144
- if (jsenvPluginOwner === "jsenv:as_js_classic_html" && !analyzeConvertedScripts) {
12148
+ if (!analyzeConvertedScripts && getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") === "jsenv:as_js_classic_html") {
12145
12149
  return;
12146
12150
  }
12147
- if (jsenvPluginOwner === "jsenv:supervisor") {
12151
+ if (getHtmlNodeAttribute(scriptNode, "jsenv-cooked-by") === "jsenv:supervisor" || getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") === "jsenv:supervisor") {
12148
12152
  return;
12149
12153
  }
12150
12154
  const {
@@ -12193,8 +12197,7 @@ const jsenvPluginHtmlInlineContent = ({
12193
12197
  mutations.push(() => {
12194
12198
  setHtmlNodeText(scriptNode, inlineScriptUrlInfo.content);
12195
12199
  setHtmlNodeAttributes(scriptNode, {
12196
- "jsenv-plugin-owner": "jsenv:html_inline_content",
12197
- "jsenv-plugin-action": "content_cooked",
12200
+ "jsenv-cooked-by": "jsenv:html_inline_content",
12198
12201
  ...(extension ? {
12199
12202
  type: type === "js_module" ? "module" : undefined
12200
12203
  } : {})
@@ -16504,7 +16507,8 @@ const jsenvPluginAsJsClassicConversion = ({
16504
16507
  type: "js_classic",
16505
16508
  originalUrl: jsModuleUrlInfo.originalUrl,
16506
16509
  originalContent: jsModuleUrlInfo.originalContent,
16507
- sourcemap
16510
+ sourcemap,
16511
+ data: jsModuleUrlInfo.data
16508
16512
  };
16509
16513
  }
16510
16514
  };
@@ -16936,7 +16940,7 @@ const rollupPluginJsenv = ({
16936
16940
  originalUrl,
16937
16941
  type: format === "esm" ? "js_module" : "common_js",
16938
16942
  data: {
16939
- generatedBy: "rollup",
16943
+ bundlerName: "rollup",
16940
16944
  bundleRelativeUrl: rollupFileInfo.fileName,
16941
16945
  usesImport: rollupFileInfo.imports.length > 0 || rollupFileInfo.dynamicImports.length > 0,
16942
16946
  isDynamicEntry: rollupFileInfo.isDynamicEntry
@@ -17278,7 +17282,8 @@ const jsenvPluginAsJsClassicLibrary = ({
17278
17282
  type: "js_classic",
17279
17283
  originalUrl: urlInfo.originalUrl,
17280
17284
  originalContent: jsModuleUrlInfo.originalContent,
17281
- sourcemap
17285
+ sourcemap,
17286
+ data: jsModuleUrlInfo.data
17282
17287
  };
17283
17288
  }
17284
17289
  };
@@ -18045,8 +18050,7 @@ const jsenvPluginImportmap = () => {
18045
18050
  });
18046
18051
  setHtmlNodeText(importmap, inlineImportmapUrlInfo.content);
18047
18052
  setHtmlNodeAttributes(importmap, {
18048
- "jsenv-plugin-owner": "jsenv:importmap",
18049
- "jsenv-plugin-action": "content_cooked"
18053
+ "jsenv-cooked-by": "jsenv:importmap"
18050
18054
  });
18051
18055
  onHtmlImportmapParsed(JSON.parse(inlineImportmapUrlInfo.content), htmlUrlInfo.url);
18052
18056
  };
@@ -18065,8 +18069,7 @@ const jsenvPluginImportmap = () => {
18065
18069
  setHtmlNodeText(importmap, importmapUrlInfo.content);
18066
18070
  setHtmlNodeAttributes(importmap, {
18067
18071
  "src": undefined,
18068
- "jsenv-plugin-owner": "jsenv:importmap",
18069
- "jsenv-plugin-action": "inlined",
18072
+ "jsenv-inlined-by": "jsenv:importmap",
18070
18073
  "inlined-from-src": src
18071
18074
  });
18072
18075
  const {
@@ -19740,10 +19743,7 @@ const jsenvPluginSupervisor = ({
19740
19743
  if (type !== "js_classic" && type !== "js_module") {
19741
19744
  return;
19742
19745
  }
19743
- const jsenvPluginOwner = getHtmlNodeAttribute(node, "jsenv-plugin-owner");
19744
- if (jsenvPluginOwner !== undefined) {
19745
- return;
19746
- }
19746
+ if (getHtmlNodeAttribute(node, "jsenv-cooked-by") || getHtmlNodeAttribute(node, "jsenv-inlined-by") || getHtmlNodeAttribute(node, "jsenv-injected-by")) return;
19747
19747
  const noSupervisor = getHtmlNodeAttribute(node, "no-supervisor");
19748
19748
  if (noSupervisor !== undefined) {
19749
19749
  return;
@@ -19817,15 +19817,13 @@ const jsenvPluginSupervisor = ({
19817
19817
  }
19818
19818
  if (src) {
19819
19819
  setHtmlNodeAttributes(node, {
19820
- "jsenv-plugin-owner": "jsenv:supervisor",
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-plugin-owner": "jsenv:supervisor",
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
- generatedBy: "parcel"
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
- // chunk generated by rollup to share code
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.5.0",
3
+ "version": "29.6.0",
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.3",
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",
@@ -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
- // chunk generated by rollup to share code
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
- generatedBy: "parcel",
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
- generatedBy: "rollup",
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-plugin-owner": "jsenv:importmap",
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-plugin-owner": "jsenv:importmap",
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-plugin-owner": "jsenv:html_inline_content",
69
- "jsenv-plugin-action": "content_cooked",
68
+ "jsenv-cooked-by": "jsenv:html_inline_content",
70
69
  })
71
70
  })
72
71
  },
@@ -78,17 +77,19 @@ 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
- jsenvPluginOwner === "jsenv:as_js_classic_html" &&
87
- !analyzeConvertedScripts
81
+ !analyzeConvertedScripts &&
82
+ getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") ===
83
+ "jsenv:as_js_classic_html"
88
84
  ) {
89
85
  return
90
86
  }
91
- if (jsenvPluginOwner === "jsenv:supervisor") {
87
+ if (
88
+ getHtmlNodeAttribute(scriptNode, "jsenv-cooked-by") ===
89
+ "jsenv:supervisor" ||
90
+ getHtmlNodeAttribute(scriptNode, "jsenv-injected-by") ===
91
+ "jsenv:supervisor"
92
+ ) {
92
93
  return
93
94
  }
94
95
  const { type, contentType, extension } =
@@ -131,8 +132,7 @@ export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
131
132
  mutations.push(() => {
132
133
  setHtmlNodeText(scriptNode, inlineScriptUrlInfo.content)
133
134
  setHtmlNodeAttributes(scriptNode, {
134
- "jsenv-plugin-owner": "jsenv:html_inline_content",
135
- "jsenv-plugin-action": "content_cooked",
135
+ "jsenv-cooked-by": "jsenv:html_inline_content",
136
136
  ...(extension
137
137
  ? { type: type === "js_module" ? "module" : undefined }
138
138
  : {}),
@@ -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-plugin-owner")
40
- currentScriptClone.removeAttribute("jsenv-plugin-action")
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-plugin-owner")
889
- currentScriptClone.removeAttribute("jsenv-plugin-action")
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,13 +277,12 @@ export const jsenvPluginSupervisor = ({
277
277
  if (type !== "js_classic" && type !== "js_module") {
278
278
  return
279
279
  }
280
- const jsenvPluginOwner = getHtmlNodeAttribute(
281
- node,
282
- "jsenv-plugin-owner",
280
+ if (
281
+ getHtmlNodeAttribute(node, "jsenv-cooked-by") ||
282
+ getHtmlNodeAttribute(node, "jsenv-inlined-by") ||
283
+ getHtmlNodeAttribute(node, "jsenv-injected-by")
283
284
  )
284
- if (jsenvPluginOwner !== undefined) {
285
285
  return
286
- }
287
286
  const noSupervisor = getHtmlNodeAttribute(node, "no-supervisor")
288
287
  if (noSupervisor !== undefined) {
289
288
  return
@@ -378,15 +377,13 @@ export const jsenvPluginSupervisor = ({
378
377
  }
379
378
  if (src) {
380
379
  setHtmlNodeAttributes(node, {
381
- "jsenv-plugin-owner": "jsenv:supervisor",
382
- "jsenv-plugin-action": "inlined",
380
+ "jsenv-inlined-by": "jsenv:supervisor",
383
381
  "src": undefined,
384
382
  "inlined-from-src": src,
385
383
  })
386
384
  } else {
387
385
  setHtmlNodeAttributes(node, {
388
- "jsenv-plugin-owner": "jsenv:supervisor",
389
- "jsenv-plugin-action": "content_cooked",
386
+ "jsenv-cooked-by": "jsenv:supervisor",
390
387
  })
391
388
  }
392
389
  },
@@ -116,6 +116,7 @@ export const jsenvPluginAsJsClassicConversion = ({
116
116
  originalUrl: jsModuleUrlInfo.originalUrl,
117
117
  originalContent: jsModuleUrlInfo.originalContent,
118
118
  sourcemap,
119
+ data: jsModuleUrlInfo.data,
119
120
  }
120
121
  },
121
122
  }
@@ -86,6 +86,7 @@ export const jsenvPluginAsJsClassicLibrary = ({
86
86
  originalUrl: urlInfo.originalUrl,
87
87
  originalContent: jsModuleUrlInfo.originalContent,
88
88
  sourcemap,
89
+ data: jsModuleUrlInfo.data,
89
90
  }
90
91
  },
91
92
  }
@@ -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
  }
@@ -138,8 +138,8 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
138
138
  const visitAttributeAsUrlSpecifier = ({ node, attributeName, ...rest }) => {
139
139
  const value = getHtmlNodeAttribute(node, attributeName)
140
140
  if (value) {
141
- const jsenvPluginOwner = getHtmlNodeAttribute(node, "jsenv-plugin-owner")
142
- if (jsenvPluginOwner === "jsenv:importmap") {
141
+ const jsenvInlinedBy = getHtmlNodeAttribute(node, "jsenv-inlined-by")
142
+ if (jsenvInlinedBy === "jsenv:importmap") {
143
143
  // during build the importmap is inlined
144
144
  // and shoud not be considered as a dependency anymore
145
145
  return null