Closed KieranTH closed 6 months ago
but any runtime/package manager should have this issue.
Apparently, if you just run dts-bundle-generator
tool it works just fine:
$ ./node_modules/.bin/dts-bundle-generator index.ts
Compiling input files...
Processing index.ts
Writing index.ts -> index.d.ts
Checking generated files...
Done in 1.31s
$ cat index.d.ts
// Generated by dts-bundle-generator v9.3.1
import { faCat, faSquareMinus } from '@fortawesome/free-solid-svg-icons';
export {
faCat,
faSquareMinus,
};
export {};
I'm curious what bun-plugin-dts
adds to the config so it makes it to fail...
It seems it might be the issue with Bun itself. Well, technically it is just the difference between runtimes. Apparently nodejs has higher limits for the callstack size than bun, thus you see this error. I just cut a ticket to bun https://github.com/oven-sh/bun/issues/10270 just in case if they want to sync/increase this value, but regardless I'll try to fix it from my size because even if they will do that, there is a cache to hit this issue even with a higher limit with more complex types.
Oh btw this has been fixed in #303 already (but it is not published yet). I just validated with local build it works just fine.
Appreciate the quick response!
Thank you for looking into it and creating the issue on Bun's side!
I'll keep a look out for the performance improvement release :) Thanks
The fix has been published in 9.4.0 version.
Bug report Computing usages recursively causes infinite loop when type declarations are cyclic.
After spending a few hours attempting to debug this myself in the
types-usage-evaluator
file, I've had no luck.I personally have valid cyclic types in a GQL backend I'm running, but I've also been able to replicate the issue with another more popular package: React FontAwesome.
I'm not entirely familiar with how other tools such as TSC deal with this issue, my first instinct is to run a check on whether a Type/Interface contains itself at any other point in the tree and exit the loop, but unsure if that's the correct approach.
Here's a repo that displays this issue in a very simple setup:
https://github.com/KieranTH/DTS-Bundle-Circular-Issue
I'm using Bun in this example but any runtime/package manager should have this issue.
To reproduce the issue just clone that repo and run
bun i && bun run build.mjs
Thanks!
Actual output