Unverified Commit b236670f authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Fix entrypoints.get and entrypoints.stream from turbopack (#50733)

## What?

Both `entrypoints.get` and `entrypoints.stream` threw an error because it was using the wrong tasks implementation. @sokra helped fix it.
parent b636d3d7
...@@ -13,7 +13,6 @@ use next_core::app_structure::{ ...@@ -13,7 +13,6 @@ use next_core::app_structure::{
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use turbopack_binding::{ use turbopack_binding::{
turbo::{ turbo::{
tasks,
tasks::{ tasks::{
debug::ValueDebugFormat, primitives::StringsVc, trace::TraceRawVcs, NothingVc, debug::ValueDebugFormat, primitives::StringsVc, trace::TraceRawVcs, NothingVc,
TryJoinIterExt, TurboTasks, ValueToString, TryJoinIterExt, TurboTasks, ValueToString,
...@@ -26,7 +25,7 @@ use turbopack_binding::{ ...@@ -26,7 +25,7 @@ use turbopack_binding::{
use crate::register; use crate::register;
#[tasks::function] #[turbo_tasks::function]
async fn project_fs(project_dir: &str, watching: bool) -> Result<FileSystemVc> { async fn project_fs(project_dir: &str, watching: bool) -> Result<FileSystemVc> {
let disk_fs = let disk_fs =
DiskFileSystemVc::new(PROJECT_FILESYSTEM_NAME.to_string(), project_dir.to_string()); DiskFileSystemVc::new(PROJECT_FILESYSTEM_NAME.to_string(), project_dir.to_string());
...@@ -36,7 +35,7 @@ async fn project_fs(project_dir: &str, watching: bool) -> Result<FileSystemVc> { ...@@ -36,7 +35,7 @@ async fn project_fs(project_dir: &str, watching: bool) -> Result<FileSystemVc> {
Ok(disk_fs.into()) Ok(disk_fs.into())
} }
#[tasks::value] #[turbo_tasks::value]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct LoaderTreeForJs { struct LoaderTreeForJs {
segment: String, segment: String,
...@@ -52,11 +51,11 @@ enum EntrypointForJs { ...@@ -52,11 +51,11 @@ enum EntrypointForJs {
AppRoute { path: String }, AppRoute { path: String },
} }
#[tasks::value(transparent)] #[turbo_tasks::value(transparent)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct EntrypointsForJs(HashMap<String, EntrypointForJs>); struct EntrypointsForJs(HashMap<String, EntrypointForJs>);
#[tasks::value(transparent)] #[turbo_tasks::value(transparent)]
struct OptionEntrypointsForJs(Option<EntrypointsForJsVc>); struct OptionEntrypointsForJs(Option<EntrypointsForJsVc>);
async fn fs_path_to_path(project_path: FileSystemPathVc, path: FileSystemPathVc) -> Result<String> { async fn fs_path_to_path(project_path: FileSystemPathVc, path: FileSystemPathVc) -> Result<String> {
...@@ -197,7 +196,7 @@ async fn prepare_components_for_js( ...@@ -197,7 +196,7 @@ async fn prepare_components_for_js(
Ok(result) Ok(result)
} }
#[tasks::function] #[turbo_tasks::function]
async fn prepare_loader_tree_for_js( async fn prepare_loader_tree_for_js(
project_path: FileSystemPathVc, project_path: FileSystemPathVc,
loader_tree: LoaderTreeVc, loader_tree: LoaderTreeVc,
...@@ -228,7 +227,7 @@ async fn prepare_loader_tree_for_js( ...@@ -228,7 +227,7 @@ async fn prepare_loader_tree_for_js(
.cell()) .cell())
} }
#[tasks::function] #[turbo_tasks::function]
async fn prepare_entrypoints_for_js( async fn prepare_entrypoints_for_js(
project_path: FileSystemPathVc, project_path: FileSystemPathVc,
entrypoints: EntrypointsVc, entrypoints: EntrypointsVc,
...@@ -257,7 +256,7 @@ async fn prepare_entrypoints_for_js( ...@@ -257,7 +256,7 @@ async fn prepare_entrypoints_for_js(
Ok(EntrypointsForJsVc::cell(entrypoints)) Ok(EntrypointsForJsVc::cell(entrypoints))
} }
#[tasks::function] #[turbo_tasks::function]
async fn get_value( async fn get_value(
root_dir: &str, root_dir: &str,
project_dir: &str, project_dir: &str,
...@@ -306,10 +305,12 @@ pub fn stream_entrypoints( ...@@ -306,10 +305,12 @@ pub fn stream_entrypoints(
let project_dir = Arc::new(project_dir); let project_dir = Arc::new(project_dir);
let page_extensions = Arc::new(page_extensions); let page_extensions = Arc::new(page_extensions);
turbo_tasks.spawn_root_task(move || { turbo_tasks.spawn_root_task(move || {
let func = func.clone(); let func: ThreadsafeFunction<
Option<turbo_tasks::ReadRef<EntrypointsForJs, HashMap<String, EntrypointForJs>>>,
> = func.clone();
let project_dir = project_dir.clone(); let project_dir = project_dir.clone();
let root_dir = root_dir.clone(); let root_dir = root_dir.clone();
let page_extensions = page_extensions.clone(); let page_extensions: Arc<Vec<String>> = page_extensions.clone();
Box::pin(async move { Box::pin(async move {
if let Some(entrypoints) = &*get_value( if let Some(entrypoints) = &*get_value(
&root_dir, &root_dir,
......
...@@ -571,13 +571,15 @@ function loadNative(isCustomTurbopack = false) { ...@@ -571,13 +571,15 @@ function loadNative(isCustomTurbopack = false) {
turboTasks: any, turboTasks: any,
rootDir: string, rootDir: string,
applicationDir: string, applicationDir: string,
pageExtensions: string[] pageExtensions: string[],
fn: (entrypoints: any) => void
) => { ) => {
return bindings.streamEntrypoints( return bindings.streamEntrypoints(
turboTasks, turboTasks,
rootDir, rootDir,
applicationDir, applicationDir,
pageExtensions pageExtensions,
fn
) )
}, },
get: ( get: (
......
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