prunelle 0.1.1 → 0.7.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.
Files changed (177) hide show
  1. package/LICENSE +21 -0
  2. package/llms.txt +137 -40
  3. package/package.json +11 -2
  4. package/src/a11y/declaration.ts +373 -0
  5. package/src/a11y/index.ts +477 -0
  6. package/src/a11y/rgaa-map.ts +230 -0
  7. package/src/attrs.ts +11 -3
  8. package/src/build/bundle.ts +89 -41
  9. package/src/build/byte-size.ts +11 -0
  10. package/src/build/client-entries.ts +3 -2
  11. package/src/build/client-plugin.ts +11 -5
  12. package/src/build/client-prune.ts +56 -6
  13. package/src/build/compile.ts +13 -10
  14. package/src/build/ecoindex.ts +238 -0
  15. package/src/build/files.ts +15 -0
  16. package/src/build/first-load.ts +85 -14
  17. package/src/build/graph.ts +29 -39
  18. package/src/build/index.ts +225 -122
  19. package/src/build/island-promote.ts +311 -0
  20. package/src/build/islands.ts +14 -203
  21. package/src/build/manifest.ts +56 -116
  22. package/src/build/output.ts +3 -6
  23. package/src/build/plugin-host.ts +115 -41
  24. package/src/build/precompress.ts +16 -3
  25. package/src/build/prerender.ts +177 -39
  26. package/src/build/reach.ts +200 -0
  27. package/src/build/render-rules.ts +2 -2
  28. package/src/build/report.ts +48 -5
  29. package/src/build/resolve.ts +8 -6
  30. package/src/build/routes.ts +175 -10
  31. package/src/build/static-headers.ts +112 -0
  32. package/src/build/static.ts +139 -39
  33. package/src/build/status-pages.ts +127 -0
  34. package/src/build/style-bundles.ts +526 -0
  35. package/src/cli/check-forms.ts +636 -0
  36. package/src/cli/check-imports.ts +31 -0
  37. package/src/cli/check-links.ts +632 -0
  38. package/src/cli/check-security.ts +64 -0
  39. package/src/cli/check.ts +101 -26
  40. package/src/cli/commands.ts +120 -11
  41. package/src/cli/docs.ts +403 -0
  42. package/src/cli/inspect.ts +105 -15
  43. package/src/cli/mcp-tools.ts +492 -0
  44. package/src/cli/mcp.ts +205 -0
  45. package/src/cli/new.ts +16 -5
  46. package/src/cli/render.ts +416 -0
  47. package/src/cli/upgrade-names.ts +73 -13
  48. package/src/cli/upgrade.ts +156 -22
  49. package/src/compiler/analyze.ts +87 -54
  50. package/src/compiler/browser-globals.ts +140 -17
  51. package/src/compiler/cacheability-private.ts +566 -0
  52. package/src/compiler/cacheability.ts +335 -0
  53. package/src/compiler/compliance-eco.ts +71 -0
  54. package/src/compiler/compliance-rgaa.ts +614 -0
  55. package/src/compiler/compliance-urls.ts +148 -0
  56. package/src/compiler/compliance.ts +407 -352
  57. package/src/compiler/data-keys.ts +199 -192
  58. package/src/compiler/dev-source.ts +87 -0
  59. package/src/compiler/dom-attrs.ts +138 -65
  60. package/src/compiler/dom.ts +517 -442
  61. package/src/compiler/expr-context.ts +260 -81
  62. package/src/compiler/foreign-imports.ts +88 -0
  63. package/src/compiler/mistakes.ts +23 -2
  64. package/src/compiler/props-body.ts +60 -0
  65. package/src/compiler/props.ts +87 -36
  66. package/src/compiler/scope.ts +400 -333
  67. package/src/compiler/server-only.ts +190 -151
  68. package/src/compiler/shared.ts +42 -14
  69. package/src/compiler/signal-reads.ts +6 -2
  70. package/src/compiler/spread-handlers.ts +295 -0
  71. package/src/compiler/ssr-prunelle-tags.ts +27 -14
  72. package/src/compiler/ssr.ts +220 -89
  73. package/src/context.ts +34 -0
  74. package/src/dev/error-log.ts +177 -0
  75. package/src/dev/host-check.ts +32 -0
  76. package/src/dev/index.ts +94 -34
  77. package/src/dev/open-editor.ts +228 -0
  78. package/src/dev/protocol.ts +3 -0
  79. package/src/dev/reload.ts +5 -3
  80. package/src/dev/supervisor.ts +50 -25
  81. package/src/dev/watchers.ts +74 -13
  82. package/src/dom/action.ts +47 -21
  83. package/src/dom/attrs.ts +15 -3
  84. package/src/dom/extras.ts +57 -40
  85. package/src/dom/index.ts +54 -14
  86. package/src/dom/island.ts +102 -68
  87. package/src/dom/loop.ts +66 -32
  88. package/src/eco/declaration.ts +328 -0
  89. package/src/eco/index.ts +69 -0
  90. package/src/index.ts +2 -2
  91. package/src/jsx-runtime.ts +2 -2
  92. package/src/plugins/config.ts +18 -12
  93. package/src/plugins/context.ts +44 -1
  94. package/src/plugins/index.ts +2 -2
  95. package/src/plugins/load.ts +30 -10
  96. package/src/plugins/order.ts +38 -1
  97. package/src/plugins/public.ts +6 -3
  98. package/src/plugins/services.ts +84 -0
  99. package/src/plugins/types.ts +51 -2
  100. package/src/reactivity/graph.ts +10 -0
  101. package/src/reactivity/index.ts +24 -16
  102. package/src/reactivity/selector.ts +31 -4
  103. package/src/reactivity/store.ts +64 -20
  104. package/src/server/action-flash.ts +158 -0
  105. package/src/server/action-protect.ts +199 -0
  106. package/src/server/action-registry.ts +1 -1
  107. package/src/server/action.ts +188 -152
  108. package/src/server/app-secret.ts +63 -0
  109. package/src/server/assets.ts +34 -2
  110. package/src/server/compress.ts +96 -10
  111. package/src/server/consent.ts +59 -22
  112. package/src/server/cookies.ts +16 -2
  113. package/src/server/document.ts +25 -10
  114. package/src/server/env.ts +14 -0
  115. package/src/server/errors.ts +308 -65
  116. package/src/server/form-schema.ts +337 -0
  117. package/src/server/health.ts +275 -0
  118. package/src/server/http.ts +186 -39
  119. package/src/server/index.ts +272 -273
  120. package/src/server/loader.ts +15 -2
  121. package/src/server/page.ts +15 -0
  122. package/src/server/param-matchers.ts +112 -0
  123. package/src/server/plugin-host.ts +125 -88
  124. package/src/server/public.ts +6 -5
  125. package/src/server/rate-limit.ts +102 -36
  126. package/src/server/request-body.ts +1 -1
  127. package/src/server/route-cache.ts +541 -0
  128. package/src/server/route-table.ts +356 -11
  129. package/src/server/router.ts +125 -40
  130. package/src/server/routing.ts +112 -63
  131. package/src/server/sanitize-html.ts +309 -0
  132. package/src/server/security.ts +279 -52
  133. package/src/server/serve-handlers.ts +31 -7
  134. package/src/server/standard-schema.ts +17 -0
  135. package/src/server/start.ts +60 -16
  136. package/src/server/static-dir.ts +91 -12
  137. package/src/server/stream.ts +68 -27
  138. package/src/ssr/consent-banner.ts +58 -0
  139. package/src/ssr/context.ts +106 -8
  140. package/src/ssr/index.ts +151 -4
  141. package/src/ssr/navigation.ts +2 -2
  142. package/src/ssr/region.ts +40 -19
  143. package/src/style.ts +64 -1
  144. package/src/test/browser.ts +28 -13
  145. package/src/test/index.ts +97 -12
  146. package/src/ts-plugin/diagnostics.ts +505 -0
  147. package/src/ts-plugin/fixes.ts +364 -0
  148. package/src/ts-plugin/index.ts +194 -0
  149. package/templates/_shared/AGENTS.md +2 -2
  150. package/templates/_shared/gitignore +5 -0
  151. package/templates/_shared/mcp.json +11 -0
  152. package/templates/_shared/src/routes/legal.tsx +15 -1
  153. package/templates/_shared/tsconfig.json +5 -0
  154. package/templates/app/.env.example +4 -0
  155. package/templates/app/package.json +2 -1
  156. package/templates/app/prunelle.config.ts +2 -0
  157. package/templates/app/src/auth.ts +4 -6
  158. package/templates/app/src/mail.ts +4 -0
  159. package/templates/app/src/routes/_layout.tsx +9 -1
  160. package/templates/app/src/routes/dashboard/index.tsx +42 -8
  161. package/templates/app/src/routes/login.tsx +49 -30
  162. package/templates/app/src/routes/privacy.tsx +25 -0
  163. package/templates/app/src/styles/app.css +8 -1
  164. package/templates/app/tests/app.test.ts +44 -3
  165. package/templates/blog/package.json +1 -1
  166. package/templates/blog/prunelle.config.ts +1 -1
  167. package/templates/blog/src/routes/_layout.tsx +6 -1
  168. package/templates/blog/src/routes/index.tsx +5 -1
  169. package/templates/blog/src/styles/app.css +6 -1
  170. package/templates/fullstack/package.json +1 -1
  171. package/templates/fullstack/src/components/GreetForm.tsx +2 -1
  172. package/templates/fullstack/src/routes/_layout.tsx +4 -0
  173. package/templates/fullstack/src/styles/app.css +11 -1
  174. package/templates/minimal/package.json +1 -1
  175. package/templates/minimal/src/routes/_layout.tsx +4 -0
  176. package/templates/minimal/src/styles/app.css +11 -1
  177. package/ts-plugin.cjs +4277 -0
