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.

[Webpack 5] 3x slowdown caused by _discoverActiveExportsFromOtherStarExports

See original GitHub issue

Bug report

What is the current behavior? Upgrading to Webpack 5 takes 5s to livereload my browser between changes: image (the light green blocks at the bottom are calls to getStarReexports and the slow hotspot _discoverActiveExportsFromOtherStarExports) Webpack 4 takes 3s: image

If the current behavior is a bug, please provide the steps to reproduce.

  1. git clone -b feat/webpack-5 https://github.com/patternfly/patternfly-org && cd patternfly-org && yarn && yarn start
  2. Wait ~1m for initial webpack compilation.
  3. Save change to packages/v4/src/pages/home.js
  4. Webpack 5 performs worse than Webpack 4, even with module: { unsafeCache: true } and eager-imports-webpack-plugin
798 assets
5779 modules
webpack 5.31.0 compiled successfully in 5051 ms

What is the expected behavior? Webpack 5 to be faster than webpack 4. Simply changing _discoverActiveExportsFromOtherStarExports to return new Map(); speeds Webpack up 3x:

798 assets
5779 modules
webpack 5.31.0 compiled successfully in 1475 ms

In 95% of cases developers aren’t touching star reexports.

I believe this is due to many included barrel files containing thousands of export * from './file';. Is there a way to speedup this _discoverActiveExportsFromOtherStarExports hotspot (or avoid it altogether) besides changing library code to export { list, of, named, exports } from './file';?

Other relevant information: webpack version: webpack@5.31.0 Node.js version: v14.16.0 Operating System: linux Relevant: #8644

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sokracommented, Apr 13, 2021

I’m looking into fixing that slowness.

If you want an easy fix: 99% of that time is spend in a single file:

node_modules\@patternfly\react-icons\dist\esm\icons\index.js

In contains 1721 lines of export *. The file seem to be autogenerated. I guess it should be easy to generate normal reexports instead:

-export * from './accessible-icon-icon';
+export { AccessibleIconIcon } from './accessible-icon-icon';

export * complexity seem to be O(n²)… Each export * looks at the exports of all previous export *s.

And we haven’t implemented caching for exports that depend on other modules…

0reactions
Z-shhcommented, Apr 17, 2021

Thank you so much. Have an amazing day!

On Wed, Apr 14, 2021 at 8:00 AM zallen @.***> wrote:

Just changing the star exports in the autogenerated code reduced reload times down to 3s. I’m sure your optimizations will help even more. Thanks @sokra https://github.com/sokra !!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/webpack/webpack/issues/13107#issuecomment-819498834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR2YZ4PT7HC4USVQP3PQPKLTIWGYNANCNFSM42VR3H2A .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding why our build got 15x slower with Webpack 5
A while back, we encountered an odd problem. All of a sudden, building our front-end went from taking a few seconds to taking...
Read more >
Build Performance - webpack
This guide contains some useful tips for improving build/compilation performance. General. The following best practices should help, whether you're running ...
Read more >
Webpack 5 release (2020-10-10)
It used to display the currently processed module. This caused much stderr output and yielded a performance problem on some consoles. This is ......
Read more >
Resolve | webpack
When enabled, symlinked resources are resolved to their real path, not their symlinked location. Note that this may cause module resolution to fail...
Read more >
Other Options - webpack
Certain popular modules written for AMD, most notably jQuery versions 1.7.0 to 1.9.1, will only register as an AMD module if the loader...
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