[Webpack 5] 3x slowdown caused by _discoverActiveExportsFromOtherStarExports
See original GitHub issueBug report
What is the current behavior?
Upgrading to Webpack 5 takes 5s to livereload my browser between changes:
(the light green blocks at the bottom are calls to getStarReexports
and the slow hotspot _discoverActiveExportsFromOtherStarExports
)
Webpack 4 takes 3s:
If the current behavior is a bug, please provide the steps to reproduce.
git clone -b feat/webpack-5 https://github.com/patternfly/patternfly-org && cd patternfly-org && yarn && yarn start
- Wait ~1m for initial webpack compilation.
- Save change to
packages/v4/src/pages/home.js
- Webpack 5 performs worse than Webpack 4, even with
module: { unsafeCache: true }
andeager-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:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
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 *
complexity seem to beO(n²)
… Eachexport *
looks at the exports of all previousexport *
s.And we haven’t implemented caching for exports that depend on other modules…
Thank you so much. Have an amazing day!
On Wed, Apr 14, 2021 at 8:00 AM zallen @.***> wrote: