Skip to content

feat(kit): add addSharedImports utility - #35813

Open
KealanAU wants to merge 2 commits into
nuxt:mainfrom
KealanAU:feat/kit-add-shared-imports
Open

KealanAU wants to merge 2 commits into
nuxt:mainfrom
KealanAU:feat/kit-add-shared-imports

Conversation

@KealanAU

Copy link
Copy Markdown
Contributor

🔗 Linked issue

resolves #32256

📚 Description

Adds an addSharedImports utility to @nuxt/kit so module authors can register auto-imports that work in the app, on the server, and in the shared/ directory.

  • add addSharedImports, which registers the given imports via both addImports and addServerImports
  • document the utility in the kit auto-imports docs, with a note that sources must be context-agnostic since they load in both environments
  • cover it in the basic-types fixture with a shared util imported from a module and referenced in shared/

Disclosure: this change was implemented with AI assistance (Claude Code).

@github-actions github-actions Bot added 5.x ✨ enhancement New feature or improvement to existing functionality labels Jul 23, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

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

@nuxt/nitro-server

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: c34ca1d

@codspeed

codspeed Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing KealanAU:feat/kit-add-shared-imports (c34ca1d) with main (5fd1ab0)

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

@KealanAU KealanAU closed this Aug 7, 2026
@danielroe

Copy link
Copy Markdown
Member

was there a reason you closed this?

@danielroe danielroe reopened this Aug 7, 2026
@KealanAU
KealanAU marked this pull request as ready for review August 8, 2026 04:45
@KealanAU
KealanAU requested a review from danielroe as a code owner August 8, 2026 04:45
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 21fedbfa-f41d-4b96-9d90-d97f2b454e66

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd1ab0 and c34ca1d.

📒 Files selected for processing (7)
  • docs/4.api/5.kit/12.nitro.md
  • docs/4.api/5.kit/4.autoimports.md
  • packages/kit/src/imports.ts
  • packages/kit/src/index.ts
  • test/fixtures/basic-types/modules/example.ts
  • test/fixtures/basic-types/modules/runtime/shared-util.ts
  • test/fixtures/basic-types/shared/shared-types.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • test/fixtures/basic-types/modules/example.ts
  • test/fixtures/basic-types/modules/runtime/shared-util.ts
  • packages/kit/src/index.ts
  • test/fixtures/basic-types/shared/shared-types.ts
  • packages/kit/src/imports.ts

Walkthrough

The change adds addSharedImports to Nuxt Kit. The function registers imports through both Nuxt and Nitro import systems. The API is publicly exported and documented. A type fixture registers sharedKitUtil and verifies that shared code can call it as a string-returning utility.

Possibly related PRs

  • nuxt/nuxt#34481: Covers related guidance for safely sharing code between Nuxt and Nitro contexts.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 and concisely describes the main change: adding the addSharedImports utility to @nuxt/kit.
Description check ✅ Passed The description accurately explains the new utility, documentation updates, context-safety requirement, and fixture coverage.
Linked Issues check ✅ Passed The changes implement the requested shared import capability for client and server contexts, including the shared/ directory requirement [#32256].
Out of Scope Changes check ✅ Passed All code, documentation, export, and fixture changes directly support the requested addSharedImports capability.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x ✨ enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[nuxt/kit] AddSharedImports

2 participants