Skip to content

fix: CSR-173 Portable defineNuxtPlugin imports; cover the module build with a test. - #220

Merged
fago merged 2 commits into
1.xfrom
feature/csr-173
Aug 5, 2026
Merged

fix: CSR-173 Portable defineNuxtPlugin imports; cover the module build with a test.#220
fago merged 2 commits into
1.xfrom
feature/csr-173

Conversation

@drubot

@drubot drubot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes the nuxt-module-build build failure that blocks the 1.1.0 release (CSR-173):

src/runtime/plugin.client.ts(3,1): error TS2742: The inferred type of 'default' cannot be named
without a reference to '~/node_modules/nuxt/dist/app/nuxt'. This is likely not portable.
src/runtime/plugins/cdn-fetch-paths.client.ts(33,1): error TS2742 (same)

Fix

Import defineNuxtPlugin from the portable nuxt/app subpath instead of the #imports alias in both runtime plugins. With the alias, the d.ts generator can only name the inferred default-export type through a node_modules path; via nuxt/app the type is nameable with a proper module specifier. All other auto-imports stay on #imports. Surfaced by the dependency bumps (nuxt 4.5, TS ~5.9, vue-tsc 3).

Test coverage

CI runs lint + vitest + e2e but never the module build, so pack-time d.ts failures were invisible until release. New test/module-build.test.ts executes the real nuxt-module-build build and asserts exit 0, no error TS*, no mkdist build failed — the builder's failOnWarn makes warnings fail the test too.

Verification

  • npx vitest run test/module-build.test.ts → green with the fix (build clean, ~7 s).
  • Negative test: with both import fixes reverted, the test fails with exactly the two TS2742 errors. (Note: reverting only one file still passes — once any file in the program imports nuxt/app, TS can name the type portably program-wide — so the guard needs the test, not just one clean file.)
  • test/cdn-fetch-paths.test.ts (16 tests) green; lint: 0 errors (5 pre-existing warnings untouched).

Drafted with assistance from Claude Code in the loki dev VM.

🤖 Generated with Claude Code

https://claude.ai/code/session_0192LX8MPzDkawiq59dB2yMu

@fago
fago merged commit 45e1519 into 1.x Aug 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants