@jsenv/core 20.0.4 → 20.0.8

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.
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "20.0.4",
3
+ "version": "20.0.8",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,8 +11,7 @@
11
11
  "node": ">=14.9.0"
12
12
  },
13
13
  "publishConfig": {
14
- "access": "public",
15
- "registry": "https://registry.npmjs.org"
14
+ "access": "public"
16
15
  },
17
16
  "type": "module",
18
17
  "exports": {
@@ -36,7 +36,7 @@ export const buildProject = async ({
36
36
  writeOnFileSystem = true,
37
37
 
38
38
  format,
39
- systemJsUrl = "/node_modules/systemjs/dist/s.min.js",
39
+ systemJsUrl,
40
40
  globalName,
41
41
  globals = {},
42
42
  babelPluginMap = jsenvBabelPluginMap,
@@ -387,7 +387,7 @@ export const createAssetBuilder = (
387
387
  return
388
388
  }
389
389
 
390
- const targetBuildBuffer = buildFileInfo.code
390
+ const targetBuildBuffer = Buffer.from(buildFileInfo.code)
391
391
  const targetFileName = buildFileInfo.fileName
392
392
  const targetBuildRelativeUrl =
393
393
  buildManifest[targetFileName] || targetFileName
@@ -543,7 +543,7 @@ export const createAssetBuilder = (
543
543
  const transform = assetTransformMap[targetUrl]
544
544
  if (typeof transform !== "function") {
545
545
  target.targetBuildEnd(
546
- target.targetBuffer,
546
+ target.targetBuildBuffer || target.targetBuffer,
547
547
  target.targetBuildRelativeUrl,
548
548
  )
549
549
  return
@@ -79,10 +79,12 @@ export const buildToCompilationResult = (
79
79
  if (fileName === mainFileName) return
80
80
 
81
81
  const rollupFile = rollupBuild[fileName]
82
+ if (rollupFile.type === "asset") return
83
+
82
84
  const file = parseRollupFile(rollupFile, {
83
85
  urlResponseBodyMap,
84
86
  compiledFileUrl,
85
- sourcemapFileUrl: resolveUrl(file.map.file, compiledFileUrl),
87
+ sourcemapFileUrl: resolveUrl(rollupFile.map.file, compiledFileUrl),
86
88
  })
87
89
  trackDependencies(file.dependencyMap)
88
90
  assets.push(resolveUrl(fileName), compiledFileUrl)
@@ -1,49 +1,9 @@
1
- import { resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
2
-
3
- import { setJavaScriptSourceMappingUrl } from "@jsenv/core/src/internal/sourceMappingURLUtils.js"
4
-
5
- export const createBuildFileContents = ({ rollupBuild, buildDirectoryUrl }) => {
1
+ export const createBuildFileContents = ({ rollupBuild }) => {
6
2
  const buildFileContents = {}
7
3
  Object.keys(rollupBuild).forEach((buildRelativeUrl) => {
8
- const rollupFileInfo = rollupBuild[buildRelativeUrl]
9
- const fileBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
10
-
11
- if (rollupFileInfo.type === "asset") {
12
- buildFileContents[buildRelativeUrl] = rollupFileInfo.source
13
- return
14
- }
15
-
16
- const { code, map } = rollupFileInfo
17
-
18
- if (!map) {
19
- buildFileContents[buildRelativeUrl] = code
20
- return
21
- }
22
-
23
- const sourcemapBuildRelativeUrl = `${buildRelativeUrl}.map`
24
- const sourcemapRollupFileInfo = rollupBuild[sourcemapBuildRelativeUrl]
25
- if (sourcemapRollupFileInfo) {
26
- // already in rollup build, sourcemap will be found
27
- buildFileContents[buildRelativeUrl] = code
28
- return
29
- }
30
-
31
- const sourcemapBuildUrl = resolveUrl(
32
- sourcemapBuildRelativeUrl,
33
- buildDirectoryUrl,
34
- )
35
- const fileSourcemapString = JSON.stringify(map, null, " ")
36
- buildFileContents[sourcemapBuildRelativeUrl] = fileSourcemapString
4
+ const { type, source, code } = rollupBuild[buildRelativeUrl]
37
5
 
38
- const sourcemapBuildUrlRelativeToFileBuildUrl = urlToRelativeUrl(
39
- sourcemapBuildUrl,
40
- fileBuildUrl,
41
- )
42
- const codeWithSourcemapComment = setJavaScriptSourceMappingUrl(
43
- code,
44
- sourcemapBuildUrlRelativeToFileBuildUrl,
45
- )
46
- buildFileContents[buildRelativeUrl] = codeWithSourcemapComment
6
+ buildFileContents[buildRelativeUrl] = type === "asset" ? source : code
47
7
  })
48
8
  return buildFileContents
49
9
  }
@@ -44,6 +44,7 @@ import { minifyJs } from "./js/minifyJs.js"
44
44
  import { createImportResolverForNode } from "../import-resolution/import-resolver-node.js"
45
45
  import { createImportResolverForImportmap } from "../import-resolution/import-resolver-importmap.js"
46
46
  import { getDefaultImportMap } from "../import-resolution/importmap-default.js"
47
+ import { injectSourcemapInRollupBuild } from "./rollup_build_sourcemap.js"
47
48
  import { createBuildFileContents } from "./build_file_contents.js"
48
49
  import { createBuildStats } from "./build_stats.js"
49
50
 
@@ -367,6 +368,7 @@ building ${entryFileRelativeUrls.length} entry files...`)
367
368
  return parseTarget(target, notifiers, {
368
369
  format,
369
370
  systemJsUrl,
371
+ projectDirectoryUrl,
370
372
  urlToOriginalFileUrl: (url) => {
371
373
  return asOriginalUrl(url)
372
374
  },
@@ -901,12 +903,14 @@ building ${entryFileRelativeUrls.length} entry files...`)
901
903
  ...jsModuleBuild,
902
904
  ...assetBuild,
903
905
  }
906
+ rollupBuild = injectSourcemapInRollupBuild(rollupBuild, {
907
+ buildDirectoryUrl,
908
+ })
904
909
  rollupBuild = sortObjectByPathnames(rollupBuild)
905
910
  buildManifest = sortObjectByPathnames(buildManifest)
906
911
  buildMappings = sortObjectByPathnames(buildMappings)
907
912
  buildFileContents = createBuildFileContents({
908
913
  rollupBuild,
909
- buildDirectoryUrl,
910
914
  })
911
915
  const buildDuration = Date.now() - buildStartMs
912
916
  buildStats = createBuildStats({
@@ -30,15 +30,18 @@ import {
30
30
  getHtmlNodeAttributeByName,
31
31
  stringifyHtmlAst,
32
32
  getUniqueNameForInlineHtmlNode,
33
- addHtmlNodeAttribute,
34
33
  removeHtmlNodeAttribute,
35
34
  setHtmlNodeText,
36
35
  getHtmlNodeTextNode,
37
- removeHtmlNodeText,
38
36
  parseSrcset,
39
37
  stringifySrcset,
40
38
  } from "@jsenv/core/src/internal/compiling/compileHtml.js"
41
- import { setJavaScriptSourceMappingUrl } from "@jsenv/core/src/internal/sourceMappingURLUtils.js"
39
+ import {
40
+ getJavaScriptSourceMappingUrl,
41
+ setJavaScriptSourceMappingUrl,
42
+ getCssSourceMappingUrl,
43
+ setCssSourceMappingUrl,
44
+ } from "@jsenv/core/src/internal/sourceMappingURLUtils.js"
42
45
  import {
43
46
  getTargetAsBase64Url,
44
47
  targetIsReferencedOnlyByRessourceHint,
@@ -68,9 +71,9 @@ export const parseHtmlAsset = async (
68
71
 
69
72
  const linksMutations = collectNodesMutations(links, notifiers, htmlTarget, [
70
73
  linkStylesheetHrefVisitor,
71
- (link, { notifyReferenceFound }) =>
74
+ (link, notifiers) =>
72
75
  linkHrefVisitor(link, {
73
- notifyReferenceFound,
76
+ ...notifiers,
74
77
  ressourceHintNeverUsedCallback,
75
78
  }),
76
79
  ])
@@ -146,7 +149,11 @@ export const parseHtmlAsset = async (
146
149
  }
147
150
  }
148
151
 
149
- const regularScriptSrcVisitor = (script, { notifyReferenceFound }) => {
152
+ const regularScriptSrcVisitor = (
153
+ script,
154
+ { notifyReferenceFound },
155
+ htmlTarget,
156
+ ) => {
150
157
  const typeAttribute = getHtmlNodeAttributeByName(script, "type")
151
158
  if (
152
159
  typeAttribute &&
@@ -172,8 +179,21 @@ const regularScriptSrcVisitor = (script, { notifyReferenceFound }) => {
172
179
 
173
180
  if (shouldInline({ reference: remoteScriptReference, htmlNode: script })) {
174
181
  removeHtmlNodeAttribute(script, srcAttribute)
175
- const { targetBuildBuffer } = remoteScriptReference.target
176
- setHtmlNodeText(script, targetBuildBuffer)
182
+ const { target } = remoteScriptReference
183
+ const { targetBuildBuffer } = target
184
+ let jsString = String(targetBuildBuffer)
185
+
186
+ const sourcemapRelativeUrl = getJavaScriptSourceMappingUrl(jsString)
187
+ if (sourcemapRelativeUrl) {
188
+ const { targetBuildRelativeUrl } = target
189
+ const jsBuildUrl = resolveUrl(targetBuildRelativeUrl, "file:///")
190
+ const sourcemapBuildUrl = resolveUrl(sourcemapRelativeUrl, jsBuildUrl)
191
+ const htmlUrl = resolveUrl(htmlTarget.targetFileNamePattern, "file:///")
192
+ const sourcemapInlineUrl = urlToRelativeUrl(sourcemapBuildUrl, htmlUrl)
193
+ jsString = setJavaScriptSourceMappingUrl(jsString, sourcemapInlineUrl)
194
+ }
195
+
196
+ setHtmlNodeText(script, jsString)
177
197
  return
178
198
  }
179
199
 
@@ -259,14 +279,19 @@ const moduleScriptSrcVisitor = (script, { format, notifyReferenceFound }) => {
259
279
  // here put a warning if we cannot inline importmap because it would mess
260
280
  // the remapping (note that it's feasible) but not yet supported
261
281
  removeHtmlNodeAttribute(script, srcAttribute)
262
- const { targetBuildBuffer } = remoteScriptReference.target
263
- const jsString = String(targetBuildBuffer)
264
-
265
- const codeWithSourcemapComment = setJavaScriptSourceMappingUrl(
266
- jsString,
267
- `${remoteScriptReference.target.targetFileName}.map`
268
- )
269
- setHtmlNodeText(script, codeWithSourcemapComment)
282
+ const { target } = remoteScriptReference
283
+ const { targetBuildBuffer } = target
284
+ let jsString = String(targetBuildBuffer)
285
+
286
+ // at this stage, for some reason the sourcemap url is not in the js
287
+ // (it will be added sshortly after by "injectSourcemapInRollupBuild")
288
+ // but we know that a script type module have a sourcemap
289
+ // and will be next to html file
290
+ // with these assumptions we can force the sourcemap url
291
+ const sourcemapUrl = `${target.targetBuildRelativeUrl}.map`
292
+ jsString = setJavaScriptSourceMappingUrl(jsString, sourcemapUrl)
293
+
294
+ setHtmlNodeText(script, jsString)
270
295
  return
271
296
  }
272
297
 
@@ -314,14 +339,12 @@ const moduleScriptTextNodeVisitor = (
314
339
  targetIsJsModule: true,
315
340
  targetIsInline: true,
316
341
  })
317
- return ({ getReferenceUrlRelativeToImporter }) => {
342
+ return () => {
318
343
  if (format === "systemjs") {
319
344
  typeAttribute.value = "systemjs-module"
320
345
  }
321
- const urlRelativeToImporter = getReferenceUrlRelativeToImporter(jsReference)
322
- const relativeUrlNotation = ensureRelativeUrlNotation(urlRelativeToImporter)
323
- removeHtmlNodeText(script)
324
- addHtmlNodeAttribute(script, { name: "src", value: relativeUrlNotation })
346
+ const { targetBuildBuffer } = jsReference.target
347
+ textNode.value = targetBuildBuffer
325
348
  }
326
349
  }
327
350
 
@@ -378,7 +401,10 @@ const importmapScriptSrcVisitor = (
378
401
  // the remapping (note that it's feasible) but not yet supported
379
402
  removeHtmlNodeAttribute(script, srcAttribute)
380
403
  const { targetBuildBuffer } = importmapReference.target
381
- setHtmlNodeText(script, targetBuildBuffer)
404
+
405
+ const jsString = String(targetBuildBuffer)
406
+
407
+ setHtmlNodeText(script, jsString)
382
408
  return
383
409
  }
384
410
 
@@ -433,7 +459,11 @@ const importmapScriptTextNodeVisitor = (
433
459
  }
434
460
  }
435
461
 
436
- const linkStylesheetHrefVisitor = (link, { notifyReferenceFound }) => {
462
+ const linkStylesheetHrefVisitor = (
463
+ link,
464
+ { notifyReferenceFound },
465
+ htmlTarget,
466
+ ) => {
437
467
  const hrefAttribute = getHtmlNodeAttributeByName(link, "href")
438
468
  if (!hrefAttribute) {
439
469
  return null
@@ -457,8 +487,22 @@ const linkStylesheetHrefVisitor = (link, { notifyReferenceFound }) => {
457
487
  }
458
488
 
459
489
  if (shouldInline({ reference: cssReference, htmlNode: link })) {
460
- const { targetBuildBuffer } = cssReference.target
461
- replaceHtmlNode(link, `<style>${targetBuildBuffer}</style>`)
490
+ const { target } = cssReference
491
+ const { targetBuildBuffer } = target
492
+ let cssString = String(targetBuildBuffer)
493
+ const sourcemapRelativeUrl = getCssSourceMappingUrl(cssString)
494
+ if (sourcemapRelativeUrl) {
495
+ const { targetBuildRelativeUrl } = target
496
+ const cssBuildUrl = resolveUrl(targetBuildRelativeUrl, "file:///")
497
+ const sourcemapBuildUrl = resolveUrl(sourcemapRelativeUrl, cssBuildUrl)
498
+ const htmlUrl = resolveUrl(htmlTarget.targetFileNamePattern, "file:///")
499
+ const sourcemapInlineUrl = urlToRelativeUrl(sourcemapBuildUrl, htmlUrl)
500
+ cssString = setCssSourceMappingUrl(cssString, sourcemapInlineUrl)
501
+ }
502
+
503
+ replaceHtmlNode(link, `<style>${cssString}</style>`, {
504
+ attributesToIgnore: ["href", "rel", "as", "crossorigin", "type"],
505
+ })
462
506
  return
463
507
  }
464
508
 
@@ -470,7 +514,7 @@ const linkStylesheetHrefVisitor = (link, { notifyReferenceFound }) => {
470
514
 
471
515
  const linkHrefVisitor = (
472
516
  link,
473
- { notifyReferenceFound, ressourceHintNeverUsedCallback },
517
+ { format, notifyReferenceFound, ressourceHintNeverUsedCallback },
474
518
  ) => {
475
519
  const hrefAttribute = getHtmlNodeAttributeByName(link, "href")
476
520
  if (!hrefAttribute) {
@@ -527,6 +571,16 @@ const linkHrefVisitor = (
527
571
  return
528
572
  }
529
573
 
574
+ if (format === "systemjs" && rel === "modulepreload") {
575
+ const urlRelativeToImporter =
576
+ getReferenceUrlRelativeToImporter(linkReference)
577
+ replaceHtmlNode(
578
+ link,
579
+ `<link rel="preload" href="${urlRelativeToImporter}" as="script" />`,
580
+ )
581
+ return
582
+ }
583
+
530
584
  if (shouldInline({ reference: linkReference, htmlNode: link })) {
531
585
  replaceHtmlNode(
532
586
  link,
@@ -1,10 +1,15 @@
1
+ import { urlToRelativeUrl } from "@jsenv/filesystem"
2
+
1
3
  import {
2
4
  parseHtmlString,
3
- htmlAstContains,
5
+ findHtmlNode,
4
6
  htmlNodeIsScriptModule,
7
+ getHtmlNodeAttributeByName,
8
+ getHtmlNodeTextNode,
5
9
  manipulateHtmlAst,
6
10
  findFirstImportMapNode,
7
11
  } from "@jsenv/core/src/internal/compiling/compileHtml.js"
12
+ import { jsenvSystemJsFileInfo } from "@jsenv/core/src/internal/jsenvInternalFiles.js"
8
13
 
9
14
  import { parseHtmlAsset } from "./html/parseHtmlAsset.js"
10
15
  import { parseImportmapAsset } from "./importmap/parseImportmapAsset.js"
@@ -18,6 +23,7 @@ export const parseTarget = (
18
23
  target,
19
24
  notifiers,
20
25
  {
26
+ projectDirectoryUrl,
21
27
  format,
22
28
  systemJsUrl,
23
29
  urlToOriginalFileUrl,
@@ -49,18 +55,49 @@ export const parseTarget = (
49
55
  return
50
56
  }
51
57
 
52
- const htmlContainsModuleScript = htmlAstContains(
53
- htmlAst,
54
- htmlNodeIsScriptModule,
55
- )
56
- if (!htmlContainsModuleScript) {
58
+ let hasModuleScript = false
59
+ let hasInlineModuleScript = false
60
+ findHtmlNode(htmlAst, (htmlNode) => {
61
+ const isScriptModule = htmlNodeIsScriptModule(htmlNode)
62
+ if (!isScriptModule) {
63
+ return false
64
+ }
65
+
66
+ hasModuleScript = true
67
+
68
+ const isInline =
69
+ getHtmlNodeAttributeByName(htmlNode, "data-jsenv-force-inline") ||
70
+ (!getHtmlNodeAttributeByName(htmlNode, "src") &&
71
+ getHtmlNodeTextNode(htmlNode))
72
+ if (!isInline) {
73
+ return false
74
+ }
75
+ hasInlineModuleScript = true
76
+ return true
77
+ })
78
+
79
+ if (!hasModuleScript) {
57
80
  return
58
81
  }
59
82
 
83
+ // use our own version of systemjs by default
84
+ // we should also detect if there is an inline script
85
+ // and, in that case, inline systemjs instead of using the url
86
+ if (typeof systemJsUrl === "undefined") {
87
+ systemJsUrl = `/${urlToRelativeUrl(
88
+ jsenvSystemJsFileInfo.url,
89
+ projectDirectoryUrl,
90
+ )}`
91
+ }
92
+
60
93
  manipulateHtmlAst(htmlAst, {
61
94
  scriptInjections: [
62
95
  {
96
+ id: "jsenv_inject_systemjs",
63
97
  src: systemJsUrl,
98
+ ...(hasInlineModuleScript
99
+ ? { "data-jsenv-force-inline": true }
100
+ : {}),
64
101
  },
65
102
  ],
66
103
  })
@@ -82,7 +119,7 @@ export const parseTarget = (
82
119
  scriptInjections: [
83
120
  {
84
121
  type: "importmap",
85
- id: "jsenv-build-importmap",
122
+ id: "jsenv_inject_importmap",
86
123
  text: "{}",
87
124
  },
88
125
  ],
@@ -0,0 +1,54 @@
1
+ import { resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
2
+
3
+ import { setJavaScriptSourceMappingUrl } from "@jsenv/core/src/internal/sourceMappingURLUtils.js"
4
+
5
+ export const injectSourcemapInRollupBuild = (
6
+ rollupBuild,
7
+ { buildDirectoryUrl },
8
+ ) => {
9
+ const rollupBuildWithSourcemap = {}
10
+
11
+ Object.keys(rollupBuild).forEach((buildRelativeUrl) => {
12
+ const rollupFileInfo = rollupBuild[buildRelativeUrl]
13
+ const { type, code, map } = rollupFileInfo
14
+
15
+ if (type === "asset" || !map) {
16
+ rollupBuildWithSourcemap[buildRelativeUrl] = rollupFileInfo
17
+ return
18
+ }
19
+
20
+ const sourcemapBuildRelativeUrl = `${buildRelativeUrl}.map`
21
+ const sourcemapRollupFileInfo = rollupBuild[sourcemapBuildRelativeUrl]
22
+ if (sourcemapRollupFileInfo) {
23
+ rollupBuildWithSourcemap[buildRelativeUrl] = rollupFileInfo
24
+ return
25
+ }
26
+
27
+ const fileBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
28
+ const sourcemapBuildUrl = resolveUrl(
29
+ sourcemapBuildRelativeUrl,
30
+ buildDirectoryUrl,
31
+ )
32
+ const fileSourcemapString = JSON.stringify(map, null, " ")
33
+ const sourcemapBuildUrlRelativeToFileBuildUrl = urlToRelativeUrl(
34
+ sourcemapBuildUrl,
35
+ fileBuildUrl,
36
+ )
37
+ const codeWithSourcemapComment = setJavaScriptSourceMappingUrl(
38
+ code,
39
+ sourcemapBuildUrlRelativeToFileBuildUrl,
40
+ )
41
+
42
+ rollupBuildWithSourcemap[sourcemapBuildRelativeUrl] = {
43
+ type: "asset",
44
+ fileName: sourcemapBuildRelativeUrl,
45
+ source: fileSourcemapString,
46
+ }
47
+ rollupBuildWithSourcemap[buildRelativeUrl] = {
48
+ ...rollupFileInfo,
49
+ code: codeWithSourcemapComment,
50
+ }
51
+ })
52
+
53
+ return rollupBuildWithSourcemap
54
+ }
@@ -67,14 +67,23 @@ export const findNodes = (htmlString, predicate) => {
67
67
  export const findNodeByTagName = (htmlString, tagName) =>
68
68
  findNode(htmlString, (node) => node.nodeName === tagName)
69
69
 
70
+ export const findHtmlNodeById = (htmlString, id) => {
71
+ return findNode(htmlString, (node) => {
72
+ const idAttribute = getHtmlNodeAttributeByName(node, "id")
73
+ return idAttribute && idAttribute.value === id
74
+ })
75
+ }
76
+
70
77
  export const findAllNodeByTagName = (htmlString, tagName) =>
71
78
  findNodes(htmlString, (node) => node.nodeName === tagName)
72
79
 
73
80
  export const findFirstImportMapNode = (htmlStringOrAst) =>
74
81
  findNode(htmlStringOrAst, htmlNodeIsScriptImportmap)
75
82
 
76
- export const getHtmlNodeAttributeByName = (htmlNode, attributeName) =>
77
- htmlNode.attrs.find((attr) => attr.name === attributeName)
83
+ export const getHtmlNodeAttributeByName = (htmlNode, attributeName) => {
84
+ const attrs = htmlNode.attrs
85
+ return attrs && attrs.find((attr) => attr.name === attributeName)
86
+ }
78
87
 
79
88
  export const removeHtmlNodeAttribute = (htmlNode, attributeToRemove) => {
80
89
  let attrIndex
@@ -148,16 +157,16 @@ export const getHtmlNodeLocation = (htmlNode) => {
148
157
  }
149
158
  }
150
159
 
151
- export const htmlAstContains = (htmlAst, predicate) => {
152
- let contains = false
160
+ export const findHtmlNode = (htmlAst, predicate) => {
161
+ let nodeFound = null
153
162
  visitHtmlAst(htmlAst, (node) => {
154
163
  if (predicate(node)) {
155
- contains = true
164
+ nodeFound = node
156
165
  return "stop"
157
166
  }
158
167
  return null
159
168
  })
160
- return contains
169
+ return nodeFound
161
170
  }
162
171
 
163
172
  export const htmlNodeIsScriptModule = (htmlNode) => {
@@ -275,7 +284,7 @@ export const parseHtmlAstRessources = (htmlAst) => {
275
284
  export const replaceHtmlNode = (
276
285
  node,
277
286
  replacement,
278
- { inheritAttributes = true } = {},
287
+ { attributesInherit = true, attributesToIgnore = [] } = {},
279
288
  ) => {
280
289
  let newNode
281
290
  if (typeof replacement === "string") {
@@ -284,16 +293,12 @@ export const replaceHtmlNode = (
284
293
  newNode = replacement
285
294
  }
286
295
 
287
- if (inheritAttributes) {
296
+ if (attributesInherit) {
297
+ // inherit attributes except thoos listed in attributesToIgnore
288
298
  newNode.attrs = [
289
- // inherit script attributes except src, type, href, rel
290
- ...node.attrs.filter(
291
- ({ name }) =>
292
- name !== "type" &&
293
- name !== "src" &&
294
- name !== "href" &&
295
- name !== "rel",
296
- ),
299
+ ...node.attrs.filter(({ name }) => {
300
+ return !attributesToIgnore.includes(name)
301
+ }),
297
302
  ...newNode.attrs,
298
303
  ]
299
304
  }
@@ -255,6 +255,7 @@ const inlineImportmapScripts = async ({ logger, htmlAst, fileUrl }) => {
255
255
  importMapUrl,
256
256
  fileUrl,
257
257
  )
258
+
258
259
  replaceHtmlNode(
259
260
  remoteImportmapScript,
260
261
  `<script type="importmap">${JSON.stringify(
@@ -262,6 +263,9 @@ const inlineImportmapScripts = async ({ logger, htmlAst, fileUrl }) => {
262
263
  null,
263
264
  " ",
264
265
  )}</script>`,
266
+ {
267
+ attributesToIgnore: ["src"],
268
+ },
265
269
  )
266
270
  }),
267
271
  )
@@ -58,11 +58,11 @@ const compileHtmlFile = ({
58
58
 
59
59
  return {
60
60
  compile: async (htmlBeforeCompilation) => {
61
- // parsing html should not throw any syntax error
61
+ // we don't have to try/catch html parsing because:
62
+ // parsing html is fault tolerant (it does not throw any syntax error)
62
63
  // invalid html markup is converted into some valid html
63
64
  // in the worst cases the faulty html string special characters
64
- // will be html encoded.
65
- // All this comment to say we don't have to try/catch html parsing
65
+ // will be html encoded
66
66
  const htmlAst = parseHtmlString(htmlBeforeCompilation)
67
67
  manipulateHtmlAst(htmlAst, {
68
68
  scriptInjections: [
@@ -79,6 +79,11 @@ const compileHtmlFile = ({
79
79
  : []),
80
80
  ],
81
81
  })
82
+ // here we must convert "modulepreload" into "preload"
83
+ if (moduleOutFormat !== "esmodule") {
84
+
85
+ }
86
+
82
87
  const { scripts } = parseHtmlAstRessources(htmlAst)
83
88
 
84
89
  let hasImportmap = false
@@ -106,3 +106,8 @@ export const jsenvToolbarJsFileInfo = {
106
106
  jsenvBuildUrl: resolveUrl("./dist/jsenv_toolbar.js", jsenvCoreDirectoryUrl),
107
107
  sourcemapFilename: "jsenv_toolbar.js.map",
108
108
  }
109
+
110
+ export const jsenvSystemJsFileInfo = {
111
+ url: resolveUrl("./src/internal/runtime/s.js", jsenvCoreDirectoryUrl),
112
+ jsenvRelativeUrl: "./src/internal/runtime/s.js",
113
+ }