Skip to content

refactor: getTypes in asset/css generator #19573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hai-x
Copy link
Member

@hai-x hai-x commented May 31, 2025

What kind of change does this PR introduce?

Refactor the getTypes logic to exclude generation when the original module is not an official JavaScript or CSS module.

Did you add tests for your changes?

Exists now but feel free to ask more

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

No

Copy link

codspeed-hq bot commented May 31, 2025

CodSpeed Performance Report

Merging #19573 will degrade performances by 74.28%

Comparing hai-x:refactor-get-types (ccd5c41) with main (19ca741)

Summary

⚡ 81 improvements
❌ 3 regressions
✅ 37 untouched benchmarks
🆕 12 new benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 42.1 ms 34.3 ms +22.8%
benchmark "future-defaults", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 52.3 ms 11.6 ms ×4.5
🆕 benchmark "lodash", scenario '{"name":"mode-development","mode":"development"}' N/A 755.8 ms N/A
🆕 benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' N/A 30.2 ms N/A
🆕 benchmark "lodash", scenario '{"name":"mode-production","mode":"production"}' N/A 9.8 s N/A
🆕 benchmark "many-chunks-commonjs", scenario '{"name":"mode-development","mode":"development"}' N/A 248.4 ms N/A
🆕 benchmark "many-chunks-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' N/A 9.8 ms N/A
🆕 benchmark "many-chunks-commonjs", scenario '{"name":"mode-production","mode":"production"}' N/A 2 s N/A
🆕 benchmark "many-chunks-esm", scenario '{"name":"mode-development","mode":"development"}' N/A 244 ms N/A
🆕 benchmark "many-chunks-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' N/A 11.1 ms N/A
🆕 benchmark "many-chunks-esm", scenario '{"name":"mode-production","mode":"production"}' N/A 2.3 s N/A
🆕 benchmark "many-modules-commonjs", scenario '{"name":"mode-development","mode":"development"}' N/A 307.9 ms N/A
🆕 benchmark "many-modules-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' N/A 10.3 ms N/A
🆕 benchmark "many-modules-commonjs", scenario '{"name":"mode-production","mode":"production"}' N/A 2.1 s N/A
benchmark "many-modules-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 11.2 ms 43.5 ms -74.28%
benchmark "minimal", scenario '{"name":"mode-development","mode":"development"}' 23.8 ms 30.4 ms -21.74%
benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 31.3 ms 35.2 ms -10.98%
md4 buffer benchmark (size: 10000) 114.1 µs 73.1 µs +56.18%
md4 buffer benchmark (size: 100000) 447.6 µs 406.7 µs +10.07%
md4 buffer benchmark (size: 120) 76 µs 34.9 µs ×2.2
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

WEBPACK_MODULE_TYPE_PROVIDE,
WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE,
WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need types here to catch cases when we added a new type and forgot about it, I think we need something like ALL_MODULES and using Exclude/Pick ts helper here, just idea

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it will be like: const ALL_MODULES = new Set(Object.values(module.exports) and then do some filter logic. To ensure correctness, ALL_MODULES must be defined after all export statements, as its value depends on the order of module definitions.

Maybe we can organize moduleTypes into separate files based on its category, i.e.
lib/JavascriptModuleTypeConstants.js, lib/CssModuleTypeConstants.js. Then in ModuleTypeConstants.js we re-export all constants, and also define AllJsModuleTypes and AllCssModuleTypes...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah make sense too, do you want to try it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah make sense too, do you want to try it?

Yeah. Try now.

@hai-x hai-x force-pushed the refactor-get-types branch from 39e8703 to ccd5c41 Compare June 4, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy