-
-
Notifications
You must be signed in to change notification settings - Fork 593
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(repo): plugin type definitions not being exported correctly in ES… #1578
Conversation
types for cjs are missing in the exports definition. It should look like this in the package.json files. "exports": {
- "types": "./types/index.d.ts",
- "import": "./dist/es/index.js",
+ "import": {
+ "types": "./types/index.d.mts",
+ "default": "./dist/es/index.js"
+ },
+ "require": {
+ "types": "./types/index.d.cts",
+ "default": "./dist/cjs/index.js"
+ },
"default": "./dist/cjs/index.js"
}, |
Technically it doesn't but I agree that the proposed structure is just less confusing. The CJS types could be sourced from the "sibling" Overall, this PR introduces references to many non-existing files and that should definitely be fixed |
I tested the commonjs module locally and it looks like typescript will use the |
@lukastaegert since this affects the entire repo and assets we publish for the entire repo, I'd like your stamp on this before w emerge. @Andarist @tada5hi you two as well please. @Geylnu please update your branch from upstream so we can run the latest CI |
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.
Currently, it looks like this PR is just removing types from all package files. Am I missing something here?
@lukastaegert TypeScript is following the standard node resolution algorithm - with small extensions.
{
"exports": {
"import": "./foo.js",
"types": "./types.d.ts"
}
} But the "sibling lookup" still works when reading from {
"exports": {
"import": { "types": "./esm/index.d.ts", "default": "./esm/index.js" },
"require": { "types": "./cjs/index.d.ts", "default": "./cjs/index.js" }
}
} Note that when publishing a dual package using a single |
Ah makes sense, I was missing that but of course generated files would not turn up in the diff. So it would emit the same file twice. If this fixes the issue at hand and we do not need slightly different types for CommonJS, I'm fine with this change. |
For me it still feels weird not to use explicit type references in the package.json and you don't know if the sibling lookup won't get depcreated unexpectedly at some point. |
Overall, I probably prefer the explicit condition as well. Although a cleaner
This is highly unlikely. It has been there almost forever and is actually a somewhat preferred way of structuring things by Andrew Branch (who is the TS team member who works a lot on the module resolution stuff). |
vuejs, for example, also does this with their ecosystem and imports work like a charm there.
I would tend to doubt it too, but I wanted to note it anyway. |
@shellscape I have updated my branch, is there anything else I need to do if I need this PR to be merged? |
a69c299
to
a9b9cd3
Compare
The build was failing with a message that looked like it was because it was out of sync with If you're able to get the build passing, then I'll leave another approval on this PR as I'd love to see it merged |
Closing as abandoned. |
Rollup Plugin type definitions
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
fixes #1541, fixes #1329
If you set
moduleResolution
toNode16
orNodeNext
intsconfig
and import the Rollup plugin, you will get the following error:For a detailed analysis of the cause see: #1541