jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.28k stars 507 forks source link

How to debug/fix slow build times in Lerna monorepo? #808

Closed coreybruyere closed 4 years ago

coreybruyere commented 4 years ago

Current Behavior

I have a lerna mono repo with 2 packages. The first package is a small UI component library with about 20 small components, and the other package builds and generates typed SVG icons so they can be imported as React components.

When running tsdx build on both of these packages, the cli process seems to hang up. Sometimes it finishes, sometimes it doesn't. When it finishes the total build time per package is around 4-7 minutes.

It hangs up when building modules and this is all I see on my cli:

✓ Creating entry file 24.2 secs
⠇ Building modules

Is there another configuration I should consider with SVG's, typescript, or lerna? Those are the only 3 unique culprits I could think of that would require additional configuration?

Software Version(s)
TSDX ^0.13.2
TypeScript ^3.9.7
Browser
npm/Yarn npm 6.12.0
Node v12.13.0
Operating System macOS 10.13.5
agilgur5 commented 4 years ago

It hangs up when building modules and this is all I see on my cli:

So the Building modules step indicates that it's stuck within Rollup processing, not in TSDX source, so the issue is somewhere upstream.

I searched upstream for debug logging in Rollup but didn't have much luck, two old issues popped up that were not resolved: https://github.com/rollup/rollup/issues/1215 and https://github.com/rollup/rollup/issues/651

That being said, rollup-plugin-typescript2 itself does have debug level logging with its verbosity option.

I'm not sure that rpts2 is what's taking long though since 20 isn't that many and you've seen #215 and maybe #243 / #307 which were larger. The latter refers to the --transpileOnly flag that would help if rpts2 is the bottleneck. The former refers to the svgr Rollup plugin specifically for SVGs.

That's about all the information I can give you since this is really specific and upstream

coreybruyere commented 4 years ago

Ok I've narrowed the issue down. I can cd into each package and build in a reasonable amount of time but when I run lerna run build (runs those same build scripts) from the root of my lerna project I'm hit with massively slow build times. This issue seems to have moved away from tsdx as of now. Just leaving my discoveries here and hoping someone else has ran into this issue.