-
Notifications
You must be signed in to change notification settings - Fork 362
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
Bundled type definitions for bundled dependencies? #1050
Comments
Indeed, and it will also cause issues if Its tough, as we don't really want to go too far off the TS reservation and have to deal with bundling |
Understood, and thanks for confirming! In this case I can remove |
Alternatively, you may be able to post-build copy the We'll definitely keep this open, I don't think we have any other issues tracking it and it's a very valid pain point. |
Have a look at API Extractor which can bundle types (uses rollup under the hood). Its maintained by Microsoft. I've used in the past. It works pretty well. Its not perfect, but it is really smooth most of the time. I wish all library maintainers used it to package up their types with their outputs. It does a really good job of making sure your types match what you're exporting as a consumable API |
Thanks @ScottAwesome! I've used API Extractor elsewhere, though using it to bundle external type definitions hadn't occurred to me. It's been an effort to set up and run in the past — not the "zero configuration" appeal of Microbundle — so I don't feel it's something I can include in my builds as a library maintainer. I deeply wish TypeScript would reconsider their position on bundling, but that's another matter. I am keeping an eye on |
Context: As documented in #454 and How Microbundle decides which dependencies to bundle, one recommended way to bundle dependencies is to put the dependency in
devDependencies
rather thandependencies
.Problem:
my-bundled-dependency
is bundled intomy-parent-library
, and affects its exported type definitions. Recently a downstream user of my package reported an issue that surprised me – while the JavaScript is bundled as expected, the type definitions are not bundled, and contain an import frommy-bundled-dependency
. This causes builds to fail for users ofmy-parent-library
if they've enabled TypeScript'sskipLibCheck: false
. If this is unexpected and a simple repro example would be helpful, I'm happy to create that.Alternatives: Should the type definitions also be bundled by Microbundle? By TypeScript? Am I perhaps making a mistake by using a bundled dependency in my exported TypeScript API? I'm inclined to the idea that this is something TypeScript, not Microbundle, should ideally handle. But they've historically been pretty unenthusiastic about such requests.
Related:
The text was updated successfully, but these errors were encountered: