Skip to content

refactor: downgrade to nitro v2 #32252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 31, 2025
Merged

refactor: downgrade to nitro v2 #32252

merged 3 commits into from
May 31, 2025

Conversation

danielroe
Copy link
Member

🔗 Linked issue

📚 Description

this moves main branch to use nitropack v2.

@Copilot Copilot AI review requested due to automatic review settings May 31, 2025 21:38
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Nuxt codebase to downgrade support from Nitro to NitroPack v2. The changes replace package and import references throughout the codebase and update related documentation and configuration files.

  • Replace import paths from 'nitro' to 'nitropack'
  • Update package.json dependencies to use nitropack v2
  • Adjust configuration settings and module aliases to support NitroPack

Reviewed Changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/nuxt/src/core/runtime/nitro/utils/cache.ts Update storage import from nitro/runtime to nitropack/runtime
packages/nuxt/src/core/runtime/nitro/plugins/dev-server-logs.ts Update type imports from nitro/types to nitropack/types
packages/nuxt/src/core/runtime/nitro/handlers/*.ts Update various handler imports to use nitropack/runtime and types
packages/nuxt/src/core/plugins/resolved-externals.ts Adjust external resolution to reference nitropack/runtime/meta
packages/nuxt/src/core/nuxt.ts Update VirtualFSPlugin aliases and add new alias mappings for nitropack/runtime
packages/nuxt/src/core/nitro.ts Replace import paths and add appConfig and priority configuration for useAppConfig
packages/nuxt/src/app/*.ts Update various type imports from nitro/types to nitropack/types
packages/kit/src/pages.ts, packages/kit/src/nitro.ts Update type imports from nitro/types to nitropack/types
package.json files and docs Replace dependency versions from nitro to nitropack and update documentation accordingly
Comments suppressed due to low confidence (1)

packages/nuxt/src/core/nitro.ts:248

  • The addition of 'priority: -1' may affect the ordering of import execution. Please verify that a negative priority is intentional and that its behavior is well-documented in the configuration context.
priority: -1,

Copy link

socket-security bot commented May 31, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License

View full report

Copy link

coderabbitai bot commented May 31, 2025

Walkthrough

This set of changes systematically updates import paths, type declarations, and module augmentations throughout the codebase, shifting references from the nitro package to the nitropack package. All TypeScript type imports, runtime utility imports, and module declaration strings have been adjusted to use nitropack as the primary namespace. Additional alias mappings for nitropack/runtime and related modules are introduced in build configurations for Vite and Webpack. The Nitro configuration passed to createNitro is extended with app configuration files and usage priority. The handling of the dynamic-require Rollup plugin is improved to avoid duplicates. Some test assertions are updated to reflect new bundle sizes, and a new PostCSS plugin is added for testing. No significant changes to logic or public API signatures are present.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7dc6b6b and ee3f49b.

📒 Files selected for processing (1)
  • packages/vite/src/server.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/vite/src/server.ts
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: test-fixtures (windows-latest, built, vite, async, manifest-on, json, 20)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, async, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, 20)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, default, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, rspack, async, manifest-on, json, 20)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, async, manifest-off, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-off, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, js, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-off, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, js, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-off, json, 20)
  • GitHub Check: typecheck (ubuntu-latest, bundler)
  • GitHub Check: release-pr
  • GitHub Check: typecheck (windows-latest, bundler)
  • GitHub Check: test-benchmark
  • GitHub Check: lint-docs
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/nuxt/types.d.ts (1)

18-43: Consider consolidating duplicate module declarations.

There are now two module declarations with identical interface definitions - one for 'nitropack' (lines 18-43) and one for 'nitropack/types' (lines 44-69). This duplication might lead to maintenance issues and confusion.

Consider whether both module declarations are necessary, or if they can be consolidated to reduce duplication:

-declare module 'nitropack' {
-  interface NitroRuntimeConfigApp {
-    buildAssetsDir: string
-    cdnURL: string
-  }
-  // ... other interfaces
-}
declare module 'nitropack/types' {
  interface NitroRuntimeConfigApp {
    buildAssetsDir: string
    cdnURL: string
  }
  // ... other interfaces
}

Also applies to: 44-69

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bec85df and 7dc6b6b.

⛔ Files ignored due to path filters (7)
  • package.json is excluded by !package.json, !**/package.json
  • packages/kit/package.json is excluded by !**/package.json
  • packages/nuxt/package.json is excluded by !**/package.json
  • packages/schema/package.json is excluded by !**/package.json
  • packages/vite/package.json is excluded by !**/package.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
  • test/fixtures/basic/package.json is excluded by !**/package.json
📒 Files selected for processing (43)
  • docs/2.guide/3.going-further/1.events.md (1 hunks)
  • docs/2.guide/3.going-further/3.modules.md (1 hunks)
  • docs/3.api/5.kit/11.nitro.md (1 hunks)
  • packages/kit/src/nitro.ts (2 hunks)
  • packages/kit/src/pages.ts (1 hunks)
  • packages/nuxt/src/app/composables/fetch.ts (1 hunks)
  • packages/nuxt/src/app/composables/manifest.ts (1 hunks)
  • packages/nuxt/src/app/composables/ssr.ts (1 hunks)
  • packages/nuxt/src/app/nuxt.ts (1 hunks)
  • packages/nuxt/src/core/nitro.ts (3 hunks)
  • packages/nuxt/src/core/nuxt.ts (1 hunks)
  • packages/nuxt/src/core/plugins/resolved-externals.ts (2 hunks)
  • packages/nuxt/src/core/runtime/nitro/handlers/error.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/handlers/island.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/handlers/renderer.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/plugins/dev-server-logs.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/utils/cache.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/utils/paths.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/utils/renderer/app.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/utils/renderer/build-files.ts (1 hunks)
  • packages/nuxt/src/core/runtime/nitro/utils/renderer/payload.ts (1 hunks)
  • packages/nuxt/src/core/templates.ts (3 hunks)
  • packages/nuxt/src/pages/module.ts (3 hunks)
  • packages/nuxt/src/pages/route-rules.ts (1 hunks)
  • packages/nuxt/src/pages/runtime/composables.ts (1 hunks)
  • packages/nuxt/test/nitro/render-index.ts (1 hunks)
  • packages/nuxt/types.d.mts (2 hunks)
  • packages/nuxt/types.d.ts (2 hunks)
  • packages/schema/src/config/nitro.ts (3 hunks)
  • packages/schema/src/config/typescript.ts (1 hunks)
  • packages/schema/src/types/config.ts (1 hunks)
  • packages/schema/src/types/debug.ts (1 hunks)
  • packages/schema/src/types/hooks.ts (1 hunks)
  • packages/schema/src/types/schema.ts (1 hunks)
  • packages/vite/src/client.ts (1 hunks)
  • packages/vite/src/server.ts (4 hunks)
  • packages/webpack/src/configs/server.ts (1 hunks)
  • packages/webpack/src/presets/base.ts (1 hunks)
  • packages/webpack/src/webpack.ts (1 hunks)
  • test/bundle.test.ts (3 hunks)
  • test/fixtures/basic-types/types.ts (1 hunks)
  • test/fixtures/basic/nuxt.config.ts (1 hunks)
  • test/fixtures/basic/postcss/plugin.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
test/fixtures/basic/postcss/plugin.ts (1)
packages/nuxt/src/app/nuxt.ts (1)
  • Plugin (226-230)
packages/vite/src/server.ts (1)
packages/vite/src/vite-node.ts (1)
  • initViteNodeServer (176-199)
packages/nuxt/src/core/nuxt.ts (1)
packages/nuxt/src/core/plugins/virtual.ts (1)
  • VirtualFSPlugin (15-92)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build
  • GitHub Check: lint-docs
  • GitHub Check: code
  • GitHub Check: lint-docs
🔇 Additional comments (58)
test/fixtures/basic/nuxt.config.ts (1)

207-211: LGTM! PostCSS configuration correctly added.

The PostCSS plugin configuration syntax is correct and properly references the custom plugin with appropriate empty options.

test/fixtures/basic/postcss/plugin.ts (1)

1-11: LGTM! Well-structured PostCSS plugin implementation.

The plugin correctly follows PostCSS conventions:

  • Proper TypeScript typing with the Plugin interface
  • Standard function signature with options parameter
  • Required postcssPlugin property in return object
  • Compatibility marker postcss = true correctly set

The minimal implementation is appropriate for a test fixture.

packages/nuxt/src/core/runtime/nitro/plugins/dev-server-logs.ts (1)

12-12: Consistent type import update
The import has been correctly switched to nitropack/types for NitroApp, aligning with the downgrade to Nitro v2.

packages/nuxt/src/core/runtime/nitro/utils/renderer/build-files.ts (1)

8-8: Updated runtime config import
The useRuntimeConfig import has been adjusted to nitropack/runtime, ensuring compatibility with the v2 namespace.

packages/nuxt/src/app/composables/ssr.ts (1)

4-4: Fetch event type import adjusted
The H3Event$Fetch type is now imported from nitropack/types, matching the overall Nitro v2 migration.

packages/nuxt/src/core/runtime/nitro/utils/cache.ts (1)

1-1: Storage util import updated
The useStorage import has been updated from nitro/runtime to nitropack/runtime, consistent with the refactor.

packages/nuxt/src/core/runtime/nitro/utils/renderer/payload.ts (1)

1-1: RenderResponse type import switched
The RenderResponse type is now sourced from nitropack/types, aligning with the Nitro v2 refactoring.

packages/schema/src/types/debug.ts (1)

1-1: Switch import path to nitropack/types
The NitroOptions type import has been correctly updated to reflect the new nitropack namespace.

packages/nuxt/src/core/runtime/nitro/utils/renderer/app.ts (1)

2-2: Use nitropack/runtime for runtime config
The useRuntimeConfig import has been updated to the nitropack/runtime entrypoint, matching the PR's migration strategy.

packages/nuxt/src/core/runtime/nitro/utils/paths.ts (1)

2-2: Update runtime import to nitropack/runtime
Updated useRuntimeConfig import to use the nitropack package. This ensures consistent resolution of runtime config across the codebase.

packages/nuxt/src/app/nuxt.ts (1)

10-10: Adjust RenderResponse type import namespace
Switched the RenderResponse type import from nitro/types to nitropack/types to align with the downgraded Nitro version.

packages/nuxt/src/app/composables/manifest.ts (1)

5-5: Import NitroRouteRules from nitropack/types
The NitroRouteRules type import now reflects the nitropack namespace, maintaining consistency in route rules typing.

packages/nuxt/src/pages/route-rules.ts (1)

3-3: Consistent import path migration

The NitroRouteConfig import has been correctly updated from nitro/types to nitropack/types, aligning with the PR’s goal of switching to Nitropack v2.

packages/kit/src/pages.ts (1)

2-2: Aligning type import with Nitropack v2

The NitroRouteConfig type is now imported from nitropack/types instead of nitro/types, which matches the overall migration strategy.

packages/nuxt/src/pages/runtime/composables.ts (1)

5-5: Update composable’s Nitro type import

The import of NitroRouteConfig has been correctly switched to nitropack/types, ensuring consistency with the other route rules updates.

packages/schema/src/types/hooks.ts (1)

9-9: Migrate Nitro hooks types to Nitropack

This change accurately replaces the import of Nitro and NitroConfig from nitro/types to nitropack/types, in line with the refactor to Nitropack v2.

packages/schema/src/types/config.ts (1)

6-6: Switch Nitro config types to Nitropack namespace

