refactor: always tag top level const value#21199
Conversation
|
|
cc @xiaoxiaojx |
|
This PR is packaged and the instant preview is available (cda325e). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@cda325e
yarn add -D webpack@https://pkg.pr.new/webpack@cda325e
pnpm add -D webpack@https://pkg.pr.new/webpack@cda325e |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21199 +/- ##
==========================================
+ Coverage 92.69% 92.76% +0.07%
==========================================
Files 588 589 +1
Lines 64122 64457 +335
Branches 17799 17910 +111
==========================================
+ Hits 59435 59793 +358
+ Misses 4687 4664 -23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| /** @type {Record<string, import("webpack-sources").Source>} */ assets | ||
| ) => { | ||
| const source = assets["bundle0.js"].source(); | ||
| expect(source).toMatchSnapshot(); |
There was a problem hiding this comment.
Add the snapshot of the code generation.
| inlineExports: Boolean(options.optimization.inlineExports) | ||
| }) | ||
| ).apply(compiler); | ||
| new CircularModulesPlugin().apply(compiler); |
There was a problem hiding this comment.
I am afraid it can eat more memory in development mode, maybe we can avoid it or rewrite
There was a problem hiding this comment.
I think we can apply it only in production mode, rspack is also doing so. What do you think?
There was a problem hiding this comment.
Let's do it, maybe we can narrow it for optimization option where we need it
There was a problem hiding this comment.
Let's move under production mode for now. It is used to detect cyclic dependency references, placing it under the optimization option is not very accurate.
| } | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
This plugin looks like wrapper plugin for other wrappers, maybe we can simplify it? and move this logic inside inline Exports Plugin directly
19808a6 to
8c99aae
Compare
Types CoverageCoverage after merging refactor-const-value into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary
What kind of change does this PR introduce?
Decouple the optimization of generation of static export definition which introduced in #21021 with
optimization.inlineExports. They just both relied on the top-level const binding data.What changes?
ConstValueParserPlugin(moved tolib/javascript/, now owningCONST_BINDING_TAG) and applies it unconditionally via a new genericJavascriptParserApplyPluginadapter, so const bindings are tagged on every build.optimization.inlineExports;InlineExportsPluginkeeps only the inline-specificprogram/evaluateIdentifierhooks.Did you add tests for your changes?
No — internal refactor with no behavior change for users; covered by the existing
optimization.inlineExportsconfig cases.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Partial