mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
### What? Make the `ImportBinding` node a phantom node. ### Why? Because they are not used. We have to import directly from the original module because of the static analysis like `next/dynamic`. So I modified the tree shaking to import directly with https://github.com/vercel/next.js/pull/71704. But #71704 didn't remove the concept of `ImportBinding`. This PR finishes the work of using direct imports. Additionally, this PR introduces `ReexportBinding` fragments because these are not phantom nodes. I'll check if it would be possible to remove `ReexportBinding` fragments with follow-up PRs. ### How? - Closes PACK-4366
1.6 KiB
1.6 KiB
Items
Count: 3
Item 1: Stmt 0, ImportOfModule
import { baz } from './module';
- Hoisted
- Side effects
Item 2: Stmt 0, ImportBinding(0)
import { baz } from './module';
- Hoisted
- Declares:
baz
Item 3: Stmt 1, Normal
if (1 + 1 == 3) {
baz();
}
- Side effects
- Reads:
baz
Phase 1
graph TD
Item1;
Item2;
Item3;
Phase 2
graph TD
Item1;
Item2;
Item3;
Item3 --> Item2;
Item3 --> Item1;
Phase 3
graph TD
Item1;
Item2;
Item3;
Item3 --> Item2;
Item3 --> Item1;
Phase 4
graph TD
Item1;
Item2;
Item3;
Item3 --> Item2;
Item3 --> Item1;
Final
graph TD
N0["Items: [ItemId(0, ImportOfModule), ItemId(1, Normal)]"];
N1["Items: [ItemId(0, ImportBinding(0))]"];
N0 --> N1;
Entrypoints
{
ModuleEvaluation: 0,
Exports: 1,
}
Modules (dev)
Part 0
import { baz } from './module';
import './module';
if (1 + 1 == 3) {
baz();
}
export { };
Part 1
Merged (module eval)
import { baz } from './module';
import './module';
if (1 + 1 == 3) {
baz();
}
export { };
Entrypoints
{
ModuleEvaluation: 0,
Exports: 1,
}
Modules (prod)
Part 0
import { baz } from './module';
import './module';
if (1 + 1 == 3) {
baz();
}
export { };
Part 1
Merged (module eval)
import { baz } from './module';
import './module';
if (1 + 1 == 3) {
baz();
}
export { };