The types NitroConfig, NitroRuntimeConfig, and NitroRuntimeConfigApp are now imported from nitropack/types, completing the namespace migration for runtime configuration.

packages/nuxt/src/core/runtime/nitro/handlers/island.ts (1)

1-2: Namespace migration: nitro → nitropack
Imports have been correctly updated to 'nitropack/runtime' and 'nitropack/types'. Ensure that the nitropack package is declared as a dependency and that no stray 'nitro' imports remain in this handler.

packages/nuxt/src/core/runtime/nitro/handlers/error.ts (2)

2-2: Update NitroErrorHandler import
The NitroErrorHandler type import has been migrated to 'nitropack/types', aligning with the refactor. Verify that error handler types resolve correctly under the new namespace.


5-5: Migrate runtime functions to nitropack
Updated imports for useNitroApp and useRuntimeConfig from 'nitro/runtime' to 'nitropack/runtime'. Confirm that runtime configuration and hook behaviour remain intact after this change.

test/fixtures/basic-types/types.ts (1)

6-7: Test fixtures updated to use nitropack
Imports for getRouteRules and the NitroRouteRules type now reference 'nitropack/runtime' and 'nitropack/types'. Ensure coverage for both the direct getRouteRules and aliased getNitroRouteRules paths in these tests.

packages/nuxt/test/nitro/render-index.ts (2)

1-1: Review TS suppression comment
The // @ts-expect-error untyped before the polyfills import may no longer be necessary now that typings are in place. Please verify if this suppression is still required or remove it for clarity.


3-3: NitroApp type import updated
The NitroApp type is now correctly imported from 'nitropack/types'. Double-check that this aligns with the expected interface used in the test harness.

docs/2.guide/3.going-further/1.events.md (1)

77-81: Documentation namespace update
The module augmentation for NitroRuntimeHooks has been updated to reference 'nitropack/types' instead of 'nitro/types'. Ensure the documentation build and any example snippets are updated accordingly.

docs/3.api/5.kit/11.nitro.md (1)

120-120: Import path updated to nitropack/types
The import source has been correctly migrated from 'nitro/types' to 'nitropack/types', keeping documentation in sync with the refactor.

packages/schema/src/types/schema.ts (1)

15-15: Align type imports with nitropack namespace
The Nitro-related types are now imported from 'nitropack/types', which matches the updated package structure across the codebase.

packages/nuxt/src/app/composables/fetch.ts (1)

2-2: Update fetch type imports to nitropack/types
The type imports for $Fetch, H3Event$Fetch, NitroFetchRequest, and related types correctly reference 'nitropack/types' as part of the migration.

docs/2.guide/3.going-further/3.modules.md (1)

617-620: Module augmentation updated to nitropack/types
The module declaration has been rewritten to extend interfaces from 'nitropack/types', in line with the broader migration from the original Nitro package.

packages/nuxt/src/core/plugins/resolved-externals.ts (1)

4-4: LGTM! Import paths correctly updated for nitropack migration.

The import type and dynamic import path have been consistently updated from nitro to nitropack, aligning with the broader package migration across the codebase.

Also applies to: 17-17

packages/vite/src/client.ts (1)

123-125: LGTM! Temporary aliases added for smooth nitropack migration.

The addition of #internal/nitro and nitropack/runtime aliases alongside the existing nitro/runtime alias ensures compatibility during the migration period. The TODO comment clearly indicates these are temporary measures for removal in v5.

packages/nuxt/types.d.ts (1)

1-1: LGTM! Reference directive correctly updated.

The reference directive has been properly updated from "nitro/types" to "nitropack/types" to align with the package migration.

packages/nuxt/src/core/runtime/nitro/handlers/renderer.ts (1)

8-8: LGTM! Import paths correctly migrated to nitropack.

Both the type import (RenderResponse) and runtime function imports (defineRenderHandler, getRouteRules, useNitroApp) have been consistently updated from nitro to nitropack, maintaining functionality while using the new package namespace.