@@ -2,10 +2,13 @@
2
2
 
3
3
  import type { ModuleAnalysis } from '../compiler/index'
4
4
  import { existsSync, readFileSync, statSync } from 'node:fs'
5
+ import { parseTsx } from '../compiler/analyze'
6
+ import { computeJsxNodes } from '../compiler/ast'
5
7
  import { analyzeModule } from '../compiler/index'
6
8
  import { PrunelleMistake } from '../compiler/mistakes'
7
9
  import { formatCodeFrame, formatDiagnostic, formatLoc } from '../compiler/shared'
8
10
  import { isTsFile, relPosix } from './files'
11
+ import { resolveExportTarget } from './island-promote'
9
12
  import { resolveImportPath } from './resolve'
10
13
 
11
14
  export interface FileStamp {
@@ -41,8 +44,28 @@ export interface BuildCacheStats {
41
44
  serverSkips: number
42
45
  }
43
46
 
47
+ /** An analysis without the AST and what is keyed by its nodes: the cache outlives a build, the AST (many times the size of the source) does not need to. */
48
+ export type SlimAnalysis = Omit<ModuleAnalysis, 'program' | 'jsxNodes' | 'exprContext'>
49
+
50
+ export function slimAnalysis(analysis: ModuleAnalysis): SlimAnalysis {
51
+ const { program: _program, jsxNodes: _jsxNodes, exprContext: _exprContext, ...slim } = analysis
52
+ return slim
53
+ }
54
+
55
+ /** The analysis again, its program and JSX node set parsed together on first use: the node set only matches the program it was computed from. */
56
+ export function reviveAnalysis(slim: SlimAnalysis, code: string): ModuleAnalysis {
57
+ let program: ModuleAnalysis['program'] | undefined
58
+ let jsxNodes: ModuleAnalysis['jsxNodes'] | undefined
59
+ const parsed = (): ModuleAnalysis['program'] => program ??= parseTsx(slim.filename, code)
60
+ return Object.defineProperties({ ...slim } as ModuleAnalysis, {
61
+ program: { get: parsed, enumerable: true, configurable: true },
62
+ jsxNodes: { get: () => jsxNodes ??= slim.hasJsx ? computeJsxNodes(parsed()) : new WeakSet(), enumerable: true, configurable: true },
63
+ exprContext: { value: undefined, writable: true, enumerable: true, configurable: true },
64
+ })
65
+ }
66
+
44
67
  export interface BuildCache {
45
- analyses: Map<string, FileStamp & { code: string, analysis: ModuleAnalysis }>
68
+ analyses: Map<string, FileStamp & { code: string, analysis: SlimAnalysis }>
46
69
  domCompiled: Map<string, FileStamp & { key?: string | undefined, code: string }>
47
70
  ssrCompiled: Map<string, FileStamp & { key: string, code: string }>
48
71
  lastClient?: CachedClientBuild | undefined
@@ -101,7 +124,6 @@ export function stampsMatch(inputStamps: ReadonlyMap<string, FileStamp>): boolea
101
124
  return true
102
125
  }
103
126
 
104
- const MAX_REEXPORT_DEPTH = 8
105
127
 
106
128
  export class ModuleGraph {
107
129
  readonly analyses = new Map<string, ModuleAnalysis>()
@@ -175,14 +197,14 @@ export class ModuleGraph {
175
197
  const cached = stamp === undefined ? undefined : this.cache?.analyses.get(file)
176
198
  let analysis: ModuleAnalysis
177
199
  if (cached !== undefined && cached.mtimeMs === stamp!.mtimeMs && cached.size === stamp!.size) {
178
- analysis = cached.analysis
200
+ analysis = reviveAnalysis(cached.analysis, cached.code)
179
201
  this.sources.set(file, cached.code)
180
202
  }
181
203
  else {
182
204
  const code = this.source(file)
183
205
  analysis = this.analyze(file, code)
184
206
  if (this.cache !== undefined && stamp !== undefined)
185
- this.cache.analyses.set(file, { mtimeMs: stamp.mtimeMs, size: stamp.size, code, analysis })
207
+ this.cache.analyses.set(file, { mtimeMs: stamp.mtimeMs, size: stamp.size, code, analysis: slimAnalysis(analysis) })
186
208
  }
187
209
  this.analyses.set(file, analysis)
188
210
  for (const dep of this.localDeps(file))
@@ -208,40 +230,8 @@ export class ModuleGraph {
208
230
  }
209
231
  }
210
232
 
211
- /** Follows `export { x } from './y'` and `export * from './y'` chains to the module that declares the export. */
212
- exportTarget(file: string, exportName: string, depth = 0, seen = new Set<string>()): { file: string, exportName: string } {
213
- if (depth > MAX_REEXPORT_DEPTH)
214
- return { file, exportName }
215
- const key = `${file}\0${exportName}`
216
- if (seen.has(key))
217
- return { file, exportName }
218
- seen.add(key)
219
-
220
- const analysis = this.load(file)
221
- const direct = analysis.reexports.find(r => r.exported === exportName)
222
- if (direct !== undefined) {
223
- const next = this.resolve(file, direct.source)
224
- if (next !== undefined && isTsFile(next))
225
- return this.exportTarget(next, direct.local, depth + 1, seen)
226
- }
227
-
228
- if (analysis.exportedNames.includes(exportName))
229
- return { file, exportName }
230
-
231
- // Follow `export * from './y'` barrel re-exports (named exports only, per ESM spec `export *` never re-exports `default`).
232
- if (exportName !== 'default') {
233
- for (const re of analysis.reexports) {
234
- if (re.exported !== '*')
235
- continue
236
- const next = this.resolve(file, re.source)
237
- if (next === undefined || !isTsFile(next))
238
- continue
239
- const candidate = this.exportTarget(next, exportName, depth + 1, seen)
240
- if (this.load(candidate.file).exportedNames.includes(candidate.exportName))
241
- return candidate
242
- }
243
- }
244
-
245
- return { file, exportName }
233
+ /** The module that declares `exportName`, following re-export chains and loading each file (parse errors are never swallowed). */
234
+ exportTarget(file: string, exportName: string): { file: string, exportName: string } {
235
+ return resolveExportTarget(this, f => this.load(f), file, exportName) ?? { file, exportName }
246
236
  }
247
237
  }
@@ -6,39 +6,47 @@
6
6
  import type { ComplianceConfig } from '../compiler/compliance'
7
7
  import type { AppRuntimeContext } from '../plugins/context'
8
8
  import type { PrunellePlugin } from '../plugins/index'
9
+ import type { BudgetConfig } from '../plugins/types'
9
10
  import type { BuildCache } from './graph'
10
11
  import type { ActionsByFile } from './islands'
11
12
  import type { BuildManifest } from './manifest'
12
13
  import type { PublicFiles } from './plugin-host'
13
14
  import { copyFileSync, existsSync, mkdirSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
14
15
  import { basename, dirname, join, relative, resolve } from 'node:path'
15
- import { collectProjectComplianceWarnings, shouldEmitWarning } from '../compiler/compliance'
16
+ import { checkAppForms } from '../cli/check-forms'
17
+ import { findCachedRoutePrivateReads } from '../compiler/cacheability'
18
+ import { collectProjectComplianceWarnings, pluginSetsLang, shouldEmitWarning } from '../compiler/compliance'
16
19
  import { formatCodeFrame, formatDiagnostic, formatLoc } from '../compiler/shared'
17
20
  import { createAppContext, loadConfig, resolvePlugins, runWithAppContext } from '../plugins/index'
18
21
  import { actionHash } from '../server/action'
19
- import { buildClient, buildServer, linkOrCopyFile, pluginBunPlugins, standaloneCssFiles } from './bundle'
22
+ import { devFromEnv } from '../server/env'
23
+ import { buildClient, buildServer, linkOrCopyFile, pluginBunPlugins, setPrunedClientCss, standaloneCssFiles } from './bundle'
20
24
  import { compileExecutable } from './compile'
21
- import { assertSafeOutDir, fileSize, isInNodeModules, relPosix, walkAllFiles, walkRoutes } from './files'
25
+ import { assertSafeOutDir, fileSize, isHiddenPublicPath, isInNodeModules, relPosix, walkAllFiles, walkRoutes } from './files'
22
26
  import { isInside } from './is-inside'
23
27
  import { ModuleGraph } from './graph'
24
28
  import { nodeEnvWarning, renderProblems, serverNodeEnvReads } from './render-rules'
29
+ import { formatIslandValueWarnings } from './island-promote'
25
30
  import { planIslands } from './islands'
26
31
  import { buildActionEntries, buildRouteEntries } from './manifest'
27
32
  import { createPluginHost, createPublicFiles } from './plugin-host'
28
33
  import { carryPreviousAssets } from './carry'
29
34
  import { assertOwnOutDir, processSuffix, removeDeadProcessDirs, removeStaleStages, stageDirFor, swapStage } from './output'
30
35
  import { prerender } from './prerender'
31
- import { analyzeBundleWeights, checkJsBudget, formatBundleReport, formatBundleReportJson, islandOrigins } from './report'
36
+ import { analyzeBundleWeights, checkFirstLoadBudget, checkJsBudget, formatBundleReport, formatBundleReportJson, islandOrigins } from './report'
37
+ import { parseByteSize } from './byte-size'
32
38
  import { SERVER_ENTRY_FILE, serverEntrySource } from './server-entry'
33
39
  import { PRUNELLE_SRC_ROOT, resolvePrunelleSpecifier } from './resolve'
34
- import { assertNoRouteConflicts, fileToRoutePath, hasRouteHandlerExport, missingPathsProblem, normalizeRoutePattern, routeExportProblem, routeFileProblem, SPECIAL_ROUTE_FILES } from './routes'
35
- import { exportStatic } from './static'
40
+ import { ancestorFiles, assertNoRouteConflicts, discoverRouteMatchers, fileToRoutePath, hasRouteHandlerExport, missingPathsProblem, normalizeRoutePattern, routeExportProblem, routeFileProblem, SPECIAL_ROUTE_FILES } from './routes'
41
+ import { emitStaticNotFoundPages, exportStatic } from './static'
42
+ import { findUnknownStatusPages } from './status-pages'
43
+ import { consolidateStylesheets } from './style-bundles'
36
44
 
37
45
  export type { BuildCache } from './graph'
38
46
  export { createBuildCache } from './graph'
39
- export type { ActionManifestEntry, BuildManifest, RouteManifestEntry } from './manifest'
40
- export { analyzeBundleWeights, checkJsBudget, formatBundleReport, formatBundleReportJson } from './report'
41
- export type { BundleReport, RouteBundleMetrics, RouteIsland } from './report'
47
+ export type { ActionManifestEntry, BuildManifest, RouteManifestEntry, StatusPageKind, StatusPageManifestEntry } from './manifest'
48
+ export { analyzeBundleWeights, checkJsBudget, computeEcoIndex, countDomElements, formatBundleReport, formatBundleReportJson } from './report'
49
+ export type { BundleReport, EcoIndexGrade, RouteBundleMetrics, RouteEcoIndex, RouteIsland } from './report'
42
50
  export { resolvePrunelleSpecifier } from './resolve'
43
51
 
44
52
  export interface BuildOptions {
@@ -49,6 +57,8 @@ export interface BuildOptions {
49
57
  minify?: boolean | undefined
50
58
  assetPrefix?: string | undefined
51
59
  site?: string | undefined
60
+ /** `<html lang>` of every page; defaults to `lang` in `prunelle.config.ts`. */
61
+ lang?: string | undefined
52
62
  plugins?: PrunellePlugin[] | undefined
53
63
  /** Reusable incremental cache for `prunelle dev` (skips re-parsing/re-compiling unchanged files). */
54
64
  cache?: BuildCache | undefined
@@ -56,12 +66,16 @@ export interface BuildOptions {
56
66
  analyze?: boolean | undefined
57
67
  /** Print the `--analyze` bundle weight report as JSON instead of a human-readable table. */
58
68
  analyzeJson?: boolean | undefined
69
+ /** Receives the computed `BundleReport` in-process without printing to stdout (used by `prunelle mcp`). */
70
+ onAnalyze?: ((report: import('./report').BundleReport) => void) | undefined
59
71
  /** Fail the build when a route's eager JS, gzipped, is over this many bytes, naming the route and its islands. */
60
72
  maxJs?: number | undefined
61
73
  /** Export a static site directly into outDir (dist/) with no server/ folder left behind. */
62
74
  static?: boolean | undefined
63
75
  /** Run build-time prerendering for routes exporting `prerender = true` (default: true; disabled in `prunelle dev`). */
64
76
  prerender?: boolean | undefined
77
+ /** Automatically prerender static pages that read nothing from the request or clock (and have no middleware or `cache` export). */
78
+ autoPrerender?: boolean | undefined
65
79
  /** Copy `public/` files into `outDir/public` (default: true; disabled in `prunelle dev` where `public/` is served directly). */
66
80
  copyPublic?: boolean | undefined
67
81
  /** Compile into a single standalone executable at this path (or true -> dist/server-bin). */
@@ -93,10 +107,16 @@ function restoreCachedPluginAssets(cache: BuildCache | undefined, clientDir: str
93
107
  }
94
108
  }
95
109
 
96
- function recordCachedPluginAssets(cache: BuildCache | undefined, clientDir: string, assets: readonly string[], builtClientAssets: ReadonlySet<string>): void {
110
+ function recordCachedPluginAssets(
111
+ cache: BuildCache | undefined,
112
+ clientDir: string,
113
+ assets: readonly string[],
114
+ builtClientAssets: ReadonlySet<string>,
115
+ consolidatedCssAssets: ReadonlySet<string>,
116
+ ): void {
97
117
  if (cache === undefined)
98
118
  return
99
- const files = assets.filter(rel => !builtClientAssets.has(rel))
119
+ const files = assets.filter(rel => !builtClientAssets.has(rel) && !consolidatedCssAssets.has(rel))
100
120
  if (files.length > 0)
101
121
  cachedPluginAssets.set(cache, { clientDir, files })
102
122
  else
@@ -121,7 +141,13 @@ interface BuildRun {
121
141
  stageSuffix: string
122
142
  assetPrefix: string
123
143
  site: string | undefined
144
+ lang: string | undefined
145
+ /** Byte caps from `budget` in `prunelle.config.ts`, `--max-js` taking over `js`. */
146
+ budget: { js: number | undefined, jsSource: string, firstLoad: number | undefined }
147
+ defaultPort: number | undefined
124
148
  compliance: ComplianceConfig | undefined
149
+ consentMaxAge: number | undefined
150
+ autoPrerender: boolean
125
151
  minify: boolean
126
152
  isDev: boolean
127
153
  nodeEnv: string | undefined
@@ -135,7 +161,7 @@ export async function build(options: BuildOptions): Promise<BuildManifest> {
135
161
  }
136
162
 
137
163
  const root = resolve(options.root)
138
- const isDev = options.dev ?? (process.env.PRUNELLE_DEV === '1')
164
+ const isDev = options.dev ?? devFromEnv()
139
165
  const effectiveNodeEnv = options.nodeEnv ?? (isDev ? undefined : (process.env.NODE_ENV ?? 'production'))
140
166
  const fileConfig = await loadConfig(root, { dev: isDev, nodeEnv: effectiveNodeEnv })
141
167
  const routesDir = resolve(root, options.routesDir ?? fileConfig.routesDir ?? 'src/routes')
@@ -179,7 +205,12 @@ export async function build(options: BuildOptions): Promise<BuildManifest> {
179
205
  stageSuffix,
180
206
  assetPrefix,
181
207
  site,
208
+ lang: options.lang ?? fileConfig.lang,
209
+ budget: resolveBudget(options.maxJs, fileConfig.budget),
210
+ defaultPort: fileConfig.port,
182
211
  compliance: fileConfig.compliance,
212
+ consentMaxAge: fileConfig.consent?.maxAge,
213
+ autoPrerender: options.autoPrerender ?? fileConfig.autoPrerender ?? false,
183
214
  minify: options.minify ?? true,
184
215
  isDev,
185
216
  nodeEnv: effectiveNodeEnv,
@@ -208,15 +239,7 @@ function emitBuildWarnings(run: BuildRun, graph: ModuleGraph, routeFiles: readon
208
239
  }
209
240
  }
210
241
  if (!run.isDev) {
211
- const projectWarnings = collectProjectComplianceWarnings({
212
- root: run.root,
213
- srcDir: join(run.root, 'src'),
214
- routesDir: run.routesDir,
215
- routeFiles,
216
- analyses: graph.analyses,
217
- compliance: run.compliance,
218
- site: run.site,
219
- })
242
+ const projectWarnings = collectProjectComplianceWarnings({ root: run.root, srcDir: join(run.root, 'src'), routesDir: run.routesDir, publicDir: run.publicDir, routeFiles, analyses: graph.analyses, compliance: run.compliance, consentMaxAge: run.consentMaxAge, site: run.site, lang: run.lang, langFromPlugin: pluginSetsLang(run.plugins) })
220
243
  for (const warning of projectWarnings)
221
244
  console.warn(warning)
222
245
  }
@@ -226,6 +249,10 @@ function emitBuildWarnings(run: BuildRun, graph: ModuleGraph, routeFiles: readon
226
249
  /** Plans the islands, then runs the rules `prunelle check` also runs on the whole graph: what server code renders wrong, and dynamic prerendered routes with no `paths()`. Throws them all at once, each placed with a code frame. */
227
250
  function planCheckedIslands(root: string, routesDir: string, graph: ModuleGraph, pageFiles: string[], specialFiles: string[], isStatic: boolean): ReturnType<typeof planIslands> {
228
251
  const islands = planIslands(graph, root, pageFiles, specialFiles)
252
+ for (const { file, warning } of islands.promotedWarnings) {
253
+ const rel = relPosix(root, file)
254
+ console.warn(formatDiagnostic(formatLoc(rel, graph.source(file), warning.start), warning.message.replaceAll(file, rel), 'warning'))
255
+ }
229
256
  const placed: string[] = []
230
257
  const place = (file: string, offset: number, message: string): void => {
231
258
  const source = graph.source(file)
@@ -246,6 +273,15 @@ function planCheckedIslands(root: string, routesDir: string, graph: ModuleGraph,
246
273
  if (missing !== undefined)
247
274
  place(file, missing.offset, `prunelle build: ${missing.message}`)
248
275
  }
276
+ const cacheProblems = findCachedRoutePrivateReads({
277
+ graph,
278
+ pageFiles,
279
+ layoutsFor: file => ancestorFiles(routesDir, file, ['_layout.tsx']),
280
+ toRel: file => relPosix(root, file),
281
+ tool: 'prunelle build',
282
+ })
283
+ for (const problem of cacheProblems)
284
+ place(problem.file, problem.offset, problem.message)
249
285
  if (placed.length > 0)
250
286
  throw new Error(placed.join('\n\n'))
251
287
  return islands
@@ -281,6 +317,81 @@ function refreshCacheWatches(cache: BuildCache, graph: ModuleGraph, extraFiles:
281
317
  }
282
318
  }
283
319
 
320
+ function validateRoutesAndMatchers(root: string, routesDir: string, allRouteFiles: readonly string[], specialFiles: readonly string[], candidateFiles: readonly string[], graph: ModuleGraph): { pageFiles: string[], customMatchers: Map<string, string> } {
321
+ const unknownStatus = findUnknownStatusPages(root, allRouteFiles)
322
+ if (unknownStatus.length > 0)
323
+ throw new Error(`prunelle build: ${unknownStatus[0]!.message}`)
324
+ const routesRel = relPosix(root, routesDir)
325
+ for (const f of [...specialFiles, ...candidateFiles]) {
326
+ const analysis = graph.analyses.get(f)!
327
+ const problem = routeFileProblem(analysis, relPosix(root, f), routesRel) ?? routeExportProblem(analysis, relPosix(root, f))
328
+ if (problem !== undefined)
329
+ throw new Error(`prunelle build: ${problem}`)
330
+ }
331
+ // A file exporting only actions stays in routes/ for its folder's middleware.
332
+ const pageFiles = candidateFiles.filter(f => hasRouteHandlerExport(graph.analyses.get(f)!))
333
+ assertNoRouteConflicts(root, routesDir, pageFiles)
334
+ const { customFiles, problems } = discoverRouteMatchers({
335
+ root,
336
+ routesDir,
337
+ routeFiles: [...specialFiles, ...pageFiles],
338
+ loadAnalysis: file => graph.load(file),
339
+ })
340
+ if (problems.length > 0)
341
+ throw new Error(`prunelle build: ${problems[0]!.message}`)
342
+ return { pageFiles, customMatchers: customFiles }
343
+ }
344
+
345
+ function collectActionsByFile(graph: ModuleGraph, root: string, assetPrefix: string): ActionsByFile {
346
+ const actionsByFile: ActionsByFile = new Map()
347
+ for (const [file, analysis] of graph.analyses) {
348
+ if (analysis.exportedActions.length > 0) {
349
+ const rel = relPosix(root, file)
350
+ actionsByFile.set(file, analysis.exportedActions.map(exportName => ({
351
+ exportName,
352
+ url: `${assetPrefix}/action/${actionHash(rel, exportName)}`,
353
+ })))
354
+ }
355
+ }
356
+ return actionsByFile
357
+ }
358
+
359
+ function copyPublicFiles(publicDir: string, outPublicDir: string, publicFiles: PublicFiles, copyPublic: boolean): void {
360
+ for (const abs of walkAllFiles(publicDir).sort()) {
361
+ const rel = relative(publicDir, abs)
362
+ if (isHiddenPublicPath(rel))
363
+ continue
364
+ publicFiles.register(rel)
365
+ if (copyPublic) {
366
+ mkdirSync(dirname(join(outPublicDir, rel)), { recursive: true })
367
+ copyFileSync(abs, join(outPublicDir, rel))
368
+ }
369
+ }
370
+ }
371
+
372
+ function collectNonEmptyClientAssets(clientDir: string, assetFiles: readonly string[]): { assets: string[], builtClientAssets: Set<string> } {
373
+ const assets: string[] = []
374
+ for (const rel of assetFiles) {
375
+ const abs = join(clientDir, rel)
376
+ const size = fileSize(abs)
377
+ if (size === 0)
378
+ rmSync(abs, { force: true })
379
+ else if (size !== undefined)
380
+ assets.push(rel)
381
+ }
382
+ return { assets, builtClientAssets: new Set(assets) }
383
+ }
384
+
385
+ async function validateAppForms(run: BuildRun, routeFiles: readonly string[], graph: ModuleGraph): Promise<void> {
386
+ const formCheck = await checkAppForms({ root: run.root, routesDir: run.routesDir, routeFiles, graph, compliance: run.compliance })
387
+ if (formCheck.errors.length > 0)
388
+ throw new Error(formCheck.errors.join('\n'))
389
+ if (!run.isDev) {
390
+ for (const warning of formCheck.warnings)
391
+ console.warn(warning)
392
+ }
393
+ }
394
+
284
395
  async function runBuild(run: BuildRun): Promise<BuildManifest> {
285
396
  const { options, root, plugins, routesDir, outDir, assetPrefix, isDev, publicFiles } = run
286
397
  const clientDir = join(outDir, 'client')
@@ -306,30 +417,16 @@ async function runBuild(run: BuildRun): Promise<BuildManifest> {
306
417
  graph.load(f)
307
418
  emitBuildWarnings(run, graph, allRouteFiles)
308
419
 
309
- const routesRel = relPosix(root, routesDir)
310
- for (const f of [...specialFiles, ...candidateFiles]) {
311
- const analysis = graph.analyses.get(f)!
312
- const problem = routeFileProblem(analysis, relPosix(root, f), routesRel) ?? routeExportProblem(analysis, relPosix(root, f))
313
- if (problem !== undefined)
314
- throw new Error(`prunelle build: ${problem}`)
315
- }
316
- // A file exporting only actions stays in routes/ for its folder's middleware.
317
- const pageFiles = candidateFiles.filter(f => hasRouteHandlerExport(graph.analyses.get(f)!))
318
- assertNoRouteConflicts(root, routesDir, pageFiles)
319
-
320
- // Server actions, keyed by source file
321
- const actionsByFile: ActionsByFile = new Map()
322
- for (const [file, analysis] of graph.analyses) {
323
- if (analysis.exportedActions.length > 0) {
324
- const rel = relPosix(root, file)
325
- actionsByFile.set(file, analysis.exportedActions.map(exportName => ({
326
- exportName,
327
- url: `${assetPrefix}/action/${actionHash(rel, exportName)}`,
328
- })))
329
- }
330
- }
420
+ const { pageFiles, customMatchers } = validateRoutesAndMatchers(root, routesDir, allRouteFiles, specialFiles, candidateFiles, graph)
421
+ const customMatcherFiles = [...new Set(customMatchers.values())]
331
422
 
423
+ const actionsByFile = collectActionsByFile(graph, root, assetPrefix)
332
424
  const islands = planCheckedIslands(root, routesDir, graph, pageFiles, specialFiles, isStatic)
425
+ if (!isDev) {
426
+ for (const warning of formatIslandValueWarnings(islands.valueUses, root, graph, f => graph.source(f), run.compliance))
427
+ console.warn(warning)
428
+ }
429
+ await validateAppForms(run, allRouteFiles, graph)
333
430
 
334
431
  mkdirSync(clientDir, { recursive: true })
335
432
  mkdirSync(serverDir, { recursive: true })
@@ -337,19 +434,21 @@ async function runBuild(run: BuildRun): Promise<BuildManifest> {
337
434
  .flatMap(p => p.css ?? [])
338
435
  .map(c => resolve(root, c))
339
436
  .filter(c => existsSync(c))
340
- const env = { root, outDir, clientDir, serverDir, assetPrefix, minify: run.minify, isDev, nodeEnv: run.nodeEnv, analyze: options.analyze === true || options.analyzeJson === true || options.maxJs !== undefined, graph, cache: options.cache, plugins, actionsByFile, islands }
437
+ const wantsAnalyze = wantsBundleAnalysis(run)
438
+ const env = { root, outDir, clientDir, serverDir, assetPrefix, lang: run.lang, minify: run.minify, isDev, nodeEnv: run.nodeEnv, analyze: wantsAnalyze, graph, cache: options.cache, plugins, actionsByFile, islands }
341
439
 
342
440
  const routeEntryFiles = new Set([...specialFiles, ...pageFiles])
343
441
  const standaloneActionFiles = [...actionsByFile.keys()].filter(f => !routeEntryFiles.has(f))
344
442
  // `_entry.js` imports all of these; each stays an entrypoint so its code lands in a content-named chunk that `prunelle dev` keeps loaded while it is unchanged.
345
- const serverEntries = [...specialFiles, ...pageFiles, ...standaloneActionFiles, ...(hasConfigFile ? [configSrc] : [])]
346
- const serverRoot = standaloneActionFiles.length > 0 || hasConfigFile ? root : routesDir
443
+ const bundledModules = [...specialFiles, ...pageFiles, ...standaloneActionFiles, ...customMatcherFiles]
444
+ const serverEntries = [...bundledModules, ...(hasConfigFile ? [configSrc] : [])]
445
+ const serverRoot = standaloneActionFiles.length > 0 || customMatcherFiles.length > 0 || hasConfigFile ? root : routesDir
347
446
  const toOutRel = (srcFile: string): string =>
348
447
  relPosix(outDir, join(serverDir, relative(serverRoot, srcFile).replace(/\.(tsx|ts)$/, '.js')))
349
448
  const serverEntry = {
350
449
  file: join(serverRoot, SERVER_ENTRY_FILE),
351
450
  source: serverEntrySource({
352
- modules: [...specialFiles, ...pageFiles, ...standaloneActionFiles].map(file => ({ file, key: toOutRel(file), source: relPosix(root, file) })),
451
+ modules: bundledModules.map(file => ({ file, key: toOutRel(file), source: relPosix(root, file) })),
353
452
  config: hasConfigFile ? { file: configSrc, source: relPosix(root, configSrc) } : undefined,
354
453
  assembler: join(PRUNELLE_SRC_ROOT, 'server/app-entry.ts'),
355
454
  }),
@@ -376,60 +475,31 @@ async function runBuild(run: BuildRun): Promise<BuildManifest> {
376
475
  if (options.cache !== undefined)
377
476
  refreshCacheWatches(options.cache, graph, [...pluginCssFiles, ...(hasConfigFile ? [configSrc] : [])])
378
477
 
379
- const assets: string[] = []
380
- for (const rel of client.assetFiles) {
381
- const abs = join(clientDir, rel)
382
- const size = fileSize(abs)
383
- if (size === 0)
384
- rmSync(abs, { force: true })
385
- else if (size !== undefined)
386
- assets.push(rel)
387
- }
388
- const builtClientAssets = new Set(assets)
478
+ const { assets, builtClientAssets } = collectNonEmptyClientAssets(clientDir, client.assetFiles)
389
479
 
390
- const { routes, globalStyles } = buildRouteEntries({
391
- graph,
392
- islands,
393
- islandChunks: client.islandChunks,
394
- srcCssToUrl: client.srcCssToUrl,
395
- islandCssUrl: client.islandCssUrl,
396
- routesDir,
397
- pageFiles,
398
- pluginCssFiles,
399
- isStatic,
400
- toOutRel,
480
+ const { routes, statusPages, globalStyles, routeSourceFiles, globalSourceFiles } = buildRouteEntries({
481
+ graph, islands, islandChunks: client.islandChunks, srcCssToUrl: client.srcCssToUrl, islandCssUrl: client.islandCssUrl,
482
+ routesDir, pageFiles, specialFiles, pluginCssFiles, isStatic, autoPrerender: run.autoPrerender, toOutRel,
401
483
  })
484
+ const paramMatchers = customMatchers.size > 0
485
+ ? Object.fromEntries([...customMatchers.entries()].map(([name, file]) => [name, toOutRel(file)]))
486
+ : undefined
402
487
 
403
488
  // public/ files are listed in the manifest and copied into outDir/public (`prunelle dev` serves public/ directly instead)
404
489
  const outPublicDir = join(outDir, 'public')
405
- for (const abs of walkAllFiles(run.publicDir).sort()) {
406
- const rel = publicFiles.register(relative(run.publicDir, abs))
407
- if (options.copyPublic !== false) {
408
- mkdirSync(dirname(join(outPublicDir, rel)), { recursive: true })
409
- copyFileSync(abs, join(outPublicDir, rel))
410
- }
411
- }
490
+ copyPublicFiles(run.publicDir, outPublicDir, publicFiles, options.copyPublic !== false)
412
491
 
413
492
  const host = createPluginHost({
414
- plugins,
415
- appCtx: run.appCtx,
416
- root,
417
- outDir,
418
- clientDir,
419
- outPublicDir,
420
- assetPrefix,
421
- site: run.site,
422
- minify: run.minify,
423
- isStatic,
424
- isDev,
425
- routes,
426
- publicFiles,
427
- assets,
428
- styleUrls: client.styleUrls,
429
- globalStyles,
493
+ plugins, appCtx: run.appCtx, root, outDir, clientDir, outPublicDir, assetPrefix, site: run.site, minify: run.minify,
494
+ isStatic, isDev, routes, statusPages, routeSourceFiles, globalSourceFiles, publicFiles, assets, styleUrls: client.styleUrls, globalStyles,
430
495
  })
431
496
  await host.runBuild()
432
497
  restoreCachedPluginAssets(options.cache, clientDir, assets, anyPassSkipped)
498
+ const consolidated = consolidateStylesheets({
499
+ clientDir, assetPrefix, minify: run.minify, isDev, srcCssToUrl: client.srcCssToUrl, capturePruned: options.cache !== undefined,
500
+ routes, statusPages, globalStyles, assets, styleUrls: client.styleUrls,
501
+ })
502
+ setPrunedClientCss(options.cache, consolidated.pruned)
433
503
  await host.precompressOutput()
434
504
 
435
505
  const manifest: BuildManifest = {
@@ -438,10 +508,11 @@ async function runBuild(run: BuildRun): Promise<BuildManifest> {
438
508
  globalStyles,
439
509
  ...(host.headTags.length > 0 ? { headTags: host.headTags } : {}),
440
510
  routes,
441
-
442
511
  ...(hasRootLayout ? { rootLayoutFile: toOutRel(rootLayoutSrc) } : {}),
443
512
  errorFile: hasErrorFile ? toOutRel(errorSrc) : undefined,
444
513
  notFoundFile: hasNotFoundFile ? toOutRel(notFoundSrc) : undefined,
514
+ ...(statusPages.length > 0 ? { statusPages } : {}),
515
+ ...(paramMatchers !== undefined ? { paramMatchers } : {}),
445
516
  actions: buildActionEntries(actionsByFile, routesDir, toOutRel),
446
517
  islands: Object.fromEntries(client.islandChunks),
447
518
  assets,
@@ -450,17 +521,11 @@ async function runBuild(run: BuildRun): Promise<BuildManifest> {
450
521
  }
451
522
  const writeManifest = (): void => writeFileSync(join(outDir, 'manifest.json'), JSON.stringify(manifest, null, 2))
452
523
  writeManifest()
453
- if (options.analyze === true || options.analyzeJson === true || options.maxJs !== undefined) {
454
- const report = analyzeBundleWeights(manifest, clientDir, assetPrefix, client.metafile, islandOrigins(islands, client.islandChunks, graph, root), [outPublicDir, run.publicDir])
455
- if (options.analyzeJson === true)
456
- console.log(formatBundleReportJson(report))
457
- else if (options.analyze === true)
458
- console.log(formatBundleReport(report))
459
- if (options.maxJs !== undefined)
460
- checkJsBudget(report, options.maxJs)
461
- }
524
+ const analyzeOrigins = wantsAnalyze
525
+ ? islandOrigins(islands, client.islandChunks, graph, root)
526
+ : undefined
462
527
 
463
- await landBuild(run, { manifest, writeManifest, host, env, assets, builtClientAssets, hasNotFoundFile })
528
+ await landBuild(run, { manifest, writeManifest, host, env, assets, builtClientAssets, consolidatedCssAssets: consolidated.emitted, hasNotFoundFile, metafile: client.metafile, analyzeOrigins, outPublicDir })
464
529
  return manifest
465
530
  }
466
531
 
@@ -471,13 +536,56 @@ interface BuiltOutput {
471
536
  env: Parameters<typeof pluginBunPlugins>[0]
472
537
  assets: string[]
473
538
  builtClientAssets: ReadonlySet<string>
539
+ consolidatedCssAssets: ReadonlySet<string>
474
540
  hasNotFoundFile: boolean
541
+ metafile: Bun.BuildOutput['metafile']
542
+ analyzeOrigins: ReturnType<typeof islandOrigins> | undefined
543
+ outPublicDir: string
544
+ }
545
+
546
+ function budgetBytes(value: number | string | undefined, key: string): number | undefined {
547
+ if (value === undefined)
548
+ return undefined
549
+ const bytes = parseByteSize(value)
550
+ if (bytes === undefined)
551
+ throw new Error(`prunelle: ${key} in prunelle.config.ts is ${JSON.stringify(value)}, not a size: give bytes or KB, e.g. ${key.endsWith('js') ? '\'40kb\'' : '\'500kb\''}.`)
552
+ return bytes
553
+ }
554
+
555
+ function resolveBudget(maxJs: number | undefined, budget: BudgetConfig | undefined): BuildRun['budget'] {
556
+ const js = budgetBytes(budget?.js, 'budget.js')
557
+ return {
558
+ js: maxJs ?? js,
559
+ jsSource: maxJs !== undefined ? '--max-js' : 'budget.js',
560
+ firstLoad: budgetBytes(budget?.firstLoad, 'budget.firstLoad'),
561
+ }
562
+ }
563
+
564
+ function wantsBundleAnalysis(run: BuildRun): boolean {
565
+ const { options, budget } = run
566
+ return options.analyze === true || options.analyzeJson === true || budget.js !== undefined || budget.firstLoad !== undefined || options.onAnalyze !== undefined
567
+ }
568
+
569
+ function emitBundleAnalysis(run: BuildRun, built: BuiltOutput, clientDir: string, prerenderBaseDir: string | undefined): void {
570
+ const { options, assetPrefix, budget } = run
571
+ if (!wantsBundleAnalysis(run))
572
+ return
573
+ const report = analyzeBundleWeights(built.manifest, clientDir, assetPrefix, built.metafile, built.analyzeOrigins, [built.outPublicDir, run.publicDir], prerenderBaseDir)
574
+ options.onAnalyze?.(report)
575
+ if (options.analyzeJson === true)
576
+ console.log(formatBundleReportJson(report))
577
+ else if (options.analyze === true)
578
+ console.log(formatBundleReport(report))
579
+ if (budget.js !== undefined)
580
+ checkJsBudget(report, budget.js, budget.jsSource)
581
+ if (budget.firstLoad !== undefined)
582
+ checkFirstLoadBudget(report, budget.firstLoad)
475
583
  }
476
584
 
477
585
  /** Prerenders, runs the plugins' after-prerender hooks, exports or carries the previous build's dropped files, compiles, then swaps the stage in. */
478
586
  async function landBuild(run: BuildRun, built: BuiltOutput): Promise<void> {
479
587
  const { options, root, plugins, outDir, assetPrefix, isDev, publicFiles } = run
480
- const { manifest, writeManifest, host, env, assets, builtClientAssets, hasNotFoundFile } = built
588
+ const { manifest, writeManifest, host, env, assets, builtClientAssets, consolidatedCssAssets, hasNotFoundFile } = built
481
589
  const clientDir = join(outDir, 'client')
482
590
  const isStatic = options.static === true
483
591
 
@@ -485,34 +593,28 @@ async function landBuild(run: BuildRun, built: BuiltOutput): Promise<void> {
485
593
  const prerenderRoutes = options.prerender !== false || isStatic ? manifest.routes.filter(r => r.prerender) : []
486
594
  const prerenderDir = isStatic ? run.stageDir : join(outDir, 'prerendered')
487
595
  const prerendered = prerenderRoutes.length > 0 || isStatic
488
- ? await prerender({ root, outDir, assetPrefix, site: run.site, plugins, pluginOverride: options.plugins, isDev, nodeEnv: run.nodeEnv, isStatic, prerenderDir, routes: prerenderRoutes })
596
+ ? await prerender({ root, outDir, assetPrefix, site: run.site, plugins, pluginOverride: options.plugins, isDev, nodeEnv: run.nodeEnv, isStatic, prerenderDir, routes: prerenderRoutes, routesDir: run.routesDir })
489
597
  : undefined
490
598
 
491
599
  try {
492
- const ranAfterPrerender = await host.runAfterPrerender()
493
- recordCachedPluginAssets(options.cache, clientDir, assets, builtClientAssets)
600
+ const staticNotFoundOpts = {
601
+ stageDir: prerenderDir, site: run.site, isDev, manifest, entry: prerendered?.entry,
602
+ pluginOverride: options.plugins, app: prerendered?.app, errorFor: prerendered?.errorFor, hasNotFoundFile,
603
+ }
604
+ if (isStatic)
605
+ await emitStaticNotFoundPages(staticNotFoundOpts)
606
+ const ranAfterPrerender = await host.runAfterPrerender(isStatic ? prerenderDir : outDir)
607
+ recordCachedPluginAssets(options.cache, clientDir, assets, builtClientAssets, consolidatedCssAssets)
494
608
  await host.precompressOutput()
495
609
  if (Object.keys(host.pluginData).length > 0)
496
610
  manifest.pluginData = host.pluginData
611
+ emitBundleAnalysis(run, built, clientDir, prerendered !== undefined ? (isStatic ? prerenderDir : outDir) : undefined)
497
612
 
498
613
  if (isStatic) {
499
614
  await exportStatic({
500
- root: run.root,
501
- stageDir: prerenderDir,
502
- finalOutDir: run.finalOutDir,
503
- outDir,
504
- clientDir,
505
- assetPrefix,
506
- site: run.site,
507
- isDev,
508
- manifest,
509
- entry: prerendered?.entry,
510
- pluginOverride: options.plugins,
511
- assets,
512
- publicFiles,
513
- app: prerendered?.app,
514
- hasNotFoundFile,
515
- stageSuffix: run.stageSuffix,
615
+ ...staticNotFoundOpts,
616
+ root: run.root, finalOutDir: run.finalOutDir, outDir, clientDir, assetPrefix, assets, publicFiles,
617
+ notFoundEmitted: true, stageSuffix: run.stageSuffix,
516
618
  })
517
619
  }
518
620
  else if (prerenderRoutes.length > 0 || ranAfterPrerender) {
@@ -539,6 +641,7 @@ async function landBuild(run: BuildRun, built: BuiltOutput): Promise<void> {
539
641
  manifest,
540
642
  assetPrefix,
541
643
  site: options.site !== undefined ? run.site : undefined,
644
+ defaultPort: run.defaultPort,
542
645
  outfile: compileOutfile(options.compile, root, outDir, run.finalOutDir),
543
646
 
544
647
  resolvePrunelleSpecifier,