Repository navigation
feat(kit,nitro,nuxt,schema,vite,webpack): nuxt/* build output contract - #35463
Conversation
nuxt/* build output contract
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
db22308 to
829c1b9
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
packages/nitro-server/src/legacy.ts (1)
23-28: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winPublish the dev server entry through
buildOutputs.Line 27 bypasses the new
NuxtBuildOutputscontract by overridingnitro.options.virtualdirectly. RegisteringserverEntrykeeps webpack/rspack dev aligned with theNUXT_BUILD_OUTPUT_MAPpath used by Nitro.Proposed change
-import { logger } from '`@nuxt/kit`' +import { logger, setBuildOutput } from '`@nuxt/kit`' @@ if (name === 'server') { const memfs = compiler.outputFileSystem as typeof import('node:fs') - nitro.options.virtual['nuxt/entry'] = () => memfs.readFileSync(join(nuxt.options.buildDir, 'dist/server/server.mjs'), 'utf-8') + setBuildOutput(nuxt, 'serverEntry', () => memfs.readFileSync(join(nuxt.options.buildDir, 'dist/server/server.mjs'), 'utf-8')) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/nitro-server/src/legacy.ts` around lines 23 - 28, The dev server entry is being injected by mutating nitro.options.virtual directly in the legacy builder hook, which bypasses the NuxtBuildOutputs contract. Update the builder logic in legacy.ts so the server entry is registered through buildOutputs as serverEntry instead of setting nitro.options.virtual['nuxt/entry'], keeping the webpack/rspack path aligned with the NUXT_BUILD_OUTPUT_MAP/Nitro flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/nitro-server/src/runtime/utils/renderer/build-files.ts`:
- Around line 34-36: The getPrecomputedDependencies loader is incorrectly using
a fallback that treats an undefined default export from nuxt/precomputed as
missing, which can pass the module namespace into createRenderer instead of
preserving no precomputed data. Update getPrecomputedDependencies in
build-files.ts to only use the default export when it is actually present, while
still allowing an explicit undefined result to flow through unchanged; keep the
function’s return behavior consistent for both function and value exports.
In `@packages/nuxt/src/core/nuxt.ts`:
- Line 85: The fallback serverEntry in nuxt.ts currently returns a no-op module,
which hides the intended builder-misconfiguration failure. Update the
serverEntry fallback to fail fast by reusing the same explicit error behavior as
the runtime server entry in packages/nuxt/src/runtime/server/entry.ts, so
missing nuxt.buildOutputs publishing surfaces the “[nuxt] nuxt/entry was not
replaced...” message. Use the serverEntry symbol in Nuxt config to locate and
replace the current placeholder implementation with an error-throwing or
error-emitting entry.
In `@packages/schema/src/types/nuxt.ts`:
- Around line 99-100: The `ssrStyles` value in the Nuxt schema is being
re-exported as a raw path, which can break ESM imports when it is an absolute
Windows path. Update the handling around `ssrStyles` in the Nuxt
virtual-module/export flow so it is normalized before being interpolated into
`export { default } from ...`; use the existing `ssrStyles` symbol to locate the
boundary where the specifier is formed and convert absolute paths to a `file://`
URL or equivalent normalized form.
---
Nitpick comments:
In `@packages/nitro-server/src/legacy.ts`:
- Around line 23-28: The dev server entry is being injected by mutating
nitro.options.virtual directly in the legacy builder hook, which bypasses the
NuxtBuildOutputs contract. Update the builder logic in legacy.ts so the server
entry is registered through buildOutputs as serverEntry instead of setting
nitro.options.virtual['nuxt/entry'], keeping the webpack/rspack path aligned
with the NUXT_BUILD_OUTPUT_MAP/Nitro flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 24e85b56-6d94-45de-ad0f-cd2487f54df5
⛔ Files ignored due to path filters (1)
packages/nuxt/package.jsonis excluded by!**/package.json
📒 Files selected for processing (26)
packages/kit/src/build.tspackages/kit/src/index.tspackages/nitro-server/src/index.tspackages/nitro-server/src/legacy.tspackages/nitro-server/src/runtime/handlers/renderer.tspackages/nitro-server/src/runtime/utils/renderer/build-files.tspackages/nitro-server/src/runtime/utils/renderer/cache.tspackages/nuxt/src/core/nuxt.tspackages/nuxt/src/runtime/server/entry-chunk.tspackages/nuxt/src/runtime/server/entry-ids.tspackages/nuxt/src/runtime/server/entry.tspackages/nuxt/src/runtime/server/manifest.tspackages/nuxt/src/runtime/server/precomputed.tspackages/nuxt/src/runtime/server/styles.tspackages/nuxt/tsdown.config.tspackages/schema/src/index.tspackages/schema/src/types/nuxt.tspackages/vite/src/plugins/client-manifest.tspackages/vite/src/plugins/server-entry.tspackages/vite/src/plugins/ssr-styles.tspackages/vite/src/plugins/stable-entry.tspackages/vite/src/plugins/vite-node.tspackages/vite/src/vite.tspackages/webpack/src/plugins/ssr-styles.tspackages/webpack/src/plugins/vue/client.tspackages/webpack/src/webpack.ts
Merging this PR will not alter performance
Comparing Footnotes
|
🔗 Linked issue
📚 Description
this is a step towards the vite environment api by finalising a contract between builders and nuxt itself
relevant for #35364