@jsenv/core 24.4.1 → 24.4.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.
- package/dist/browser_runtime/asset-manifest.json +3 -0
- package/dist/browser_runtime/{browser_runtime-fbd309a1.js → browser_runtime-015d0fc5.js} +94 -1
- package/dist/browser_runtime/{browser_runtime-fbd309a1.js.map → browser_runtime-015d0fc5.js.map} +11 -3
- package/dist/build_manifest.js +5 -5
- package/dist/compile_proxy/asset-manifest.json +4 -0
- package/dist/compile_proxy/assets/{s.js-749702e8.map → s.js-55849eca.map} +14 -4
- package/dist/compile_proxy/{compile_proxy-405777e6.html → compile_proxy-2eabd1f7.html} +99 -4
- package/dist/compile_proxy/{compile_proxy.html__inline__20-39c0801c.js.map → compile_proxy.html__inline__20-672ba17c.js.map} +0 -0
- package/dist/event_source_client/asset-manifest.json +3 -0
- package/dist/redirector/asset-manifest.json +4 -0
- package/dist/{toolbar/assets/s.js-749702e8.map → redirector/assets/s.js-55849eca.map} +14 -4
- package/dist/redirector/{redirector-237cd168.html → redirector-3029c4d3.html} +99 -4
- package/dist/redirector/{redirector.html__inline__15-33acb0b9.js.map → redirector.html__inline__15-4d453af0.js.map} +0 -0
- package/dist/toolbar/asset-manifest.json +13 -0
- package/dist/{redirector/assets/s.js-749702e8.map → toolbar/assets/s.js-55849eca.map} +14 -4
- package/dist/toolbar/{toolbar-29e91dcd.html → toolbar-40bcd3a0.html} +94 -1
- package/dist/toolbar_injector/asset-manifest.json +4 -0
- package/dist/toolbar_injector/{toolbar_injector-0af91b43.js → toolbar_injector-0a9d5d4c.js} +2 -2
- package/dist/toolbar_injector/{toolbar_injector-0af91b43.js.map → toolbar_injector-0a9d5d4c.js.map} +2 -2
- package/package.json +10 -18
- package/src/internal/building/buildUsingRollup.js +2 -2
- package/src/internal/building/createJsenvRollupPlugin.js +67 -41
- package/src/internal/building/css/parseCssRessource.js +4 -1
- package/src/internal/building/html/parseHtmlRessource.js +16 -3
- package/src/internal/building/js/parseJsRessource.js +2 -0
- package/src/internal/building/ressource_builder.js +27 -37
- package/src/internal/building/ressource_builder_util.js +10 -137
- package/src/internal/building/svg/parseSvgRessource.js +2 -0
- package/src/internal/building/url_loader.js +3 -1
- package/src/internal/building/webmanifest/parseWebmanifestRessource.js +2 -1
- package/src/internal/runtime/s.js +83 -1
- package/dist/browser_system/browser_system-29eda202.js +0 -5160
- package/dist/browser_system/browser_system-29eda202.js.map +0 -1065
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extname } from "node:path"
|
|
2
|
+
import MagicString from "magic-string"
|
|
2
3
|
import { normalizeImportMap } from "@jsenv/importmap"
|
|
3
4
|
import { isSpecifierForNodeCoreModule } from "@jsenv/importmap/src/isSpecifierForNodeCoreModule.js"
|
|
4
5
|
import { createDetailedMessage, loggerToLogLevel } from "@jsenv/logger"
|
|
@@ -205,7 +206,14 @@ export const createJsenvRollupPlugin = async ({
|
|
|
205
206
|
fileName,
|
|
206
207
|
})
|
|
207
208
|
}
|
|
209
|
+
// rollup expects an input option, if we provide only an html file
|
|
210
|
+
// without any script type module in it, we won't emit "chunk" and rollup will throw.
|
|
211
|
+
// It is valid to build an html not referencing any js (rare but valid)
|
|
212
|
+
// In that case jsenv emits an empty chunk and discards rollup warning about it
|
|
213
|
+
// This chunk is later ignored in "generateBundle" hook
|
|
214
|
+
let atleastOneChunkEmitted = false
|
|
208
215
|
const emitChunk = (chunk) => {
|
|
216
|
+
atleastOneChunkEmitted = true
|
|
209
217
|
return rollupEmitFile({
|
|
210
218
|
type: "chunk",
|
|
211
219
|
...chunk,
|
|
@@ -444,12 +452,6 @@ export const createJsenvRollupPlugin = async ({
|
|
|
444
452
|
})
|
|
445
453
|
}
|
|
446
454
|
|
|
447
|
-
// rollup expects an input option, if we provide only an html file
|
|
448
|
-
// without any script type module in it, we won't emit "chunk" and rollup will throw.
|
|
449
|
-
// It is valid to build an html not referencing any js (rare but valid)
|
|
450
|
-
// In that case jsenv emits an empty chunk and discards rollup warning about it
|
|
451
|
-
// This chunk is later ignored in "generateBundle" hook
|
|
452
|
-
let atleastOneChunkEmitted = false
|
|
453
455
|
ressourceBuilder = createRessourceBuilder(
|
|
454
456
|
{
|
|
455
457
|
urlFetcher,
|
|
@@ -555,15 +557,11 @@ export const createJsenvRollupPlugin = async ({
|
|
|
555
557
|
emitChunk,
|
|
556
558
|
emitAsset,
|
|
557
559
|
setAssetSource,
|
|
558
|
-
|
|
559
|
-
jsModuleUrl,
|
|
560
|
-
jsModuleIsInline,
|
|
561
|
-
jsModuleSource,
|
|
562
|
-
}) => {
|
|
563
|
-
atleastOneChunkEmitted = true
|
|
560
|
+
onJsModule: ({ ressource, jsModuleUrl, jsModuleIsInline }) => {
|
|
564
561
|
if (jsModuleIsInline) {
|
|
565
|
-
inlineModuleScripts[jsModuleUrl] =
|
|
562
|
+
inlineModuleScripts[jsModuleUrl] = ressource
|
|
566
563
|
}
|
|
564
|
+
|
|
567
565
|
urlImporterMap[jsModuleUrl] = {
|
|
568
566
|
url: resolveUrl(
|
|
569
567
|
entryPointsPrepared[0].entryProjectRelativeUrl,
|
|
@@ -573,6 +571,15 @@ export const createJsenvRollupPlugin = async ({
|
|
|
573
571
|
column: undefined,
|
|
574
572
|
}
|
|
575
573
|
jsModulesFromEntry[asRollupUrl(jsModuleUrl)] = true
|
|
574
|
+
const name = urlToBasename(jsModuleUrl)
|
|
575
|
+
const rollupReferenceId = emitChunk({
|
|
576
|
+
id: asRollupUrl(jsModuleUrl),
|
|
577
|
+
name,
|
|
578
|
+
})
|
|
579
|
+
return {
|
|
580
|
+
name,
|
|
581
|
+
rollupReferenceId,
|
|
582
|
+
}
|
|
576
583
|
},
|
|
577
584
|
lineBreakNormalization,
|
|
578
585
|
},
|
|
@@ -587,7 +594,6 @@ export const createJsenvRollupPlugin = async ({
|
|
|
587
594
|
entryBuffer,
|
|
588
595
|
}) => {
|
|
589
596
|
if (entryContentType === "application/javascript") {
|
|
590
|
-
atleastOneChunkEmitted = true
|
|
591
597
|
emitChunk({
|
|
592
598
|
id: ensureRelativeUrlNotation(entryProjectRelativeUrl),
|
|
593
599
|
name: urlToBasename(`file:///${entryBuildRelativeUrl}`),
|
|
@@ -620,6 +626,7 @@ export const createJsenvRollupPlugin = async ({
|
|
|
620
626
|
},
|
|
621
627
|
),
|
|
622
628
|
)
|
|
629
|
+
|
|
623
630
|
if (!atleastOneChunkEmitted) {
|
|
624
631
|
emitChunk({
|
|
625
632
|
id: EMPTY_CHUNK_URL,
|
|
@@ -790,6 +797,7 @@ export const createJsenvRollupPlugin = async ({
|
|
|
790
797
|
// otherwise rollup would never concat module together
|
|
791
798
|
referenceShouldNotEmitChunk: jsConcatenation,
|
|
792
799
|
contentTypeExpected: "application/javascript",
|
|
800
|
+
referenceLabel: "static or dynamic import",
|
|
793
801
|
referenceUrl: importer.url,
|
|
794
802
|
referenceColumn: importer.column,
|
|
795
803
|
referenceLine: importer.line,
|
|
@@ -826,6 +834,7 @@ export const createJsenvRollupPlugin = async ({
|
|
|
826
834
|
const { line, column } = importNode.loc.start
|
|
827
835
|
const reference =
|
|
828
836
|
await ressourceBuilder.createReferenceFoundInJsModule({
|
|
837
|
+
referenceLabel: "URL + import.meta.url",
|
|
829
838
|
jsUrl: url,
|
|
830
839
|
jsLine: line,
|
|
831
840
|
jsColumn: column,
|
|
@@ -939,6 +948,7 @@ export const createJsenvRollupPlugin = async ({
|
|
|
939
948
|
if (importAssertionSupportedByRuntime) {
|
|
940
949
|
const reference =
|
|
941
950
|
await ressourceBuilder.createReferenceFoundInJsModule({
|
|
951
|
+
referenceLabel: "import assertion",
|
|
942
952
|
isImportAssertion: true,
|
|
943
953
|
jsUrl: url,
|
|
944
954
|
jsLine: line,
|
|
@@ -991,7 +1001,6 @@ export const createJsenvRollupPlugin = async ({
|
|
|
991
1001
|
},
|
|
992
1002
|
})
|
|
993
1003
|
if (mutations.length > 0) {
|
|
994
|
-
const { default: MagicString } = await import("magic-string")
|
|
995
1004
|
const magicString = new MagicString(code)
|
|
996
1005
|
mutations.forEach((mutation) => {
|
|
997
1006
|
mutation(magicString)
|
|
@@ -1071,30 +1080,32 @@ export const createJsenvRollupPlugin = async ({
|
|
|
1071
1080
|
// as rollup rightfully prevent late js emission
|
|
1072
1081
|
Object.keys(rollupResult).forEach((fileName) => {
|
|
1073
1082
|
const file = rollupResult[fileName]
|
|
1074
|
-
if (file.type !== "chunk") {
|
|
1075
|
-
return
|
|
1076
|
-
}
|
|
1077
1083
|
|
|
1078
|
-
|
|
1079
|
-
if (
|
|
1084
|
+
// there is 3 types of file: "placeholder", "asset", "chunk"
|
|
1085
|
+
if (file.type === "asset") {
|
|
1080
1086
|
return
|
|
1081
1087
|
}
|
|
1082
1088
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1089
|
+
if (file.type === "chunk") {
|
|
1090
|
+
const { facadeModuleId } = file
|
|
1091
|
+
if (facadeModuleId === EMPTY_CHUNK_URL) {
|
|
1092
|
+
return
|
|
1093
|
+
}
|
|
1094
|
+
const fileCopy = { ...file }
|
|
1095
|
+
if (facadeModuleId) {
|
|
1096
|
+
fileCopy.url = asServerUrl(facadeModuleId)
|
|
1097
|
+
} else {
|
|
1098
|
+
const sourcePath = file.map.sources[file.map.sources.length - 1]
|
|
1099
|
+
const fileBuildUrl = resolveUrl(file.fileName, buildDirectoryUrl)
|
|
1100
|
+
const originalProjectUrl = resolveUrl(sourcePath, fileBuildUrl)
|
|
1101
|
+
fileCopy.url = asCompiledServerUrl(originalProjectUrl, {
|
|
1102
|
+
projectDirectoryUrl,
|
|
1103
|
+
compileServerOrigin,
|
|
1104
|
+
compileDirectoryRelativeUrl,
|
|
1105
|
+
})
|
|
1106
|
+
}
|
|
1107
|
+
jsChunks[fileName] = fileCopy
|
|
1095
1108
|
}
|
|
1096
|
-
|
|
1097
|
-
jsChunks[fileName] = fileCopy
|
|
1098
1109
|
})
|
|
1099
1110
|
await ensureTopLevelAwaitTranspilationIfNeeded({
|
|
1100
1111
|
format,
|
|
@@ -1110,6 +1121,16 @@ export const createJsenvRollupPlugin = async ({
|
|
|
1110
1121
|
urlVersionningForEntryPoints ||
|
|
1111
1122
|
!file.isEntry
|
|
1112
1123
|
|
|
1124
|
+
if (file.url in inlineModuleScripts && format === "systemjs") {
|
|
1125
|
+
const magicString = new MagicString(file.code)
|
|
1126
|
+
magicString.overwrite(
|
|
1127
|
+
0,
|
|
1128
|
+
"System.register([".length,
|
|
1129
|
+
`System.register("${fileName}", [`,
|
|
1130
|
+
)
|
|
1131
|
+
file.code = magicString.toString()
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1113
1134
|
if (urlVersioning) {
|
|
1114
1135
|
if (canBeVersioned && useImportMapToMaximizeCacheReuse) {
|
|
1115
1136
|
buildRelativeUrl = computeBuildRelativeUrl(
|
|
@@ -1134,18 +1155,20 @@ export const createJsenvRollupPlugin = async ({
|
|
|
1134
1155
|
originalProjectUrl,
|
|
1135
1156
|
projectDirectoryUrl,
|
|
1136
1157
|
)
|
|
1137
|
-
|
|
1138
|
-
jsModuleBuild[buildRelativeUrl] = file
|
|
1139
|
-
|
|
1140
1158
|
const jsRessource = ressourceBuilder.findRessource(
|
|
1141
1159
|
(ressource) => ressource.url === file.url,
|
|
1142
1160
|
)
|
|
1143
1161
|
if (jsRessource && jsRessource.isInline) {
|
|
1162
|
+
if (format === "systemjs") {
|
|
1163
|
+
markBuildRelativeUrlAsUsedByJs(buildRelativeUrl)
|
|
1164
|
+
}
|
|
1144
1165
|
buildInlineFileContents[buildRelativeUrl] = file.code
|
|
1145
1166
|
} else {
|
|
1146
1167
|
markBuildRelativeUrlAsUsedByJs(buildRelativeUrl)
|
|
1147
1168
|
buildMappings[originalProjectRelativeUrl] = buildRelativeUrl
|
|
1148
1169
|
}
|
|
1170
|
+
|
|
1171
|
+
jsModuleBuild[buildRelativeUrl] = file
|
|
1149
1172
|
})
|
|
1150
1173
|
|
|
1151
1174
|
// it's important to do this to emit late asset
|
|
@@ -1239,10 +1262,13 @@ export const createJsenvRollupPlugin = async ({
|
|
|
1239
1262
|
Object.keys(rollupBuild).forEach((buildRelativeUrl) => {
|
|
1240
1263
|
const rollupFileInfo = rollupBuild[buildRelativeUrl]
|
|
1241
1264
|
const ressource = ressourceBuilder.findRessource((ressource) => {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
)
|
|
1265
|
+
if (ressource.buildRelativeUrl === buildRelativeUrl) {
|
|
1266
|
+
return true
|
|
1267
|
+
}
|
|
1268
|
+
if (ressource.url === rollupFileInfo.url) {
|
|
1269
|
+
return true
|
|
1270
|
+
}
|
|
1271
|
+
return false
|
|
1246
1272
|
})
|
|
1247
1273
|
if (ressource && ressource.isInline) {
|
|
1248
1274
|
const fileName = buildRelativeUrlToFileName(buildRelativeUrl)
|
|
@@ -27,6 +27,7 @@ export const parseCssRessource = async (
|
|
|
27
27
|
let sourcemapReference
|
|
28
28
|
if (cssSourcemapUrl) {
|
|
29
29
|
sourcemapReference = notifyReferenceFound({
|
|
30
|
+
referenceLabel: "css sourcemaping comment",
|
|
30
31
|
contentTypeExpected: ["application/json", "application/octet-stream"],
|
|
31
32
|
ressourceSpecifier: cssSourcemapUrl,
|
|
32
33
|
// we don't really know the line or column
|
|
@@ -39,6 +40,7 @@ export const parseCssRessource = async (
|
|
|
39
40
|
map = JSON.parse(String(sourcemapReference.ressource.bufferBeforeBuild))
|
|
40
41
|
} else {
|
|
41
42
|
sourcemapReference = notifyReferenceFound({
|
|
43
|
+
referenceLabel: "css sourcemaping comment",
|
|
42
44
|
contentType: "application/octet-stream",
|
|
43
45
|
ressourceSpecifier: `${urlToFilename(cssRessource.url)}.map`,
|
|
44
46
|
isPlaceholder: true,
|
|
@@ -54,6 +56,7 @@ export const parseCssRessource = async (
|
|
|
54
56
|
const atImportReferences = []
|
|
55
57
|
atImports.forEach((atImport) => {
|
|
56
58
|
const importReference = notifyReferenceFound({
|
|
59
|
+
referenceLabel: "css @import",
|
|
57
60
|
ressourceSpecifier: atImport.specifier,
|
|
58
61
|
...cssNodeToReferenceLocation(atImport.urlDeclarationNode),
|
|
59
62
|
})
|
|
@@ -64,8 +67,8 @@ export const parseCssRessource = async (
|
|
|
64
67
|
if (urlDeclaration.specifier[0] === "#") {
|
|
65
68
|
return
|
|
66
69
|
}
|
|
67
|
-
|
|
68
70
|
const urlReference = notifyReferenceFound({
|
|
71
|
+
referenceLabel: "css url",
|
|
69
72
|
ressourceSpecifier: urlDeclaration.specifier,
|
|
70
73
|
...cssNodeToReferenceLocation(urlDeclaration.urlDeclarationNode),
|
|
71
74
|
})
|
|
@@ -179,6 +179,7 @@ const regularScriptSrcVisitor = (
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
const remoteScriptReference = notifyReferenceFound({
|
|
182
|
+
referenceLabel: "html script",
|
|
182
183
|
contentTypeExpected: "application/javascript",
|
|
183
184
|
ressourceSpecifier: srcAttribute.value,
|
|
184
185
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
@@ -244,6 +245,7 @@ const regularScriptTextNodeVisitor = (
|
|
|
244
245
|
`${urlToFilename(htmlRessource.url)}__inline__[id].js`,
|
|
245
246
|
)
|
|
246
247
|
const jsReference = notifyReferenceFound({
|
|
248
|
+
referenceLabel: "html inline script",
|
|
247
249
|
contentTypeExpected: "application/javascript",
|
|
248
250
|
ressourceSpecifier,
|
|
249
251
|
...referenceLocationFromHtmlNode(script),
|
|
@@ -271,6 +273,7 @@ const moduleScriptSrcVisitor = (script, { format, notifyReferenceFound }) => {
|
|
|
271
273
|
}
|
|
272
274
|
|
|
273
275
|
const remoteScriptReference = notifyReferenceFound({
|
|
276
|
+
referenceLabel: "html module script",
|
|
274
277
|
contentTypeExpected: "application/javascript",
|
|
275
278
|
ressourceSpecifier: srcAttribute.value,
|
|
276
279
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
@@ -295,7 +298,7 @@ const moduleScriptSrcVisitor = (script, { format, notifyReferenceFound }) => {
|
|
|
295
298
|
let jsString = String(bufferAfterBuild)
|
|
296
299
|
|
|
297
300
|
// at this stage, for some reason the sourcemap url is not in the js
|
|
298
|
-
// (it will be added
|
|
301
|
+
// (it will be added shortly after by "injectSourcemapInRollupBuild")
|
|
299
302
|
// but we know that a script type module have a sourcemap
|
|
300
303
|
// and will be next to html file
|
|
301
304
|
// with these assumptions we can force the sourcemap url
|
|
@@ -341,6 +344,7 @@ const moduleScriptTextNodeVisitor = (
|
|
|
341
344
|
`${urlToFilename(htmlRessource.url)}__inline__[id].js`,
|
|
342
345
|
)
|
|
343
346
|
const jsReference = notifyReferenceFound({
|
|
347
|
+
referenceLabel: "html inline module script",
|
|
344
348
|
contentTypeExpected: "application/javascript",
|
|
345
349
|
ressourceSpecifier,
|
|
346
350
|
...referenceLocationFromHtmlNode(script),
|
|
@@ -378,6 +382,7 @@ const importmapScriptSrcVisitor = (
|
|
|
378
382
|
}
|
|
379
383
|
|
|
380
384
|
const importmapReference = notifyReferenceFound({
|
|
385
|
+
referenceLabel: "html importmap",
|
|
381
386
|
contentTypeExpected: "application/importmap+json",
|
|
382
387
|
ressourceSpecifier: srcAttribute.value,
|
|
383
388
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
@@ -465,6 +470,7 @@ const importmapScriptTextNodeVisitor = (
|
|
|
465
470
|
}
|
|
466
471
|
|
|
467
472
|
const importmapReference = notifyReferenceFound({
|
|
473
|
+
referenceLabel: "html inline importmap",
|
|
468
474
|
contentTypeExpected: "application/importmap+json",
|
|
469
475
|
ressourceSpecifier: getUniqueNameForInlineHtmlNode(
|
|
470
476
|
script,
|
|
@@ -505,6 +511,7 @@ const linkStylesheetHrefVisitor = (
|
|
|
505
511
|
}
|
|
506
512
|
|
|
507
513
|
const cssReference = notifyReferenceFound({
|
|
514
|
+
referenceLabel: "html stylesheet link",
|
|
508
515
|
contentTypeExpected: "text/css",
|
|
509
516
|
ressourceSpecifier: hrefAttribute.value,
|
|
510
517
|
...referenceLocationFromHtmlNode(link, "href"),
|
|
@@ -574,6 +581,7 @@ const linkHrefVisitor = (
|
|
|
574
581
|
return null
|
|
575
582
|
}
|
|
576
583
|
|
|
584
|
+
const href = hrefAttribute.value
|
|
577
585
|
const relAttribute = getHtmlNodeAttributeByName(link, "rel")
|
|
578
586
|
const rel = relAttribute ? relAttribute.value : undefined
|
|
579
587
|
const isRessourceHint = [
|
|
@@ -598,9 +606,10 @@ const linkHrefVisitor = (
|
|
|
598
606
|
}
|
|
599
607
|
|
|
600
608
|
const linkReference = notifyReferenceFound({
|
|
609
|
+
referenceLabel: rel ? `html ${rel} link href` : `html link href`,
|
|
601
610
|
isRessourceHint,
|
|
602
611
|
contentTypeExpected,
|
|
603
|
-
ressourceSpecifier:
|
|
612
|
+
ressourceSpecifier: href,
|
|
604
613
|
...referenceLocationFromHtmlNode(link, "href"),
|
|
605
614
|
urlVersioningDisabled: contentTypeExpected === "application/manifest+json",
|
|
606
615
|
isJsModule,
|
|
@@ -664,6 +673,7 @@ const styleTextNodeVisitor = (
|
|
|
664
673
|
}
|
|
665
674
|
|
|
666
675
|
const inlineStyleReference = notifyReferenceFound({
|
|
676
|
+
referenceLabel: "html style",
|
|
667
677
|
contentTypeExpected: "text/css",
|
|
668
678
|
ressourceSpecifier: getUniqueNameForInlineHtmlNode(
|
|
669
679
|
style,
|
|
@@ -689,6 +699,7 @@ const imgSrcVisitor = (img, { notifyReferenceFound }) => {
|
|
|
689
699
|
}
|
|
690
700
|
|
|
691
701
|
const srcReference = notifyReferenceFound({
|
|
702
|
+
referenceLabel: "html img src",
|
|
692
703
|
ressourceSpecifier: srcAttribute.value,
|
|
693
704
|
...referenceLocationFromHtmlNode(img, "src"),
|
|
694
705
|
})
|
|
@@ -709,8 +720,9 @@ const srcsetVisitor = (htmlNode, { notifyReferenceFound }) => {
|
|
|
709
720
|
}
|
|
710
721
|
|
|
711
722
|
const srcsetParts = parseSrcset(srcsetAttribute.value)
|
|
712
|
-
const srcsetPartsReferences = srcsetParts.map(({ specifier }) =>
|
|
723
|
+
const srcsetPartsReferences = srcsetParts.map(({ specifier }, index) =>
|
|
713
724
|
notifyReferenceFound({
|
|
725
|
+
referenceLabel: `html srcset ${index}`,
|
|
714
726
|
ressourceSpecifier: specifier,
|
|
715
727
|
...referenceLocationFromHtmlNode(htmlNode, "srcset"),
|
|
716
728
|
}),
|
|
@@ -742,6 +754,7 @@ const sourceSrcVisitor = (source, { notifyReferenceFound }) => {
|
|
|
742
754
|
|
|
743
755
|
const typeAttribute = getHtmlNodeAttributeByName(source, "type")
|
|
744
756
|
const srcReference = notifyReferenceFound({
|
|
757
|
+
referenceLabel: "html source",
|
|
745
758
|
contentTypeExpected: typeAttribute ? typeAttribute.value : undefined,
|
|
746
759
|
ressourceSpecifier: srcAttribute.value,
|
|
747
760
|
...referenceLocationFromHtmlNode(source, "src"),
|
|
@@ -18,6 +18,7 @@ export const parseJsRessource = async (
|
|
|
18
18
|
|
|
19
19
|
if (jsSourcemapUrl) {
|
|
20
20
|
sourcemapReference = notifyReferenceFound({
|
|
21
|
+
referenceLabel: "js sourcemapping comment",
|
|
21
22
|
contentTypeExpected: ["application/json", "application/octet-stream"],
|
|
22
23
|
ressourceSpecifier: jsSourcemapUrl,
|
|
23
24
|
// we don't really know the line or column
|
|
@@ -29,6 +30,7 @@ export const parseJsRessource = async (
|
|
|
29
30
|
})
|
|
30
31
|
} else {
|
|
31
32
|
sourcemapReference = notifyReferenceFound({
|
|
33
|
+
referenceLabel: "js sourcemapping comment",
|
|
32
34
|
contentType: "application/octet-stream",
|
|
33
35
|
ressourceSpecifier: `${urlToFilename(jsUrl)}.map`,
|
|
34
36
|
isPlaceholder: true,
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
urlToRelativeUrl,
|
|
4
4
|
urlIsInsideOf,
|
|
5
5
|
urlToParentUrl,
|
|
6
|
-
urlToBasename,
|
|
7
6
|
urlToFilename,
|
|
8
7
|
} from "@jsenv/filesystem"
|
|
9
8
|
import { createLogger } from "@jsenv/logger"
|
|
@@ -34,10 +33,9 @@ export const createRessourceBuilder = (
|
|
|
34
33
|
asOriginalServerUrl,
|
|
35
34
|
urlToHumanUrl,
|
|
36
35
|
|
|
37
|
-
emitChunk,
|
|
38
36
|
emitAsset,
|
|
39
37
|
setAssetSource,
|
|
40
|
-
|
|
38
|
+
onJsModule,
|
|
41
39
|
resolveRessourceUrl,
|
|
42
40
|
lineBreakNormalization,
|
|
43
41
|
},
|
|
@@ -122,6 +120,7 @@ export const createRessourceBuilder = (
|
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
const createReferenceFoundInJsModule = async ({
|
|
123
|
+
referenceLabel,
|
|
125
124
|
jsUrl,
|
|
126
125
|
jsLine,
|
|
127
126
|
jsColumn,
|
|
@@ -136,6 +135,7 @@ export const createRessourceBuilder = (
|
|
|
136
135
|
isImportAssertion,
|
|
137
136
|
ressourceSpecifier,
|
|
138
137
|
contentTypeExpected,
|
|
138
|
+
referenceLabel,
|
|
139
139
|
referenceUrl: jsUrl,
|
|
140
140
|
referenceLine: jsLine,
|
|
141
141
|
referenceColumn: jsColumn,
|
|
@@ -168,6 +168,7 @@ export const createRessourceBuilder = (
|
|
|
168
168
|
isImportAssertion,
|
|
169
169
|
contentTypeExpected,
|
|
170
170
|
ressourceSpecifier,
|
|
171
|
+
referenceLabel,
|
|
171
172
|
referenceUrl,
|
|
172
173
|
referenceColumn,
|
|
173
174
|
referenceLine,
|
|
@@ -302,6 +303,7 @@ export const createRessourceBuilder = (
|
|
|
302
303
|
isRessourceHint,
|
|
303
304
|
isImportAssertion,
|
|
304
305
|
contentTypeExpected,
|
|
306
|
+
referenceLabel,
|
|
305
307
|
referenceUrl,
|
|
306
308
|
referenceColumn,
|
|
307
309
|
referenceLine,
|
|
@@ -321,12 +323,21 @@ export const createRessourceBuilder = (
|
|
|
321
323
|
|
|
322
324
|
reference.ressource = ressource
|
|
323
325
|
if (fromRollup && ressourceImporter.isEntryPoint) {
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
|
|
326
|
+
// When HTML references JS, ressource builder has emitted the js chunk.
|
|
327
|
+
// so it already knows it exists and is part of references
|
|
328
|
+
// -> no need to push into reference (would incorrectly consider html references js twice)
|
|
329
|
+
// -> no need to log the js ressource (already logged during the HTML parsing)
|
|
327
330
|
} else {
|
|
328
331
|
ressource.references.push(reference)
|
|
329
|
-
ressource.applyReferenceEffects(reference, { isJsModule })
|
|
332
|
+
const effects = ressource.applyReferenceEffects(reference, { isJsModule })
|
|
333
|
+
logger.debug(
|
|
334
|
+
formatFoundReference({
|
|
335
|
+
reference,
|
|
336
|
+
referenceEffects: effects,
|
|
337
|
+
showReferenceSourceLocation,
|
|
338
|
+
shortenUrl,
|
|
339
|
+
}),
|
|
340
|
+
)
|
|
330
341
|
}
|
|
331
342
|
|
|
332
343
|
return reference
|
|
@@ -452,6 +463,7 @@ export const createRessourceBuilder = (
|
|
|
452
463
|
isRessourceHint,
|
|
453
464
|
contentTypeExpected,
|
|
454
465
|
ressourceSpecifier,
|
|
466
|
+
referenceLabel,
|
|
455
467
|
referenceLine,
|
|
456
468
|
referenceColumn,
|
|
457
469
|
|
|
@@ -472,6 +484,7 @@ export const createRessourceBuilder = (
|
|
|
472
484
|
|
|
473
485
|
const dependencyReference = createReference({
|
|
474
486
|
ressourceSpecifier,
|
|
487
|
+
referenceLabel,
|
|
475
488
|
referenceUrl: ressource.url,
|
|
476
489
|
referenceLine,
|
|
477
490
|
referenceColumn,
|
|
@@ -648,18 +661,12 @@ export const createRessourceBuilder = (
|
|
|
648
661
|
}
|
|
649
662
|
}
|
|
650
663
|
|
|
651
|
-
const
|
|
664
|
+
const applyReferenceEffects = (reference, infoFromReference) => {
|
|
652
665
|
const effects = []
|
|
653
666
|
if (ressource.isEntryPoint) {
|
|
654
667
|
if (ressource.contentType === "text/html") {
|
|
655
668
|
effects.push(`parse html to find references`)
|
|
656
669
|
}
|
|
657
|
-
} else {
|
|
658
|
-
effects.push(
|
|
659
|
-
`mark ${urlToHumanUrl(
|
|
660
|
-
ressource.url,
|
|
661
|
-
)} as referenced by ${urlToHumanUrl(reference.referenceUrl)}`,
|
|
662
|
-
)
|
|
663
670
|
}
|
|
664
671
|
|
|
665
672
|
if (reference.isRessourceHint) {
|
|
@@ -708,22 +715,18 @@ export const createRessourceBuilder = (
|
|
|
708
715
|
}
|
|
709
716
|
|
|
710
717
|
const jsModuleUrl = ressource.url
|
|
711
|
-
|
|
712
|
-
|
|
718
|
+
const rollupChunk = onJsModule({
|
|
719
|
+
ressource,
|
|
713
720
|
jsModuleUrl,
|
|
714
721
|
jsModuleIsInline: ressource.isInline,
|
|
715
722
|
jsModuleSource: String(bufferBeforeBuild),
|
|
716
723
|
line: reference.referenceLine,
|
|
717
724
|
column: reference.referenceColumn,
|
|
718
725
|
})
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
name,
|
|
724
|
-
})
|
|
725
|
-
ressource.rollupReferenceId = rollupReferenceId
|
|
726
|
-
effects.push(`emit rollup chunk "${name}" (${rollupReferenceId})`)
|
|
726
|
+
ressource.rollupReferenceId = rollupChunk.rollupReferenceId
|
|
727
|
+
effects.push(
|
|
728
|
+
`emit rollup chunk "${rollupChunk.name}" (${rollupChunk.rollupReferenceId})`,
|
|
729
|
+
)
|
|
727
730
|
return effects
|
|
728
731
|
}
|
|
729
732
|
|
|
@@ -739,22 +742,9 @@ export const createRessourceBuilder = (
|
|
|
739
742
|
effects.push(
|
|
740
743
|
`emit rollup asset "${ressource.relativeUrl}" (${rollupReferenceId})`,
|
|
741
744
|
)
|
|
742
|
-
|
|
743
745
|
return effects
|
|
744
746
|
}
|
|
745
747
|
|
|
746
|
-
const applyReferenceEffects = (reference, infoFromReference) => {
|
|
747
|
-
const referenceEffects = onReference(reference, infoFromReference)
|
|
748
|
-
|
|
749
|
-
logger.debug(
|
|
750
|
-
formatFoundReference({
|
|
751
|
-
reference,
|
|
752
|
-
referenceEffects,
|
|
753
|
-
showReferenceSourceLocation,
|
|
754
|
-
}),
|
|
755
|
-
)
|
|
756
|
-
}
|
|
757
|
-
|
|
758
748
|
Object.assign(ressource, {
|
|
759
749
|
applyReferenceEffects,
|
|
760
750
|
getBufferAvailablePromise,
|