Also applies to: 14-14

packages/webpack/src/webpack.ts (1)

53-59: LGTM: Improved plugin deduplication logic.

The updated logic correctly prevents duplicate dynamic-require plugins by removing any existing instances before adding the new one. This defensive approach ensures consistent plugin application across both prerenderRollupPlugins and rollupPlugins arrays.

packages/schema/src/config/typescript.ts (1)

49-52: LGTM: Temporary hoisting support for nitropack transition.

The addition of nitropack module names to the TypeScript hoisting configuration properly supports the migration to nitropack v2 whilst maintaining compatibility. The TODO comment correctly indicates these are temporary additions planned for removal in v5.

packages/schema/src/config/nitro.ts (4)

7-7: LGTM: Consistent type reference updates for nitropack migration.

The JSDoc type import path changes from 'nitro/types' to 'nitropack/types' correctly align the documentation with the broader migration to nitropack v2. These updates ensure accurate TypeScript intellisense and maintain consistency across the codebase.


42-42: LGTM: Consistent type reference updates for nitropack migration.

The JSDoc type import path changes from 'nitro/types' to 'nitropack/types' correctly align the documentation with the broader migration to nitropack v2.


65-65: LGTM: Consistent type reference updates for nitropack migration.

The JSDoc type import path changes from 'nitro/types' to 'nitropack/types' correctly align the documentation with the broader migration to nitropack v2.


72-72: LGTM: Consistent type reference updates for nitropack migration.

The JSDoc type import path changes from 'nitro/types' to 'nitropack/types' correctly align the documentation with the broader migration to nitropack v2.

packages/webpack/src/presets/base.ts (1)

131-133: LGTM: Transitional alias support for nitropack migration.

The addition of '#internal/nitro' and 'nitropack/runtime' aliases alongside the existing 'nitro/runtime' alias properly supports the migration to nitropack v2 whilst maintaining backwards compatibility. All aliases correctly resolve to the same nitro.client.mjs file, and the TODO comment appropriately indicates these are temporary additions for the transition period.

packages/nuxt/src/core/nuxt.ts (1)

286-292: Expansion of VirtualFS aliases supports the nitropack migration.

The addition of #internal/nitro and nitropack/runtime aliases alongside the existing nitro/runtime alias ensures compatibility during the migration to nitropack v2. All three aliases correctly point to the same client build file.

packages/webpack/src/configs/server.ts (1)

57-59:

✅ Verification successful

External dependencies properly updated for nitropack migration.

The addition of nitropack/runtime to the external set aligns with the migration to nitropack v2. The temporary #internal/nitro alias with the TODO comment for v5 removal provides transitional compatibility.

Verify that these external dependencies are consistently configured across all build tools:


🏁 Script executed:

#!/bin/bash
# Description: Check for consistency of nitro/nitropack externals across build configurations

echo "=== Checking Vite configurations ==="
rg -A 3 -B 3 "nitro.*runtime|nitropack.*runtime" --type ts --glob "**/vite/**"

echo -e "\n=== Checking Webpack configurations ==="  
rg -A 3 -B 3 "nitro.*runtime|nitropack.*runtime" --type ts --glob "**/webpack/**"

echo -e "\n=== Checking for #internal/nitro usage ==="
rg "#internal/nitro" --type ts

Length of output: 4129


Consistency confirmed: Externals identical across build configurations

All instances of the external set and alias mappings now include the same entries for the nitro→nitropack migration, and the // TODO: remove in v5 comment is present everywhere it should be:

• packages/vite/src/server.ts
– SSR external: 'nitro/runtime', '#internal/nitro', '#internal/nitro/utils'
– rollupOptions.external: 'nitro/runtime', '#internal/nitro', 'nitropack/runtime', …

