-
Notifications
You must be signed in to change notification settings - Fork 361
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
[Question] How to specify different formats for multiple exports? #973
Comments
You combine them: "exports": {
"./one": {
"require": "./dist/one.cjs",
"default": "./dist/one.modern.js"
},
"./two": {
"require": "./dist/two.cjs",
"default": "./dist/two.modern.js"
}
}, |
Thanks a lot. Now I'm getting import One from 'x/one';
import Two from 'x/two'; Is there something I should additionally specify in my |
Hmm, are you sure the path is correct/types distributed? In TS 4.7 I believe you're required to add types to subpath exports like this, though (AFAIK) that's still in beta: "exports": {
"./one": {
"types": "./dist/one.d.ts",
"require": "./dist/one.cjs",
"default": "./dist/one.modern.js"
},
"./two": {
"types": "./dist/two.d.ts",
"require": "./dist/two.cjs",
"default": "./dist/two.modern.js"
}
}, Edit: Microbundle might be compiling both types files to the same output destination. Does |
I can confirm my |
It does contain a You have |
Yes and yes (on 4.7.4 as we're speaking).
I actually removed that field after adding |
Hm, interesting. Can reproduce, but don't know what the correct method is in TS these days. It sounds like this should work? https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#package-json-exports-imports-and-self-referencing
|
I've set up a reproduction here: https://github.com/hood/microbundle-issue-973 . EDIT: EDIT #2: "exports": {
"./a": {
"import": {
"types": "./dist/a.d.ts",
"default": "./dist/a.modern.js"
},
"require": {
"types": "./dist/a.d.ts",
"default": "./dist/a.cjs"
}
},
"./b": {
"import": {
"types": "./dist/b.d.ts",
"default": "./dist/b.modern.js"
},
"require": {
"types": "./dist/b.d.ts",
"default": "./dist/b.cjs"
}
}
}, but still to no avail. 😢 |
Any news on this? It's pretty blocking for a project I'm currently working on... |
Well, there's no news because this isn't a Microbundle issue. I personally have no idea how TS wants users to distribute types these days, your best bet is probably to post on Stack or a TS forum. I imagine this might be somewhat editor-specific too. |
I'm trying to setup
microbundle
to provide separate exports for several modules my package is exporting, like this:However, I don't know how to specify different export formats for each one of my exports.
The documentations provides either this example, which shows how to proceed when doing "single" exports:
or this example, which shows an example of multiple exports, but in a single format:
How could I specify multiple formats like in the 1st example, while still specifying multiple named exports like in the 2nd example?
The text was updated successfully, but these errors were encountered: