-
Notifications
You must be signed in to change notification settings - Fork 0
TURBOPACK: expose node ecmascript chunk types and accessors #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| pub(crate) mod node; | ||
| pub mod node; | ||
|
|
||
| pub use node::{ | ||
| EcmascriptBuildNodeChunk, EcmascriptBuildNodeEntryChunk, EcmascriptBuildNodeRuntimeChunk, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ use turbo_tasks::{ResolvedVc, ValueToString, Vc, turbobail}; | |
| use turbo_tasks_fs::{File, FileContent, FileSystemPath}; | ||
| use turbopack_core::{ | ||
| asset::{Asset, AssetContent}, | ||
| chunk::{ChunkingContext, EvaluatableAssets, ModuleChunkItemIdExt}, | ||
| chunk::{ChunkData, ChunkingContext, ChunksData, EvaluatableAssets, ModuleChunkItemIdExt}, | ||
|
fireairforce marked this conversation as resolved.
|
||
| code_builder::{Code, CodeBuilder}, | ||
| module_graph::ModuleGraph, | ||
| output::{ | ||
|
|
@@ -25,7 +25,7 @@ use crate::NodeJsChunkingContext; | |
| #[turbo_tasks::value(shared)] | ||
| #[derive(ValueToString)] | ||
| #[value_to_string("Ecmascript Build Node Entry Chunk")] | ||
| pub(crate) struct EcmascriptBuildNodeEntryChunk { | ||
| pub struct EcmascriptBuildNodeEntryChunk { | ||
| path: FileSystemPath, | ||
| other_chunks: ResolvedVc<OutputAssets>, | ||
| evaluatable_assets: ResolvedVc<EvaluatableAssets>, | ||
|
|
@@ -63,6 +63,29 @@ impl EcmascriptBuildNodeEntryChunk { | |
| .cell() | ||
| } | ||
|
|
||
| #[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, | ||
| )) | ||
| } | ||
|
Comment on lines
+66
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The #[turbo_tasks::function]
pub fn chunks_data(&self) -> Vc<ChunksData> {
ChunkData::from_assets(self.chunking_context.output_root(), *self.other_chunks)
} |
||
|
|
||
| #[turbo_tasks::function] | ||
| pub fn evaluatable_assets(&self) -> Vc<EvaluatableAssets> { | ||
| *self.evaluatable_assets | ||
| } | ||
|
Comment on lines
+74
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| #[turbo_tasks::function] | ||
| pub fn module_graph(&self) -> Vc<ModuleGraph> { | ||
| *self.module_graph | ||
| } | ||
|
Comment on lines
+79
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| #[turbo_tasks::function] | ||
| pub fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> { | ||
| Vc::upcast(*self.chunking_context) | ||
| } | ||
|
Comment on lines
+84
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| #[turbo_tasks::function] | ||
| async fn code(self: Vc<Self>) -> Result<Vc<Code>> { | ||
| let this = self.await?; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| pub(crate) mod chunk; | ||
| pub(crate) mod runtime; | ||
| pub mod chunk; | ||
| pub mod runtime; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| pub(crate) mod chunk; | ||
| pub mod chunk; | ||
| pub(crate) mod content; | ||
| pub(crate) mod entry; | ||
| pub mod entry; | ||
| pub(crate) mod update; | ||
| pub(crate) mod version; | ||
|
|
||
| pub use chunk::EcmascriptBuildNodeChunk; | ||
| pub use entry::{chunk::EcmascriptBuildNodeEntryChunk, runtime::EcmascriptBuildNodeRuntimeChunk}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
chunkmethod is a simple accessor that performs a cheapVc::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.