[package/rolldown] Emit types by bundling
This PR solve another problem related unbundled-dts. We have met some many of them and use many workaround now.
This is not ideal. Let's try to solve it in the best suitable way. We should either use rollup-plugin-dts or https://github.com/Rich-Harris/dts-buddy to generate bundled dts files.
Originally posted by @hyf0 in https://github.com/rolldown/rolldown/issues/1387#issuecomment-2165048190
We are prototyping dts transform with --isolatedDeclarations in oxc, stay tuned.
But you still need another plugin if you want normal dts emit :-(
We gonna wait for #1396 to be supported.
Hi, is this something that's always planned?
At Symfony UX we use Rollup with the typescript plugin to emit types when building our .ts files, but we'd like to migrate to Rolldown to reduce build time.
Is there anything we can do to help?
Thanks!
EDIT: While playing with Rolldown on https://github.com/symfony/stimulus-bridge/pull/99, I found out that it was still possible to emit types while bundling by using @rollup/plugin-typescript.
While playing with Rolldown on https://github.com/symfony/stimulus-bridge/pull/99, I found out that it was still possible to emit types while bundling by using
@rollup/plugin-typescript.
I figured that out too but noticed that the build times are significantly higher because it is using the official typescript compiler instead of the fast oxidation compiler rolldown would be using.
https://github.com/sxzz/rolldown-plugin-dts is now pretty stable and will soon be integrated as a built-in plugin.
@sxzz Does rolldown-plugin-dts depend on npm:typescript or is standalone? (to be able to generate bundled types)
@pi0 it depends on oxc-transform if isolatedDeclaration is enabled, and depend on typescript compiler if not.
Ah ok. So for bundling, we need (rather slower) typescript dep.. Any plans to support OXC-based type bundler? (this is my main blocker right now for migration as advantage of rolldown to rollup is speed and most of build time is spent on typescript invokes)
The most challenging aspect is the lack of a native-language .d.ts emitter (except for tsgo). Undoubtedly, Oxc is currently limited to supporting isolated declarations and will remain so in the future.
The only thing we can do is wait for tsgo to become stable.
makes sense to wait on tsgo.
~~I was hoping to achieve an isolated-type bundler for short term, bundling oxc emited isolated declarations into a single chunk. (happy to move discussion upstream if you prefer)~~ update: trying.. single bundle with isolatedDeclaration works as expected with fast speed 🚀 https://github.com/unjs/unenv/pull/497