Skip to content

perf(nuxt,kit)!: make jiti an optional peer dependency - #35943

Merged
danielroe merged 4 commits into
mainfrom
perf/optional-jiti
Aug 2, 2026
Merged

danielroe merged 4 commits into
mainfrom
perf/optional-jiti

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

this drops jiti as a direct dependency of nuxt, just as nitro has done. in cases where users still need its transformations, nuxt will prompt to install it

@github-actions github-actions Bot added the 🐛 bug Something isn't working as expected label Aug 2, 2026
@danielroe danielroe changed the title fix(nuxt,kit)!: make jiti an optional peer dependency perf(nuxt,kit)!: make jiti an optional peer dependency Aug 2, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35943

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35943

nuxt

npm i https://pkg.pr.new/nuxt@35943

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35943

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35943

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35943

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35943

commit: 1d18549

@danielroe
danielroe force-pushed the perf/optional-jiti branch from 44521ca to 53a0fdc Compare August 2, 2026 09:22
@codspeed

codspeed Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 26.73%

❌ 1 regressed benchmark
✅ 20 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ writeTypes in the basic-types fixture 52.3 ms 71.4 ms -26.73%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/optional-jiti (1d18549) with main (c6a7d2b)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Base automatically changed from perf/kit-jiti to main August 2, 2026 10:44
@danielroe
danielroe force-pushed the perf/optional-jiti branch from 53a0fdc to 4abc83c Compare August 2, 2026 12:45
@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Nuxt adds native Node.js TypeScript loading support for compatibility version 5. It updates TypeScript path and extension resolution, generated nodeTsConfig settings, schema loading, and PostCSS plugin resolution. Schema loading now reports NUXT_B5019 when jiti is unavailable. The repository adds no-jiti loader tests, fixture checks, package manifest checks, Vitest configuration, and CI execution. Migration documentation describes the new loading requirements and optional jiti fallback.

Possibly related PRs

  • nuxt/nuxt#35451: Updates the same Kit type-path APIs and Nuxt integration.
  • nuxt/nuxt#35901: Modifies lazy jiti and schema loading in packages/nuxt/src/core/schema.ts.
  • nuxt/nuxt#35936: Modifies Nuxt jiti handling, configuration loading, diagnostics, and related tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: making jiti an optional peer dependency for Nuxt and Kit.
Description check ✅ Passed The description directly explains removing jiti as a direct dependency and prompting users to install it when required.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/optional-jiti

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
vitest.config.ts (1)

150-159: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider adding retry for consistency with other heavy test projects.

The fixtureMatrix and bundle projects both set retry: isCI ? 2 : 0. The new no-jiti project spawns child processes and builds a fixture, a similar cost profile, but has no retry. 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

📥 Commits

Reviewing files that changed from the base of the PR and between c6a7d2b and 4abc83c.

⛔ Files ignored due to path filters (6)
  • package.json is excluded by !package.json, !**/package.json
  • packages/nuxt/package.json is excluded by !**/package.json
  • packages/rspack/package.json is excluded by !**/package.json
  • packages/vite/package.json is excluded by !**/package.json
  • packages/webpack/package.json is excluded by !**/package.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (22)
  • .github/workflows/ci.yml
  • docs/1.getting-started/18.upgrade.md
  • knip.json
  • packages/kit/src/diagnostics/config.ts
  • packages/kit/src/index.ts
  • packages/kit/src/loader/config.ts
  • packages/kit/src/template.ts
  • packages/kit/src/types.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/kit/test/jiti-resolution.spec.ts
  • packages/nuxt/src/core/nuxt.ts
  • packages/nuxt/src/core/plugins/plugin-metadata.ts
  • packages/nuxt/src/core/schema.ts
  • packages/nuxt/src/core/templates.ts
  • packages/vite/src/css.ts
  • packages/webpack/src/utils/postcss.ts
  • patches/[email protected]
  • pnpm-workspace.yaml
  • test/no-jiti/block-jiti-loader.mjs
  • test/no-jiti/no-jiti.test.ts
  • test/no-jiti/run-without-jiti.mjs
  • vitest.config.ts

Comment thread docs/1.getting-started/18.upgrade.md Outdated

::

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Comment thread test/no-jiti/no-jiti.test.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Clarify that this override changes type-checking only.

moduleResolution: 'bundler' and erasableSyntaxOnly: false do not restore the previous runtime. They can allow extensionless imports and non-erasable syntax that native Node.js still rejects. Node.js does not use tsconfig.json for runtime resolution and supports only erasable syntax by default. (nodejs.org)

Change “previous behaviour” to “previous TypeScript checking behaviour”. State that jiti remains 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

📥 Commits

Reviewing files that changed from the base of the PR and between fcf4495 and 1d18549.

⛔ Files ignored due to path filters (1)
  • package.json is excluded by !package.json, !**/package.json
📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • docs/1.getting-started/18.upgrade.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

@danielroe
danielroe added this pull request to the merge queue Aug 2, 2026
Merged via the queue into main with commit d1f774d Aug 2, 2026
37 checks passed
@danielroe
danielroe deleted the perf/optional-jiti branch August 2, 2026 13:39
@github-actions github-actions Bot mentioned this pull request Aug 2, 2026
2 of 5 tasks
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
@github-actions github-actions Bot mentioned this pull request Aug 12, 2026
@github-actions github-actions Bot mentioned this pull request Aug 28, 2026
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant