Closed MartinX3 closed 7 months ago
Which version is affected? Please provide a minimal reproduction. I cannot reproduce this issue in any of my projects.
Thank you for your response. I added the needed information.
Thanks for the report!
As far as I can tell, vue-tsc
is the issue.
exports
in package.json
are valid, as checked by publint.main.ts
and running tsc --noEmit
reports no errors."module": "NodeNext"
is not the trigger, but the implicit "moduleResolution": "NodeNext"
it results in.If you're using Vite anyway, why not switch to
"module": "ESNext",
"moduleResolution": "bundler",
in the first place?
Thank you for the answer!
Oh, that means vue-tsc has a bug or that this project violates what NodeNext
wants?
I did choose NodeNext
because of this:
In addition to adopting the following settings, it’s also recommended not to set { "type": "module" } or use .mts files in bundler projects for now. Some bundlers adopt different ESM/CJS interop behavior under these circumstances, which TypeScript cannot currently analyze with "moduleResolution": "bundler". See issue #54102 for more information.
(Quasar wants "type": "module"
soon)
In short, "moduleResolution": "bundler" is infectious, allowing code that only works in bundlers to be produced. Likewise, "moduleResolution": "nodenext" is only checking that the output works in Node.js, but in most cases, module code that works in Node.js will work in other runtimes and in bundlers.
https://www.typescriptlang.org/docs/handbook/modules/guides/choosing-compiler-options.html
I don't think my library violates the NodeNext
spec, since it works fine with tsc
, just not vue-tsc
.
I also don't think the "infectious" nature of "moduleResolution": "bundler"
applies to my library, because it's built using a custom Vite plugin that adds missing file types to imports and exports (see https://www.npmjs.com/package/@yeger/vue-masonry-wall?activeTab=code).
Thank you.
I switch to ESNext
and Bundler
to use your plugin.
Then also vue-tsc doesn't complain and I can continue to use it.
At least I don't need to use node
/ node10
anymore.
I just wondered why I only get the error message with your plugin. :D
Affected Packages
5.0.8
Description
After using
"module": "NodeNext",
in the tsconfig.ts and"type": "module"
in the package.json using vue-tsc to check my code I get the error:Any other 3rd party library I use is working.
Reproduction
https://stackblitz.com/edit/vitejs-vite-martix3-yeger-masonry-bug-270
Additional context
No response
Preferences