question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Very slow builds with many files

See original GitHub issue

Current Behavior

When building a single entry file with ~160 exports (each in their own file), the build process takes several minutes without a warm cache (crashes with an OOM error on CI)

Expected behavior

I’d expect it to be slower than a single module file, but not THAT much slower

Suggested solution(s)

It looks like it’s a issue with either rollup or one of its plugins - but I have no way of knowing. Perhaps you’ve stumbled upon this issue previously?

Also, perhaps a --perf flag could be added to the CLI, to simplify this debugging process for future users?

Additional context

I added a { perf: true; } flag to the rollup config, and console.log-ed out the resulting getTimings() call:

Here's the output

{ '# BUILD': [ 45448.705339, 242397656, 537384520 ],
  '## parse modules': [ 90855.13704900001, 489351016, 541983792 ],
  '- plugin 0 (node-resolve) - resolveId': [ 16.686786000000005, 1722304, 334375352 ],
  '- plugin 0 (node-resolve) - resolveId (async)': [ 87850.61065700013, 4134695144, 346438824 ],
  'load modules': [ 1401519.6063479998, 1050694920, 352076056 ],
  '- plugin 0 (node-resolve) - load': [ 11.477684000000005, 94360, 346416168 ],
  '- plugin 3 (rpt2) - load': [ 11.088360000000012, 104168, 346420296 ],
  '- plugin 4 (babel) - load': [ 11.090018000000006, 89096, 346423304 ],
  '- plugin 6 (sourcemaps) - load': [ 16.119847000000004, 647744, 346432968 ],
  '- plugin 6 (sourcemaps) - load (async)': [ 943857.0503409998, 615032768, 352005520 ],
  '- plugin 5 (sourcemaps) - load': [ 9.865984000000001, 326648, 346426376 ],
  '- plugin 5 (sourcemaps) - load (async)': [ 452015.570979, 316842608, 352004560 ],
  '- plugin 1 (json) - transform': [ 12.718466, 76960, 352309288 ],
  '- plugin 2 (at position 3) - transform': [ 13.978003999999999, 144240, 352517584 ],
  '- plugin 3 (rpt2) - transform': [ 38510.69158600002, 247762048, 592937568 ],
  '- plugin 4 (babel) - transform': [ 1020.9119190000005, 24824640, 537346512 ],
  '- plugin 4 (babel) - transform (async)': [ 513363.3542649998, 25696740784, 581710376 ],
  '- plugin 5 (replace) - transform': [ 55.411102000000014, 4937944, 589553936 ],
  'generate ast': [ 223.65392300000016, 10677648, 593264432 ],
  'analyse ast': [ 185.6019320000002, -246277192, 593236144 ],
  '- plugin 3 (rpt2) - resolveId': [ 91.53104199999997, -5452616, 346475520 ],
  '## analyse dependency graph': [ 23.803683, 4306704, 544409184 ],
  '## mark included statements': [ 22.00839, -6872496, 540410416 ],
  'treeshaking pass 1': [ 7.548756, 1165800, 545589000 ],
  'treeshaking pass 2': [ 9.726016, -8792840, 540409800 ],
  '## generate chunks': [ 10.429739, 1763976, 541256168 ] }
{ '# BUILD': [ 136458.975271, 742819144, 545222456 ],
  '## parse modules': [ 136328.120818, 735788816, 541983792 ],
  '- plugin 0 (node-resolve) - resolveId': [ 16.686786000000005, 1722304, 334375352 ],
  '- plugin 0 (node-resolve) - resolveId (async)': [ 87850.61065700013, 4134695144, 346438824 ],
  'load modules': [ 1401519.6063479998, 1050694920, 352076056 ],
  '- plugin 0 (node-resolve) - load': [ 11.477684000000005, 94360, 346416168 ],
  '- plugin 3 (rpt2) - load': [ 11.088360000000012, 104168, 346420296 ],
  '- plugin 4 (babel) - load': [ 11.090018000000006, 89096, 346423304 ],
  '- plugin 6 (sourcemaps) - load': [ 16.119847000000004, 647744, 346432968 ],
  '- plugin 6 (sourcemaps) - load (async)': [ 943857.0503409998, 615032768, 352005520 ],
  '- plugin 5 (sourcemaps) - load': [ 9.865984000000001, 326648, 346426376 ],
  '- plugin 5 (sourcemaps) - load (async)': [ 452015.570979, 316842608, 352004560 ],
  '- plugin 1 (json) - transform': [ 12.718466, 76960, 352309288 ],
  '- plugin 2 (at position 3) - transform': [ 13.978003999999999, 144240, 352517584 ],
  '- plugin 3 (rpt2) - transform': [ 38510.69158600002, 247762048, 592937568 ],
  '- plugin 4 (babel) - transform': [ 1020.9119190000005, 24824640, 537346512 ],
  '- plugin 4 (babel) - transform (async)': [ 513363.3542649998, 25696740784, 581710376 ],
  '- plugin 5 (replace) - transform': [ 55.411102000000014, 4937944, 589553936 ],
  'generate ast': [ 223.65392300000016, 10677648, 593264432 ],
  'analyse ast': [ 185.6019320000002, -246277192, 593236144 ],
  '- plugin 3 (rpt2) - resolveId': [ 91.53104199999997, -5452616, 346475520 ],
  '## analyse dependency graph': [ 37.019328, 6046336, 544409184 ],
  '## mark included statements': [ 32.907793999999996, -5799072, 544293544 ],
  'treeshaking pass 1': [ 13.899056, 1559440, 545589000 ],
  'treeshaking pass 2': [ 11.831361, -8455048, 544293088 ],
  '## generate chunks': [ 14.988824999999999, 2623968, 545153640 ],
  '# GENERATE': [ 0, 0, 0 ] }
{ '# BUILD': [ 136458.975271, 742819144, 545222456 ],
  '## parse modules': [ 136328.120818, 735788816, 541983792 ],
  '- plugin 0 (node-resolve) - resolveId': [ 16.686786000000005, 1722304, 334375352 ],
  '- plugin 0 (node-resolve) - resolveId (async)': [ 87850.61065700013, 4134695144, 346438824 ],
  'load modules': [ 1401519.6063479998, 1050694920, 352076056 ],
  '- plugin 0 (node-resolve) - load': [ 11.477684000000005, 94360, 346416168 ],
  '- plugin 3 (rpt2) - load': [ 11.088360000000012, 104168, 346420296 ],
  '- plugin 4 (babel) - load': [ 11.090018000000006, 89096, 346423304 ],
  '- plugin 6 (sourcemaps) - load': [ 16.119847000000004, 647744, 346432968 ],
  '- plugin 6 (sourcemaps) - load (async)': [ 943857.0503409998, 615032768, 352005520 ],
  '- plugin 5 (sourcemaps) - load': [ 9.865984000000001, 326648, 346426376 ],
  '- plugin 5 (sourcemaps) - load (async)': [ 452015.570979, 316842608, 352004560 ],
  '- plugin 1 (json) - transform': [ 12.718466, 76960, 352309288 ],
  '- plugin 2 (at position 3) - transform': [ 13.978003999999999, 144240, 352517584 ],
  '- plugin 3 (rpt2) - transform': [ 38510.69158600002, 247762048, 592937568 ],
  '- plugin 4 (babel) - transform': [ 1020.9119190000005, 24824640, 537346512 ],
  '- plugin 4 (babel) - transform (async)': [ 513363.3542649998, 25696740784, 581710376 ],
  '- plugin 5 (replace) - transform': [ 55.411102000000014, 4937944, 589553936 ],
  'generate ast': [ 223.65392300000016, 10677648, 593264432 ],
  'analyse ast': [ 185.6019320000002, -246277192, 593236144 ],
  '- plugin 3 (rpt2) - resolveId': [ 91.53104199999997, -5452616, 346475520 ],
  '## analyse dependency graph': [ 37.019328, 6046336, 544409184 ],
  '## mark included statements': [ 32.907793999999996, -5799072, 544293544 ],
  'treeshaking pass 1': [ 13.899056, 1559440, 545589000 ],
  'treeshaking pass 2': [ 11.831361, -8455048, 544293088 ],
  '## generate chunks': [ 14.988824999999999, 2623968, 545153640 ],

The “Building modules” stage of the build process takes 47.3 seconds - that’s for building the 160 SVGR generated React components (it’s an icon library) on my 2.7GHz i7 16GB RAM MacBook Pro.

Your environment

Software Version(s)
TSDX 0.9.0
TypeScript 3.6.2
Browser n/a
npm/Yarn yarn 1.17.3
Operating System osx 10.14.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
coreybruyerecommented, Aug 19, 2020

@selbekk - you mind sharing you tsdx rollup config? I’m using the default tsdx config and am getting terribly slow build times.

0reactions
selbekkcommented, Aug 20, 2020

I’m no longer working on that particular project, and has lost access to the source code unfortunately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build time: Visual Studio 2015-2017 build very slow [closed]
During a build a large amount of files will be created. If the virus scanner accesses these files during build, this can cause...
Read more >
Why the Build System might be slow - Firefox Source Docs
It may not be obvious, but the main reason the build system is slow is because it does a lot of work! The...
Read more >
Visual Studio 2019 version 16.8.0 very slow to build ...
I recently updated to Visual Studio 2019 version 16.8.0 and it is very very slow to build. It sits there at 100% CPU...
Read more >
Improving Compilation Time of C/C++ Projects - Interrupt
Large Files = Slow Builds. Generally speaking, the larger the input file into the compiler is, the longer it will take to compile....
Read more >
Optimize your build speed | Android Developers
The general process of improving your app's build speed is as follows: ... such as the Android Runtime (ART) and native support for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found