-
Notifications
You must be signed in to change notification settings - Fork 472
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: asset resource side effects #2849
Conversation
|
750fc3c
to
7223674
Compare
0c3449f
to
c367be8
Compare
c367be8
to
fc7e40a
Compare
fc7e40a
to
08d0a1c
Compare
* chore: 馃 ck point * chore: 馃 init include_module_ids * chore: 馃 update test * chore: 馃 update test * chore: 馃 make test pass * chore: 馃 update used ids * feat: update include_module_ids strategy * feat: more abstraction * feat: 馃幐 add asset module * chore: 馃 inspect asset module side effects * chore: 馃 recover main bindinng.d.ts * chore: 馃 clean up * chore: 馃 finish it * chore: 馃 add test * chore: 馃 pass test * chore: 馃 clean up * chore: 馃 lint * fix: 馃悰 cr issue
Related issue (if exists)
Closed #2804
Summary
馃 Generated by Copilot at 070e0b3
This pull request implements and improves the tree-shaking optimization for
rspack_core
andrspack_plugin_javascript
crates, using a newOptimizeAnalyzer
trait and a newOptimizeAnalyzeResult
struct. It also adds a newsideEffects
option to the compiler and therspack.config.js
file, to enable or disable the optimization based on the module metadata. It also adds an example project that demonstrates the usage of asset modules and the tree-shaking optimization.Walkthrough
馃 Generated by Copilot at 070e0b3
TreeShakingResult
toOptimizeAnalyzeResult
and update imports and types accordingly (link,link,link,link,link,link,link,link,link,link,link,link,link)include_module_ids
field toCompilation
struct and populate it with the result of tree-shaking optimization (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)used
flag fromModuleGraphModule
struct and related logic, since it is no longer used for tree-shaking (link,link,link,link,link)SideEffect
enum toSideEffectType
and update imports and pattern matching accordingly (link,link,link,link,link,link,link,link,link,link,link,link,link,link,link)OptimizeAnalyzer
trait and implement it forJsModule
andAssetModule
structs, to provide a common interface for analyzing different types of modules for tree-shaking optimization (link,link,link,link,link)ModuleGraphModule
struct toModuleType
and derive it withDefault
, to avoid confusion with theModuleGraphModule
struct in themodule_graph
module and allow creating an empty instance (link)included_in_chunk
method toModuleType
struct, to check if a module should be included in the final chunk based on theinclude_module_ids
set and theside_effects_options
flag (link,link)ConvertModulePath
trait frommod.rs
toutils.rs
, to avoid circular imports (link,link,link)ExtraMark
struct to pass the marks for the top-level and helper symbols to the tree-shaker (link,link,link,link,link,link,link)tree_shaking.rs
file fromrspack_plugin_javascript
crate torspack_core
crate, to make the tree-shaking logic more generic and reusable for different types of modules (link)options
parameter totree_shaking
function andTreeShaker
struct, to pass the compiler options to the tree-shaker (link,link,link,link)from_description
method ofSideEffects
struct topub
, to allow using it from other modules (link)index.js
andpackage.json
files toexamples/basic/a
folder, to demonstrate the usage of an asset module and the tree-shaking optimization (link,link)rspack.config.js
file to enablesideEffects
andtreeShaking
options, setmode
todevelopment
, and specify the type of asset modules (link)