@jsenv/core 38.3.2 → 38.3.3

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.
@@ -13,7 +13,7 @@ import http from "node:http";
13
13
  import { Readable, Stream, Writable } from "node:stream";
14
14
  import { Http2ServerResponse } from "node:http2";
15
15
  import { lookup } from "node:dns";
16
- import { injectJsImport, visitJsAstUntil, applyBabelPlugins, parseHtmlString, visitHtmlNodes, getHtmlNodeAttribute, analyzeScriptNode, getHtmlNodeText, stringifyHtmlAst, setHtmlNodeAttributes, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, generateUrlForInlineContent, parseJsWithAcorn, getHtmlNodePosition, getUrlForContentInsideHtml, getHtmlNodeAttributePosition, parseSrcSet, removeHtmlNodeText, setHtmlNodeText, removeHtmlNode, parseCssUrls, parseJsUrls, getUrlForContentInsideJs, analyzeLinkNode, findHtmlNode, insertHtmlNodeAfter } from "@jsenv/ast";
16
+ import { injectJsImport, visitJsAstUntil, applyBabelPlugins, parseHtml, visitHtmlNodes, getHtmlNodeAttribute, analyzeScriptNode, getHtmlNodeText, stringifyHtmlAst, setHtmlNodeAttributes, injectHtmlNodeAsEarlyAsPossible, createHtmlNode, generateUrlForInlineContent, parseJsWithAcorn, getHtmlNodePosition, getUrlForContentInsideHtml, getHtmlNodeAttributePosition, parseSrcSet, removeHtmlNodeText, setHtmlNodeText, removeHtmlNode, parseCssUrls, parseJsUrls, getUrlForContentInsideJs, analyzeLinkNode, findHtmlNode, insertHtmlNodeAfter } from "@jsenv/ast";
17
17
  import { sourcemapConverter, createMagicSource, composeTwoSourcemaps, SOURCEMAP, generateSourcemapFileUrl, generateSourcemapDataUrl } from "@jsenv/sourcemap";
18
18
  import { createRequire } from "node:module";
19
19
  import { systemJsClientFileUrlDefault, convertJsModuleToJsClassic } from "@jsenv/js-module-fallback";