• packages/vite/src/client.ts
– alias:
'nitro/runtime'nitro.client.mjs
'#internal/nitro'nitro.client.mjs
'nitropack/runtime'nitro.client.mjs

• packages/webpack/src/configs/server.ts
– external: 'nitro/runtime', '#internal/nitro', 'nitropack/runtime', …

• packages/webpack/src/presets/base.ts
– alias: same three mappings as above

No discrepancies were found.

packages/nuxt/src/pages/module.ts (2)

13-13: Import source correctly updated for nitropack migration.

The NitroRouteConfig type import has been properly updated from 'nitro/types' to 'nitropack/types', aligning with the broader migration to nitropack v2.


165-169: Module declarations consistently updated for nitropack.

Both TypeScript module declarations have been correctly updated from 'nitro/types' to 'nitropack', ensuring proper type augmentation for the NitroRouteConfig interface in the new package namespace.

Also applies to: 616-620

packages/nuxt/src/core/nitro.ts (3)

7-8: Nitro imports correctly updated for nitropack migration.

The import statements have been properly updated from the nitro package to nitropack, maintaining the same functionality while aligning with the nitropack v2 migration.


132-135: App configuration integration enhanced in Nitro setup.

The addition of appConfig and appConfigFiles properties explicitly integrates Nuxt's app configuration into the Nitro configuration, improving the integration between Nuxt layers and Nitro's app config handling.


248-248: Import priority correctly set for useAppConfig.

The priority: -1 setting ensures proper import ordering for the useAppConfig function, likely preventing conflicts with user-defined imports or other auto-imports.

packages/nuxt/types.d.mts (2)

1-1: LGTM: Reference directive updated for nitropack migration

The triple slash directive has been correctly updated to reference nitropack/types instead of nitro/types, aligning with the broader migration from nitro to nitropack namespace.


18-43: LGTM: Module declaration updated with proper namespace migration

The module declaration has been updated from 'nitro/types' to 'nitropack' whilst maintaining identical interface definitions. The presence of both 'nitropack' and 'nitropack/types' module declarations provides backward compatibility during the migration.

packages/nuxt/src/core/templates.ts (3)

11-11: LGTM: Type import updated for nitropack migration

The import of Nitro type has been correctly updated from 'nitro/types' to 'nitropack/types', consistent with the systematic migration across the codebase.


359-383: LGTM: Module declaration updated for nitropack namespace

The module declaration has been updated from 'nitro/types' to 'nitropack' whilst preserving all interface definitions. This maintains API compatibility during the migration to nitropack.


498-498: LGTM: Runtime import updated for nitropack migration

The conditional import of useRuntimeConfig has been updated from 'nitro/runtime' to 'nitropack/runtime', maintaining the same functionality under the new package namespace.

packages/kit/src/nitro.ts (2)

1-1: LGTM: Type imports updated for nitropack migration

The import statement has been correctly updated from 'nitro/types' to 'nitropack/types', consistent with the systematic migration across the codebase.


14-19:

❓ Verification inconclusive

Verify type assertion change for method property

The type assertion for the method property has been changed to exclude | undefined, but the extraction logic still assigns undefined as the default value when no match is found. This could be a breaking change if downstream code expects the method to potentially be undefined.


🏁 Script executed:

#!/bin/bash
# Description: Check how the method property is used downstream to verify if undefined handling is still needed

# Search for usage of normalizeHandlerMethod and how the method property is accessed
rg -A 10 -B 5 "normalizeHandlerMethod|\.method\b" --type ts

Length of output: 5404


🏁 Script executed:

#!/bin/bash
# Locate the definition of NitroEventHandler to inspect its `method` property type
rg -n "type NitroEventHandler" --type ts || rg -n "interface NitroEventHandler" --type ts

Length of output: 90


🏁 Script executed:

#!/bin/bash
# Locate the import of NitroEventHandler and inspect its definition context
rg -n "import.*NitroEventHandler" --type ts

