nuxt / module-builder

Complete solution to build and ship Nuxt modules.
MIT License
211 stars 22 forks source link

Typescript 5.5 - Error: module is a string value; #299

Closed markbrockhoff closed 4 days ago

markbrockhoff commented 4 days ago

Hi, I encountered the following error after updating from Typescript 5.4.5 to 5.5.2.

Whenever I run the build command I get this strange error message:

> nuxt-module-build build

ℹ Building my-module                                                                               6:10:15 PM
ℹ Cleaning dist directory: ./dist                                                                  6:10:15 PM

[6:10:15 PM]  ERROR  module is a string value; tsconfig JSON must be parsed with parseJsonSourceFileConfigFileContent or getParsedCommandLineOfConfigFile before passing to createProgram

  at Object.createProgram (node_modules/.pnpm/typescript@5.5.2/node_modules/typescript/lib/typescript.js:123997:15)
  at getDeclarations (node_modules/.pnpm/mkdist@1.5.1_typescript@5.5.2_vue-tsc@2.0.22_typescript@5.5.2_/node_modules/mkdist/dist/index.mjs:302:22)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async mkdist (node_modules/.pnpm/mkdist@1.5.1_typescript@5.5.2_vue-tsc@2.0.22_typescript@5.5.2_/node_modules/mkdist/dist/index.mjs:525:35)
  at async mkdistBuild (node_modules/.pnpm/unbuild@2.0.0_typescript@5.5.2_vue-tsc@2.0.22_typescript@5.5.2_/node_modules/unbuild/dist/index.mjs:927:22)
  at async _build (node_modules/.pnpm/unbuild@2.0.0_typescript@5.5.2_vue-tsc@2.0.22_typescript@5.5.2_/node_modules/unbuild/dist/index.mjs:1086:3)
  at async build (node_modules/.pnpm/unbuild@2.0.0_typescript@5.5.2_vue-tsc@2.0.22_typescript@5.5.2_/node_modules/unbuild/dist/index.mjs:945:5)
  at async Object.run (node_modules/.pnpm/@nuxt+module-builder@0.8.0_@nuxt+kit@3.12.2_magicast@0.3.4_rollup@4.18.0__nuxi@3.12.0_typescr_mlzbradpvbwn42jlyps562epy4/node_modules/@nuxt/module-builder/dist/chunks/build.mjs:43:5)
  at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:316:16)
  at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:307:11)

It looks like something might be wrong with the way the declarations are generated. I created a minimal reproduction using the nuxt module template as baseline: https://github.com/markbrockhoff/nuxt-module-template-bug-repro/tree/reproduce-ts-5.5-bug (Use branch reproduce-ts-5.5-bug)

To reproduce the issue you only need to install the dependencies and run pnpm prepack.

Any help narrowing this issue down would be appreciated, thanks.

markbrockhoff commented 4 days ago

By the way: You can even see this issue within the action run of dependabot trying to upgrade typescript to 5.5 as well: https://github.com/nuxt/module-builder/actions/runs/9626387745/job/26552301785?pr=296

danielroe commented 4 days ago

This is now resolved in mkdist and should be fixed with a lockfile refresh.

markbrockhoff commented 4 days ago

Wow, that was fast. Issue is fixed thanks a lot @danielroe 👍🏻