@wular/pnext 0.1.6 → 0.1.7
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/bin/pnext +9 -2
- package/dist/server/_chunks/aliases-j47a10ce.js +44 -0
- package/dist/server/_chunks/analyze-arswqe6s.js +445 -0
- package/dist/server/_chunks/boot-af0mv3dy.js +36 -0
- package/dist/server/_chunks/build-spy3dxp4.js +84 -0
- package/dist/server/_chunks/build-t9h0hec3.js +3550 -0
- package/dist/server/_chunks/build-tier-m7yvqz61.js +2472 -0
- package/dist/server/_chunks/compile-53j02j27.js +22 -0
- package/dist/server/_chunks/config-1yzwexq6.js +27 -0
- package/dist/server/_chunks/config-n2z7yxps.js +22 -0
- package/dist/server/_chunks/create-meec9hs6.js +134 -0
- package/dist/server/_chunks/dev-fjmqg6en.js +220 -0
- package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
- package/dist/server/_chunks/generate-n9sh6hzt.js +21 -0
- package/dist/server/_chunks/index-0374j2b9.js +66 -0
- package/dist/server/_chunks/index-06nyqntx.js +213 -0
- package/dist/server/_chunks/index-1011cscr.js +5263 -0
- package/dist/server/_chunks/index-11sfk4hb.js +170 -0
- package/dist/server/_chunks/index-20ppawv7.js +297 -0
- package/dist/server/_chunks/index-2dv4y4wd.js +1065 -0
- package/dist/server/_chunks/index-2vz0wzdn.js +59 -0
- package/dist/server/_chunks/index-2wfv4kvx.js +182 -0
- package/dist/server/_chunks/index-357na4a8.js +109 -0
- package/dist/server/_chunks/index-3b3at80h.js +109 -0
- package/dist/server/_chunks/index-3tf1xjsp.js +6166 -0
- package/dist/server/_chunks/index-3xbr4eyv.js +105 -0
- package/dist/server/_chunks/index-4399bvd2.js +18 -0
- package/dist/server/_chunks/index-4hgjrqh7.js +851 -0
- package/dist/server/_chunks/index-4q2gbfwk.js +2530 -0
- package/dist/server/_chunks/index-4t92hdxd.js +172 -0
- package/dist/server/_chunks/index-4zzebszd.js +10 -0
- package/dist/server/_chunks/index-5gyr4emz.js +107 -0
- package/dist/server/_chunks/index-5hr4062s.js +70 -0
- package/dist/server/_chunks/index-68m3mwbd.js +84 -0
- package/dist/server/_chunks/index-6b009mt0.js +56 -0
- package/dist/server/_chunks/index-6e4fqv30.js +588 -0
- package/dist/server/_chunks/index-6gex3pfa.js +15 -0
- package/dist/server/_chunks/index-6kp9r0d9.js +11 -0
- package/dist/server/_chunks/index-6q7zvrap.js +134 -0
- package/dist/server/_chunks/index-73z4esab.js +38 -0
- package/dist/server/_chunks/index-79ngvam8.js +60 -0
- package/dist/server/_chunks/index-7wc9n8be.js +25 -0
- package/dist/server/_chunks/index-8k7pfejn.js +1599 -0
- package/dist/server/_chunks/index-8kcxdfya.js +206 -0
- package/dist/server/_chunks/index-91x12ykq.js +274 -0
- package/dist/server/_chunks/index-9ch50vtq.js +18 -0
- package/dist/server/_chunks/index-9hx2641q.js +28 -0
- package/dist/server/_chunks/index-9n2914ww.js +535 -0
- package/dist/server/_chunks/index-9ych9ma8.js +207 -0
- package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
- package/dist/server/_chunks/index-bcws5eh2.js +35 -0
- package/dist/server/_chunks/index-c0g2wf3z.js +92 -0
- package/dist/server/_chunks/index-cf4rvxv6.js +95 -0
- package/dist/server/_chunks/index-cjgqs13g.js +65 -0
- package/dist/server/_chunks/index-ckkdpht5.js +41 -0
- package/dist/server/_chunks/index-cyfednwb.js +87 -0
- package/dist/server/_chunks/index-danncfhy.js +311 -0
- package/dist/server/_chunks/index-dg0f05zs.js +199 -0
- package/dist/server/_chunks/index-e3a6yx84.js +18 -0
- package/dist/server/_chunks/index-e88tyv35.js +45 -0
- package/dist/server/_chunks/index-eajaspjk.js +1253 -0
- package/dist/server/_chunks/index-eeaanp2e.js +483 -0
- package/dist/server/_chunks/index-egykcqg3.js +101 -0
- package/dist/server/_chunks/index-en7n9f7m.js +22 -0
- package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
- package/dist/server/_chunks/index-fkp000p1.js +590 -0
- package/dist/server/_chunks/index-fn1chkkd.js +214 -0
- package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
- package/dist/server/_chunks/index-ggk2j965.js +9432 -0
- package/dist/server/_chunks/index-grta8ap3.js +238 -0
- package/dist/server/_chunks/index-h2a70tg4.js +7 -0
- package/dist/server/_chunks/index-h4xy648y.js +51 -0
- package/dist/server/_chunks/index-hkdfj58q.js +92 -0
- package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
- package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
- package/dist/server/_chunks/index-jepjvcrf.js +198 -0
- package/dist/server/_chunks/index-jks0x0a1.js +14 -0
- package/dist/server/_chunks/index-jx7bqvw1.js +57 -0
- package/dist/server/_chunks/index-k1g3epw0.js +1299 -0
- package/dist/server/_chunks/index-knp0s912.js +7 -0
- package/dist/server/_chunks/index-kq8kpzye.js +472 -0
- package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
- package/dist/server/_chunks/index-kresp2n8.js +445 -0
- package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
- package/dist/server/_chunks/index-n4hxpng2.js +11 -0
- package/dist/server/_chunks/index-ncnes8c6.js +17 -0
- package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
- package/dist/server/_chunks/index-nyrba2kr.js +4130 -0
- package/dist/server/_chunks/index-p77b4kcx.js +296 -0
- package/dist/server/_chunks/index-pym1cezq.js +39 -0
- package/dist/server/_chunks/index-q738kkhj.js +100 -0
- package/dist/server/_chunks/index-qjj6gddn.js +54 -0
- package/dist/server/_chunks/index-qm6kmhqs.js +110 -0
- package/dist/server/_chunks/index-qn4z5s3c.js +819 -0
- package/dist/server/_chunks/index-qpwsgt3a.js +158 -0
- package/dist/server/_chunks/index-r97ptz1q.js +97 -0
- package/dist/server/_chunks/index-ras0sdab.js +26 -0
- package/dist/server/_chunks/index-rcs322t1.js +19 -0
- package/dist/server/_chunks/index-rn8dyr1f.js +126 -0
- package/dist/server/_chunks/index-rt9qq1va.js +4 -0
- package/dist/server/_chunks/index-rthrsed5.js +356 -0
- package/dist/server/_chunks/index-sctcgyvv.js +185 -0
- package/dist/server/_chunks/index-sjpckxqn.js +213 -0
- package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
- package/dist/server/_chunks/index-stbk3jhn.js +31 -0
- package/dist/server/_chunks/index-sv8m6789.js +266 -0
- package/dist/server/_chunks/index-tgcakdxc.js +125 -0
- package/dist/server/_chunks/index-tgsfjmep.js +74 -0
- package/dist/server/_chunks/index-tq0pc7eg.js +154 -0
- package/dist/server/_chunks/index-tq1f96v7.js +51 -0
- package/dist/server/_chunks/index-tqn2qnnn.js +241 -0
- package/dist/server/_chunks/index-tvqkq6e6.js +128 -0
- package/dist/server/_chunks/index-v1ags1na.js +132 -0
- package/dist/server/_chunks/index-vvmmknm1.js +1431 -0
- package/dist/server/_chunks/index-vvq7rqtn.js +329 -0
- package/dist/server/_chunks/index-vz0km5qk.js +33 -0
- package/dist/server/_chunks/index-w6h8m6vp.js +138 -0
- package/dist/server/_chunks/index-web361b8.js +138 -0
- package/dist/server/_chunks/index-wpfhfbs4.js +194 -0
- package/dist/server/_chunks/index-x0y005nh.js +283 -0
- package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
- package/dist/server/_chunks/index-x93hv0sc.js +271 -0
- package/dist/server/_chunks/index-xvj80c3a.js +30 -0
- package/dist/server/_chunks/index-xywjg2vc.js +100 -0
- package/dist/server/_chunks/index-y2jr2n72.js +152 -0
- package/dist/server/_chunks/index-y36a0ybw.js +57 -0
- package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
- package/dist/server/_chunks/index-yhxkxghe.js +56 -0
- package/dist/server/_chunks/index-ym67zqxp.js +130 -0
- package/dist/server/_chunks/index-ytjvpbm2.js +736 -0
- package/dist/server/_chunks/index-yz54pxrh.js +960 -0
- package/dist/server/_chunks/index-z4z9zv3b.js +733 -0
- package/dist/server/_chunks/index-z84ab1w0.js +1270 -0
- package/dist/server/_chunks/index-z88qv16t.js +11 -0
- package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
- package/dist/server/_chunks/loader-7yw0j98z.js +78 -0
- package/dist/server/_chunks/modules-jn8bmbn8.js +74 -0
- package/dist/server/_chunks/pipeline-yy9jhydf.js +832 -0
- package/dist/server/_chunks/production-jar9ztm3.js +44 -0
- package/dist/server/_chunks/proxy-config-j84dgksn.js +21 -0
- package/dist/server/_chunks/proxy-w1d0wmsn.js +33 -0
- package/dist/server/_chunks/router-k1reahfn.js +498 -0
- package/dist/server/_chunks/routes-2s277fc6.js +64 -0
- package/dist/server/_chunks/run-pvd8bs1t.js +696 -0
- package/dist/server/_chunks/server-mt4a994c.js +1835 -0
- package/dist/server/_chunks/tsconfig-defaults-1nb3308g.js +20 -0
- package/dist/server/_chunks/typegen-0qr0459b.js +35 -0
- package/dist/server/api/client-cache.js +14 -0
- package/dist/server/cli/index.js +378 -0
- package/dist/server/cli/start.js +137 -0
- package/dist/server/client/reference.js +16 -0
- package/dist/server/compat/next/cache.js +56 -0
- package/dist/server/compat/next/canonical-url.js +13 -0
- package/dist/server/compat/next/client-cache.js +57 -0
- package/dist/server/compat/next/client-navigation.js +232 -0
- package/dist/server/compat/next/client-only.js +1 -0
- package/dist/server/compat/next/client-script.js +178 -0
- package/dist/server/compat/next/client-server.js +34 -0
- package/dist/server/compat/next/config-headers.js +32 -0
- package/dist/server/compat/next/config-loader.js +25 -0
- package/dist/server/compat/next/config.js +10 -0
- package/dist/server/compat/next/constants.js +18 -0
- package/dist/server/compat/next/custom-server.js +10 -0
- package/dist/server/compat/next/dist/client/components/app-router-headers.js +48 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/revalidate.js +27 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-cache.js +25 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-no-store.js +25 -0
- package/dist/server/compat/next/dynamic.js +32 -0
- package/dist/server/compat/next/error.js +112 -0
- package/dist/server/compat/next/font/cache.js +14 -0
- package/dist/server/compat/next/font/google.js +3 -0
- package/dist/server/compat/next/font/index.js +1 -0
- package/dist/server/compat/next/font/local.js +22 -0
- package/dist/server/compat/next/font/runtime-client.js +33 -0
- package/dist/server/compat/next/font/runtime.js +41 -0
- package/dist/server/compat/next/font/shared.js +22 -0
- package/dist/server/compat/next/form.js +129 -0
- package/dist/server/compat/next/head.js +10 -0
- package/dist/server/compat/next/headers.js +30 -0
- package/dist/server/compat/next/image/client.js +11 -0
- package/dist/server/compat/next/image/config.js +18 -0
- package/dist/server/compat/next/image/optimizer.js +25 -0
- package/dist/server/compat/next/image/patterns.js +12 -0
- package/dist/server/compat/next/image/props.js +16 -0
- package/dist/server/compat/next/image/shared.js +86 -0
- package/dist/server/compat/next/image/static-metadata.js +32 -0
- package/dist/server/compat/next/image/validate.js +8 -0
- package/dist/server/compat/next/image.js +59 -0
- package/dist/server/compat/next/index.js +1 -0
- package/dist/server/compat/next/legacy-image.js +78 -0
- package/dist/server/compat/next/legacy-request-apis.js +24 -0
- package/dist/server/compat/next/link-transform.js +14 -0
- package/dist/server/compat/next/link.js +14 -0
- package/dist/server/compat/next/navigation.js +190 -0
- package/dist/server/compat/next/offline.js +45 -0
- package/dist/server/compat/next/og.js +8 -0
- package/dist/server/compat/next/preferred-region.js +8 -0
- package/dist/server/compat/next/redirects.js +30 -0
- package/dist/server/compat/next/resource-hints.js +30 -0
- package/dist/server/compat/next/rewrites.js +41 -0
- package/dist/server/compat/next/root-params.js +121 -0
- package/dist/server/compat/next/route-state.js +23 -0
- package/dist/server/compat/next/router.js +103 -0
- package/dist/server/compat/next/script.js +37 -0
- package/dist/server/compat/next/server-only.js +1 -0
- package/dist/server/compat/next/server.js +131 -0
- package/dist/server/compat/next/svgr.js +14 -0
- package/dist/server/compat/next/telemetry.js +10 -0
- package/dist/server/compat/next/usage.js +13 -0
- package/dist/server/compat/next/user-agent.js +12 -0
- package/dist/server/compat/next/web-vitals.js +35 -0
- package/dist/server/compat/react/action-state.js +11 -0
- package/dist/server/compat/react/client-lite.js +83 -0
- package/dist/server/compat/react/client.js +131 -0
- package/dist/server/compat/react/compiler-runtime.js +42 -0
- package/dist/server/compat/react/dom-client.js +106 -0
- package/dist/server/compat/react/dom-react-server.js +37 -0
- package/dist/server/compat/react/dom-server.js +40 -0
- package/dist/server/compat/react/dom.js +52 -0
- package/dist/server/compat/react/hooks-extra.js +12 -0
- package/dist/server/compat/react/internals.js +14 -0
- package/dist/server/compat/react/parity.js +11 -0
- package/dist/server/compat/react/preact.js +113 -0
- package/dist/server/compat/react/react-server.js +133 -0
- package/dist/server/compat/react/router-shim.js +8 -0
- package/dist/server/compat/react/server-component-use.js +14 -0
- package/dist/server/compat/react/server-inserted-html.js +14 -0
- package/dist/server/compat/react/server.js +194 -0
- package/dist/server/compat/react/style-values.js +10 -0
- package/dist/server/compat/react/use.js +10 -0
- package/dist/server/compat/react/view-transition.js +12 -0
- package/dist/server/generation.json +1 -0
- package/package.json +4 -1
- package/src/api/dynamic.tsx +2 -0
- package/src/api/server.ts +24 -6
- package/src/cli/adapters/vercel-warm.ts +315 -61
- package/src/cli/adapters/vercel.ts +348 -71
- package/src/cli/build.ts +56 -23
- package/src/cli/index.ts +23 -3
- package/src/cli/serve/entry.ts +9 -2
- package/src/cli/serve/immutable.ts +31 -0
- package/src/cli/serve/pipeline.ts +82 -84
- package/src/cli/start.ts +2 -0
- package/src/client/chunk-fold.ts +19 -6
- package/src/client/react-tier.ts +3 -2
- package/src/client/reference-stub.ts +21 -2
- package/src/compat/actions/client-plugin.ts +4 -2
- package/src/compat/actions/config.ts +6 -5
- package/src/compat/actions/extensions.ts +2 -3
- package/src/compat/aliases.ts +8 -1
- package/src/compat/bundler/config.ts +88 -0
- package/src/compat/bundler/optimize-package-imports.ts +86 -26
- package/src/compat/bundler/relay-transform.ts +15 -3
- package/src/compat/cache-control.ts +16 -8
- package/src/compat/css/modules.ts +18 -5
- package/src/compat/lifecycle/error-funnel.ts +1 -1
- package/src/compat/lifecycle/instrumentation.ts +117 -24
- package/src/compat/lifecycle/testmode.ts +3 -2
- package/src/compat/next/config-loader.ts +137 -13
- package/src/compat/next/font/runtime.ts +22 -2
- package/src/compat/next/og.ts +3 -3
- package/src/compat/next/usage.ts +3 -2
- package/src/compat/pages/api.ts +83 -14
- package/src/compat/pages/router.ts +30 -14
- package/src/compat/register/bundler.ts +3 -1
- package/src/compat/register/middleware.ts +1 -1
- package/src/compat/register/otel.ts +5 -9
- package/src/compat/register/render.ts +3 -1
- package/src/compat/register/use-cache.ts +3 -1
- package/src/compat/release.ts +46 -0
- package/src/compat/segment/serve.ts +1 -1
- package/src/compat/validation/validate.ts +10 -7
- package/src/config.ts +51 -7
- package/src/css/assets.ts +213 -0
- package/src/css/build.ts +174 -238
- package/src/dev/server.ts +27 -8
- package/src/extensions.ts +4 -0
- package/src/render/hooks.ts +13 -0
- package/src/render/renderer.ts +52 -32
- package/src/request/context.ts +9 -0
- package/src/resolve/dynamic.ts +3 -1
- package/src/resolve/imports.ts +12 -52
- package/src/resolve/package-json.ts +56 -0
- package/src/resolve/scan-facts.ts +65 -0
- package/src/routing/href.ts +10 -3
- package/src/routing/match.ts +287 -0
- package/src/routing/metadata-files.ts +19 -5
- package/src/routing/proxy-config.ts +137 -0
- package/src/routing/proxy.ts +35 -134
- package/src/routing/routes.ts +22 -281
- package/src/runtime/fingerprint.ts +23 -8
- package/src/runtime/load.ts +170 -0
- package/src/runtime/loader.ts +215 -43
- package/src/runtime/module-cache.ts +13 -0
- package/src/runtime/modules.ts +370 -81
- package/src/runtime/prebundle.ts +81 -0
- package/src/runtime/production.ts +391 -0
- package/src/runtime/release-graph.ts +334 -0
- package/src/runtime/vendor-build.ts +724 -13
- package/src/runtime/vendor.ts +16 -3
- package/src/types.ts +2 -0
- package/src/utils/fs.ts +89 -3
package/src/cli/build.ts
CHANGED
|
@@ -25,13 +25,15 @@ import { beginSourceScope, endSourceScope, sourceCacheStats } from '../resolve/s
|
|
|
25
25
|
import { flushDevModuleCaches } from '../runtime/module-cache'
|
|
26
26
|
import { scanFactsStats } from '../resolve/scan-facts'
|
|
27
27
|
import { clientEntryName } from '../client/chunk-name'
|
|
28
|
+
import { compiledClientReferenceFiles } from '../client/reference'
|
|
29
|
+
import { buildIndexFile } from '../runtime/production'
|
|
28
30
|
import { registerServerRuntime, serverBundleTargetForRuntime } from '../runtime/loader'
|
|
29
31
|
import {
|
|
30
|
-
buildClientReferenceCss,
|
|
31
32
|
buildGlobalCss,
|
|
32
33
|
buildNotFoundCss,
|
|
33
|
-
|
|
34
|
+
buildRouteStylesheets,
|
|
34
35
|
emittedAssetNames,
|
|
36
|
+
globalCssSources,
|
|
35
37
|
prepareRouteCssChunks,
|
|
36
38
|
registerCssRuntime,
|
|
37
39
|
warmCssPipeline,
|
|
@@ -72,6 +74,7 @@ import {
|
|
|
72
74
|
devServerModuleHref,
|
|
73
75
|
resetModuleGraphFailure,
|
|
74
76
|
setEmitCompiledSpecifiersManifest,
|
|
77
|
+
setReleaseCompile,
|
|
75
78
|
throwIfModuleGraphFailed,
|
|
76
79
|
} from '../runtime/modules'
|
|
77
80
|
import {
|
|
@@ -92,6 +95,7 @@ import { interceptionMarkerLevels } from '../routing/slots'
|
|
|
92
95
|
import { writeTypegen } from './typegen'
|
|
93
96
|
import { lookupBuildCache, writeBuildCache } from './build/cache'
|
|
94
97
|
import { emitServerEntry } from './serve/entry'
|
|
98
|
+
import { immutableAssetPath } from './serve/immutable'
|
|
95
99
|
import { createVerboseLogger, type VerboseLogger } from '../utils/verbose'
|
|
96
100
|
import { bold, cyan, dim, green } from '../utils/ansi'
|
|
97
101
|
import type {
|
|
@@ -165,6 +169,7 @@ export async function buildProject(root?: string, options: BuildOptions = {}) {
|
|
|
165
169
|
// Only the vercel adapter's trace step reads the per-artifact specifier
|
|
166
170
|
// sidecars; every other build path pays nothing for them.
|
|
167
171
|
const restoreSpecifiersManifest = setEmitCompiledSpecifiersManifest(options.adapter === 'vercel')
|
|
172
|
+
const restoreReleaseCompile = setReleaseCompile(true)
|
|
168
173
|
const lifecycle: { warm?: WarmChild } = {}
|
|
169
174
|
try {
|
|
170
175
|
return await runBuild(root, options, lifecycle)
|
|
@@ -177,6 +182,7 @@ export async function buildProject(root?: string, options: BuildOptions = {}) {
|
|
|
177
182
|
lifecycle.warm?.kill()
|
|
178
183
|
endSourceScope()
|
|
179
184
|
restoreSpecifiersManifest()
|
|
185
|
+
restoreReleaseCompile()
|
|
180
186
|
flushDevModuleCaches()
|
|
181
187
|
}
|
|
182
188
|
}
|
|
@@ -225,11 +231,12 @@ async function runBuild(
|
|
|
225
231
|
const warmMode = options.adapter === 'vercel' ? 'full' : 'compile'
|
|
226
232
|
const warm = startWarmChild(config, warmMode)
|
|
227
233
|
lifecycle.warm = warm
|
|
228
|
-
await log.step('prepare output directory', async () => {
|
|
234
|
+
const publicFiles = await log.step('prepare output directory', async () => {
|
|
229
235
|
// Build-owned outputs only: `<outRoot>/dev` belongs to a possibly-running
|
|
230
236
|
// dev server and must survive.
|
|
231
|
-
|
|
232
|
-
await
|
|
237
|
+
// Materialized pages sources too: this build's config already resolved into them.
|
|
238
|
+
await ensureEmptyDir(config.outPath, [devOutSegment, 'pnext-pages-compat'])
|
|
239
|
+
return copyPublicDir(config.publicPath, path.join(config.outPath, 'public'))
|
|
233
240
|
})
|
|
234
241
|
// The document-level stylesheets run their postcss/Tailwind pass on the CSS
|
|
235
242
|
// worker, so they overlap with the route scan below instead of serializing
|
|
@@ -305,6 +312,14 @@ async function runBuild(
|
|
|
305
312
|
// - those are awaited just before the first route stylesheet is emitted, which lets a Tailwind
|
|
306
313
|
// pass run under the build steps and the client bundles instead of ahead of them.
|
|
307
314
|
prepareRouteCssChunks(routes)
|
|
315
|
+
// Route stylesheets bundle all at once under the client stage; the loop below publishes each
|
|
316
|
+
// route's names right before its prerender, after the document ones.
|
|
317
|
+
const routeStylesheets = buildRouteStylesheets(
|
|
318
|
+
config,
|
|
319
|
+
routes.filter(route => route.kind !== 'handler' && !route.dynamicErrorApi),
|
|
320
|
+
documentCss,
|
|
321
|
+
{ verbose },
|
|
322
|
+
)
|
|
308
323
|
// output:'export' with trailingSlash:false lays prerendered pages out flat
|
|
309
324
|
// (`/a.html` rather than `/a/index.html`). Only meaningful under compat (the
|
|
310
325
|
// Next config carries `output`); pure-core apps always use the dir layout.
|
|
@@ -353,9 +368,11 @@ async function runBuild(
|
|
|
353
368
|
)
|
|
354
369
|
: undefined
|
|
355
370
|
metadataWarnings?.catch(() => undefined)
|
|
356
|
-
|
|
371
|
+
// Imports the route modules; the client stage needs none of it, so both run at once.
|
|
372
|
+
const moduleMetadata = log.step('core module metadata', () =>
|
|
357
373
|
collectStaticModuleMetadata(config, routes),
|
|
358
374
|
)
|
|
375
|
+
moduleMetadata.catch(() => undefined)
|
|
359
376
|
|
|
360
377
|
const actionSources = buildState.actionSources ?? buildState.actions.map(a => a.sourceKey)
|
|
361
378
|
// realpath, not resolve: a hybrid app's routes are scanned through the pages-compat mirror, whose
|
|
@@ -366,13 +383,18 @@ async function runBuild(
|
|
|
366
383
|
// A node_modules action module never lands in route.sourceFiles itself (that walk stops at the
|
|
367
384
|
// package boundary), so a route reaching one only through a first-party importer is matched here.
|
|
368
385
|
const actionImporters = new Set((buildState.actionImporters ?? []).map(realFilePath))
|
|
386
|
+
// Routes share most of their files; resolve each once.
|
|
387
|
+
const realFiles = new Map<string, string>()
|
|
388
|
+
const reachesAction = (file: string) => {
|
|
389
|
+
let real = realFiles.get(file)
|
|
390
|
+
if (real === undefined) realFiles.set(file, (real = realFilePath(file)))
|
|
391
|
+
return actionFiles.has(real) || actionImporters.has(real)
|
|
392
|
+
}
|
|
369
393
|
for (const route of routes) {
|
|
370
394
|
if (
|
|
371
395
|
route.kind === 'page' &&
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
return actionFiles.has(real) || actionImporters.has(real)
|
|
375
|
-
})
|
|
396
|
+
(actionFiles.size > 0 || actionImporters.size > 0) &&
|
|
397
|
+
route.sourceFiles.some(reachesAction)
|
|
376
398
|
) {
|
|
377
399
|
addClientEntryReason(route, 'actions')
|
|
378
400
|
}
|
|
@@ -400,14 +422,14 @@ async function runBuild(
|
|
|
400
422
|
// other document does, and those names are only final once the client stage has
|
|
401
423
|
// fingerprinted them — so this render follows the bundle rather than racing it.
|
|
402
424
|
// Result is consumed after the prerender pass, where it always was.
|
|
403
|
-
const notFoundDocuments = clientBundles.then(() =>
|
|
425
|
+
const notFoundDocuments = clientBundles.then(async () =>
|
|
404
426
|
renderNotFoundDocuments({
|
|
405
427
|
config,
|
|
406
428
|
log,
|
|
407
429
|
skip: options.buildMode === 'compile',
|
|
408
430
|
documentCss,
|
|
409
431
|
staticMetadataFiles,
|
|
410
|
-
staticModuleMetadata,
|
|
432
|
+
staticModuleMetadata: await moduleMetadata,
|
|
411
433
|
}),
|
|
412
434
|
)
|
|
413
435
|
notFoundDocuments.catch(() => undefined)
|
|
@@ -420,6 +442,7 @@ async function runBuild(
|
|
|
420
442
|
).then(() => log.step('typegen', () => writeTypegen(config, routes)))
|
|
421
443
|
remainingSteps.catch(() => undefined)
|
|
422
444
|
await remainingSteps
|
|
445
|
+
const staticModuleMetadata = await moduleMetadata
|
|
423
446
|
await clientBundles
|
|
424
447
|
const proxyModule = await proxyBuild
|
|
425
448
|
await partytownLib
|
|
@@ -472,8 +495,7 @@ async function runBuild(
|
|
|
472
495
|
const generateFailures: { route: string; omitErrorLine: boolean }[] = []
|
|
473
496
|
if (isGenerate) console.log(' Collecting page data ...')
|
|
474
497
|
|
|
475
|
-
//
|
|
476
|
-
// point that needs them, so everything above ran alongside the CSS worker.
|
|
498
|
+
// The first point that needs the stylesheets, so everything above ran alongside them.
|
|
477
499
|
await documentCss
|
|
478
500
|
|
|
479
501
|
for (const route of routes) {
|
|
@@ -515,10 +537,7 @@ async function runBuild(
|
|
|
515
537
|
continue
|
|
516
538
|
}
|
|
517
539
|
|
|
518
|
-
await
|
|
519
|
-
for (const reference of route.clientReferences) {
|
|
520
|
-
await buildClientReferenceCss(config, reference, { verbose })
|
|
521
|
-
}
|
|
540
|
+
await routeStylesheets.get(route)?.()
|
|
522
541
|
|
|
523
542
|
// Compile mode bundles only — every prerender/export step is generate's.
|
|
524
543
|
if (isCompile) continue
|
|
@@ -906,6 +925,7 @@ async function runBuild(
|
|
|
906
925
|
// carries its entries, so this is where it has to have landed.
|
|
907
926
|
await deferredSteps
|
|
908
927
|
const actions = buildState.actions
|
|
928
|
+
const publicAssets = publicFiles.filter(relative => immutableAssetPath(relative))
|
|
909
929
|
const manifest: BuildManifest = {
|
|
910
930
|
version: 0,
|
|
911
931
|
root: config.root,
|
|
@@ -916,6 +936,7 @@ async function runBuild(
|
|
|
916
936
|
// The serving process re-publishes these so a render resolves the same
|
|
917
937
|
// content-hashed names the build emitted.
|
|
918
938
|
assetNames: emittedAssetNames(config.outPath),
|
|
939
|
+
...(publicAssets.length > 0 ? { publicAssets } : {}),
|
|
919
940
|
staticMetadataFiles,
|
|
920
941
|
...(Object.keys(staticModuleMetadata).length > 0 ? { staticModuleMetadata } : {}),
|
|
921
942
|
...(!config.compat?.next
|
|
@@ -941,7 +962,19 @@ async function runBuild(
|
|
|
941
962
|
// Plain build: the adapter owns the child in the branch above. Compiling the
|
|
942
963
|
// rest of the app's modules is build work, so it counts toward the build's own
|
|
943
964
|
// duration rather than hiding after it.
|
|
944
|
-
else
|
|
965
|
+
else {
|
|
966
|
+
await log.step('warm module cache', () =>
|
|
967
|
+
warm.finish(log, undefined, {
|
|
968
|
+
globalCss: globalCssSources(config),
|
|
969
|
+
clientReferences: [...compiledClientReferenceFiles()],
|
|
970
|
+
}),
|
|
971
|
+
)
|
|
972
|
+
}
|
|
973
|
+
// The release names every module production imports; a server compile that did not finish
|
|
974
|
+
// fails the build here rather than a request later.
|
|
975
|
+
if (!existsSync(buildIndexFile(config.outPath))) {
|
|
976
|
+
throw new Error('pnext build: the server compile did not complete (see the error above).')
|
|
977
|
+
}
|
|
945
978
|
|
|
946
979
|
// Also cover module loads performed by completion hooks or the warm pass.
|
|
947
980
|
throwIfModuleGraphFailed()
|
|
@@ -3194,11 +3227,11 @@ function resolvePartytownLibDir(root: string): string | null {
|
|
|
3194
3227
|
}
|
|
3195
3228
|
|
|
3196
3229
|
async function copyPublicDir(from: string, to: string) {
|
|
3197
|
-
const files = await listFiles(from)
|
|
3198
|
-
for (const
|
|
3199
|
-
const relative = toPosixPath(path.relative(from, file))
|
|
3230
|
+
const files = (await listFiles(from)).map(file => toPosixPath(path.relative(from, file)))
|
|
3231
|
+
for (const relative of files) {
|
|
3200
3232
|
const target = path.join(to, relative)
|
|
3201
3233
|
await mkdir(path.dirname(target), { recursive: true })
|
|
3202
|
-
await copyFile(
|
|
3234
|
+
await copyFile(path.join(from, relative), target)
|
|
3203
3235
|
}
|
|
3236
|
+
return files
|
|
3204
3237
|
}
|
package/src/cli/index.ts
CHANGED
|
@@ -50,8 +50,8 @@ markBoot('cli:entry')
|
|
|
50
50
|
namedBunBinary(commandBinaryName(command))
|
|
51
51
|
|
|
52
52
|
// Before any command lazily imports esbuild, which captures the binary path on
|
|
53
|
-
// module load.
|
|
54
|
-
nameEsbuildProcess()
|
|
53
|
+
// module load. `start` serves a finished build and never loads it.
|
|
54
|
+
if (command !== 'start') nameEsbuildProcess()
|
|
55
55
|
markBoot('cli:naming')
|
|
56
56
|
|
|
57
57
|
try {
|
|
@@ -90,7 +90,10 @@ try {
|
|
|
90
90
|
} else if (command === 'start') {
|
|
91
91
|
warnUnknownFlags(command, args)
|
|
92
92
|
const root = positionalRoot(args)
|
|
93
|
-
|
|
93
|
+
// A build of other source than this prebundle's is served from that source.
|
|
94
|
+
const { start } = (await prebundleServes(root))
|
|
95
|
+
? await import('./start')
|
|
96
|
+
: ((await import(new URL('./start.ts', import.meta.url).href)) as typeof import('./start'))
|
|
94
97
|
await start({
|
|
95
98
|
root,
|
|
96
99
|
port: optionNumber(args, '--port'),
|
|
@@ -160,6 +163,23 @@ function formatCliError(error: unknown) {
|
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
|
|
166
|
+
declare const PNEXT_PREBUNDLE: { version: string; fingerprint: string } | undefined
|
|
167
|
+
|
|
168
|
+
/** Whether this process's prebundle may serve `root`'s build: one made from its source and version. */
|
|
169
|
+
async function prebundleServes(root = process.cwd()) {
|
|
170
|
+
if (typeof PNEXT_PREBUNDLE !== 'object') return true
|
|
171
|
+
const [{ DEFAULT_OUT_DIR }, { locateRelease, readBuildIndex }] = await Promise.all([
|
|
172
|
+
import('../config'),
|
|
173
|
+
import('../runtime/production'),
|
|
174
|
+
])
|
|
175
|
+
const outPath = locateRelease(path.resolve(root), DEFAULT_OUT_DIR)
|
|
176
|
+
return (
|
|
177
|
+
!outPath ||
|
|
178
|
+
(readBuildIndex(outPath).framework === PNEXT_PREBUNDLE.fingerprint &&
|
|
179
|
+
VERSION === PNEXT_PREBUNDLE.version)
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
163
183
|
function positionalRoot(args: string[]) {
|
|
164
184
|
return positionals(args)[0]
|
|
165
185
|
}
|
package/src/cli/serve/entry.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { readFileSync } from 'node:fs'
|
|
|
7
7
|
import { mkdir, writeFile } from 'node:fs/promises'
|
|
8
8
|
import path from 'node:path'
|
|
9
9
|
import { frameworkFingerprint } from '../../runtime/fingerprint'
|
|
10
|
+
import { readPrebundleStamp } from '../../runtime/prebundle'
|
|
10
11
|
|
|
11
12
|
const frameworkRoot = path.resolve(import.meta.dirname, '..', '..', '..')
|
|
12
13
|
|
|
@@ -31,15 +32,21 @@ export function serverEntryDir(outPath: string): string {
|
|
|
31
32
|
return path.join(outPath, 'server', `bundle-${frameworkVersion()}-${generation}`)
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Write `<outPath>/server/bundle-<version>-<fingerprint>/entry.js`, re-exporting the published
|
|
37
|
+
* prebundle's cli/start.js when it was built from this source, else src/cli/start.ts.
|
|
38
|
+
*/
|
|
35
39
|
export async function emitServerEntry(outPath: string): Promise<void> {
|
|
36
40
|
const start = await Bun.file(path.join(import.meta.dirname, '..', 'start.ts')).text()
|
|
37
41
|
const names = new Bun.Transpiler({ loader: 'ts' }).scan(start).exports
|
|
38
42
|
const dir = serverEntryDir(outPath)
|
|
43
|
+
const target = readPrebundleStamp(frameworkRoot, frameworkFingerprint())
|
|
44
|
+
? '../dist/server/cli/start.js'
|
|
45
|
+
: './cli/start.ts'
|
|
39
46
|
await mkdir(dir, { recursive: true })
|
|
40
47
|
await writeFile(
|
|
41
48
|
path.join(dir, 'entry.js'),
|
|
42
|
-
`const pnext = await import(new URL('
|
|
49
|
+
`const pnext = await import(new URL('${target}', import.meta.resolve('@wular/pnext')).href)\n` +
|
|
43
50
|
`export const { ${names.join(', ')} } = pnext\n`,
|
|
44
51
|
)
|
|
45
52
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getAssetExtensions } from '../../extensions'
|
|
2
|
+
|
|
3
|
+
export const immutableCacheControl = 'public, max-age=31536000, immutable'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Everything the build emits under `assets/` (served at `/_next/static/*` in
|
|
7
|
+
* compat) is immutable, which is the promise Next makes for that whole
|
|
8
|
+
* namespace. It holds because every one of those names carries a content hash:
|
|
9
|
+
* esbuild's for chunks and fonts, assetContentHash for the route entries and the
|
|
10
|
+
* stylesheets (see fingerprintClientEntries / fingerprintAsset), and a build id
|
|
11
|
+
* for `_next/static/<id>/_*Manifest.js`. An UNHASHED name must never reach here —
|
|
12
|
+
* the same URL would answer different bytes after a deploy, and every browser
|
|
13
|
+
* that saw the old ones would keep them for a year.
|
|
14
|
+
*
|
|
15
|
+
* Route outputs (prerendered html, handler bodies) live outside both prefixes
|
|
16
|
+
* and stay revalidating; so do the app's own public/ files (manifest.publicAssets).
|
|
17
|
+
*/
|
|
18
|
+
export function immutableAssetPath(relativePath: string) {
|
|
19
|
+
return immutableAssetPrefixes().some(prefix => relativePath.startsWith(prefix))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The public-relative prefixes `immutableAssetPath` covers. */
|
|
23
|
+
export function immutableAssetPrefixes() {
|
|
24
|
+
return [
|
|
25
|
+
'assets/',
|
|
26
|
+
'_next/static/',
|
|
27
|
+
...getAssetExtensions()
|
|
28
|
+
.staticAssetPublicPrefixes()
|
|
29
|
+
.map(prefix => prefix.replace(/^\/+/, '')),
|
|
30
|
+
]
|
|
31
|
+
}
|