# Show the first 50 lines of the file to see where the type comes from
sed -n '1,50p' packages/kit/src/nitro.ts

Length of output: 1849


Review normalizeHandlerMethod’s method assertion

The method variable still defaults to undefined when the handler filename doesn’t match HANDLER_METHOD_RE, yet the cast omits | undefined. This mismatch can lead to a runtime undefined slip through a stricter TypeScript signature.

• File packages/kit/src/nitro.ts, function normalizeHandlerMethod (around lines 14–19):

  • The destructuring [, method = undefined] can yield undefined.
  • The subsequent cast method as 'get' | … | 'trace' excludes undefined.

Please verify that all handler filenames always include a valid HTTP method suffix or adjust the type assertion (e.g. include | undefined) or provide a safe default before casting.

packages/vite/src/server.ts (4)

9-9: LGTM: Type import updated for nitropack migration

The import of Nitro type has been correctly updated from 'nitro/types' to 'nitropack/types', consistent with the systematic migration across the codebase.


66-69: LGTM: Temporary SSR externals added for migration

New SSR externals '#internal/nitro' and '#internal/nitro/utils' have been added with appropriate TODO comments indicating they are temporary and planned for removal in v5. This supports the migration whilst maintaining compatibility.


89-92: LGTM: Temporary Rollup externals added for migration

New Rollup externals '#internal/nitro' and 'nitropack/runtime' have been added with appropriate TODO comments indicating they are temporary and planned for removal in v5. This supports the migration to nitropack whilst maintaining build compatibility.


198-198: LGTM: Formatting improvement

The indentation of the initViteNodeServer(ctx) call has been corrected, improving code consistency.

test/bundle.test.ts (1)

61-61:

✅ Verification successful

Verify that bundle size increases are expected for the nitro to nitropack migration.

The server bundle sizes have increased across all test scenarios:

  • Default server bundle: 191k → 194k (+1.6%)
  • Inlined Vue modules: 544k → 547k (+0.6%)
  • Pages configuration: 283k → 289k (+2.1%)

Whilst these increases are relatively modest, bundle size is a critical performance metric. Please confirm that these size increases are expected consequences of migrating from nitro to nitropack v2 and that they fall within acceptable performance thresholds.

Also applies to: 98-98, 120-120


🏁 Script executed:

#!/bin/bash
# Description: Compare package sizes and dependencies between nitro and nitropack
# Expected: Understanding of what's causing the bundle size increases

echo "Checking nitro package info..."
npm view nitro version size dependencies --json

echo -e "\nChecking nitropack package info..." 
npm view nitropack version size dependencies --json

echo -e "\nChecking if nitropack has additional dependencies that might explain size increase..."
npm view nitropack dependencies peerDependencies --json

Length of output: 4630


Bundle size increases are expected after migrating to nitropack

The modest regressions (1.6%–2.1%) align with the extra dependencies introduced in nitropack v2.11.12 (e.g. multiple Rollup plugins and an xml2js peer dependency). These changes fall within acceptable performance thresholds, so updating the inline snapshots is appropriate.

Files to update:

  • test/bundle.test.ts: line 61
  • test/bundle.test.ts: line 98
  • test/bundle.test.ts: line 120

Copy link

pkg-pr-new bot commented May 31, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: ee3f49b

Copy link

codspeed-hq bot commented May 31, 2025

CodSpeed Performance Report

Merging #32252 will degrade performances by 27.65%

Comparing refactor/nitropack (ee3f49b) with main (ca2dff2)

Summary

❌ 1 regressions
✅ 9 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
writeTypes in the basic-types fixture 39.1 ms 54 ms -27.65%

@danielroe danielroe merged commit 7beaa67 into main May 31, 2025
49 of 51 checks passed
@danielroe danielroe deleted the refactor/nitropack branch May 31, 2025 22:04
This was referenced May 31, 2025
@blouflashdb
Copy link

Why?

@danielroe
Copy link
Member Author

check back tomorrow 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy