Module: Support ES Modules and TypeScript, with no training wheels (moduleResolution: Node16) #3159
Labels
Status: Pending Review
Issue or pull request is being reviewed by Core Team
Milestone
Describe the feature you would like to see added
To avoid ambiguity with imports, support better tree shaking, top level async-await and compatibility problems between packages and tooling, we need to use Node16 mode in TS moduleResolution.
PrimeVue is currently very broken with direct Node16 resolution.
d.ts
type definitions use correct default export syntax, but the ESM file uses incorrectexport { PrimeVue as default, usePrimeVue }
which relies on spotty and unpredictable synthetic import compatibility poly-fills... this package is running into the pitfalls of relying on that.main
entry point property currently points to a CJS module... which is incapable of using standard ESM default exports without webpack hacks that doesn't work on esbuild/vite/rollup.CF: https://stackblitz.com/~/github.com/FossPrime/bug-primevue-esm-types
SBC: https://stackblitz.com/edit/public-sakai-yqyw2y?file=src%2Fmain.ts%3AL13,src%2Fvite-env.d.ts%3AL11
This is currently not a big deal as TS Support for
"moduleResolution": "Node16"
has some pitfalls in Vite 3.1, however there is a work being done to fix the plugins/docs, official support may come Vite 3.2/3.3.Is your feature request related to a problem?
Describe the solution you'd like
Define exports, like the Vite plugin does https://unpkg.com/browse/@vitejs/[email protected]/package.json
And define default exports types correctly, using
export default
in both the type definition and the ESM codeDescribe alternatives you have considered
Additional context
Somewhat related to #2847
The text was updated successfully, but these errors were encountered: