Skip to content

TURBOPACK: expose node ecmascript chunk types and accessors#147

Merged
fireairforce merged 1 commit into
utoofrom
feat/pub-node-chunk-types
May 10, 2026
Merged

TURBOPACK: expose node ecmascript chunk types and accessors#147
fireairforce merged 1 commit into
utoofrom
feat/pub-node-chunk-types

Conversation

@yuzheng14
Copy link
Copy Markdown

Promote EcmascriptBuildNodeChunk, EcmascriptBuildNodeEntryChunk, and EcmascriptBuildNodeRuntimeChunk from pub(crate) to pub, and re-export them from turbopack_nodejs, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible stats generation):

  • EcmascriptBuildNodeChunk::chunk() — exposes the inner Chunk for chunk_items
  • EcmascriptBuildNodeEntryChunk::chunks_data() / evaluatable_assets() / module_graph() / chunking_context() — mirror EcmascriptBrowserEvaluateChunk

No behavior changes inside turbopack-nodejs itself.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request exposes several internal Ecmascript Node.js chunk types and modules by making them public and adding various accessor methods. The review feedback highlights opportunities to reduce task graph overhead by removing the #[turbo_tasks::function] attribute from simple field accessors and cheap upcasts. Furthermore, the chunks_data method should be simplified to a synchronous implementation, as the current asynchronous approach and error handling are unnecessary for the operations being performed.

Comment on lines +70 to +73
#[turbo_tasks::function]
pub fn chunk(&self) -> Vc<Box<dyn Chunk>> {
Vc::upcast(*self.chunk)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The chunk method is a simple accessor that performs a cheap Vc::upcast. Marking it as a #[turbo_tasks::function] adds unnecessary overhead to the task graph (scheduling, memoization, etc.). It is better to provide it as a regular public method.

    pub fn chunk(&self) -> Vc<Box<dyn Chunk>> {
        Vc::upcast(*self.chunk)
    }

Comment on lines +66 to +72
#[turbo_tasks::function]
pub async fn chunks_data(&self) -> Result<Vc<ChunksData>> {
Ok(ChunkData::from_assets(
self.chunking_context.output_root().owned().await?,
*self.other_chunks,
))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The chunks_data implementation can be simplified. ChunkData::from_assets accepts Vc arguments, so there is no need to await the output root or use .owned(). Removing the async and Result reduces overhead and aligns with the implementation in EcmascriptBrowserEvaluateChunk.

    #[turbo_tasks::function]
    pub fn chunks_data(&self) -> Vc<ChunksData> {
        ChunkData::from_assets(self.chunking_context.output_root(), *self.other_chunks)
    }

Comment on lines +74 to +77
#[turbo_tasks::function]
pub fn evaluatable_assets(&self) -> Vc<EvaluatableAssets> {
*self.evaluatable_assets
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a simple field accessor. Using #[turbo_tasks::function] here is unnecessary and adds overhead to the task graph. It should be a regular public method.

    pub fn evaluatable_assets(&self) -> Vc<EvaluatableAssets> {
        *self.evaluatable_assets
    }

Comment on lines +79 to +82
#[turbo_tasks::function]
pub fn module_graph(&self) -> Vc<ModuleGraph> {
*self.module_graph
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a simple field accessor. Using #[turbo_tasks::function] here is unnecessary and adds overhead to the task graph. It should be a regular public method.

    pub fn module_graph(&self) -> Vc<ModuleGraph> {
        *self.module_graph
    }

Comment on lines +84 to +87
#[turbo_tasks::function]
pub fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(*self.chunking_context)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This method performs a simple field access and a cheap Vc::upcast. Using #[turbo_tasks::function] here is unnecessary and adds overhead to the task graph. It should be a regular public method.

    pub fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
        Vc::upcast(*self.chunking_context)
    }

Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
@yuzheng14 yuzheng14 force-pushed the feat/pub-node-chunk-types branch from deaac1d to 4b33fa3 Compare May 9, 2026 12:11
@fireairforce fireairforce merged commit a1f6c5c into utoo May 10, 2026
60 of 77 checks passed
@yuzheng14 yuzheng14 deleted the feat/pub-node-chunk-types branch May 11, 2026 03:05
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 26, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
yuzheng14 added a commit that referenced this pull request May 27, 2026
Promote `EcmascriptBuildNodeChunk`, `EcmascriptBuildNodeEntryChunk`, and
`EcmascriptBuildNodeRuntimeChunk` from `pub(crate)` to `pub`, and re-export them
from `turbopack_nodejs`, mirroring the browser-side visibility.

Add public accessors needed for downstream consumers (e.g. webpack-compatible
stats generation):
- `EcmascriptBuildNodeChunk::chunk()` — exposes the inner `Chunk` for chunk_items
- `EcmascriptBuildNodeEntryChunk::chunks_data()` / `evaluatable_assets()` /
  `module_graph()` / `chunking_context()` — mirror `EcmascriptBrowserEvaluateChunk`

No behavior changes inside turbopack-nodejs itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants