Unverified Commit 2f07579a authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

place virtual module inside the project directory (#58798)

### What?

This virtual module was created in a weird path/filesystem: [node]/.next/server/app/.../page/actions.js. It's in the output filesystem, which can't access the monorepo root, so it can't resolve the tsconfig. But it shouldn't be in that filesystem in first place.


Closes PACK-2025
parent 0155ec70
......@@ -826,6 +826,7 @@ impl AppEndpoint {
let (loader, manifest) = create_server_actions_manifest(
Vc::upcast(app_entry.rsc_entry),
get_app_server_reference_modules(client_reference_types),
this.app_project.project().project_path(),
node_root,
&app_entry.pathname,
&app_entry.original_name,
......@@ -977,6 +978,7 @@ impl AppEndpoint {
let (loader, manifest) = create_server_actions_manifest(
Vc::upcast(app_entry.rsc_entry),
get_app_server_reference_modules(client_reference_types),
this.app_project.project().project_path(),
node_root,
&app_entry.pathname,
&app_entry.original_name,
......
......@@ -45,6 +45,7 @@ use turbopack_binding::{
pub(crate) async fn create_server_actions_manifest(
rsc_entry: Vc<Box<dyn Module>>,
server_reference_modules: Vc<Vec<Vc<Box<dyn Module>>>>,
project_path: Vc<FileSystemPath>,
node_root: Vc<FileSystemPath>,
pathname: &str,
page_name: &str,
......@@ -53,7 +54,8 @@ pub(crate) async fn create_server_actions_manifest(
chunking_context: Vc<Box<dyn EcmascriptChunkingContext>>,
) -> Result<(Vc<Box<dyn EvaluatableAsset>>, Vc<Box<dyn OutputAsset>>)> {
let actions = get_actions(rsc_entry, server_reference_modules, asset_context);
let loader = build_server_actions_loader(node_root, page_name, actions, asset_context).await?;
let loader =
build_server_actions_loader(project_path, page_name, actions, asset_context).await?;
let Some(evaluable) = Vc::try_resolve_sidecast::<Box<dyn EvaluatableAsset>>(loader).await?
else {
bail!("loader module must be evaluatable");
......@@ -75,7 +77,7 @@ pub(crate) async fn create_server_actions_manifest(
/// file's name and the action name). This hash matches the id sent to the
/// client and present inside the paired manifest.
async fn build_server_actions_loader(
node_root: Vc<FileSystemPath>,
project_path: Vc<FileSystemPath>,
page_name: &str,
actions: Vc<AllActions>,
asset_context: Vc<Box<dyn AssetContext>>,
......@@ -100,7 +102,7 @@ async fn build_server_actions_loader(
}
write!(contents, "}});")?;
let output_path = node_root.join(format!("server/app{page_name}/actions.js"));
let output_path = project_path.join(format!(".next-internal/server/app{page_name}/actions.js"));
let file = File::from(contents.build());
let source = VirtualSource::new(output_path, AssetContent::file(file.into()));
let import_map = import_map.into_iter().map(|(k, v)| (v, k)).collect();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment