Skip to content

Commit

Permalink
fix layout segment key to match up with manifest (#60783)
Browse files Browse the repository at this point in the history
### What?

When webpack loaders are applied on a page file and it's renamed with
the `as` key, layout segment key no longer matches. This fixes that

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes PACK-2251
  • Loading branch information
sokra authored Jan 17, 2024
1 parent 72e381c commit 861b472
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/next-swc/crates/next-core/src/loader_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ impl LoaderTreeBuilder {
let i = self.unique_number();
let identifier = magic_identifier::mangle(&format!("{name} #{i}"));

let source = Vc::upcast(FileSource::new(component));
let reference_ty = Value::new(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::Undefined,
));
let module = self
.server_component_transition
.process(source, self.context, reference_ty)
.module();

match self.mode {
NextMode::Development => {
let chunks_identifier =
Expand All @@ -131,7 +140,7 @@ impl LoaderTreeBuilder {
self.loader_tree_code,
" {name}: [() => {identifier}, {path}],",
name = StringifyJs(name),
path = StringifyJs(&component.to_string().await?)
path = StringifyJs(&module.ident().path().to_string().await?)
)?;

self.imports.push(formatdoc!(
Expand All @@ -144,16 +153,6 @@ impl LoaderTreeBuilder {
}
}

let source = Vc::upcast(FileSource::new(component));
let reference_ty = Value::new(ReferenceType::EcmaScriptModules(
EcmaScriptModulesReferenceSubType::Undefined,
));

let module = self
.server_component_transition
.process(source, self.context, reference_ty)
.module();

self.inner_assets.insert(format!("COMPONENT_{i}"), module);
}
Ok(())
Expand Down

0 comments on commit 861b472

Please sign in to comment.