-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-legacy): ensure correct typing for node esm #13892
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning behind removing this entry? We have the same setup on all other plugins: https://github.com/vitejs/vite-plugin-vue/blob/93c444cb99d64c65b71050d0f6a5e3016f7046a1/packages/plugin-vue/package.json#L14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript is able to pick up the adjacent
.ts
by removing this, .e.g./dist/index.mjs
->./dist/index.d.mts
. What this PR does is that it emits two dts files for the two formats :(There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unjs/unbuild#273
Because of .d.mts and .d.cts, removing it will allow TS to find correct one by itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patak-dev Here is also another PR https://github.com/vitejs/vite-plugin-vue/pull/179/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing , the only way to correct provide types for both Node ESM and CJS is to have two separate declaration files, so we need to generate index.d.cts and index.d.mts.
unbuild@2 could generate index.d.cts and index.d.mts standing for types of index.cjs and index.mjs, and could generate index.d.ts for legacy typescript usage.
releated commit:
vuejs/core@d621d4c
releated PRs:
unjs/unbuild#273
vitejs/vite-plugin-vue#179
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is good for plugins given our current setup. We could release it in a minor for the plugin. I added it to the 5.0 milestone (that we're going to start working on soon) because there is a parallel discussion about moving vite core and the plugins to ESM only. I still don't know if Vite 5 is the right major to do this, so if we don't move forward with that, we should merge this PR instead.
Polls that @bluwy started for reference: