@jsenv/core 24.6.5 → 25.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser_runtime/asset-manifest.json +2 -1
- package/dist/browser_runtime/{browser_runtime-bb0e3aa4.js → browser_runtime_a8097085.js} +1 -1
- package/dist/browser_runtime/{browser_runtime-bb0e3aa4.js.map → browser_runtime_a8097085.js.map} +1 -1
- package/dist/build_manifest.js +6 -6
- package/dist/compile_proxy/asset-manifest.json +2 -1
- package/dist/compile_proxy/{compile_proxy-6eb67db4.html → compile_proxy_e16d7de8.html} +2 -2
- package/dist/compile_proxy/{compile_proxy.html__inline__20-9e168143.js.map → compile_proxy_e3b0c442_9e168143.js.map} +0 -0
- package/dist/event_source_client/asset-manifest.json +2 -1
- package/dist/event_source_client/{event_source_client-9f14c8b9.js → event_source_client_620fbc2c.js} +1 -1
- package/dist/event_source_client/{event_source_client-9f14c8b9.js.map → event_source_client_620fbc2c.js.map} +1 -1
- package/dist/redirector/asset-manifest.json +2 -1
- package/dist/redirector/{redirector-b6ad84bf.html → redirector_2e0c8abe.html} +2 -2
- package/dist/redirector/{redirector.html__inline__15-3a34a156.js.map → redirector_e3b0c442_3a34a156.js.map} +0 -0
- package/dist/toolbar/asset-manifest.json +11 -10
- package/dist/toolbar/assets/{compilation.css-209d68b4.map → compilation.css_e37c747b.map} +1 -1
- package/dist/toolbar/assets/{eventsource.css-38cd0a36.map → eventsource.css_c0c71e7b.map} +1 -1
- package/dist/toolbar/assets/{execution.css-0ebe522f.map → execution.css_f3377c10.map} +1 -1
- package/dist/toolbar/assets/{focus.css-3f9c156d.map → focus.css_896f3e45.map} +1 -1
- package/dist/toolbar/assets/{light-theme.css-78b19a80.map → light-theme.css_72a60fa3.map} +1 -1
- package/dist/toolbar/assets/{overflow-menu.css-d9688a1c.map → overflow-menu.css_2859d519.map} +1 -1
- package/dist/toolbar/assets/{settings.css-2b81b245.map → settings.css_61548139.map} +1 -1
- package/dist/toolbar/assets/{toolbar.main.css-846920e9.map → toolbar.main.css_269d7ce2.map} +9 -9
- package/dist/toolbar/assets/{tooltip.css-03395ee6.map → tooltip.css_a94a8bdd.map} +1 -1
- package/dist/toolbar/{toolbar.main-a5ef2c60.js.map → toolbar.main_a5ef2c60.js.map} +0 -0
- package/dist/toolbar/{toolbar-1fbf8dcb.html → toolbar_412abb83.html} +3 -5
- package/dist/toolbar_injector/asset-manifest.json +3 -2
- package/dist/toolbar_injector/assets/{jsenv-logo-188b9ca6.svg → jsenv-logo_188b9ca6.svg} +0 -0
- package/dist/toolbar_injector/{toolbar_injector-997dbaa0.js → toolbar_injector_4f9c19e5.js} +3 -3
- package/dist/toolbar_injector/{toolbar_injector-997dbaa0.js.map → toolbar_injector_4f9c19e5.js.map} +2 -2
- package/package.json +1 -1
- package/readme.md +2 -2
- package/src/buildProject.js +18 -16
- package/src/internal/building/buildUsingRollup.js +9 -7
- package/src/internal/building/build_logs.js +2 -2
- package/src/internal/building/build_stats.js +11 -1
- package/src/internal/building/html/parseHtmlRessource.js +2 -26
- package/src/internal/building/js/parseJsRessource.js +3 -2
- package/src/internal/building/json_module.js +11 -0
- package/src/internal/building/parseRessource.js +1 -1
- package/src/internal/building/ressource_builder.js +216 -215
- package/src/internal/building/rollup_plugin_jsenv.js +462 -306
- package/src/internal/building/url_loader.js +8 -145
- package/src/internal/building/url_versioning.js +226 -0
- package/src/internal/compiling/compileHtml.js +8 -1
- package/src/jsenvServiceWorkerFinalizer.js +7 -8
- package/src/internal/building/asset_url_versioning.js +0 -50
- package/src/internal/building/rollup_build_sourcemap.js +0 -54
- package/src/internal/building/url-versioning.js +0 -96
- package/src/internal/renderNamePattern.js +0 -6
package/src/buildProject.js
CHANGED
|
@@ -22,7 +22,7 @@ export const buildProject = async ({
|
|
|
22
22
|
logger,
|
|
23
23
|
|
|
24
24
|
projectDirectoryUrl,
|
|
25
|
-
|
|
25
|
+
entryPoints,
|
|
26
26
|
buildDirectoryRelativeUrl,
|
|
27
27
|
buildDirectoryClean = true,
|
|
28
28
|
assetManifestFile = false,
|
|
@@ -57,7 +57,6 @@ export const buildProject = async ({
|
|
|
57
57
|
urlVersioning = format === "systemjs" ||
|
|
58
58
|
format === "esmodule" ||
|
|
59
59
|
format === "global",
|
|
60
|
-
urlVersionningForEntryPoints = false,
|
|
61
60
|
lineBreakNormalization = process.platform === "win32",
|
|
62
61
|
// when jsConcatenation is disabled rollup becomes almost useless
|
|
63
62
|
// except it can still do tree shaking
|
|
@@ -81,6 +80,8 @@ export const buildProject = async ({
|
|
|
81
80
|
workers = {},
|
|
82
81
|
serviceWorkers = {},
|
|
83
82
|
serviceWorkerFinalizer,
|
|
83
|
+
classicWorkers = {},
|
|
84
|
+
classicServiceWorkers = {},
|
|
84
85
|
|
|
85
86
|
env = {},
|
|
86
87
|
protocol,
|
|
@@ -117,10 +118,10 @@ export const buildProject = async ({
|
|
|
117
118
|
projectDirectoryUrl = assertProjectDirectoryUrl({ projectDirectoryUrl })
|
|
118
119
|
await assertProjectDirectoryExists({ projectDirectoryUrl })
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
assertentryPoints({ entryPoints })
|
|
121
122
|
|
|
122
|
-
if (Object.keys(
|
|
123
|
-
logger.error(`
|
|
123
|
+
if (Object.keys(entryPoints).length === 0) {
|
|
124
|
+
logger.error(`entryPoints is an empty object`)
|
|
124
125
|
return {
|
|
125
126
|
rollupBuilds: {},
|
|
126
127
|
}
|
|
@@ -197,7 +198,7 @@ export const buildProject = async ({
|
|
|
197
198
|
buildOperation,
|
|
198
199
|
logger,
|
|
199
200
|
|
|
200
|
-
|
|
201
|
+
entryPoints,
|
|
201
202
|
projectDirectoryUrl,
|
|
202
203
|
compileServerOrigin,
|
|
203
204
|
compileDirectoryRelativeUrl: `${outDirectoryRelativeUrl}${COMPILE_ID_BEST}/`,
|
|
@@ -222,7 +223,6 @@ export const buildProject = async ({
|
|
|
222
223
|
runtimeSupport,
|
|
223
224
|
|
|
224
225
|
urlVersioning,
|
|
225
|
-
urlVersionningForEntryPoints,
|
|
226
226
|
lineBreakNormalization,
|
|
227
227
|
useImportMapToMaximizeCacheReuse,
|
|
228
228
|
preserveEntrySignatures,
|
|
@@ -238,6 +238,8 @@ export const buildProject = async ({
|
|
|
238
238
|
workers,
|
|
239
239
|
serviceWorkers,
|
|
240
240
|
serviceWorkerFinalizer,
|
|
241
|
+
classicWorkers,
|
|
242
|
+
classicServiceWorkers,
|
|
241
243
|
|
|
242
244
|
writeOnFileSystem,
|
|
243
245
|
sourcemapExcludeSources,
|
|
@@ -255,27 +257,27 @@ export const buildProject = async ({
|
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
259
|
|
|
258
|
-
const
|
|
259
|
-
if (typeof
|
|
260
|
-
throw new TypeError(`
|
|
260
|
+
const assertentryPoints = ({ entryPoints }) => {
|
|
261
|
+
if (typeof entryPoints !== "object") {
|
|
262
|
+
throw new TypeError(`entryPoints must be an object, got ${entryPoints}`)
|
|
261
263
|
}
|
|
262
|
-
const keys = Object.keys(
|
|
264
|
+
const keys = Object.keys(entryPoints)
|
|
263
265
|
keys.forEach((key) => {
|
|
264
266
|
if (!key.startsWith("./")) {
|
|
265
267
|
throw new TypeError(
|
|
266
|
-
`unexpected key in
|
|
268
|
+
`unexpected key in entryPoints, all keys must start with ./ but found ${key}`,
|
|
267
269
|
)
|
|
268
270
|
}
|
|
269
271
|
|
|
270
|
-
const value =
|
|
272
|
+
const value = entryPoints[key]
|
|
271
273
|
if (typeof value !== "string") {
|
|
272
274
|
throw new TypeError(
|
|
273
|
-
`unexpected value in
|
|
275
|
+
`unexpected value in entryPoints, all values must be strings found ${value} for key ${key}`,
|
|
274
276
|
)
|
|
275
277
|
}
|
|
276
|
-
if (
|
|
278
|
+
if (value.includes("/")) {
|
|
277
279
|
throw new TypeError(
|
|
278
|
-
`unexpected value in
|
|
280
|
+
`unexpected value in entryPoints, all values must be plain strings (no "/") but found ${value} for key ${key}`,
|
|
279
281
|
)
|
|
280
282
|
}
|
|
281
283
|
})
|
|
@@ -22,7 +22,7 @@ export const buildUsingRollup = async ({
|
|
|
22
22
|
logger,
|
|
23
23
|
|
|
24
24
|
projectDirectoryUrl,
|
|
25
|
-
|
|
25
|
+
entryPoints,
|
|
26
26
|
compileServerOrigin,
|
|
27
27
|
compileDirectoryRelativeUrl,
|
|
28
28
|
buildDirectoryUrl,
|
|
@@ -49,9 +49,10 @@ export const buildUsingRollup = async ({
|
|
|
49
49
|
workers,
|
|
50
50
|
serviceWorkers,
|
|
51
51
|
serviceWorkerFinalizer,
|
|
52
|
+
classicWorkers,
|
|
53
|
+
classicServiceWorkers,
|
|
52
54
|
|
|
53
55
|
urlVersioning,
|
|
54
|
-
urlVersionningForEntryPoints,
|
|
55
56
|
lineBreakNormalization,
|
|
56
57
|
jsConcatenation,
|
|
57
58
|
cssConcatenation,
|
|
@@ -99,7 +100,7 @@ export const buildUsingRollup = async ({
|
|
|
99
100
|
logger,
|
|
100
101
|
|
|
101
102
|
projectDirectoryUrl,
|
|
102
|
-
|
|
103
|
+
entryPoints,
|
|
103
104
|
compileServerOrigin,
|
|
104
105
|
compileDirectoryRelativeUrl,
|
|
105
106
|
buildDirectoryUrl,
|
|
@@ -121,9 +122,10 @@ export const buildUsingRollup = async ({
|
|
|
121
122
|
workers,
|
|
122
123
|
serviceWorkers,
|
|
123
124
|
serviceWorkerFinalizer,
|
|
125
|
+
classicWorkers,
|
|
126
|
+
classicServiceWorkers,
|
|
124
127
|
|
|
125
128
|
urlVersioning,
|
|
126
|
-
urlVersionningForEntryPoints,
|
|
127
129
|
lineBreakNormalization,
|
|
128
130
|
jsConcatenation,
|
|
129
131
|
cssConcatenation,
|
|
@@ -204,7 +206,7 @@ export const buildUsingRollup = async ({
|
|
|
204
206
|
buildFileContents,
|
|
205
207
|
buildInlineFileContents,
|
|
206
208
|
buildStats,
|
|
207
|
-
} = getResult()
|
|
209
|
+
} = await getResult()
|
|
208
210
|
|
|
209
211
|
if (writeOnFileSystem) {
|
|
210
212
|
if (buildDirectoryClean) {
|
|
@@ -264,7 +266,7 @@ const useRollup = async ({
|
|
|
264
266
|
|
|
265
267
|
const rollupInputOptions = {
|
|
266
268
|
// about cache here, we should/could reuse previous rollup call
|
|
267
|
-
// to get the cache from the
|
|
269
|
+
// to get the cache from the entryPoints
|
|
268
270
|
// as shown here: https://rollupjs.org/guide/en#cache
|
|
269
271
|
// it could be passed in arguments to this function
|
|
270
272
|
// however parallelism and having different rollup options per
|
|
@@ -307,7 +309,7 @@ const useRollup = async ({
|
|
|
307
309
|
logger.warn(String(warning))
|
|
308
310
|
},
|
|
309
311
|
// on passe input: [] car c'est le plugin jsenv qui se chargera d'emit des chunks
|
|
310
|
-
// en fonction de
|
|
312
|
+
// en fonction de entryPoints
|
|
311
313
|
// on fait cela car sinon rollup est pénible si on passe un input de type html
|
|
312
314
|
input: [],
|
|
313
315
|
preserveEntrySignatures,
|
|
@@ -5,8 +5,8 @@ import { byteAsFileSize } from "../logs/byteAsFileSize.js"
|
|
|
5
5
|
import { msAsDuration } from "../logs/msAsDuration.js"
|
|
6
6
|
import { stringifyUrlSite } from "./url_trace.js"
|
|
7
7
|
|
|
8
|
-
export const formatBuildStartLog = ({
|
|
9
|
-
const entryFileRelativeUrls = Object.keys(
|
|
8
|
+
export const formatBuildStartLog = ({ entryPoints }) => {
|
|
9
|
+
const entryFileRelativeUrls = Object.keys(entryPoints)
|
|
10
10
|
if (entryFileRelativeUrls.length === 1) {
|
|
11
11
|
return `
|
|
12
12
|
building ${entryFileRelativeUrls[0]}...`
|
|
@@ -59,7 +59,13 @@ const getProjectFileContents = (ressourceBuilder) => {
|
|
|
59
59
|
|
|
60
60
|
Object.keys(ressourceMap).forEach((url) => {
|
|
61
61
|
const ressource = ressourceMap[url]
|
|
62
|
-
const {
|
|
62
|
+
const {
|
|
63
|
+
isInline,
|
|
64
|
+
isExternal,
|
|
65
|
+
isPlaceholder,
|
|
66
|
+
isSourcemap,
|
|
67
|
+
bufferBeforeBuild,
|
|
68
|
+
} = ressource
|
|
63
69
|
if (isInline) {
|
|
64
70
|
// inline ressources are not files
|
|
65
71
|
return
|
|
@@ -80,6 +86,10 @@ const getProjectFileContents = (ressourceBuilder) => {
|
|
|
80
86
|
// to generate it in the build
|
|
81
87
|
return
|
|
82
88
|
}
|
|
89
|
+
if (isSourcemap && !bufferBeforeBuild) {
|
|
90
|
+
// sourcemap generated by rollup do not have bufferBeforeBuild
|
|
91
|
+
return
|
|
92
|
+
}
|
|
83
93
|
projectFileContents[url] = bufferBeforeBuild
|
|
84
94
|
})
|
|
85
95
|
return projectFileContents
|
|
@@ -16,12 +16,7 @@ Or be sure to also reference this url somewhere in the html file like
|
|
|
16
16
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
urlToFilename,
|
|
21
|
-
urlToRelativeUrl,
|
|
22
|
-
resolveUrl,
|
|
23
|
-
urlToParentUrl,
|
|
24
|
-
} from "@jsenv/filesystem"
|
|
19
|
+
import { urlToFilename, urlToRelativeUrl, resolveUrl } from "@jsenv/filesystem"
|
|
25
20
|
|
|
26
21
|
import {
|
|
27
22
|
parseHtmlString,
|
|
@@ -255,7 +250,7 @@ const regularScriptTextNodeVisitor = (
|
|
|
255
250
|
})
|
|
256
251
|
return () => {
|
|
257
252
|
const { bufferAfterBuild } = jsReference.ressource
|
|
258
|
-
textNode.value = bufferAfterBuild
|
|
253
|
+
textNode.value = String(bufferAfterBuild)
|
|
259
254
|
}
|
|
260
255
|
}
|
|
261
256
|
|
|
@@ -359,8 +354,6 @@ const moduleScriptTextNodeVisitor = (
|
|
|
359
354
|
}
|
|
360
355
|
const { bufferAfterBuild } = jsReference.ressource
|
|
361
356
|
const jsText = String(bufferAfterBuild)
|
|
362
|
-
// ici on voudrait pouvoir ajouter le commentaire de la sourcemap
|
|
363
|
-
// sauf que cela se produit un poil plus tard je crois?
|
|
364
357
|
textNode.value = jsText
|
|
365
358
|
}
|
|
366
359
|
}
|
|
@@ -386,23 +379,6 @@ const importmapScriptSrcVisitor = (
|
|
|
386
379
|
contentTypeExpected: "application/importmap+json",
|
|
387
380
|
ressourceSpecifier: srcAttribute.value,
|
|
388
381
|
...referenceLocationFromHtmlNode(script, "src"),
|
|
389
|
-
// here we want to force the fileName for the importmap
|
|
390
|
-
// so that we don't have to rewrite its content
|
|
391
|
-
// the goal is to put the importmap at the same relative path
|
|
392
|
-
// than in the project
|
|
393
|
-
fileNamePattern: () => {
|
|
394
|
-
const importmapReferenceUrl = importmapReference.referenceUrl
|
|
395
|
-
const importmapRessourceUrl = importmapReference.ressource.url
|
|
396
|
-
const importmapUrlRelativeToImporter = urlToRelativeUrl(
|
|
397
|
-
importmapRessourceUrl,
|
|
398
|
-
importmapReferenceUrl,
|
|
399
|
-
)
|
|
400
|
-
const importmapParentRelativeUrl = urlToRelativeUrl(
|
|
401
|
-
urlToParentUrl(resolveUrl(importmapUrlRelativeToImporter, "file://")),
|
|
402
|
-
"file://",
|
|
403
|
-
)
|
|
404
|
-
return `${importmapParentRelativeUrl}[name]-[hash][extname]`
|
|
405
|
-
},
|
|
406
382
|
})
|
|
407
383
|
return ({ getUrlRelativeToImporter }) => {
|
|
408
384
|
const { ressource } = importmapReference
|
|
@@ -103,9 +103,10 @@ export const parseJsRessource = async (
|
|
|
103
103
|
map.file = urlToFilename(jsBuildUrl)
|
|
104
104
|
if (map.sources) {
|
|
105
105
|
map.sources = map.sources.map((source) => {
|
|
106
|
-
const sourceUrl = resolveUrl(source,
|
|
106
|
+
const sourceUrl = resolveUrl(source, jsUrl)
|
|
107
|
+
const sourceOriginalUrl = asOriginalUrl(sourceUrl)
|
|
107
108
|
const sourceUrlRelativeToSourceMap = urlToRelativeUrl(
|
|
108
|
-
|
|
109
|
+
sourceOriginalUrl,
|
|
109
110
|
sourcemapPrecomputedBuildUrl,
|
|
110
111
|
)
|
|
111
112
|
return sourceUrlRelativeToSourceMap
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const convertJsonTextToJavascriptModule = ({ code }) => {
|
|
2
|
+
// here we could do the following
|
|
3
|
+
// return export default jsonText
|
|
4
|
+
// This would return valid js, that would be minified later
|
|
5
|
+
// however we will prefer using JSON.parse because it's faster
|
|
6
|
+
// for js engine to parse JSON than JS
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
code: `export default JSON.parse(${JSON.stringify(code.trim())})`,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -22,7 +22,7 @@ import { parseJsRessource } from "./js/parseJsRessource.js"
|
|
|
22
22
|
import { parseJsonRessource } from "./json/parseJsonRessource.js"
|
|
23
23
|
import { parseWebmanifestRessource } from "./webmanifest/parseWebmanifestRessource.js"
|
|
24
24
|
|
|
25
|
-
export const parseRessource = (
|
|
25
|
+
export const parseRessource = async (
|
|
26
26
|
ressource,
|
|
27
27
|
notifiers,
|
|
28
28
|
{
|