@sigil-dev/grimoire 0.9.20 → 0.9.22
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/README.md +83 -83
- package/index.ts +50 -48
- package/package.json +16 -5
- package/public/__grimoire__/grimoire-client.js +12 -0
- package/public/__grimoire__/runtime.js +1241 -0
- package/server.ts +22 -20
- package/src/adapters/bun.ts +17 -0
- package/src/adapters/static.ts +41 -0
- package/src/adapters/types.ts +36 -0
- package/src/base.ts +91 -0
- package/src/client/csrf.ts +47 -47
- package/src/client/deferred.ts +179 -179
- package/src/client/enhance.ts +160 -160
- package/src/client/router.ts +870 -833
- package/src/dev/compile-module.ts +211 -211
- package/src/dev/loader.ts +141 -141
- package/src/dev/resolve.ts +70 -70
- package/src/dev/runtime-bundle.ts +51 -51
- package/src/env/modules.ts +62 -62
- package/src/env/required.ts +42 -0
- package/src/env/typegen.ts +61 -61
- package/src/headers.ts +105 -114
- package/src/logger/transports.ts +117 -117
- package/src/rendering/head.ts +49 -49
- package/src/rendering/hydrate.ts +161 -161
- package/src/rendering/images.ts +43 -43
- package/src/rendering/index.ts +755 -745
- package/src/rendering/preload.ts +101 -95
- package/src/rendering/ssrPlugin.ts +108 -108
- package/src/rendering/timing.ts +40 -40
- package/src/routing/router.ts +186 -186
- package/src/routing/scanner.ts +225 -196
- package/src/routing/transform-routes.ts +102 -102
- package/src/server/after-response.ts +206 -194
- package/src/server/asset-cache.ts +57 -55
- package/src/server/build.ts +262 -249
- package/src/server/cached.ts +114 -114
- package/src/server/client-address.ts +82 -82
- package/src/server/client-dir.ts +57 -57
- package/src/server/client-entry.ts +44 -0
- package/src/server/cookie-utils.ts +80 -80
- package/src/server/coordinator.ts +476 -471
- package/src/server/hooks.ts +122 -122
- package/src/server/index.ts +1138 -1022
- package/src/server/plugins.ts +172 -172
- package/src/server/prerender.ts +444 -0
- package/src/server/reserved.ts +17 -0
- package/src/server/resolver.ts +98 -98
- package/src/server/rewrite.ts +28 -0
- package/src/server/warm.ts +91 -91
- package/src/server/with-headers.ts +27 -0
- package/src/server/worker.ts +74 -72
- package/src/testing/dom.ts +73 -0
- package/src/testing/index.ts +169 -0
- package/src/testing/server.ts +162 -0
- package/src/typegen/index.ts +450 -450
- package/src/types.ts +501 -432
- package/test/after-response.test.ts +132 -113
- package/test/asset-cache-policy.test.ts +96 -96
- package/test/base.test.ts +134 -0
- package/test/cached.test.ts +126 -126
- package/test/client-address.test.ts +78 -78
- package/test/client-csrf.test.ts +61 -61
- package/test/client-dir.test.ts +101 -69
- package/test/client-router.test.ts +789 -734
- package/test/coordinator.test.ts +96 -94
- package/test/deferred.test.ts +256 -256
- package/test/dev-loader.test.ts +30 -30
- package/test/env.test.ts +168 -168
- package/test/force-production.test.ts +44 -0
- package/test/images.test.ts +49 -49
- package/test/locals-header.test.ts +61 -0
- package/test/middleware.test.ts +243 -243
- package/test/parser-plugins.test.ts +92 -92
- package/test/plugin-handle.test.ts +62 -62
- package/test/plugin-services-context.test.ts +97 -97
- package/test/preload.test.ts +48 -48
- package/test/prerender.test.ts +353 -0
- package/test/rendering.test.ts +798 -798
- package/test/required-env.test.ts +32 -0
- package/test/rewrite-html.test.ts +90 -0
- package/test/scanning.test.ts +349 -314
- package/test/server.test.ts +640 -619
- package/test/services.test.ts +90 -90
- package/test/streaming.test.ts +378 -378
- package/test/testing-helpers.test.ts +166 -0
- package/test/typegen.test.ts +805 -799
- package/test/warm.test.ts +96 -96
- package/test/worker-context.test.ts +59 -59
- package/test/workspace-files.test.ts +149 -146
- package/test/workspace-versions.test.ts +131 -131
- package/.grimoire/_routes.ts +0 -4
- package/public/__grimoire__/client.js +0 -55
- package/public/__grimoire__/hydrate.js +0 -63
package/src/server/build.ts
CHANGED
|
@@ -1,249 +1,262 @@
|
|
|
1
|
-
import { mkdir } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute, join } from "node:path";
|
|
3
|
-
import { sigil } from "@sigil-dev/compiler/bun";
|
|
4
|
-
import { generateManifest } from "../routing/manifest-gen";
|
|
5
|
-
import type { RouteTree } from "../routing/scanner";
|
|
6
|
-
import { scanRoutes } from "../routing/scanner";
|
|
7
|
-
import { transformRoutes } from "../routing/transform-routes";
|
|
8
|
-
import { generateTypes } from "../typegen";
|
|
9
|
-
import type { BuildResult, GrimoireConfig, GrimoirePlugin } from "../types";
|
|
10
|
-
import { clientDir, pruneClientDir, resetClientDir } from "./client-dir";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
...tree.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
transformRoutes(clientRoutes, compiledDir, "
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { isAbsolute, join } from "node:path";
|
|
3
|
+
import { sigil } from "@sigil-dev/compiler/bun";
|
|
4
|
+
import { generateManifest } from "../routing/manifest-gen";
|
|
5
|
+
import type { RouteTree } from "../routing/scanner";
|
|
6
|
+
import { scanRoutes } from "../routing/scanner";
|
|
7
|
+
import { transformRoutes } from "../routing/transform-routes";
|
|
8
|
+
import { generateTypes } from "../typegen";
|
|
9
|
+
import type { BuildResult, GrimoireConfig, GrimoirePlugin } from "../types";
|
|
10
|
+
import { clientDir, pruneClientDir, resetClientDir } from "./client-dir";
|
|
11
|
+
import { recordClientEntry } from "./client-entry";
|
|
12
|
+
import { runHook } from "./plugins";
|
|
13
|
+
import { projectAliases, resolverPlugin } from "./resolver";
|
|
14
|
+
|
|
15
|
+
const makeRoutesPlugin = (manifestPath: string) => ({
|
|
16
|
+
name: "grimoire-routes",
|
|
17
|
+
setup(build: any) {
|
|
18
|
+
build.onResolve({ filter: /^#grimoire-routes$/ }, () => ({
|
|
19
|
+
path: manifestPath,
|
|
20
|
+
}));
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Rebuild the client bundles in dev.
|
|
26
|
+
*
|
|
27
|
+
* `hydrate.js` and the dom bundle are produced once at startup, so any full
|
|
28
|
+
* reload after an edit would otherwise hand the browser pre-edit code. Route
|
|
29
|
+
* files are re-transformed (Bun.build only ever sees plain JS) and the
|
|
30
|
+
* manifests regenerated, which also picks up routes added since startup.
|
|
31
|
+
* Returns the freshly scanned tree so the server can adopt it.
|
|
32
|
+
*/
|
|
33
|
+
export async function rebuildClient(
|
|
34
|
+
config: GrimoireConfig,
|
|
35
|
+
plugins: GrimoirePlugin[] = [],
|
|
36
|
+
): Promise<{ result: BuildResult; tree: RouteTree }> {
|
|
37
|
+
const { routes = "src/routes" } = config;
|
|
38
|
+
const isDev = config.dev ?? false;
|
|
39
|
+
const routesDir = isAbsolute(routes) ? routes : join(process.cwd(), routes);
|
|
40
|
+
|
|
41
|
+
const tree = await scanRoutes(routesDir, process.cwd());
|
|
42
|
+
const compiledDir = join(process.cwd(), ".grimoire/compiled");
|
|
43
|
+
const clientRoutes = [
|
|
44
|
+
...tree.routes.filter((r) => r.type === "page" || r.type === "simple"),
|
|
45
|
+
...tree.layouts.filter((r) => r.type === "layout"),
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const hydrateManifest = join(process.cwd(), ".grimoire/_routes.hydrate.js");
|
|
49
|
+
const domManifest = join(process.cwd(), ".grimoire/_routes.dom.js");
|
|
50
|
+
const [hydrateFiles, domFiles] = await Promise.all([
|
|
51
|
+
transformRoutes(clientRoutes, compiledDir, "hydrate", plugins),
|
|
52
|
+
transformRoutes(clientRoutes, compiledDir, "dom", plugins),
|
|
53
|
+
]);
|
|
54
|
+
await Promise.all([
|
|
55
|
+
Bun.write(
|
|
56
|
+
hydrateManifest,
|
|
57
|
+
generateManifest(clientRoutes, hydrateFiles, tree.paramMatcherFiles),
|
|
58
|
+
),
|
|
59
|
+
Bun.write(
|
|
60
|
+
domManifest,
|
|
61
|
+
generateManifest(clientRoutes, domFiles, tree.paramMatcherFiles),
|
|
62
|
+
),
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
const bundleDir = clientDir();
|
|
66
|
+
|
|
67
|
+
const [hydrateResult, domResult] = await Promise.all([
|
|
68
|
+
Bun.build({
|
|
69
|
+
entrypoints: [join(import.meta.dir, "../rendering/hydrate.ts")],
|
|
70
|
+
outdir: bundleDir,
|
|
71
|
+
naming: { entry: "[name]-[hash].[ext]" },
|
|
72
|
+
// report failures in result.logs instead of throwing past them
|
|
73
|
+
throw: false,
|
|
74
|
+
// lazy route entries in the manifest use dynamic import()
|
|
75
|
+
splitting: true,
|
|
76
|
+
plugins: [
|
|
77
|
+
sigil({ mode: "hydrate", dev: isDev }),
|
|
78
|
+
makeRoutesPlugin(hydrateManifest),
|
|
79
|
+
resolverPlugin(config, "browser"),
|
|
80
|
+
],
|
|
81
|
+
}),
|
|
82
|
+
Bun.build({
|
|
83
|
+
entrypoints: [join(import.meta.dir, "../client/index.ts")],
|
|
84
|
+
outdir: bundleDir,
|
|
85
|
+
naming: { entry: "[name]-[hash].[ext]" },
|
|
86
|
+
// report failures in result.logs instead of throwing past them
|
|
87
|
+
throw: false,
|
|
88
|
+
splitting: true,
|
|
89
|
+
plugins: [
|
|
90
|
+
sigil({ mode: "dom", dev: isDev }),
|
|
91
|
+
makeRoutesPlugin(domManifest),
|
|
92
|
+
resolverPlugin(config, "browser"),
|
|
93
|
+
],
|
|
94
|
+
}),
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
const outputs = [...hydrateResult.outputs, ...domResult.outputs].map(
|
|
98
|
+
(o) => o.path,
|
|
99
|
+
);
|
|
100
|
+
const success = hydrateResult.success && domResult.success;
|
|
101
|
+
// a failed build keeps the last good bundle in place
|
|
102
|
+
if (success) {
|
|
103
|
+
recordClientEntry([...hydrateResult.outputs, ...domResult.outputs]);
|
|
104
|
+
await pruneClientDir(outputs);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
tree,
|
|
109
|
+
result: {
|
|
110
|
+
success,
|
|
111
|
+
outputs,
|
|
112
|
+
errors: [...hydrateResult.logs, ...domResult.logs].map(String),
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export async function buildProject(
|
|
118
|
+
config: GrimoireConfig,
|
|
119
|
+
plugins: GrimoirePlugin[] = [],
|
|
120
|
+
): Promise<{ result: BuildResult; tree: RouteTree }> {
|
|
121
|
+
await runHook(plugins, "onBuildStart");
|
|
122
|
+
|
|
123
|
+
const { routes = "src/routes" } = config;
|
|
124
|
+
const isDev = config.dev ?? false;
|
|
125
|
+
|
|
126
|
+
const routesDir = isAbsolute(routes)
|
|
127
|
+
? routes.replace(/\0/g, "")
|
|
128
|
+
: join(process.cwd(), routes).replace(/\0/g, "");
|
|
129
|
+
const tree = await scanRoutes(routesDir, process.cwd());
|
|
130
|
+
|
|
131
|
+
const outDir = join(process.cwd(), ".grimoire");
|
|
132
|
+
await mkdir(outDir, { recursive: true });
|
|
133
|
+
|
|
134
|
+
await generateTypes(tree, {
|
|
135
|
+
projectRoot: process.cwd(),
|
|
136
|
+
routesDir,
|
|
137
|
+
outDir: join(outDir, "types"),
|
|
138
|
+
aliases: projectAliases(config),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const { generateEnvTypes } = await import("../env/typegen");
|
|
142
|
+
const envTypeDir = join(outDir, "types");
|
|
143
|
+
await mkdir(envTypeDir, { recursive: true });
|
|
144
|
+
await generateEnvTypes(process.cwd(), envTypeDir);
|
|
145
|
+
|
|
146
|
+
const compiledDir = join(outDir, "compiled");
|
|
147
|
+
await mkdir(compiledDir, { recursive: true });
|
|
148
|
+
|
|
149
|
+
const clientRoutes = [
|
|
150
|
+
...tree.routes.filter((r) => r.type === "page" || r.type === "simple"),
|
|
151
|
+
...tree.layouts.filter((r) => r.type === "layout"),
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
const [hydrateFiles, domFiles] = await Promise.all([
|
|
155
|
+
transformRoutes(clientRoutes, compiledDir, "hydrate", plugins),
|
|
156
|
+
transformRoutes(clientRoutes, compiledDir, "dom", plugins),
|
|
157
|
+
]);
|
|
158
|
+
|
|
159
|
+
const hydrateManifest = join(process.cwd(), ".grimoire/_routes.hydrate.js");
|
|
160
|
+
const domManifest = join(process.cwd(), ".grimoire/_routes.dom.js");
|
|
161
|
+
await Promise.all([
|
|
162
|
+
Bun.write(
|
|
163
|
+
hydrateManifest,
|
|
164
|
+
generateManifest(clientRoutes, hydrateFiles, tree.paramMatcherFiles),
|
|
165
|
+
),
|
|
166
|
+
Bun.write(
|
|
167
|
+
domManifest,
|
|
168
|
+
generateManifest(clientRoutes, domFiles, tree.paramMatcherFiles),
|
|
169
|
+
),
|
|
170
|
+
]);
|
|
171
|
+
|
|
172
|
+
const bundleStrategy = config.bundleStrategy ?? "split";
|
|
173
|
+
const bundleDir = clientDir();
|
|
174
|
+
await resetClientDir();
|
|
175
|
+
|
|
176
|
+
if (bundleStrategy === "single") {
|
|
177
|
+
const singleResult = await Bun.build({
|
|
178
|
+
entrypoints: [
|
|
179
|
+
join(import.meta.dir, "../rendering/hydrate.ts"),
|
|
180
|
+
join(import.meta.dir, "../client/index.ts"),
|
|
181
|
+
],
|
|
182
|
+
outdir: bundleDir,
|
|
183
|
+
naming: { entry: "[name]-[hash].[ext]" },
|
|
184
|
+
// report failures in result.logs instead of throwing past them
|
|
185
|
+
throw: false,
|
|
186
|
+
// lazy route entries in the manifest use dynamic import()
|
|
187
|
+
splitting: true,
|
|
188
|
+
plugins: [
|
|
189
|
+
sigil({ mode: "hydrate", dev: isDev }),
|
|
190
|
+
sigil({ mode: "dom", dev: isDev }),
|
|
191
|
+
makeRoutesPlugin(hydrateManifest),
|
|
192
|
+
makeRoutesPlugin(domManifest),
|
|
193
|
+
resolverPlugin(config, "browser"),
|
|
194
|
+
],
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
if (!singleResult.success) {
|
|
198
|
+
for (const log of singleResult.logs) console.error(log);
|
|
199
|
+
} else {
|
|
200
|
+
recordClientEntry(singleResult.outputs);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const result: BuildResult = {
|
|
204
|
+
success: singleResult.success,
|
|
205
|
+
outputs: singleResult.outputs.map((o) => o.path),
|
|
206
|
+
errors: singleResult.logs.map(String),
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
await runHook(plugins, "onBuildEnd", result);
|
|
210
|
+
return { result, tree };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const [hydrateResult, domResult] = await Promise.all([
|
|
214
|
+
Bun.build({
|
|
215
|
+
entrypoints: [join(import.meta.dir, "../rendering/hydrate.ts")],
|
|
216
|
+
outdir: bundleDir,
|
|
217
|
+
naming: { entry: "[name]-[hash].[ext]" },
|
|
218
|
+
// report failures in result.logs instead of throwing past them
|
|
219
|
+
throw: false,
|
|
220
|
+
// lazy route entries in the manifest use dynamic import()
|
|
221
|
+
splitting: true,
|
|
222
|
+
plugins: [
|
|
223
|
+
sigil({ mode: "hydrate", dev: isDev }),
|
|
224
|
+
makeRoutesPlugin(hydrateManifest),
|
|
225
|
+
resolverPlugin(config, "browser"),
|
|
226
|
+
],
|
|
227
|
+
}),
|
|
228
|
+
Bun.build({
|
|
229
|
+
entrypoints: [join(import.meta.dir, "../client/index.ts")],
|
|
230
|
+
outdir: bundleDir,
|
|
231
|
+
naming: { entry: "[name]-[hash].[ext]" },
|
|
232
|
+
// report failures in result.logs instead of throwing past them
|
|
233
|
+
throw: false,
|
|
234
|
+
splitting: true,
|
|
235
|
+
plugins: [
|
|
236
|
+
sigil({ mode: "dom", dev: isDev }),
|
|
237
|
+
makeRoutesPlugin(domManifest),
|
|
238
|
+
resolverPlugin(config, "browser"),
|
|
239
|
+
],
|
|
240
|
+
}),
|
|
241
|
+
]);
|
|
242
|
+
|
|
243
|
+
if (!hydrateResult.success) {
|
|
244
|
+
for (const log of hydrateResult.logs) console.error(log);
|
|
245
|
+
} else {
|
|
246
|
+
recordClientEntry(hydrateResult.outputs);
|
|
247
|
+
}
|
|
248
|
+
if (!domResult.success) {
|
|
249
|
+
for (const log of domResult.logs) console.error(log);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const result: BuildResult = {
|
|
253
|
+
success: hydrateResult.success && domResult.success,
|
|
254
|
+
outputs: [...hydrateResult.outputs, ...domResult.outputs].map(
|
|
255
|
+
(o) => o.path,
|
|
256
|
+
),
|
|
257
|
+
errors: [...hydrateResult.logs, ...domResult.logs].map(String),
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
await runHook(plugins, "onBuildEnd", result);
|
|
261
|
+
return { result, tree };
|
|
262
|
+
}
|