@jsenv/core 27.0.0-alpha.84 → 27.0.0-alpha.85

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.
Files changed (40) hide show
  1. package/dist/js/event_source_client.js +3 -3
  2. package/dist/js/s.js +2 -2
  3. package/dist/main.js +355 -380
  4. package/dist/s.js +2 -2
  5. package/dist/s.js.map +1 -1
  6. package/package.json +5 -2
  7. package/src/build/build.js +1 -4
  8. package/src/build/inject_global_version_mappings.js +3 -3
  9. package/src/build/resync_ressource_hints.js +17 -18
  10. package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +3 -3
  11. package/src/omega/kitchen.js +2 -0
  12. package/src/plugins/autoreload/dev_sse/client/reload.js +6 -3
  13. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +3 -3
  14. package/src/plugins/bundling/css/bundle_css.js +1 -2
  15. package/src/plugins/bundling/js_module/bundle_js_module.js +85 -66
  16. package/src/plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +1 -1
  17. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +3 -3
  18. package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +62 -74
  19. package/src/plugins/import_meta_hot/html_hot_dependencies.js +9 -15
  20. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +1 -2
  21. package/src/plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +1 -1
  22. package/src/plugins/importmap/jsenv_plugin_importmap.js +24 -25
  23. package/src/plugins/inject_globals/inject_globals.js +3 -3
  24. package/src/plugins/inline/jsenv_plugin_html_inline_content.js +39 -41
  25. package/src/plugins/inline/jsenv_plugin_js_inline_content.js +1 -1
  26. package/src/plugins/minification/css/minify_css.js +1 -1
  27. package/src/plugins/transpilation/as_js_classic/client/s.js +2 -2
  28. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +2 -2
  29. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +41 -63
  30. package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +2 -3
  31. package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +2 -2
  32. package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +1 -1
  33. package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +2 -2
  34. package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +2 -2
  35. package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +1 -1
  36. package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +1 -1
  37. package/src/plugins/url_analysis/css/css_urls.js +1 -2
  38. package/src/plugins/url_analysis/html/html_urls.js +98 -113
  39. package/src/plugins/url_analysis/js/js_urls.js +1 -1
  40. package/src/test/coverage/empty_coverage_factory.js +1 -1
@@ -3,18 +3,17 @@ import {
3
3
  injectQueryParamsIntoSpecifier,
4
4
  } from "@jsenv/urls"
5
5
  import {
6
- getHtmlNodeAttributeByName,
7
- getHtmlNodeTextNode,
8
6
  parseHtmlString,
9
- removeHtmlNodeAttributeByName,
10
- assignHtmlNodeAttributes,
7
+ visitHtmlNodes,
11
8
  stringifyHtmlAst,
12
- visitHtmlAst,
13
- htmlNodePosition,
14
- setHtmlNodeGeneratedText,
15
- injectScriptAsEarlyAsPossible,
9
+ getHtmlNodeAttribute,
10
+ getHtmlNodeText,
11
+ getHtmlNodePosition,
12
+ setHtmlNodeAttributes,
13
+ setHtmlNodeText,
14
+ injectScriptNodeAsEarlyAsPossible,
16
15
  createHtmlNode,
17
- } from "@jsenv/utils/src/html_ast/html_ast.js"
16
+ } from "@jsenv/ast"
18
17
 
