Skip to content
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

[Turbopack] remove asset context and layer from static files #75892

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions crates/next-core/src/next_image/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ impl StructuredImageModuleType {
blur_placeholder_mode: BlurPlaceholderMode,
module_asset_context: ResolvedVc<ModuleAssetContext>,
) -> Result<Vc<Box<dyn Module>>> {
let static_asset = StaticModuleAsset::new(*source, Vc::upcast(*module_asset_context))
.to_resolved()
.await?;
let static_asset = StaticModuleAsset::new(*source).to_resolved().await?;
Ok(module_asset_context
.process(
Vc::upcast(
Expand Down
17 changes: 3 additions & 14 deletions turbopack/crates/turbopack-static/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{
asset::{Asset, AssetContent},
chunk::{ChunkItem, ChunkType, ChunkableModule, ChunkingContext},
context::AssetContext,
ident::AssetIdent,
module::Module,
module_graph::ModuleGraph,
Expand Down Expand Up @@ -49,20 +48,13 @@ fn modifier() -> Vc<RcStr> {
#[derive(Clone)]
pub struct StaticModuleAsset {
pub source: ResolvedVc<Box<dyn Source>>,
pub asset_context: ResolvedVc<Box<dyn AssetContext>>,
}

#[turbo_tasks::value_impl]
impl StaticModuleAsset {
#[turbo_tasks::function]
pub fn new(
source: ResolvedVc<Box<dyn Source>>,
asset_context: ResolvedVc<Box<dyn AssetContext>>,
) -> Vc<Self> {
Self::cell(StaticModuleAsset {
source,
asset_context,
})
pub fn new(source: ResolvedVc<Box<dyn Source>>) -> Vc<Self> {
Self::cell(StaticModuleAsset { source })
}

#[turbo_tasks::function]
Expand All @@ -78,10 +70,7 @@ impl StaticModuleAsset {
impl Module for StaticModuleAsset {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
self.source
.ident()
.with_modifier(modifier())
.with_layer(self.asset_context.layer())
self.source.ident().with_modifier(modifier())
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([
"output/4e721_crates_turbopack-tests_tests_snapshot_import-meta_url_input_index_da7049.js",
"output/4e721_crates_turbopack-tests_tests_snapshot_import-meta_url_input_index_ba5716.js",
{},
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_url_input_6c57ac._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/input/index.js [test] (ecmascript)"]}
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_import-meta_url_input_7615cd._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/url/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([
"output/b1abf_turbopack-tests_tests_snapshot_imports_ignore-comments_input_index_e44b7c.js",
"output/b1abf_turbopack-tests_tests_snapshot_imports_ignore-comments_input_index_958d93.js",
{},
{"otherChunks":["output/b1abf_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_bc04b7._.js","output/4e721_crates_turbopack-tests_tests_snapshot_imports_ignore-comments_input_26ea62._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/index.js [test] (ecmascript)"]}
{"otherChunks":["output/b1abf_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_348d99._.js","output/4e721_crates_turbopack-tests_tests_snapshot_imports_ignore-comments_input_6c932d._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/b1abf_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_bc04b7._.js", {
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push(["output/b1abf_turbopack-tests_tests_snapshot_imports_ignore-comments_input_vercel_mjs_348d99._.js", {

"[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/ignore-comments/input/vercel.mjs [test] (ecmascript, async loader)": ((__turbopack_context__) => {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([
"output/4e721_crates_turbopack-tests_tests_snapshot_imports_static_input_index_b30b52.js",
"output/4e721_crates_turbopack-tests_tests_snapshot_imports_static_input_index_d62553.js",
{},
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_imports_static_input_73301e._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/static/input/index.js [test] (ecmascript)"]}
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_imports_static_input_7116c6._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/imports/static/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions turbopack/crates/turbopack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,9 @@ async fn apply_module_type(
.to_resolved()
.await?,
),
ModuleType::Static => ResolvedVc::upcast(
StaticModuleAsset::new(*source, Vc::upcast(module_asset_context))
.to_resolved()
.await?,
),
ModuleType::Static => {
ResolvedVc::upcast(StaticModuleAsset::new(*source).to_resolved().await?)
}
ModuleType::WebAssembly { source_ty } => ResolvedVc::upcast(
WebAssemblyModuleAsset::new(
WebAssemblySource::new(*source, *source_ty),
Expand Down
Loading