Skip to content

Commit

Permalink
refactor(next-core): apply correct url rewrite behavior (#58237)
Browse files Browse the repository at this point in the history
### What

Apply correct url rewrite behavior in the specific context (pages/api). 

This won't change anything yet, but it will prevent breaking changes when turbopack makes future changes.
  • Loading branch information
kwonoj authored Nov 9, 2023
1 parent bbb730e commit 51fec99
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/next-swc/crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use turbopack_binding::{
free_var_references,
resolve::{parse::Request, pattern::Pattern},
},
ecmascript::TransformPlugin,
ecmascript::{references::esm::UrlRewriteBehavior, TransformPlugin},
ecmascript_plugin::transform::directives::client::ClientDirectiveTransformer,
node::execution_context::ExecutionContext,
turbopack::{
Expand Down Expand Up @@ -351,8 +351,18 @@ pub async fn get_server_module_options_context(
},
));

let url_rewrite_behavior = Some(
//https://github.com/vercel/next.js/blob/bbb730e5ef10115ed76434f250379f6f53efe998/packages/next/src/build/webpack-config.ts#L1384
if let ServerContextType::PagesApi { .. } = ty.into_value() {
UrlRewriteBehavior::Full
} else {
UrlRewriteBehavior::Relative
},
);

let module_options_context = ModuleOptionsContext {
execution_context: Some(execution_context),
esm_url_rewrite_behavior: url_rewrite_behavior,
..Default::default()
};

Expand Down

0 comments on commit 51fec99

Please sign in to comment.