@jsenv/core 24.5.1 → 24.5.2
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/package.json
CHANGED
|
@@ -1560,21 +1560,20 @@ const finalizeServiceWorkers = async ({
|
|
|
1560
1560
|
Object.keys(serviceWorkers).map(async (projectRelativeUrl) => {
|
|
1561
1561
|
const projectUrl = resolveUrl(projectRelativeUrl, "file://")
|
|
1562
1562
|
projectRelativeUrl = urlToRelativeUrl(projectUrl, "file://")
|
|
1563
|
-
const
|
|
1564
|
-
if (!
|
|
1563
|
+
const serviceWorkerBuildRelativeUrl = buildMappings[projectRelativeUrl]
|
|
1564
|
+
if (!serviceWorkerBuildRelativeUrl) {
|
|
1565
1565
|
throw new Error(
|
|
1566
1566
|
`"${projectRelativeUrl}" service worker file missing in the build`,
|
|
1567
1567
|
)
|
|
1568
1568
|
}
|
|
1569
|
-
const buildFileContent = rollupBuild[
|
|
1570
|
-
rollupBuild[
|
|
1571
|
-
buildFileContent,
|
|
1572
|
-
|
|
1569
|
+
const buildFileContent = rollupBuild[serviceWorkerBuildRelativeUrl].source
|
|
1570
|
+
rollupBuild[serviceWorkerBuildRelativeUrl].source =
|
|
1571
|
+
serviceWorkerFinalizer(buildFileContent, {
|
|
1572
|
+
serviceWorkerBuildRelativeUrl,
|
|
1573
1573
|
buildManifest,
|
|
1574
1574
|
rollupBuild,
|
|
1575
1575
|
lineBreakNormalization,
|
|
1576
|
-
}
|
|
1577
|
-
)
|
|
1576
|
+
})
|
|
1578
1577
|
}),
|
|
1579
1578
|
)
|
|
1580
1579
|
}
|
|
@@ -1,19 +1,36 @@
|
|
|
1
|
+
import { resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
|
|
2
|
+
|
|
1
3
|
import { generateContentHash } from "./internal/building/url-versioning.js"
|
|
2
4
|
|
|
3
5
|
export const jsenvServiceWorkerFinalizer = (
|
|
4
6
|
code,
|
|
5
|
-
{
|
|
7
|
+
{
|
|
8
|
+
serviceWorkerBuildRelativeUrl,
|
|
9
|
+
buildManifest,
|
|
10
|
+
rollupBuild,
|
|
11
|
+
lineBreakNormalization,
|
|
12
|
+
},
|
|
6
13
|
) => {
|
|
7
14
|
const generatedUrlsConfig = {}
|
|
8
15
|
Object.keys(buildManifest).forEach((projectRelativeUrl) => {
|
|
9
16
|
if (projectRelativeUrl.endsWith(".map")) {
|
|
10
17
|
return
|
|
11
18
|
}
|
|
19
|
+
|
|
12
20
|
const buildRelativeUrl = buildManifest[projectRelativeUrl]
|
|
21
|
+
const buildUrl = resolveUrl(buildRelativeUrl, "file://")
|
|
22
|
+
const serviceWorkerBuildUrl = resolveUrl(
|
|
23
|
+
serviceWorkerBuildRelativeUrl,
|
|
24
|
+
"file://",
|
|
25
|
+
)
|
|
26
|
+
const urlRelativeToServiceWorker = urlToRelativeUrl(
|
|
27
|
+
buildUrl,
|
|
28
|
+
serviceWorkerBuildUrl,
|
|
29
|
+
)
|
|
13
30
|
const versioned = fileNameContainsHash(buildRelativeUrl)
|
|
14
31
|
const rollupFile = rollupBuild[buildRelativeUrl]
|
|
15
32
|
|
|
16
|
-
generatedUrlsConfig[
|
|
33
|
+
generatedUrlsConfig[urlRelativeToServiceWorker] = {
|
|
17
34
|
versioned,
|
|
18
35
|
...(versioned
|
|
19
36
|
? {}
|