Repository navigation
perf(nuxt,kit)!: make jiti an optional peer dependency - #35943
Conversation
jiti an optional peer dependencyjiti an optional peer dependency
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
44521ca to
53a0fdc
Compare
Merging this PR will degrade performance by 26.73%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
53a0fdc to
4abc83c
Compare
WalkthroughNuxt adds native Node.js TypeScript loading support for compatibility version 5. It updates TypeScript path and extension resolution, generated Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
vitest.config.ts (1)
150-159: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding
retryfor consistency with other heavy test projects.The
fixtureMatrixandbundleprojects both setretry: isCI ? 2 : 0. The newno-jitiproject spawns child processes and builds a fixture, a similar cost profile, but has noretry. A transient CI flake here fails the job without a retry, unlike its siblings.♻️ Proposed change
{ test: { name: 'no-jiti', include: ['test/no-jiti/*.test.ts'], globalSetup: ['./test/setup-prepare.ts'], setupFiles: ['./test/setup-env.ts'], testTimeout: 300_000, + retry: isCI ? 2 : 0, benchmark: { include: [] }, }, },🤖 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 `@vitest.config.ts` around lines 150 - 159, Add the same CI-conditional retry configuration used by the fixtureMatrix and bundle projects to the no-jiti project definition, setting retries to 2 in CI and 0 locally while preserving its existing test settings.
🤖 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 `@docs/1.getting-started/18.upgrade.md`:
- Line 218: Update the upgrade documentation’s schema filename guidance to
require `nuxt.schema` rather than `nuxt.schema.ts` for all Node versions,
matching the `getSchemaLoader()` behavior in `packages/nuxt/src/core/schema.ts`;
do not suggest that JavaScript schema files load natively unless that loader is
implemented.
In `@test/no-jiti/no-jiti.test.ts`:
- Around line 74-79: Update the CI preparation flow before test:no-jiti to build
packages/kit using its existing build or prepack command, after dev:prepare and
test:prepare as appropriate. Ensure packages/kit/dist/index.mjs exists so the
no-jiti assertions execute rather than being skipped.
---
Nitpick comments:
In `@vitest.config.ts`:
- Around line 150-159: Add the same CI-conditional retry configuration used by
the fixtureMatrix and bundle projects to the no-jiti project definition, setting
retries to 2 in CI and 0 locally while preserving its existing test settings.
🪄 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 Plus
Run ID: a7bfd1f4-8212-49e7-a7ff-5ff2ad6c7848
⛔ Files ignored due to path filters (6)
package.jsonis excluded by!package.json,!**/package.jsonpackages/nuxt/package.jsonis excluded by!**/package.jsonpackages/rspack/package.jsonis excluded by!**/package.jsonpackages/vite/package.jsonis excluded by!**/package.jsonpackages/webpack/package.jsonis excluded by!**/package.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (22)
.github/workflows/ci.ymldocs/1.getting-started/18.upgrade.mdknip.jsonpackages/kit/src/diagnostics/config.tspackages/kit/src/index.tspackages/kit/src/loader/config.tspackages/kit/src/template.tspackages/kit/src/types.tspackages/kit/test/generate-types.spec.tspackages/kit/test/jiti-resolution.spec.tspackages/nuxt/src/core/nuxt.tspackages/nuxt/src/core/plugins/plugin-metadata.tspackages/nuxt/src/core/schema.tspackages/nuxt/src/core/templates.tspackages/vite/src/css.tspackages/webpack/src/utils/postcss.tspatches/[email protected]pnpm-workspace.yamltest/no-jiti/block-jiti-loader.mjstest/no-jiti/no-jiti.test.tstest/no-jiti/run-without-jiti.mjsvitest.config.ts
|
|
||
| :: | ||
|
|
||
| A `nuxt.schema.ts` file always needs `jiti`, whatever Node version you are on: its JSDoc annotations are read by an import-time transform rather than by importing the file. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Describe the requirement for every nuxt.schema file.
packages/nuxt/src/core/schema.ts requests getSchemaLoader() before it imports any resolved nuxt.schema file. Without jiti, it skips the file regardless of its extension. Change nuxt.schema.ts to nuxt.schema here, or add native loading for JavaScript schema files.
🤖 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 `@docs/1.getting-started/18.upgrade.md` at line 218, Update the upgrade
documentation’s schema filename guidance to require `nuxt.schema` rather than
`nuxt.schema.ts` for all Node versions, matching the `getSchemaLoader()`
behavior in `packages/nuxt/src/core/schema.ts`; do not suggest that JavaScript
schema files load natively unless that loader is implemented.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/1.getting-started/18.upgrade.md (1)
142-155: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winClarify that this override changes type-checking only.
moduleResolution: 'bundler'anderasableSyntaxOnly: falsedo not restore the previous runtime. They can allow extensionless imports and non-erasable syntax that native Node.js still rejects. Node.js does not usetsconfig.jsonfor runtime resolution and supports only erasable syntax by default. (nodejs.org)Change “previous behaviour” to “previous TypeScript checking behaviour”. State that
jitiremains required for runtime transformations.Proposed wording update
-If you need the previous behaviour, override it: +If you need the previous TypeScript checking behaviour, override the generated `node` tsconfig: ... +This does not restore jiti-based runtime loading. Native loading still requires explicit extensions and erasable TypeScript syntax.#!/bin/sh set -eu tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT printf 'export const value = 1\n' > "$tmp/dep.ts" printf "import './dep'\n" > "$tmp/extensionless.ts" printf 'enum Status { Ready }\n' > "$tmp/non-erasable.ts" node "$tmp/extensionless.ts" 2>"$tmp/extensionless.err" && exit 1 grep -Eq 'ERR_MODULE_NOT_FOUND|Cannot find module' "$tmp/extensionless.err" node "$tmp/non-erasable.ts" 2>"$tmp/non-erasable.err" && exit 1 grep -Eq 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX|TypeScript enum is not supported' "$tmp/non-erasable.err"🤖 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 `@docs/1.getting-started/18.upgrade.md` around lines 142 - 155, Update the wording around the `typescript.nodeTsConfig` override to say it restores the previous TypeScript checking behaviour only, not runtime behaviour. Explicitly state that Node.js does not use `tsconfig.json` for runtime resolution and that `jiti` remains required for runtime transformations, while preserving the existing configuration example.
🤖 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.
Outside diff comments:
In `@docs/1.getting-started/18.upgrade.md`:
- Around line 142-155: Update the wording around the `typescript.nodeTsConfig`
override to say it restores the previous TypeScript checking behaviour only, not
runtime behaviour. Explicitly state that Node.js does not use `tsconfig.json`
for runtime resolution and that `jiti` remains required for runtime
transformations, while preserving the existing configuration example.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c6fad2b8-d30f-45c4-bdf6-5ddcecbac53b
⛔ Files ignored due to path filters (1)
package.jsonis excluded by!package.json,!**/package.json
📒 Files selected for processing (2)
.github/workflows/ci.ymldocs/1.getting-started/18.upgrade.md
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/ci.yml
🔗 Linked issue
📚 Description
this drops
jitias a direct dependency of nuxt, just as nitro has done. in cases where users still need its transformations, nuxt will prompt to install it