diff --git a/turbopack/crates/turbopack-ecmascript/src/references/pattern_mapping.rs b/turbopack/crates/turbopack-ecmascript/src/references/pattern_mapping.rs index b933aca1ec55b..1c6d9bdecb696 100644 --- a/turbopack/crates/turbopack-ecmascript/src/references/pattern_mapping.rs +++ b/turbopack/crates/turbopack-ecmascript/src/references/pattern_mapping.rs @@ -29,6 +29,7 @@ use turbopack_core::{ use super::util::{request_to_string, throw_module_not_found_expr}; use crate::{ + chunk::EcmascriptChunkPlaceable, references::util::throw_module_not_found_error_expr, runtime_functions::{ TURBOPACK_ASYNC_LOADER, TURBOPACK_EXTERNAL_IMPORT, TURBOPACK_EXTERNAL_REQUIRE, @@ -361,6 +362,13 @@ async fn to_single_pattern_mapping( } }; if let Some(chunkable) = ResolvedVc::try_downcast::>(module) { + // Check if it's an EcmascriptChunkPlaceable + // Non-JS modules should be ignored as their side effects + // are handled through their own chunk types + if ResolvedVc::try_downcast::>(module).is_none() { + return Ok(SinglePatternMapping::Ignored); + } + match resolve_type { ResolveType::AsyncChunkLoader => { let loader_id = chunking_context.async_loader_chunk_item_id(*chunkable);