19
18
  export const jsenvPluginAsJsClassicHtml = ({
20
19
  systemJsInjection,
@@ -35,18 +34,13 @@ export const jsenvPluginAsJsClassicHtml = ({
35
34
  const moduleScriptNodes = []
36
35
  const classicScriptNodes = []
37
36
  const visitLinkNodes = (node) => {
38
- if (node.nodeName !== "link") {
39
- return
40
- }
41
- const relAttribute = getHtmlNodeAttributeByName(node, "rel")
42
- const rel = relAttribute ? relAttribute.value : undefined
37
+ const rel = getHtmlNodeAttribute(node, "rel")
43
38
  if (rel === "modulepreload") {
44
39
  modulePreloadNodes.push(node)
45
40
  return
46
41
  }
47
42
  if (rel === "preload") {
48
- const asAttribute = getHtmlNodeAttributeByName(node, "as")
49
- const asValue = asAttribute ? asAttribute.value : undefined
43
+ const asValue = getHtmlNodeAttribute(node, "as")
50
44
  if (asValue === "script") {
51
45
  preloadAsScriptNodes.push(node)
52
46
  }
@@ -54,11 +48,7 @@ export const jsenvPluginAsJsClassicHtml = ({
54
48
  }
55
49
  }
56
50
  const visitScriptNodes = (node) => {
57
- if (node.nodeName !== "script") {
58
- return
59
- }
60
- const typeAttribute = getHtmlNodeAttributeByName(node, "type")
61
- const type = typeAttribute ? typeAttribute.value : undefined
51
+ const type = getHtmlNodeAttribute(node, "type")
62
52
  if (type === "module") {
63
53
  moduleScriptNodes.push(node)
64
54
  return
@@ -68,9 +58,13 @@ export const jsenvPluginAsJsClassicHtml = ({
68
58
  return
69
59
  }
70
60
  }
71
- visitHtmlAst(htmlAst, (node) => {
72
- visitLinkNodes(node)
73
- visitScriptNodes(node)
61
+ visitHtmlNodes(htmlAst, {
62
+ link: (node) => {
63
+ visitLinkNodes(node)
64
+ },
65
+ script: (node) => {
66
+ visitScriptNodes(node)
67
+ },
74
68
  })
75
69
 
76
70
  const actions = []
@@ -113,15 +107,11 @@ export const jsenvPluginAsJsClassicHtml = ({
113
107
  }
114
108
 
115
109
  classicScriptNodes.forEach((classicScriptNode) => {
116
- const srcAttribute = getHtmlNodeAttributeByName(
117
- classicScriptNode,
118
- "src",
119
- )
120
- if (srcAttribute) {
110
+ const src = getHtmlNodeAttribute(classicScriptNode, "src")
111
+ if (src !== undefined) {
121
112
  const reference = urlInfo.references.find(
122
113
  (ref) =>
123
- ref.generatedSpecifier === srcAttribute.value &&
124
- ref.type === "script_src",
114
+ ref.generatedSpecifier === src && ref.type === "script_src",
125
115
  )
126
116
  const urlObject = new URL(reference.url)
127
117
  if (urlObject.searchParams.has("as_js_classic")) {
@@ -138,14 +128,11 @@ export const jsenvPluginAsJsClassicHtml = ({
138
128
  }
139
129
  })
140
130
  moduleScriptNodes.forEach((moduleScriptNode) => {
141
- const srcAttribute = getHtmlNodeAttributeByName(
142
- moduleScriptNode,
143
- "src",
144
- )
145
- if (srcAttribute) {
131
+ const src = getHtmlNodeAttribute(moduleScriptNode, "src")
132
+ if (src !== undefined) {
146
133
  const reference = urlInfo.references.find(
147
134
  (ref) =>
148
- ref.generatedSpecifier === srcAttribute.value &&
135
+ ref.generatedSpecifier === src &&
149
136
  ref.type === "script_src" &&
150
137
  ref.expectedType === "js_module",
151
138
  )
@@ -158,17 +145,19 @@ export const jsenvPluginAsJsClassicHtml = ({
158
145
  cookIt: true,
159
146
  },
160
147
  )
161
- removeHtmlNodeAttributeByName(moduleScriptNode, "type")
162
- srcAttribute.value = newReference.generatedSpecifier
148
+ setHtmlNodeAttributes(moduleScriptNode, {
149
+ type: undefined,
150
+ src: newReference.generatedSpecifier,
151
+ })
163
152
  })
164
153
  }
165
154
  return
166
155
  }
167
156
  if (shouldTransformScriptTypeModule) {
168
- const textNode = getHtmlNodeTextNode(moduleScriptNode)
157
+ const htmlNodeText = getHtmlNodeText(moduleScriptNode)
169
158
  actions.push(async () => {
170
159
  const { line, column, lineEnd, columnEnd, isOriginal } =
171
- htmlNodePosition.readNodePosition(moduleScriptNode, {
160
+ getHtmlNodePosition(moduleScriptNode, {
172
161
  preferOriginal: true,
173
162
  })
174
163
  let inlineScriptUrl = generateInlineContentUrl({
@@ -191,27 +180,23 @@ export const jsenvPluginAsJsClassicHtml = ({
191
180
  specifierColumn: column,
192
181
  specifier: inlineScriptUrl,
193
182
  contentType: "text/javascript",
194
- content: textNode.value,
183
+ content: htmlNodeText,
195
184
  })
196
185
  const [, newUrlInfo] = await getReferenceAsJsClassic(
197
186
  inlineReference,
198
187
  { cookIt: true },
199
188
  )
200
- removeHtmlNodeAttributeByName(moduleScriptNode, "type")
201
- setHtmlNodeGeneratedText(moduleScriptNode, {
202
- generatedText: newUrlInfo.content,
203
- generatedBy: "jsenv:as_js_classic_html",
189
+ setHtmlNodeText(moduleScriptNode, newUrlInfo.content)
190
+ setHtmlNodeAttributes(moduleScriptNode, {
191
+ "type": undefined,
192
+ "generated-by": "jsenv:as_js_classic_html",
204
193
  })
205
194
  })
206
195
  }
207
196
  })
208
197
  if (shouldTransformScriptTypeModule) {
209
198
  preloadAsScriptNodes.forEach((preloadAsScriptNode) => {
210
- const hrefAttribute = getHtmlNodeAttributeByName(
211
- preloadAsScriptNode,
212
- "href",
213
- )
214
- const href = hrefAttribute.value
199
+ const href = getHtmlNodeAttribute(preloadAsScriptNode, "href")
215
200
  const reference = urlInfo.references.find(
216
201
  (ref) =>
217
202
  ref.generatedSpecifier === href &&
@@ -233,22 +218,15 @@ export const jsenvPluginAsJsClassicHtml = ({
233
218
  // but it's unlikely to happen and people should use "modulepreload" in that case anyway
234
219
  ;[newReference] = await getReferenceAsJsClassic(reference)
235
220
  }
236
- assignHtmlNodeAttributes(preloadAsScriptNode, {
221
+ setHtmlNodeAttributes(preloadAsScriptNode, {
237
222
  href: newReference.generatedSpecifier,
223
+ crossorigin: undefined,
238
224
  })
239
- removeHtmlNodeAttributeByName(
240
- preloadAsScriptNode,
241
- "crossorigin",
242
- )
243
225
  })
244
226
  }
245
227
  })
246
228
  modulePreloadNodes.forEach((modulePreloadNode) => {
247
- const hrefAttribute = getHtmlNodeAttributeByName(
248
- modulePreloadNode,
249
- "href",
250
- )
251
- const href = hrefAttribute.value
229
+ const href = getHtmlNodeAttribute(modulePreloadNode, "href")
252
230
  const reference = urlInfo.references.find(
253
231
  (ref) =>
254
232
  ref.generatedSpecifier === href &&
@@ -262,7 +240,7 @@ export const jsenvPluginAsJsClassicHtml = ({
262
240
  } else {
263
241
  ;[newReference] = await getReferenceAsJsClassic(reference)
264
242
  }
265
- assignHtmlNodeAttributes(modulePreloadNode, {
243
+ setHtmlNodeAttributes(modulePreloadNode, {
266
244
  rel: "preload",
267
245
  as: "script",
268
246
  href: newReference.generatedSpecifier,
@@ -287,7 +265,7 @@ export const jsenvPluginAsJsClassicHtml = ({
287
265
  expectedType: "js_classic",
288
266
  specifier: systemJsClientFileUrl,
289
267
  })
290
- injectScriptAsEarlyAsPossible(
268
+ injectScriptNodeAsEarlyAsPossible(
291
269
  htmlAst,
292
270
  createHtmlNode({
293
271
  "tagName": "script",
@@ -1,6 +1,5 @@
1
1
  import { pathToFileURL } from "node:url"
2
-
3
- import { injectImport } from "@jsenv/utils/src/js_ast/babel_utils.js"
2
+ import { injectJsImport } from "@jsenv/ast"
4
3
 
5
4
  export const babelPluginGlobalThisAsJsenvImport = (
6
5
  babel,
@@ -23,7 +22,7 @@ export const babelPluginGlobalThisAsJsenvImport = (
23
22
  const { node } = path
24
23
  // we should do this once, tree shaking will remote it but still
25
24
  if (node.name === "globalThis") {
26
- injectImport({
25
+ injectJsImport({
27
26
  programPath: path.scope.getProgramParent().path,
28
27
  from: getImportSpecifier(globalThisClientFileUrl),
29
28
  sideEffect: true,
@@ -1,5 +1,5 @@
1
1
  import { pathToFileURL } from "node:url"
2
- import { injectImport } from "@jsenv/utils/src/js_ast/babel_utils.js"
2
+ import { injectJsImport } from "@jsenv/ast"
3
3
  import {
4
4
  getBabelHelperFileUrl,
5
5
  babelHelperNameFromUrl,
@@ -36,7 +36,7 @@ export const babelPluginBabelHelpersAsJsenvImports = (
36
36
  return undefined
37
37
  }
38
38
  const babelHelperImportSpecifier = getBabelHelperFileUrl(name)
39
- const helper = injectImport({
39
+ const helper = injectJsImport({
40
40
  programPath: file.path,
41
41
  from: getImportSpecifier(babelHelperImportSpecifier),
42
42
  nameHint: `_${name}`,
@@ -1,4 +1,4 @@
1
- import { applyBabelPlugins } from "@jsenv/utils/src/js_ast/apply_babel_plugins.js"
1
+ import { applyBabelPlugins } from "@jsenv/ast"
2
2
 
3
3
  import { RUNTIME_COMPAT } from "@jsenv/core/src/omega/compat/runtime_compat.js"
4
4
  import { getBaseBabelPluginStructure } from "./helpers/babel_plugin_structure.js"
@@ -1,5 +1,5 @@
1
1
  import { pathToFileURL } from "node:url"
2
- import { injectImport } from "@jsenv/utils/src/js_ast/babel_utils.js"
2
+ import { injectJsImport } from "@jsenv/ast"
3
3
 
4
4
  export const babelPluginNewStylesheetAsJsenvImport = (
5
5
  babel,
@@ -84,7 +84,7 @@ export const babelPluginNewStylesheetAsJsenvImport = (
84
84
  },
85
85
  })
86
86
  if (usesNewStylesheet) {
87
- injectImport({
87
+ injectJsImport({
88
88
  programPath,
89
89
  from: getImportSpecifier(newStylesheetClientFileUrl),
90
90
  sideEffect: true,
@@ -1,5 +1,5 @@
1
1
  import { pathToFileURL } from "node:url"
2
- import { injectImport } from "@jsenv/utils/src/js_ast/babel_utils.js"
2
+ import { injectJsImport } from "@jsenv/ast"
3
3
 
4
4
  export const babelPluginRegeneratorRuntimeAsJsenvImport = (
5
5
  babel,
@@ -21,7 +21,7 @@ export const babelPluginRegeneratorRuntimeAsJsenvImport = (
21
21
  }
22
22
  const { node } = path
23
23
  if (node.name === "regeneratorRuntime") {
24
- injectImport({
24
+ injectJsImport({
25
25
  programPath: path.scope.getProgramParent().path,
26
26
  from: getImportSpecifier(regeneratorRuntimeClientFileUrl),
27
27
  sideEffect: true,
@@ -1,4 +1,4 @@
1
- import { transpileWithParcel } from "@jsenv/utils/src/css_ast/parcel_css.js"
1
+ import { transpileWithParcel } from "@jsenv/ast"
2
2
 
3
3
  // https://github.com/parcel-bundler/parcel-css
4
4
  export const jsenvPluginCssParcel = () => {
@@ -1,4 +1,4 @@
1
- import { applyBabelPlugins } from "@jsenv/utils/src/js_ast/apply_babel_plugins.js"
1
+ import { applyBabelPlugins } from "@jsenv/ast"
2
2
 
3
3
  import { requireBabelPlugin } from "./babel/require_babel_plugin.js"
4
4
 
@@ -3,8 +3,7 @@
3
3
  */
4
4
 
5
5
  import { createMagicSource } from "@jsenv/sourcemap"
6
- import { applyPostCss } from "@jsenv/utils/src/css_ast/apply_post_css.js"
7
- import { postCssPluginUrlVisitor } from "@jsenv/utils/src/css_ast/postcss_plugin_url_visitor.js"
6
+ import { applyPostCss, postCssPluginUrlVisitor } from "@jsenv/ast"
8
7
 
9
8
  export const parseAndTransformCssUrls = async (urlInfo, context) => {
10
9
  const actions = []
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  parseHtmlString,
3
+ visitHtmlNodes,
4
+ getHtmlNodeAttribute,
5
+ getHtmlNodePosition,
6
+ setHtmlNodeAttributes,
7
+ getHtmlNodeAttributePosition,
8
+ parseSrcSet,
3
9
  stringifyHtmlAst,
4
- getHtmlNodeAttributeByName,
5
- htmlNodePosition,
6
- visitHtmlAst,
7
- } from "@jsenv/utils/src/html_ast/html_ast.js"
8
- import { htmlAttributeSrcSet } from "@jsenv/utils/src/html_ast/html_attribute_src_set.js"
10
+ } from "@jsenv/ast"
9
11
 
10
12
  export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
11
13
  const url = urlInfo.originalUrl
@@ -26,9 +28,12 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
26
28
  column,
27
29
  originalLine,
28
30
  originalColumn,
31
+ node,
32
+ attributeName,
29
33
  specifier,
30
- attribute,
31
34
  }) => {
35
+ const { crossorigin, integrity } = readFetchMetas(node)
36
+
32
37
  const isRessourceHint = [
33
38
  "preconnect",
34
39
  "dns-prefetch",
@@ -45,9 +50,15 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
45
50
  specifierLine: line,
46
51
  specifierColumn: column,
47
52
  isRessourceHint,
53
+ crossorigin,
54
+ integrity,
48
55
  })
49
56
  actions.push(async () => {
50
- attribute.value = await referenceUtils.readGeneratedSpecifier(reference)
57
+ setHtmlNodeAttributes(node, {
58
+ [attributeName]: await referenceUtils.readGeneratedSpecifier(
59
+ reference,
60
+ ),
61
+ })
51
62
  })
52
63
  },
53
64
  })
@@ -60,25 +71,39 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
60
71
  }
61
72
  }
62
73
 
74
+ const crossOriginCompatibleTagNames = ["script", "link", "img", "source"]
75
+ const integrityCompatibleTagNames = ["script", "link", "img", "source"]
76
+ const readFetchMetas = (node) => {
77
+ const meta = {}
78
+ if (crossOriginCompatibleTagNames.includes(node.nodeName)) {
79
+ const crossorigin = getHtmlNodeAttribute(node, "crossorigin") !== undefined
80
+ meta.crossorigin = crossorigin
81
+ }
82
+ if (integrityCompatibleTagNames.includes(node.nodeName)) {
83
+ const integrity = getHtmlNodeAttribute(node, "integrity")
84
+ meta.integrity = integrity
85
+ }
86
+ return meta
87
+ }
88
+
63
89
  const visitHtmlUrls = ({ url, htmlAst, onUrl }) => {
64
90
  const addDependency = ({
65
91
  type,
66
92
  subtype,
67
93
  expectedType,
68
94
  node,
69
- attribute,
95
+ attributeName,
70
96
  specifier,
71
97
  }) => {
72
- const generatedFromInlineContent = Boolean(
73
- getHtmlNodeAttributeByName(node, "generated-from-inline-content"),
74
- )
98
+ const generatedFromInlineContent =
99
+ getHtmlNodeAttribute(node, "generated-from-inline-content") !== undefined
75
100
  let position
76
101
  if (generatedFromInlineContent) {
77
102
  // when generated from inline content,
78
103
  // line, column is not "src" nor "generated-from-src" but "original-position"
79
- position = htmlNodePosition.readNodePosition(node)
104
+ position = getHtmlNodePosition(node)
80
105
  } else {
81
- position = htmlNodePosition.readAttributePosition(node, attribute.name)
106
+ position = getHtmlNodeAttributePosition(node, attributeName)
82
107
  }
83
108
  const {
84
109
  line,
@@ -93,18 +118,61 @@ const visitHtmlUrls = ({ url, htmlAst, onUrl }) => {
93
118
  column,
94
119
  // originalLine, originalColumn
95
120
  specifier,
96
- attribute,
97
- // injected:Boolean(getHtmlNodeAttributeByName(node, "injected-by"))
98
- // srcGeneratedFromInlineContent
99
- ...readFetchMetas(node),
121
+ node,
122
+ attributeName,
100
123
  })
101
124
  }
102
- const visitors = {
125
+ const visitAttributeAsUrlSpecifier = ({ node, attributeName, ...rest }) => {
126
+ const value = getHtmlNodeAttribute(node, attributeName)
127
+ if (value) {
128
+ const generatedBy = getHtmlNodeAttribute(node, "generated-by")
129
+ if (generatedBy !== undefined) {
130
+ // during build the importmap is inlined
131
+ // and shoud not be considered as a dependency anymore
132
+ return
133
+ }
134
+ addDependency({
135
+ ...rest,
136
+ node,
137
+ attributeName,
138
+ specifier:
139
+ attributeName === "generated-from-src" ||
140
+ attributeName === "generated-from-href"
141
+ ? new URL(value, url).href
142
+ : value,
143
+ })
144
+ } else if (attributeName === "src") {
145
+ visitAttributeAsUrlSpecifier({
146
+ ...rest,
147
+ node,
148
+ attributeName: "generated-from-src",
149
+ })
150
+ } else if (attributeName === "href") {
151
+ visitAttributeAsUrlSpecifier({
152
+ ...rest,
153
+ node,
154
+ attributeName: "generated-from-href",
155
+ })
156
+ }
157
+ }
158
+ const visitSrcset = ({ type, node }) => {
159
+ const srcset = getHtmlNodeAttribute(node, "srcset")
160
+ if (srcset) {
161
+ const srcCandidates = parseSrcSet(srcset)
162
+ srcCandidates.forEach((srcCandidate) => {
163
+ addDependency({
164
+ type,
165
+ node,
166
+ attributeName: "srcset",
167
+ specifier: srcCandidate.specifier,
168
+ })
169
+ })
170
+ }
171
+ }
172
+ visitHtmlNodes(htmlAst, {
103
173
  link: (node) => {
104
- const relAttribute = getHtmlNodeAttributeByName(node, "rel")
105
- const rel = relAttribute ? relAttribute.value : undefined
106
- const typeAttribute = getHtmlNodeAttributeByName(node, "type")
107
- const type = typeAttribute ? typeAttribute.value : undefined
174
+ const rel = getHtmlNodeAttribute(node, "rel")
175
+ const type = getHtmlNodeAttribute(node, "type")
108
176
  visitAttributeAsUrlSpecifier({
109
177
  type: "link_href",
110
178
  subtype: rel,
@@ -120,15 +188,16 @@ const visitHtmlUrls = ({ url, htmlAst, onUrl }) => {
120
188
  },
121
189
  // style: () => {},
122
190
  script: (node) => {
123
- const typeAttributeNode = getHtmlNodeAttributeByName(node, "type")
191
+ const type = getHtmlNodeAttribute(node, "type")
192
+ const expectedType = {
193
+ "undefined": "js_classic",
194
+ "text/javascript": "js_classic",
195
+ "module": "js_module",
196
+ "importmap": "importmap",
197
+ }[type]
124
198
  visitAttributeAsUrlSpecifier({
125
199
  type: "script_src",
126
- expectedType: {
127
- "undefined": "js_classic",
128
- "text/javascript": "js_classic",
129
- "module": "js_module",
130
- "importmap": "importmap",
131
- }[typeAttributeNode ? typeAttributeNode.value : undefined],
200
+ expectedType,
132
201
  node,
133
202
  attributeName: "src",
134
203
  })
@@ -184,89 +253,5 @@ const visitHtmlUrls = ({ url, htmlAst, onUrl }) => {
184
253
  attributeName: "href",
185
254
  })
186
255
  },
187
- }
188
- const visitAttributeAsUrlSpecifier = ({
189
- type,
190
- subtype,
191
- expectedType,
192
- node,
193
- attributeName,
194
- }) => {
195
- const attribute = getHtmlNodeAttributeByName(node, attributeName)
196
- const value = attribute ? attribute.value : undefined
197
- if (value) {
198
- const generatedBy = getHtmlNodeAttributeByName(node, "generated-by")
199
- if (generatedBy) {
200
- // during build the importmap is inlined
201
- // and shoud not be considered as a dependency anymore
202
- return
203
- }
204
- addDependency({
205
- type,
206
- subtype,
207
- expectedType,
208
- node,
209
- attribute,
210
- specifier:
211
- attributeName === "generated-from-src" ||
212
- attributeName === "generated-from-href"
213
- ? new URL(value, url).href
214
- : value,
215
- })
216
- } else if (attributeName === "src") {
217
- visitAttributeAsUrlSpecifier({
218
- type,
219
- subtype,
220
- expectedType,
221
- node,
222
- attributeName: "generated-from-src",
223
- })
224
- } else if (attributeName === "href") {
225
- visitAttributeAsUrlSpecifier({
226
- type,
227
- subtype,
228
- expectedType,
229
- node,
230
- attributeName: "generated-from-href",
231
- })
232
- }
233
- }
234
- const visitSrcset = ({ type, node }) => {
235
- const srcsetAttribute = getHtmlNodeAttributeByName(node, "srcset")
236
- const srcset = srcsetAttribute ? srcsetAttribute.value : undefined
237
- if (srcset) {
238
- const srcCandidates = htmlAttributeSrcSet.parse(srcset)
239
- srcCandidates.forEach((srcCandidate) => {
240
- addDependency({
241
- type,
242
- node,
243
- attribute: srcsetAttribute,
244
- specifier: srcCandidate.specifier,
245
- })
246
- })
247
- }
248
- }
249
- visitHtmlAst(htmlAst, (node) => {
250
- const visitor = visitors[node.nodeName]
251
- if (visitor) {
252
- visitor(node)
253
- }
254
256
  })
255
257
  }
256
-
257
- const crossOriginCompatibleTagNames = ["script", "link", "img", "source"]
258
- const integrityCompatibleTagNames = ["script", "link", "img", "source"]
259
- const readFetchMetas = (node) => {
260
- const meta = {}
261
- if (crossOriginCompatibleTagNames.includes(node.nodeName)) {
262
- const crossoriginAttribute = getHtmlNodeAttributeByName(node, "crossorigin")
263
- meta.crossorigin = crossoriginAttribute
264
- ? crossoriginAttribute.value
265
- : undefined
266
- }
267
- if (integrityCompatibleTagNames.includes(node.nodeName)) {
268
- const integrityAttribute = getHtmlNodeAttributeByName(node, "integrity")
269
- meta.integrity = integrityAttribute ? integrityAttribute.value : undefined
270
- }
271
- return meta
272
- }
@@ -1,5 +1,5 @@
1
1
  import { createMagicSource } from "@jsenv/sourcemap"
2
- import { parseJsUrls } from "@jsenv/utils/src/js_ast/parse_js_urls.js"
2
+ import { parseJsUrls } from "@jsenv/ast"
3
3
 
4
4
  import { isWebWorkerUrlInfo } from "@jsenv/core/src/omega/web_workers.js"
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { readFile } from "@jsenv/filesystem"
2
2
  import { resolveUrl } from "@jsenv/urls"
3
3
  import { Abort } from "@jsenv/abort"
4
- import { applyBabelPlugins } from "@jsenv/utils/src/js_ast/apply_babel_plugins.js"
4
+ import { applyBabelPlugins } from "@jsenv/ast"
5
5
 
6
6
  import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
7
7
  import { babelPluginInstrument } from "./babel_plugin_instrument.js"