Files
Donny/강동윤andGitHub 3a5b73d2d6 perf(turbopack): Remove ImportBinding fragments (#78470)
### 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
2025-04-28 15:10:59 +00:00

2.5 KiB

Items

Count: 3

Item 1: Stmt 0, ImportOfModule

export { cat as fakeCat } from "./lib";

  • Hoisted
  • Side effects

Item 2: Stmt 0, ReexportBinding(0)

export { cat as fakeCat } from "./lib";

  • Hoisted
  • Declares: __TURBOPACK__reexport__cat__

Phase 1

graph TD
    Item1;
    Item2;
    Item3;
    Item3["export fakeCat"];

Phase 2

graph TD
    Item1;
    Item2;
    Item3;
    Item3["export fakeCat"];
    Item3 --> Item2;

Phase 3

graph TD
    Item1;
    Item2;
    Item3;
    Item3["export fakeCat"];
    Item3 --> Item2;

Phase 4

graph TD
    Item1;
    Item2;
    Item3;
    Item3["export fakeCat"];
    Item3 --> Item2;

Final

graph TD
    N0["Items: [ItemId(0, ImportOfModule), ItemId(0, ReexportBinding(0)), ItemId(Export(("__TURBOPACK__reexport__cat__", #3), "fakeCat"))]"];

Entrypoints

{
    ModuleEvaluation: 0,
    Export(
        "fakeCat",
    ): 0,
    Exports: 1,
}

Modules (dev)

Part 0

import "./lib";
import { cat as __TURBOPACK__reexport__cat__ } from "./lib";
export { __TURBOPACK__reexport__cat__ as fakeCat };
export { __TURBOPACK__reexport__cat__ as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };

Part 1

export { fakeCat } from "__TURBOPACK_PART__" assert {
    __turbopack_part__: "export fakeCat"
};

Merged (module eval)

import "./lib";
import { cat as __TURBOPACK__reexport__cat__ } from "./lib";
export { __TURBOPACK__reexport__cat__ as fakeCat };
export { __TURBOPACK__reexport__cat__ as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };

Entrypoints

{
    ModuleEvaluation: 0,
    Export(
        "fakeCat",
    ): 0,
    Exports: 1,
}

Modules (prod)

Part 0

import "./lib";
import { cat as __TURBOPACK__reexport__cat__ } from "./lib";
export { __TURBOPACK__reexport__cat__ as fakeCat };
export { __TURBOPACK__reexport__cat__ as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };

Part 1

export { fakeCat } from "__TURBOPACK_PART__" assert {
    __turbopack_part__: "export fakeCat"
};

Merged (module eval)

import "./lib";
import { cat as __TURBOPACK__reexport__cat__ } from "./lib";
export { __TURBOPACK__reexport__cat__ as fakeCat };
export { __TURBOPACK__reexport__cat__ as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };