refactor: build exports-presence guards from formula#21320
Conversation
|
|
This PR is packaged and the instant preview is available (cebd793). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@cebd793
yarn add -D webpack@https://pkg.pr.new/webpack@cebd793
pnpm add -D webpack@https://pkg.pr.new/webpack@cebd793 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21320 +/- ##
=======================================
Coverage 92.86% 92.87%
=======================================
Files 594 594
Lines 65210 65247 +37
Branches 18143 18164 +21
=======================================
+ Hits 60559 60595 +36
- Misses 4651 4652 +1
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:
|
Merging this PR will improve performance by 21.58%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "wasm-modules-sync", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
253.4 KB | 361.2 KB | -29.84% |
| ❌ | Memory | benchmark "devtool-eval-source-map", scenario '{"name":"mode-production","mode":"production"}' |
6.3 MB | 8.1 MB | -22.03% |
| ⚡ | Memory | benchmark "asset-modules-inline", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,075.1 KB | 380.8 KB | ×2.8 |
| ⚡ | Memory | benchmark "context-esm", scenario '{"name":"mode-production","mode":"production"}' |
10.2 MB | 7.4 MB | +38.61% |
| ⚡ | Memory | benchmark "many-chunks-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
9.2 MB | 7.4 MB | +24.12% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing refactor-exports-presence-guard (1b66ad9) with main (f84840f)
|
Looks like #21322 the same but just ignoring (not a good idea, but fix the problem), right? |
Do you mean the changes in this PR? |
|
@hai-x wrong place, feel free to make ready to review and let’s rerun bun |
Types CoverageCoverage after merging refactor-exports-presence-guard into main will be
Coverage Report |
Summary
What kind of change does this PR introduce?
The export-presence guard that suppresses "export not found" warnings for namespace accesses behind an
"x" in nscheck was backed by an eagerly-builtMap<string, Set<string>>. This PR reworks it into a boolean formula built lazilyfrom the branch test (atoms are the
"x" in nsdependencies), sharing the same tuple-formula machinery already used for dead-branch dependency guards.It also recognizes guards it missed before: the
elsebranch of a negated check (if (!("a" in ns)) {} else { ns.a }), a statically-falsy right operand ("a" in ns || 0), and"a" in ns ?? 0— the last enabled by teaching the evaluator thatinalways yields a (non-nullish) boolean.Did you add tests for your changes?
Yes — extended
test/configCases/compiletime/exports-presence/module.jswith theelse-branch,|| 0, and?? 0guard 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
Yes