Skip to content

Commit a28e373

Browse files
committed
fix(turbopack): script externals chunk name simplify
1 parent a4c05f3 commit a28e373

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

turbopack/crates/turbopack-ecmascript/src/references/external_module.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,17 @@ fn externals_fs_root() -> Vc<FileSystemPath> {
292292
impl Module for CachedExternalModule {
293293
#[turbo_tasks::function]
294294
async fn ident(&self) -> Result<Vc<AssetIdent>> {
295-
let mut ident = AssetIdent::from_path(externals_fs_root().await?.join(&self.request)?)
295+
// For script externals, simplify the path by using variable name
296+
// instead of the full url to avoid long filenames
297+
let path_str = if self.external_type == CachedExternalType::Script
298+
&& let Some(at_index) = self.request.find('@')
299+
{
300+
let variable_name = &self.request[..at_index];
301+
variable_name.to_string()
302+
} else {
303+
self.request.to_string()
304+
};
305+
let mut ident = AssetIdent::from_path(externals_fs_root().await?.join(&path_str)?)
296306
.with_layer(Layer::new(rcstr!("external")))
297307
.with_modifier(self.request.clone())
298308
.with_modifier(self.external_type.to_string().into());

0 commit comments

Comments
 (0)