@antelopejs/dms-frontend 0.10.2 → 0.10.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/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
const HIDDEN_NAME = /^\./;
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Rolldown's `output
|
|
4
|
+
* Rolldown's `output` for the client build: how it splits the code, and the
|
|
5
|
+
* file names it gives the chunks.
|
|
3
6
|
*
|
|
4
7
|
* By default Rolldown gives every set of dynamic imports that shares a module
|
|
5
8
|
* its own common chunk. The DMS's pages are hundreds of dynamic imports (a
|
|
@@ -9,7 +12,7 @@
|
|
|
9
12
|
* than the single entry file Rollup made, for no byte saved.
|
|
10
13
|
*
|
|
11
14
|
* The `$initial` tag is every module the entry imports statically, directly or
|
|
12
|
-
* not. One group over it puts them in
|
|
15
|
+
* not. One group over it puts them in a single chunk again, and leaves every
|
|
13
16
|
* lazy chunk to Rolldown's own splitting, which a page only loads when it needs
|
|
14
17
|
* it: what an anonymous page loads is still what that page's own routes pull.
|
|
15
18
|
*
|
|
@@ -19,10 +22,26 @@
|
|
|
19
22
|
* uses any of it, and the anonymous pages pay 70 to 115 KB of Brotli for code
|
|
20
23
|
* only the signed-in shell uses.
|
|
21
24
|
*
|
|
22
|
-
*
|
|
25
|
+
* What the lazy chunks share still comes out as about two hundred common
|
|
26
|
+
* chunks, most under 2 KB. `experimentalInlineCommonChunks` copies each one
|
|
27
|
+
* under 8 KB of source into the chunks that import it, behind a shared
|
|
28
|
+
* runtime that keeps one instance of each module: half the files on every
|
|
29
|
+
* page, for 1 to 2% more bytes. It turns on `strictExecutionOrder`, and puts
|
|
30
|
+
* the entry's code in a chunk of its own, which Rolldown names after the
|
|
31
|
+
* folder the build runs in, `.dms-frontend`. The server serves no file whose
|
|
32
|
+
* name starts with a dot, so that chunk and its stylesheet are named `index`.
|
|
33
|
+
*
|
|
34
|
+
* @type {import("vite").Rolldown.OutputOptions}
|
|
23
35
|
*/
|
|
24
|
-
export const
|
|
25
|
-
|
|
36
|
+
export const clientOutput = {
|
|
37
|
+
codeSplitting: {
|
|
38
|
+
groups: [{ name: "entry", tags: ["$initial"] }],
|
|
39
|
+
experimentalInlineCommonChunks: { maxSize: 8192 },
|
|
40
|
+
},
|
|
41
|
+
chunkFileNames: ({ name }) =>
|
|
42
|
+
`assets/${HIDDEN_NAME.test(name) ? "index" : "[name]"}-[hash].js`,
|
|
43
|
+
assetFileNames: ({ names }) =>
|
|
44
|
+
`assets/${names.some((name) => HIDDEN_NAME.test(name)) ? "index" : "[name]"}-[hash][extname]`,
|
|
26
45
|
};
|
|
27
46
|
|
|
28
47
|
const MODULE_ENTRY = /[\\/]dms\.frontend\.[cm]?[jt]sx?$/;
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
normalizePath,
|
|
10
10
|
type Plugin,
|
|
11
11
|
} from "vite";
|
|
12
|
-
import {
|
|
12
|
+
import { clientOutput, onBuildLog } from "./client-chunking.mjs";
|
|
13
13
|
import { recordEntryWeight } from "./entry-weight.mjs";
|
|
14
14
|
import { rejectBackendSources } from "./backend-boundary.mjs";
|
|
15
15
|
import { rejectServerSourcesInClient } from "./client-server-guard.mjs";
|
|
@@ -318,7 +318,7 @@ export default defineConfig({
|
|
|
318
318
|
environments: {
|
|
319
319
|
client: {
|
|
320
320
|
build: {
|
|
321
|
-
rolldownOptions: { output:
|
|
321
|
+
rolldownOptions: { output: clientOutput },
|
|
322
322
|
},
|
|
323
323
|
},
|
|
324
324
|
},
|