@@ -10474,7 +10474,7 @@ const jsenvPluginJsModuleFallbackInsideHtml = ({
10474
10474
  },
10475
10475
  finalizeUrlContent: {
10476
10476
  html: async (urlInfo) => {
10477
- const htmlAst = parseHtmlString(urlInfo.content);
10477
+ const htmlAst = parseHtml({ html: urlInfo.content, url: urlInfo.url });
10478
10478
  const mutations = [];
10479
10479
  visitHtmlNodes(htmlAst, {
10480
10480
  link: (node) => {
@@ -11368,7 +11368,10 @@ const prependContent = async (
11368
11368
  };
11369
11369
 
11370
11370
  const prependJsClassicInHtml = (htmlUrlInfo, urlInfoToPrepend) => {
11371
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
11371
+ const htmlAst = parseHtml({
11372
+ html: htmlUrlInfo.content,
11373
+ url: htmlUrlInfo.url,
11374
+ });
11372
11375
  injectHtmlNodeAsEarlyAsPossible(
11373
11376
  htmlAst,
11374
11377
  createHtmlNode({
@@ -12978,7 +12981,10 @@ const returnValueAssertions = [
12978
12981
  ];
12979
12982
 
12980
12983
  const applyScriptInjections = (htmlUrlInfo, scriptInjections, hook) => {
12981
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
12984
+ const htmlAst = parseHtml({
12985
+ html: htmlUrlInfo.content,
12986
+ url: htmlUrlInfo.url,
12987
+ });
12982
12988
 
12983
12989
  scriptInjections.reverse().forEach((scriptInjection) => {
12984
12990
  const { setup } = scriptInjection;
@@ -14393,24 +14399,25 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
14393
14399
  });
14394
14400
  } catch (e) {
14395
14401
  urlInfo.error = e;
14396
- if (e.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
14397
- throw e;
14398
- }
14399
- if (urlInfo.isInline && errorOnInlineContentCanSkipThrow(urlInfo)) {
14400
- // When something like <style> or <script> contains syntax error
14401
- // the HTML in itself it still valid
14402
- // keep the syntax error and continue with the HTML
14402
+ if (
14403
+ urlInfo.isInline &&
14404
+ e.code !== "DIRECTORY_REFERENCE_NOT_ALLOWED" &&
14405
+ errorOnInlineContentCanSkipThrow(urlInfo)
14406
+ ) {
14403
14407
  const errorInfo =
14404
14408
  e.code === "PARSE_ERROR" && e.cause
14405
14409
  ? `${e.cause.reasonCode}\n${e.traceMessage}`
14406
14410
  : e.stack;
14411
+ // When something like <style> or <script> contains syntax error
14412
+ // the HTML in itself it still valid
14413
+ // keep the syntax error and continue with the HTML
14407
14414
  logger.error(
14408
- `Error while handling ${urlInfo.type} declared in ${urlInfo.firstReference.trace.message}:
14415
+ `Error while cooking ${urlInfo.type} declared in ${urlInfo.firstReference.trace.message}:
14409
14416
  ${errorInfo}`,
14410
14417
  );
14411
- } else {
14412
- throw e;
14418
+ return;
14413
14419
  }
14420
+ throw e;
14414
14421
  }
14415
14422
  }
14416
14423
 
@@ -15842,8 +15849,10 @@ const jsenvPluginHtmlReferenceAnalysis = ({
15842
15849
  let importmapFound = false;
15843
15850
  const importmapLoaded = startLoadingImportmap(urlInfo);
15844
15851
 
15845
- const content = urlInfo.content;
15846
- const htmlAst = parseHtmlString(content);
15852
+ const htmlAst = parseHtml({
15853
+ html: urlInfo.content,
15854
+ url: urlInfo.url,
15855
+ });
15847
15856
 
15848
15857
  const mutations = [];
15849
15858
  const actions = [];
@@ -18409,7 +18418,10 @@ const jsenvPluginInliningIntoHtml = () => {
18409
18418
  appliesDuring: "*",
18410
18419
  transformUrlContent: {
18411
18420
  html: async (urlInfo) => {
18412
- const htmlAst = parseHtmlString(urlInfo.content);
18421
+ const htmlAst = parseHtml({
18422
+ html: urlInfo.content,
18423
+ url: urlInfo.url,
18424
+ });
18413
18425
  const mutations = [];
18414
18426
  const actions = [];
18415
18427
 
@@ -19145,7 +19157,10 @@ const jsenvPluginImportMetaHot = () => {
19145
19157
  if (htmlUrlInfo.context.build) {
19146
19158
  return;
19147
19159
  }
19148
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
19160
+ const htmlAst = parseHtml({
19161
+ html: htmlUrlInfo.content,
19162
+ url: htmlUrlInfo.url,
19163
+ });
19149
19164
  const hotReferences = collectHotDataFromHtmlAst(htmlAst);
19150
19165
  htmlUrlInfo.data.hotDecline = false;
19151
19166
  htmlUrlInfo.data.hotAcceptSelf = false;
@@ -19332,7 +19347,10 @@ const jsenvPluginAutoreloadClient = () => {
19332
19347
  appliesDuring: "dev",
19333
19348
  transformUrlContent: {
19334
19349
  html: (htmlUrlInfo) => {
19335
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
19350
+ const htmlAst = parseHtml({
19351
+ html: htmlUrlInfo.content,
19352
+ url: htmlUrlInfo.url,
19353
+ });
19336
19354
  const autoreloadClientReference = htmlUrlInfo.dependencies.inject({
19337
19355
  type: "script",
19338
19356
  subtype: "js_module",
@@ -19769,7 +19787,10 @@ const jsenvPluginRibbon = ({
19769
19787
  if (!ribbon) {
19770
19788
  return null;
19771
19789
  }
19772
- const htmlAst = parseHtmlString(urlInfo.content);
19790
+ const htmlAst = parseHtml({
19791
+ html: urlInfo.content,
19792
+ url: urlInfo.url,
19793
+ });
19773
19794
  const ribbonClientFileReference = urlInfo.dependencies.inject({
19774
19795
  type: "script",
19775
19796
  subtype: "js_module",
@@ -19804,7 +19825,10 @@ const jsenvPluginCleanHTML = () => {
19804
19825
  appliesDuring: "dev",
19805
19826
  finalizeUrlContent: {
19806
19827
  html: (urlInfo) => {
19807
- const htmlAst = parseHtmlString(urlInfo.content);
19828
+ const htmlAst = parseHtml({
19829
+ html: urlInfo.content,
19830
+ url: urlInfo.url,
19831
+ });
19808
19832
  return stringifyHtmlAst(htmlAst, {
19809
19833
  cleanupPositionAttributes: true,
19810
19834
  });
@@ -20163,7 +20187,9 @@ const generateClientCodeForVersionMappings = (
20163
20187
  };
20164
20188
 
20165
20189
  const injectVersionMappingsAsImportmap = (urlInfo, versionMappings) => {
20166
- const htmlAst = parseHtmlString(urlInfo.content, {
20190
+ const htmlAst = parseHtml({
20191
+ html: urlInfo.content,
20192
+ url: urlInfo.url,
20167
20193
  storeOriginalPositions: false,
20168
20194
  });
20169
20195
  // jsenv_plugin_importmap.js is removing importmap during build
@@ -20680,7 +20706,9 @@ const createBuildSpecifierManager = ({
20680
20706
  let content = urlInfo.content;
20681
20707
  if (urlInfo.type === "html") {
20682
20708
  content = stringifyHtmlAst(
20683
- parseHtmlString(urlInfo.content, {
20709
+ parseHtml({
20710
+ html: urlInfo.content,
20711
+ url: urlInfo.url,
20684
20712
  storeOriginalPositions: false,
20685
20713
  }),
20686
20714
  {
@@ -20933,7 +20961,9 @@ const createBuildSpecifierManager = ({
20933
20961
  if (urlInfo.type !== "html") {
20934
20962
  return;
20935
20963
  }
20936
- const htmlAst = parseHtmlString(urlInfo.content, {
20964
+ const htmlAst = parseHtml({
20965
+ html: urlInfo.content,
20966
+ url: urlInfo.url,
20937
20967
  storeOriginalPositions: false,
20938
20968
  });
20939
20969
  const mutations = [];
@@ -21930,7 +21960,9 @@ build ${entryPointKeys.length} entry points`);
21930
21960
  return;
21931
21961
  }
21932
21962
  if (urlInfo.type === "html") {
21933
- const htmlAst = parseHtmlString(urlInfo.content, {
21963
+ const htmlAst = parseHtml({
21964
+ html: urlInfo.content,
21965
+ url: urlInfo.url,
21934
21966
  storeOriginalPositions: false,
21935
21967
  });
21936
21968
  urlInfo.content = stringifyHtmlAst(htmlAst, {
@@ -22509,6 +22541,9 @@ const createFileService = ({
22509
22541
  // it's not possible to do that when url info content is not available
22510
22542
  // (happens for js_module_fallback for instance)
22511
22543
  if (urlInfo.content !== undefined) {
22544
+ kitchen.context.logger.error(`Error while handling ${request.url}:
22545
+ ${originalError.reasonCode || originalError.code}
22546
+ ${e.traceMessage}`);
22512
22547
  return {
22513
22548
  url: reference.url,
22514
22549
  status: 200,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "38.3.2",
3
+ "version": "38.3.3",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -44,13 +44,13 @@
44
44
  "eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
45
45
  "dev": "node --conditions=development ./scripts/dev/dev.mjs",
46
46
  "test": "node --conditions=development ./scripts/test/test.mjs",
47
+ "test:workspace": "npm run test --workspaces --if-present -- --workspace",
47
48
  "snapshots:core": "npm run test -- --no-snapshot-assertion",
48
49
  "snapshots:packages": "npm run test --workspaces --if-present -- --workspace --no-snapshot-assertion",
49
50
  "snapshots:only_dev_server_errors": "node --conditions=development ./tests/dev_server/errors/generate_snapshot_files.mjs",
50
- "workspace:test": "npm run test --workspaces --if-present -- --workspace",
51
51
  "build": "node --conditions=development ./scripts/build/build.mjs",
52
52
  "build:file_size": "node ./scripts/build/build_file_size.mjs --log",
53
- "workspace:build": "npm run build --workspaces --if-present",
53
+ "build:workspace": "npm run build --workspaces --if-present --conditions=developement",
54
54
  "monorepo:upgrade_versions": "node ./scripts/monorepo/upgrade_external_versions.mjs",
55
55
  "monorepo:sync_packages_versions": "node ./scripts/monorepo/sync_packages_versions.mjs",
56
56
  "monorepo:publish": "node ./scripts/monorepo/publish_packages.mjs",
@@ -63,17 +63,17 @@
63
63
  "dependencies": {
64
64
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
65
65
  "@jsenv/abort": "4.2.4",
66
- "@jsenv/ast": "5.2.1",
66
+ "@jsenv/ast": "6.0.0",
67
67
  "@jsenv/filesystem": "4.3.2",
68
68
  "@jsenv/importmap": "1.2.1",
69
69
  "@jsenv/integrity": "0.0.1",
70
- "@jsenv/js-module-fallback": "1.3.7",
70
+ "@jsenv/js-module-fallback": "1.3.8",
71
71
  "@jsenv/log": "3.4.2",
72
72
  "@jsenv/node-esm-resolution": "1.0.1",
73
73
  "@jsenv/plugin-bundling": "2.5.8",
74
74
  "@jsenv/plugin-minification": "1.5.4",
75
- "@jsenv/plugin-supervisor": "1.3.7",
76
- "@jsenv/plugin-transpilation": "1.3.6",
75
+ "@jsenv/plugin-supervisor": "1.3.8",
76
+ "@jsenv/plugin-transpilation": "1.3.7",
77
77
  "@jsenv/runtime-compat": "1.2.0",
78
78
  "@jsenv/server": "15.1.5",
79
79
  "@jsenv/sourcemap": "1.2.4",
@@ -87,10 +87,10 @@
87
87
  "@jsenv/assert": "./packages/independent/assert/",
88
88
  "@jsenv/core": "./",
89
89
  "@jsenv/eslint-config": "./packages/independent/eslint-config/",
90
- "@jsenv/file-size-impact": "14.1.3",
90
+ "@jsenv/file-size-impact": "14.1.4",
91
91
  "@jsenv/https-local": "3.0.7",
92
- "@jsenv/monorepo": "0.0.2",
93
- "@jsenv/performance-impact": "4.1.3",
92
+ "@jsenv/monorepo": "0.0.4",
93
+ "@jsenv/performance-impact": "4.1.4",
94
94
  "@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
95
95
  "@jsenv/test": "./packages/related/test/",
96
96
  "babel-plugin-transform-async-to-promises": "0.8.18",
@@ -23,7 +23,7 @@ import {
23
23
  } from "@jsenv/filesystem";
24
24
  import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
25
25
  import { createLogger, createTaskLog } from "@jsenv/log";
26
- import { parseHtmlString, stringifyHtmlAst } from "@jsenv/ast";
26
+ import { parseHtml, stringifyHtmlAst } from "@jsenv/ast";
27
27
  import { jsenvPluginBundling } from "@jsenv/plugin-bundling";
28
28
  import { jsenvPluginMinification } from "@jsenv/plugin-minification";
29
29
  import { jsenvPluginJsModuleFallback } from "@jsenv/plugin-transpilation";
@@ -587,7 +587,9 @@ build ${entryPointKeys.length} entry points`);
587
587
  return;
588
588
  }
589
589
  if (urlInfo.type === "html") {
590
- const htmlAst = parseHtmlString(urlInfo.content, {
590
+ const htmlAst = parseHtml({
591
+ html: urlInfo.content,
592
+ url: urlInfo.url,
591
593
  storeOriginalPositions: false,
592
594
  });
593
595
  urlInfo.content = stringifyHtmlAst(htmlAst, {
@@ -9,7 +9,7 @@ import {
9
9
  renderUrlOrRelativeUrlFilename,
10
10
  } from "@jsenv/urls";
11
11
  import {
12
- parseHtmlString,
12
+ parseHtml,
13
13
  stringifyHtmlAst,
14
14
  visitHtmlNodes,
15
15
  getHtmlNodeAttribute,
@@ -510,7 +510,9 @@ export const createBuildSpecifierManager = ({
510
510
  let content = urlInfo.content;
511
511
  if (urlInfo.type === "html") {
512
512
  content = stringifyHtmlAst(
513
- parseHtmlString(urlInfo.content, {
513
+ parseHtml({
514
+ html: urlInfo.content,
515
+ url: urlInfo.url,
514
516
  storeOriginalPositions: false,
515
517
  }),
516
518
  {
@@ -763,7 +765,9 @@ export const createBuildSpecifierManager = ({
763
765
  if (urlInfo.type !== "html") {
764
766
  return;
765
767
  }
766
- const htmlAst = parseHtmlString(urlInfo.content, {
768
+ const htmlAst = parseHtml({
769
+ html: urlInfo.content,
770
+ url: urlInfo.url,
767
771
  storeOriginalPositions: false,
768
772
  });
769
773
  const mutations = [];
@@ -1,7 +1,7 @@
1
1
  // https://bundlers.tooling.report/hashing/avoid-cascade/
2
2
 
3
3
  import {
4
- parseHtmlString,
4
+ parseHtml,
5
5
  injectHtmlNodeAsEarlyAsPossible,
6
6
  createHtmlNode,
7
7
  stringifyHtmlAst,
@@ -58,7 +58,9 @@ const generateClientCodeForVersionMappings = (
58
58
  };
59
59
 
60
60
  export const injectVersionMappingsAsImportmap = (urlInfo, versionMappings) => {
61
- const htmlAst = parseHtmlString(urlInfo.content, {
61
+ const htmlAst = parseHtml({
62
+ html: urlInfo.content,
63
+ url: urlInfo.url,
62
64
  storeOriginalPositions: false,
63
65
  });
64
66
  // jsenv_plugin_importmap.js is removing importmap during build
@@ -349,6 +349,9 @@ export const createFileService = ({
349
349
  // it's not possible to do that when url info content is not available
350
350
  // (happens for js_module_fallback for instance)
351
351
  if (urlInfo.content !== undefined) {
352
+ kitchen.context.logger.error(`Error while handling ${request.url}:
353
+ ${originalError.reasonCode || originalError.code}
354
+ ${e.traceMessage}`);
352
355
  return {
353
356
  url: reference.url,
354
357
  status: 200,
@@ -480,24 +480,25 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
480
480
  });
481
481
  } catch (e) {
482
482
  urlInfo.error = e;
483
- if (e.code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
484
- throw e;
485
- }
486
- if (urlInfo.isInline && errorOnInlineContentCanSkipThrow(urlInfo)) {
487
- // When something like <style> or <script> contains syntax error
488
- // the HTML in itself it still valid
489
- // keep the syntax error and continue with the HTML
483
+ if (
484
+ urlInfo.isInline &&
485
+ e.code !== "DIRECTORY_REFERENCE_NOT_ALLOWED" &&
486
+ errorOnInlineContentCanSkipThrow(urlInfo)
487
+ ) {
490
488
  const errorInfo =
491
489
  e.code === "PARSE_ERROR" && e.cause
492
490
  ? `${e.cause.reasonCode}\n${e.traceMessage}`
493
491
  : e.stack;
492
+ // When something like <style> or <script> contains syntax error
493
+ // the HTML in itself it still valid
494
+ // keep the syntax error and continue with the HTML
494
495
  logger.error(
495
- `Error while handling ${urlInfo.type} declared in ${urlInfo.firstReference.trace.message}:
496
+ `Error while cooking ${urlInfo.type} declared in ${urlInfo.firstReference.trace.message}:
496
497
  ${errorInfo}`,
497
498
  );
498
- } else {
499
- throw e;
499
+ return;
500
500
  }
501
+ throw e;
501
502
  }
502
503
  }
503
504
 
@@ -1,6 +1,6 @@
1
1
  import { createMagicSource, composeTwoSourcemaps } from "@jsenv/sourcemap";
2
2
  import {
3
- parseHtmlString,
3
+ parseHtml,
4
4
  stringifyHtmlAst,
5
5
  createHtmlNode,
6
6
  injectHtmlNodeAsEarlyAsPossible,
@@ -44,7 +44,10 @@ export const prependContent = async (
44
44
  };
45
45
 
46
46
  const prependJsClassicInHtml = (htmlUrlInfo, urlInfoToPrepend) => {
47
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
47
+ const htmlAst = parseHtml({
48
+ html: htmlUrlInfo.content,
49
+ url: htmlUrlInfo.url,
50
+ });
48
51
  injectHtmlNodeAsEarlyAsPossible(
49
52
  htmlAst,
50
53
  createHtmlNode({
@@ -1,5 +1,5 @@
1
1
  import {
2
- parseHtmlString,
2
+ parseHtml,
3
3
  stringifyHtmlAst,
4
4
  injectHtmlNodeAsEarlyAsPossible,
5
5
  createHtmlNode,
@@ -16,7 +16,10 @@ export const jsenvPluginAutoreloadClient = () => {
16
16
  appliesDuring: "dev",
17
17
  transformUrlContent: {
18
18
  html: (htmlUrlInfo) => {
19
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
19
+ const htmlAst = parseHtml({
20
+ html: htmlUrlInfo.content,
21
+ url: htmlUrlInfo.url,
22
+ });
20
23
  const autoreloadClientReference = htmlUrlInfo.dependencies.inject({
21
24
  type: "script",
22
25
  subtype: "js_module",
@@ -1,4 +1,4 @@
1
- import { parseHtmlString, stringifyHtmlAst } from "@jsenv/ast";
1
+ import { parseHtml, stringifyHtmlAst } from "@jsenv/ast";
2
2
 
3
3
  export const jsenvPluginCleanHTML = () => {
4
4
  return {
@@ -6,7 +6,10 @@ export const jsenvPluginCleanHTML = () => {
6
6
  appliesDuring: "dev",
7
7
  finalizeUrlContent: {
8
8
  html: (urlInfo) => {
9
- const htmlAst = parseHtmlString(urlInfo.content);
9
+ const htmlAst = parseHtml({
10
+ html: urlInfo.content,
11
+ url: urlInfo.url,
12
+ });
10
13
  return stringifyHtmlAst(htmlAst, {
11
14
  cleanupPositionAttributes: true,
12
15
  });
@@ -1,5 +1,5 @@
1
1
  import { createMagicSource } from "@jsenv/sourcemap";
2
- import { parseHtmlString, applyBabelPlugins } from "@jsenv/ast";
2
+ import { parseHtml, applyBabelPlugins } from "@jsenv/ast";
3
3
 
4
4
  import { collectHotDataFromHtmlAst } from "./html_hot_dependencies.js";
5
5
  import { babelPluginMetadataImportMetaHot } from "./babel_plugin_metadata_import_meta_hot.js";
@@ -19,7 +19,10 @@ export const jsenvPluginImportMetaHot = () => {
19
19
  if (htmlUrlInfo.context.build) {
20
20
  return;
21
21
  }
22
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
22
+ const htmlAst = parseHtml({
23
+ html: htmlUrlInfo.content,
24
+ url: htmlUrlInfo.url,
25
+ });
23
26
  const hotReferences = collectHotDataFromHtmlAst(htmlAst);
24
27
  htmlUrlInfo.data.hotDecline = false;
25
28
  htmlUrlInfo.data.hotAcceptSelf = false;
@@ -1,6 +1,6 @@
1
1
  import { createMagicSource } from "@jsenv/sourcemap";
2
2
  import {
3
- parseHtmlString,
3
+ parseHtml,
4
4
  injectHtmlNodeAsEarlyAsPossible,
5
5
  createHtmlNode,
6
6
  stringifyHtmlAst,
@@ -16,11 +16,13 @@ export const injectGlobals = (content, globals, urlInfo) => {
16
16
  throw new Error(`cannot inject globals into "${urlInfo.type}"`);
17
17
  };
18
18
 
19
- const globalInjectorOnHtml = (content, globals) => {
19
+ const globalInjectorOnHtml = (content, globals, urlInfo) => {
20
20
  // ideally we would inject an importmap but browser support is too low
21
21
  // (even worse for worker/service worker)
22
22
  // so for now we inject code into entry points
23
- const htmlAst = parseHtmlString(content, {
23
+ const htmlAst = parseHtml({
24
+ html: content,
25
+ url: urlInfo.url,
24
26
  storeOriginalPositions: false,
25
27
  });
26
28
  const clientCode = generateClientCodeForGlobals(globals, {
@@ -1,5 +1,5 @@
1
1
  import {
2
- parseHtmlString,
2
+ parseHtml,
3
3
  stringifyHtmlAst,
4
4
  visitHtmlNodes,
5
5
  getHtmlNodeText,
@@ -17,7 +17,10 @@ export const jsenvPluginInliningIntoHtml = () => {
17
17
  appliesDuring: "*",
18
18
  transformUrlContent: {
19
19
  html: async (urlInfo) => {
20
- const htmlAst = parseHtmlString(urlInfo.content);
20
+ const htmlAst = parseHtml({
21
+ html: urlInfo.content,
22
+ url: urlInfo.url,
23
+ });
21
24
  const mutations = [];
22
25
  const actions = [];
23
26
 
@@ -1,6 +1,6 @@
1
1
  import { performance } from "node:perf_hooks";
2
2
  import {
3
- parseHtmlString,
3
+ parseHtml,
4
4
  stringifyHtmlAst,
5
5
  injectHtmlNodeAsEarlyAsPossible,
6
6
  createHtmlNode,
@@ -388,7 +388,10 @@ const returnValueAssertions = [
388
388
  ];
389
389
 
390
390
  const applyScriptInjections = (htmlUrlInfo, scriptInjections, hook) => {
391
- const htmlAst = parseHtmlString(htmlUrlInfo.content);
391
+ const htmlAst = parseHtml({
392
+ html: htmlUrlInfo.content,
393
+ url: htmlUrlInfo.url,
394
+ });
392
395
 
393
396
  scriptInjections.reverse().forEach((scriptInjection) => {
394
397
  const { setup } = scriptInjection;
@@ -1,5 +1,5 @@
1
1
  import {
2
- parseHtmlString,
2
+ parseHtml,
3
3
  visitHtmlNodes,
4
4
  getHtmlNodeText,
5
5
  setHtmlNodeText,
@@ -129,8 +129,10 @@ export const jsenvPluginHtmlReferenceAnalysis = ({
129
129
  let importmapFound = false;
130
130
  const importmapLoaded = startLoadingImportmap(urlInfo);
131
131
 
132
- const content = urlInfo.content;
133
- const htmlAst = parseHtmlString(content);
132
+ const htmlAst = parseHtml({
133
+ html: urlInfo.content,
134
+ url: urlInfo.url,
135
+ });
134
136
 
135
137
  const mutations = [];
136
138
  const actions = [];
@@ -1,5 +1,5 @@
1
1
  import {
2
- parseHtmlString,
2
+ parseHtml,
3
3
  stringifyHtmlAst,
4
4
  createHtmlNode,
5
5
  injectHtmlNodeAsEarlyAsPossible,
@@ -42,7 +42,10 @@ export const jsenvPluginRibbon = ({
42
42
  if (!ribbon) {
43
43
  return null;
44
44
  }
45
- const htmlAst = parseHtmlString(urlInfo.content);
45
+ const htmlAst = parseHtml({
46
+ html: urlInfo.content,
47
+ url: urlInfo.url,
48
+ });
46
49
  const ribbonClientFileReference = urlInfo.dependencies.inject({
47
50
  type: "script",
48
51
  subtype: "js_module",