-
Notifications
You must be signed in to change notification settings - Fork 507
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
.d.ts bundles #80
Comments
just for learning's sake what would be the benefit of bundling everything in 1 .d.ts vs all separate? |
Cleaner |
Oh boy! Here's a library that doesn't require Rollup (not sure if that's better or worse in the case of |
Yeah this would be cool. Seems experimental though? |
I'm trying it on react-spring in a little bit. We'll see how it goes. Would definitely be an opt-in feature in tsdx. |
Both More details: https://api-extractor.com/pages/setup/configure_rollup/ |
@aleclarson can you please show how did you test it? Afaik by default |
Since |
@timocov @Swatinem Thanks for the info! I would definitely prefer using one of your libraries, since API Extractor has awful configuration requirements. This is what I used to get API Extractor working: {
"mainEntryPointFilePath": "<projectFolder>/types/index.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/index.d.ts"
},
"docModel": {
"enabled": false
},
"apiReport": {
"enabled": false
},
"messages": {
"extractorMessageReporting": {
"ae-missing-release-tag": {
"logLevel": "none"
}
}
}
} @timocov I've only tried
|
Dependencies from local files of course. All external deps it'll import/or add via triple-slash directive (depends on where typings are) by default, but what should be imported/inlinded can be changed via CLI args (or config file). |
This is an overview of rollup-plugin-dts
dts-bundle-generator
dts-generator
@microsoft/api-extractor
|
@aleclarson great job 👍!
Does it related to timocov/dts-bundle-generator#53? I'm not sure how it will even work, because afaik TypeScript compiler doesn't compile source files from node_modules. |
Now that Swatinem/rollup-plugin-dts#32 is merged, my needs are satisfied by |
I would very much appreciate something like this - right now, I can't import anything from any .d.ts file except from the index.d.ts - as they don't have accompanying .js/.ts files and webpack refuses to Re-exporting everything I need from the index.js/.d.ts on the other hand does not play well with babel-preset-typescript as that doesn't support re-exporting types. So currently, I'm renaming all .d.ts post-build from .d.ts to .ts for babel-loader and webpack to recognize them. And that certainly isn't the "right" way :/ |
we had some churn with v0.10 but now are back to separate .d.ts - if anyone wants to explore rollup-plugin-dts or any other solutions please have a try |
Just quickly tested rollup-plugin-dts with tsdx and unfortunately it didn't work out of the box. Got |
That is definitely a bug in my library. Would very much appreciate an issue report with a reduced testcase. |
@Swatinem I tried to create a small example to demonstrate the issue. I started with a clean tsdx project. Added test.ts file in addition to index.ts. Added rollup-plugin-dts and run build. I didn't get any TypeError, but I also didn't get a result I was expecting to get. I was expecting to get single .d.ts bundle with all the types, but instead got two separate files: index.d.ts and test.d.ts. Is it another bug or I'm doing something wrong? Here is my test project https://github.com/smashercosmo/rollup-plugin-dts-issue |
Hm, it doesn’t seem the plugin is actually invoked? No idea. I just pasted your code into the plugin testsuite, and it ran fine. |
@aleclarson In response to #80 (comment): API Extractor doesn't just solve this (.d.ts bundles issues).. it also generates API documentation & API reports (for PR process).. that should count for a lot! Another note about API extractor, regarding "Must write your own Rollup plugin". Here's some work that's been done on this: https://github.com/rocketbase-io/rollup-plugin-api-extractor It looks pretty simply/straightforward. We could easily include this plugin functionality in tsdx, do the .d.ts bundling by default, and add expose some new options for generating API documentation and reports. Couldn't we? |
Current Behavior
Every module has its own
.d.ts
moduleDesired Behavior
Bundle the typedefs into a single
.d.ts
moduleSuggested Solution
https://www.npmjs.com/package/rollup-plugin-dts
The text was updated successfully, but these errors were encountered: