Files
7759ea32c0 perf(turbopack): Use last side effect as ModuleEvaluation fragment (#76940)
### What?

Use the last side effect fragment instead of the module evaluation fragment.

### Why?

Module evaluation fragment is a waste of memory.

### How?

Closes PACK-3440

---------

Co-authored-by: Tobias Koppers <[email protected]>
2025-03-11 18:57:50 +09:00

1.7 KiB

Items

Count: 3

Item 1: Stmt 0, Normal

a = ()=>{};

  • Write: a

Item 2: Stmt 1, Normal

function a() {}

  • Hoisted
  • Declares: a
  • Write: a

Item 3: Stmt 2, Normal

console.log(a);

  • Side effects
  • Reads: a

Phase 1

graph TD
    Item1;
    Item2;
    Item3;

Phase 2

graph TD
    Item1;
    Item2;
    Item3;
    Item1 --> Item2;
    Item3 --> Item1;
    Item3 --> Item2;

Phase 3

graph TD
    Item1;
    Item2;
    Item3;
    Item1 --> Item2;
    Item3 --> Item1;
    Item3 --> Item2;

Phase 4

graph TD
    Item1;
    Item2;
    Item3;
    Item1 --> Item2;
    Item3 --> Item1;
    Item3 --> Item2;

Final

graph TD
    N0["Items: [ItemId(0, Normal), ItemId(1, Normal), ItemId(2, Normal)]"];

Entrypoints

{
    ModuleEvaluation: 0,
    Exports: 1,
}

Modules (dev)

Part 0

a = ()=>{};
function a() {}
console.log(a);
export { a as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };

Part 1


Merged (module eval)

a = ()=>{};
function a() {}
console.log(a);
export { a as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };

Entrypoints

{
    ModuleEvaluation: 0,
    Exports: 1,
}

Modules (prod)

Part 0

a = ()=>{};
function a() {}
console.log(a);
export { a as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };

Part 1


Merged (module eval)

a = ()=>{};
function a() {}
console.log(a);
export { a as a } from "__TURBOPACK_VAR__" assert {
    __turbopack_var__: true
};
export { };