From d222321f7758e4ecdfb36992e9f76ea0760f3627 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Wed, 25 Nov 2026 15:49:50 +1100 Subject: [PATCH 1/5] docs: explain how to ship vendored types A packed bundle can work at runtime while its public declarations refer to a package consumers cannot resolve. --- docs/upgrade-v2.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/upgrade-v2.md b/docs/upgrade-v2.md index 79e5eb52..0078608e 100644 --- a/docs/upgrade-v2.md +++ b/docs/upgrade-v2.md @@ -351,6 +351,8 @@ The build fails when the bundled entries bundle a package from `node_modules` th - If bundling it is intended, list it in tsdown's `deps.onlyBundle`. Without a `tsdown.config.ts`, list it in `rollup.inlineDependencies` instead. - If the app provides it, add it to `builder({ externals })`. +Module Builder keeps imports of installed packages in generated declarations, even when it bundles their JavaScript. If you vendor a dependency, point public declarations at the types you ship. Type-check a public import from a fresh tarball install. + See [Externals](./4.configuration.md#externals). ### Output directory From 50bfae8b9542b49351ff6f374671ceea1a49f515 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Wed, 25 Nov 2026 16:16:12 +1100 Subject: [PATCH 2/5] docs: show how to test packed modules A fresh Nuxt app checks the entry points that consumers receive in the published tarball. --- docs/upgrade-v2.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/upgrade-v2.md b/docs/upgrade-v2.md index 0078608e..c7f65cbd 100644 --- a/docs/upgrade-v2.md +++ b/docs/upgrade-v2.md @@ -294,7 +294,7 @@ Run your module's type-check script, and fix what it reports. [Errors from check ### Step 10: Check the package -1. Run `pnpm pack`. It writes a tarball, such as `my-module-1.0.0.tgz`. +1. Pack the module with the package manager you publish with. Run `pnpm pack` for pnpm or `npm pack` for npm. This writes a tarball, such as `my-module-1.0.0.tgz`. 2. Run `pnpm dlx publint my-module-1.0.0.tgz`. 3. List the imports in its declarations that don't resolve from the package alone. Write the report to a file first, as attw can exit before a pipe reads all of it: @@ -313,6 +313,13 @@ Run your module's type-check script, and fix what it reports. [Errors from check 5. If you kept `types` and `typesVersions` in step 3, check `node10` resolution as well, with `--ignore-rules cjs-resolves-to-esm internal-resolution-error` and no `--profile`. 6. Fix any path that publint or attw reports. +7. In a fresh Nuxt app, install the tarball: + + ```bash + npm install /path/to/my-module-1.0.0.tgz + ``` + + Register the module in `nuxt.config.ts`, then start and build the app. If your package exposes public imports, use them in the app and run its type check. This checks how JavaScript and type imports resolve from the installed package. [Checking the package](./3.develop-and-publish.md#checking-the-package) explains what attw reports for a module that is correct, and how to run step 4 on every build with tsdown's `attw` option. Finally, run your module's tests and its playground. @@ -351,7 +358,7 @@ The build fails when the bundled entries bundle a package from `node_modules` th - If bundling it is intended, list it in tsdown's `deps.onlyBundle`. Without a `tsdown.config.ts`, list it in `rollup.inlineDependencies` instead. - If the app provides it, add it to `builder({ externals })`. -Module Builder keeps imports of installed packages in generated declarations, even when it bundles their JavaScript. If you vendor a dependency, point public declarations at the types you ship. Type-check a public import from a fresh tarball install. +Module Builder keeps imports of installed packages in generated declarations, even when it bundles their JavaScript. If you vendor a dependency, point public declarations at the types you ship. Type-check a public import from the tarball as in [step 10](#step-10-check-the-package). See [Externals](./4.configuration.md#externals). From da434e291d02dac312734c3a2d2797a3d40231e4 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Wed, 25 Nov 2026 16:32:15 +1100 Subject: [PATCH 3/5] docs: use pnpm in the package smoke test --- docs/upgrade-v2.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/upgrade-v2.md b/docs/upgrade-v2.md index c7f65cbd..6b73c88e 100644 --- a/docs/upgrade-v2.md +++ b/docs/upgrade-v2.md @@ -294,7 +294,7 @@ Run your module's type-check script, and fix what it reports. [Errors from check ### Step 10: Check the package -1. Pack the module with the package manager you publish with. Run `pnpm pack` for pnpm or `npm pack` for npm. This writes a tarball, such as `my-module-1.0.0.tgz`. +1. Run `pnpm pack`. It writes a tarball, such as `my-module-1.0.0.tgz`. 2. Run `pnpm dlx publint my-module-1.0.0.tgz`. 3. List the imports in its declarations that don't resolve from the package alone. Write the report to a file first, as attw can exit before a pipe reads all of it: @@ -316,10 +316,10 @@ Run your module's type-check script, and fix what it reports. [Errors from check 7. In a fresh Nuxt app, install the tarball: ```bash - npm install /path/to/my-module-1.0.0.tgz + pnpm install /path/to/my-module-1.0.0.tgz ``` - Register the module in `nuxt.config.ts`, then start and build the app. If your package exposes public imports, use them in the app and run its type check. This checks how JavaScript and type imports resolve from the installed package. + Add the module to `modules` in `nuxt.config.ts`, then start and build the app. If consumers import from your package directly, use those imports in the app and run its type check. [Checking the package](./3.develop-and-publish.md#checking-the-package) explains what attw reports for a module that is correct, and how to run step 4 on every build with tsdown's `attw` option. Finally, run your module's tests and its playground. @@ -358,7 +358,7 @@ The build fails when the bundled entries bundle a package from `node_modules` th - If bundling it is intended, list it in tsdown's `deps.onlyBundle`. Without a `tsdown.config.ts`, list it in `rollup.inlineDependencies` instead. - If the app provides it, add it to `builder({ externals })`. -Module Builder keeps imports of installed packages in generated declarations, even when it bundles their JavaScript. If you vendor a dependency, point public declarations at the types you ship. Type-check a public import from the tarball as in [step 10](#step-10-check-the-package). +Module Builder keeps imports of installed packages in generated declarations, even when it bundles their JavaScript. If you vendor a dependency, point your public declarations at the types you ship. Check those imports as in [step 10](#step-10-check-the-package). See [Externals](./4.configuration.md#externals). From 6626a102c281ac7b2bd8c37f0a5f1ec90c19e6ba Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Wed, 25 Nov 2026 16:36:06 +1100 Subject: [PATCH 4/5] docs: check vendored declarations with TypeScript --- docs/upgrade-v2.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/upgrade-v2.md b/docs/upgrade-v2.md index 6b73c88e..0ca7e09e 100644 --- a/docs/upgrade-v2.md +++ b/docs/upgrade-v2.md @@ -321,6 +321,8 @@ Run your module's type-check script, and fix what it reports. [Errors from check Add the module to `modules` in `nuxt.config.ts`, then start and build the app. If consumers import from your package directly, use those imports in the app and run its type check. + If you vendor types, import the affected entry points in a separate TypeScript project with `skipLibCheck: false`. Check for errors in your package's declarations. + [Checking the package](./3.develop-and-publish.md#checking-the-package) explains what attw reports for a module that is correct, and how to run step 4 on every build with tsdown's `attw` option. Finally, run your module's tests and its playground. ## Build messages From 40a0c7e3eff6f9cb72777a3440f9e953ffea6788 Mon Sep 17 00:00:00 2001 From: Harlan Wilton Date: Wed, 25 Nov 2026 16:41:49 +1100 Subject: [PATCH 5/5] docs: retain Nuxt aliases in declaration checks --- docs/upgrade-v2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/upgrade-v2.md b/docs/upgrade-v2.md index 0ca7e09e..c1dfc8d9 100644 --- a/docs/upgrade-v2.md +++ b/docs/upgrade-v2.md @@ -321,7 +321,7 @@ Run your module's type-check script, and fix what it reports. [Errors from check Add the module to `modules` in `nuxt.config.ts`, then start and build the app. If consumers import from your package directly, use those imports in the app and run its type check. - If you vendor types, import the affected entry points in a separate TypeScript project with `skipLibCheck: false`. Check for errors in your package's declarations. + If you vendor types, check the affected imports again in a separate TypeScript config with `skipLibCheck: false`. Extend the relevant generated Nuxt config, such as `.nuxt/tsconfig.app.json`, to keep aliases like `#app`. Look for errors in your package's declarations. [Checking the package](./3.develop-and-publish.md#checking-the-package) explains what attw reports for a module that is correct, and how to run step 4 on every build with tsdown's `attw` option. Finally, run your module's tests and its playground.