@jsenv/core 25.0.0-alpha.2 → 25.0.0-alpha.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/compile_proxy/asset-manifest.json +2 -2
- package/dist/toolbar/asset-manifest.json +9 -9
- package/dist/toolbar_injector/asset-manifest.json +1 -1
- package/package.json +1 -1
- package/src/buildProject.js +9 -0
- package/src/executeTestPlan.js +1 -1
- package/src/internal/building/rollup_plugin_jsenv.js +33 -22
- package/src/jsenvServiceWorkerFinalizer.js +3 -9
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
2
|
+
"assets/compilation.css.map": "assets/compilation.css_e37c747b.map",
|
|
3
|
+
"assets/eventsource.css.map": "assets/eventsource.css_c0c71e7b.map",
|
|
4
|
+
"assets/execution.css.map": "assets/execution.css_f3377c10.map",
|
|
5
|
+
"assets/focus.css.map": "assets/focus.css_896f3e45.map",
|
|
6
|
+
"assets/light-theme.css.map": "assets/light-theme.css_72a60fa3.map",
|
|
7
|
+
"assets/overflow-menu.css.map": "assets/overflow-menu.css_2859d519.map",
|
|
8
|
+
"assets/settings.css.map": "assets/settings.css_61548139.map",
|
|
9
|
+
"assets/toolbar.main.css.map": "assets/toolbar.main.css_269d7ce2.map",
|
|
10
|
+
"assets/tooltip.css.map": "assets/tooltip.css_a94a8bdd.map",
|
|
11
11
|
"toolbar.html": "toolbar_04ba410c.html",
|
|
12
12
|
"toolbar.main2.js.map": "toolbar.main2_6c1b3d82.js.map"
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"assets/jsenv-logo.svg": "assets/jsenv-logo_188b9ca6.svg",
|
|
3
3
|
"toolbar_injector.js": "toolbar_injector_4a48bc53.js",
|
|
4
4
|
"toolbar_injector.js.map": "toolbar_injector_4a48bc53.js.map"
|
|
5
5
|
}
|
package/package.json
CHANGED
package/src/buildProject.js
CHANGED
|
@@ -15,6 +15,15 @@ import {
|
|
|
15
15
|
jsenvNodeRuntimeSupport,
|
|
16
16
|
} from "./internal/generateGroupMap/jsenvRuntimeSupport.js"
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Generate optimized version of source files into a directory
|
|
20
|
+
* @param {string|url} projectDirectoryUrl Root directory of the project
|
|
21
|
+
* @param {string|url} buildDirectoryRelativeUrl Directory where optimized files are written
|
|
22
|
+
* @param {object} entryPoints Describe entry point paths and control their names in the build directory
|
|
23
|
+
* @param {"esmodule" | "systemjs" | "commonjs" | "global"} format Code generated will use this module format
|
|
24
|
+
* @param {object} runtimeSupport Code generated will be compatible with these runtimes
|
|
25
|
+
* @param {boolean} [minify=false] Minify file content in the build directory (HTML, CSS, JS, JSON, SVG)
|
|
26
|
+
*/
|
|
18
27
|
export const buildProject = async ({
|
|
19
28
|
signal = new AbortController().signal,
|
|
20
29
|
handleSIGINT = true,
|
package/src/executeTestPlan.js
CHANGED
|
@@ -22,7 +22,7 @@ import { jsenvCoverageConfig } from "./jsenvCoverageConfig.js"
|
|
|
22
22
|
/**
|
|
23
23
|
* Execute a list of files and log how it goes
|
|
24
24
|
* @param {object} testPlan Configure files to execute and their runtimes (browsers/node)
|
|
25
|
-
* @param {string|url} projectDirectoryUrl Root directory of
|
|
25
|
+
* @param {string|url} projectDirectoryUrl Root directory of the project
|
|
26
26
|
* @param {number} [maxExecutionsInParallel=1] Maximum amount of execution in parallel
|
|
27
27
|
* @param {number} [defaultMsAllocatedPerExecution=30000] Milliseconds after which execution is aborted and considered as failed by timeout
|
|
28
28
|
* @param {number} [cooldownBetweenExecutions=0] Millisecond to wait between each execution
|
|
@@ -182,14 +182,16 @@ export const createRollupPlugins = async ({
|
|
|
182
182
|
projectDirectoryUrl,
|
|
183
183
|
)
|
|
184
184
|
|
|
185
|
-
//
|
|
186
|
-
let
|
|
185
|
+
// Object mapping project relative urls to build relative urls
|
|
186
|
+
let buildMappings = {}
|
|
187
|
+
// Object mapping ressource names to build relative urls
|
|
188
|
+
let ressourceMappings = {}
|
|
187
189
|
|
|
188
190
|
const ressourcesReferencedByJs = []
|
|
189
191
|
const createImportMapForFilesUsedInJs = () => {
|
|
190
192
|
const topLevelMappings = {}
|
|
191
193
|
ressourcesReferencedByJs.sort(comparePathnames).forEach((ressourceName) => {
|
|
192
|
-
const buildRelativeUrl =
|
|
194
|
+
const buildRelativeUrl = ressourceMappings[ressourceName]
|
|
193
195
|
if (
|
|
194
196
|
ressourceName &&
|
|
195
197
|
buildRelativeUrl &&
|
|
@@ -203,12 +205,6 @@ export const createRollupPlugins = async ({
|
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
|
|
206
|
-
// an object where keys are build relative urls
|
|
207
|
-
// and values rollup chunk or asset
|
|
208
|
-
// we need this because we sometimes tell rollup
|
|
209
|
-
// that a file.fileName is something while it's not really this
|
|
210
|
-
// because of remapping
|
|
211
|
-
let buildMappings = {}
|
|
212
208
|
let rollupBuild
|
|
213
209
|
|
|
214
210
|
const EMPTY_CHUNK_URL = resolveUrl("__empty__", projectDirectoryUrl)
|
|
@@ -1390,7 +1386,7 @@ export const createRollupPlugins = async ({
|
|
|
1390
1386
|
buildMappings[originalProjectRelativeUrl] =
|
|
1391
1387
|
jsRessource.buildRelativeUrl
|
|
1392
1388
|
}
|
|
1393
|
-
|
|
1389
|
+
ressourceMappings[jsRessource.fileName] = jsRessource.buildRelativeUrl
|
|
1394
1390
|
})
|
|
1395
1391
|
// wait for asset build relative urls
|
|
1396
1392
|
// to ensure the importmap will contain remappings for them
|
|
@@ -1402,7 +1398,7 @@ export const createRollupPlugins = async ({
|
|
|
1402
1398
|
})
|
|
1403
1399
|
if (ressource && !ressource.isJsModule) {
|
|
1404
1400
|
await ressource.getReadyPromise()
|
|
1405
|
-
|
|
1401
|
+
ressourceMappings[ressourceName] = ressource.buildRelativeUrl
|
|
1406
1402
|
}
|
|
1407
1403
|
}),
|
|
1408
1404
|
)
|
|
@@ -1456,7 +1452,7 @@ export const createRollupPlugins = async ({
|
|
|
1456
1452
|
// in case sourcemap is mutated, we must not trust rollup but the asset builder source instead
|
|
1457
1453
|
rollupFileInfo.source = assetRessource.bufferAfterBuild
|
|
1458
1454
|
assetBuild[buildRelativeUrl] = rollupFileInfo
|
|
1459
|
-
|
|
1455
|
+
ressourceMappings[assetRessource.fileName] = buildRelativeUrl
|
|
1460
1456
|
if (assetRessource.bufferBeforeBuild) {
|
|
1461
1457
|
const originalProjectUrl = asOriginalUrl(assetRessource.url)
|
|
1462
1458
|
const originalProjectRelativeUrl = urlToRelativeUrl(
|
|
@@ -1474,8 +1470,8 @@ export const createRollupPlugins = async ({
|
|
|
1474
1470
|
}
|
|
1475
1471
|
rollupBuild = sortObjectByPathnames(rollupBuild)
|
|
1476
1472
|
// fill "buildFileContents", "buildInlineFilesContents"
|
|
1477
|
-
// and update "
|
|
1478
|
-
// by ressourceBuilder.rollupBuildEnd
|
|
1473
|
+
// and update "buildMappings"
|
|
1474
|
+
// in case some ressource where inlined by ressourceBuilder.rollupBuildEnd
|
|
1479
1475
|
Object.keys(rollupBuild).forEach((buildRelativeUrl) => {
|
|
1480
1476
|
const rollupFileInfo = rollupBuild[buildRelativeUrl]
|
|
1481
1477
|
const ressource = ressourceBuilder.findRessource((ressource) => {
|
|
@@ -1488,7 +1484,6 @@ export const createRollupPlugins = async ({
|
|
|
1488
1484
|
return false
|
|
1489
1485
|
})
|
|
1490
1486
|
if (ressource.isInline) {
|
|
1491
|
-
delete buildManifest[ressource.fileName]
|
|
1492
1487
|
if (ressource.isJsModule) {
|
|
1493
1488
|
delete jsModuleBuild[buildRelativeUrl]
|
|
1494
1489
|
} else {
|
|
@@ -1508,19 +1503,18 @@ export const createRollupPlugins = async ({
|
|
|
1508
1503
|
}
|
|
1509
1504
|
})
|
|
1510
1505
|
|
|
1506
|
+
ressourceMappings = sortObjectByPathnames(ressourceMappings)
|
|
1507
|
+
buildMappings = sortObjectByPathnames(buildMappings)
|
|
1511
1508
|
await visitServiceWorkers({
|
|
1512
1509
|
projectDirectoryUrl,
|
|
1513
1510
|
serviceWorkerUrls,
|
|
1514
1511
|
classicServiceWorkerUrls,
|
|
1515
1512
|
serviceWorkerFinalizer,
|
|
1516
1513
|
buildMappings,
|
|
1517
|
-
|
|
1514
|
+
ressourceMappings,
|
|
1518
1515
|
buildFileContents,
|
|
1519
1516
|
lineBreakNormalization,
|
|
1520
1517
|
})
|
|
1521
|
-
|
|
1522
|
-
buildManifest = sortObjectByPathnames(buildManifest)
|
|
1523
|
-
buildMappings = sortObjectByPathnames(buildMappings)
|
|
1524
1518
|
const buildDuration = Date.now() - buildStartMs
|
|
1525
1519
|
buildStats = createBuildStats({
|
|
1526
1520
|
buildFileContents,
|
|
@@ -1560,7 +1554,11 @@ export const createRollupPlugins = async ({
|
|
|
1560
1554
|
rollupBuild,
|
|
1561
1555
|
urlResponseBodyMap: urlLoader.getUrlResponseBodyMap(),
|
|
1562
1556
|
buildMappings,
|
|
1563
|
-
|
|
1557
|
+
ressourceMappings,
|
|
1558
|
+
// Object mapping build relative urls without hash to build relative urls
|
|
1559
|
+
buildManifest: createBuildManifest({
|
|
1560
|
+
buildFileContents,
|
|
1561
|
+
}),
|
|
1564
1562
|
buildImportMap: createImportMapForFilesUsedInJs(),
|
|
1565
1563
|
buildFileContents,
|
|
1566
1564
|
buildInlineFileContents,
|
|
@@ -1573,6 +1571,21 @@ export const createRollupPlugins = async ({
|
|
|
1573
1571
|
}
|
|
1574
1572
|
}
|
|
1575
1573
|
|
|
1574
|
+
const createBuildManifest = ({ buildFileContents }) => {
|
|
1575
|
+
const buildManifest = {}
|
|
1576
|
+
Object.keys(buildFileContents).forEach((buildRelativeUrl) => {
|
|
1577
|
+
const relativeUrlWithoutHash = asFileNameWithoutHash(buildRelativeUrl)
|
|
1578
|
+
buildManifest[relativeUrlWithoutHash] = buildRelativeUrl
|
|
1579
|
+
})
|
|
1580
|
+
return buildManifest
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
const asFileNameWithoutHash = (fileName) => {
|
|
1584
|
+
return fileName.replace(/_[a-z0-9]{8,}(\..*?)?$/, (_, afterHash = "") => {
|
|
1585
|
+
return afterHash
|
|
1586
|
+
})
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1576
1589
|
const prepareEntryPoints = async (
|
|
1577
1590
|
entryPoints,
|
|
1578
1591
|
{
|
|
@@ -1718,7 +1731,6 @@ const visitServiceWorkers = async ({
|
|
|
1718
1731
|
classicServiceWorkerUrls,
|
|
1719
1732
|
serviceWorkerFinalizer,
|
|
1720
1733
|
buildMappings,
|
|
1721
|
-
buildManifest,
|
|
1722
1734
|
buildFileContents,
|
|
1723
1735
|
lineBreakNormalization,
|
|
1724
1736
|
}) => {
|
|
@@ -1745,7 +1757,6 @@ const visitServiceWorkers = async ({
|
|
|
1745
1757
|
let code = buildFileContents[serviceWorkerBuildRelativeUrl]
|
|
1746
1758
|
code = await serviceWorkerFinalizer(code, {
|
|
1747
1759
|
serviceWorkerBuildRelativeUrl,
|
|
1748
|
-
buildManifest,
|
|
1749
1760
|
buildFileContents,
|
|
1750
1761
|
lineBreakNormalization,
|
|
1751
1762
|
})
|
|
@@ -4,20 +4,14 @@ import { generateContentHash } from "./internal/building/url_versioning.js"
|
|
|
4
4
|
|
|
5
5
|
export const jsenvServiceWorkerFinalizer = (
|
|
6
6
|
code,
|
|
7
|
-
{
|
|
8
|
-
serviceWorkerBuildRelativeUrl,
|
|
9
|
-
buildManifest,
|
|
10
|
-
buildFileContents,
|
|
11
|
-
lineBreakNormalization,
|
|
12
|
-
},
|
|
7
|
+
{ serviceWorkerBuildRelativeUrl, buildFileContents, lineBreakNormalization },
|
|
13
8
|
) => {
|
|
14
9
|
const generatedUrlsConfig = {}
|
|
15
|
-
Object.keys(
|
|
16
|
-
if (
|
|
10
|
+
Object.keys(buildFileContents).forEach((buildRelativeUrl) => {
|
|
11
|
+
if (buildRelativeUrl.endsWith(".map")) {
|
|
17
12
|
return
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
const buildRelativeUrl = buildManifest[projectRelativeUrl]
|
|
21
15
|
const buildUrl = resolveUrl(buildRelativeUrl, "file://")
|
|
22
16
|
const serviceWorkerBuildUrl = resolveUrl(
|
|
23
17
|
serviceWorkerBuildRelativeUrl,
|