Skip to content

Commit

Permalink
Split turbopack-node from next-core (#2874)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Dec 1, 2022
1 parent a21e8da commit ded3566
Show file tree
Hide file tree
Showing 20 changed files with 96 additions and 37 deletions.
31 changes: 24 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ members = [
"crates/turbopack-dev-server",
"crates/turbopack-ecmascript",
"crates/turbopack-env",
"crates/turbopack-node",
"crates/turbopack-json",
"crates/turbopack-static",
"crates/turbopack-swc-utils",
Expand Down
8 changes: 1 addition & 7 deletions crates/next-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@ bench = false

[dependencies]
anyhow = "1.0.47"
futures = "0.3.21"
indexmap = { workspace = true, features = ["serde"] }
mime = "0.3.16"
rand = "0.8.5"
regex = "1.6.0"
serde = "1.0.136"
serde_json = "1.0.85"
serde_qs = "0.10.1"
sourcemap = "6.0.1"
tokio = { version = "1.21.2", features = ["full"] }
turbo-tasks = { path = "../turbo-tasks" }
turbo-tasks-env = { path = "../turbo-tasks-env" }
Expand All @@ -29,7 +23,7 @@ turbopack-core = { path = "../turbopack-core" }
turbopack-dev-server = { path = "../turbopack-dev-server" }
turbopack-ecmascript = { path = "../turbopack-ecmascript" }
turbopack-env = { path = "../turbopack-env" }
url = "2.2.2"
turbopack-node = { path = "../turbopack-node" }

[build-dependencies]
turbo-tasks-build = { path = "../turbo-tasks-build" }
10 changes: 5 additions & 5 deletions crates/next-core/src/app_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ use turbopack_ecmascript::{
EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc,
};
use turbopack_env::ProcessEnvAssetVc;
use turbopack_node::{
create_node_rendered_source,
node_entry::{NodeRenderingEntry, NodeRenderingEntryVc},
NodeEntry, NodeEntryVc,
};

use crate::{
app_render::{
Expand All @@ -60,11 +65,6 @@ use crate::{
get_server_environment, get_server_module_options_context,
get_server_resolve_options_context, ServerContextType,
},
nodejs::{
create_node_rendered_source,
node_entry::{NodeRenderingEntry, NodeRenderingEntryVc},
NodeEntry, NodeEntryVc,
},
util::regular_expression_for_path,
};

Expand Down
5 changes: 2 additions & 3 deletions crates/next-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ pub mod next_client;
mod next_client_component;
mod next_import_map;
pub mod next_server;
mod nodejs;
mod path_regex;
pub mod react_refresh;
mod runtime;
mod server_rendered_source;
pub mod source_map;
mod util;
mod web_entry_source;

pub use app_source::create_app_source;
pub use server_rendered_source::create_server_rendered_source;
pub use turbopack_node::source_map;
pub use web_entry_source::create_web_entry_source;

pub fn register() {
turbo_tasks::register();
turbo_tasks_fs::register();
turbopack_dev_server::register();
turbopack::register();
turbopack_node::register();
include!(concat!(env!("OUT_DIR"), "/register.rs"));
}
10 changes: 5 additions & 5 deletions crates/next-core/src/server_rendered_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ use turbopack_ecmascript::{
EcmascriptModuleAssetType, EcmascriptModuleAssetVc,
};
use turbopack_env::ProcessEnvAssetVc;
use turbopack_node::{
create_node_api_source, create_node_rendered_source,
node_entry::{NodeRenderingEntry, NodeRenderingEntryVc},
NodeEntry, NodeEntryVc,
};

use crate::{
embed_js::{next_js_file, wrap_with_next_js_fs},
Expand All @@ -45,11 +50,6 @@ use crate::{
get_server_environment, get_server_module_options_context,
get_server_resolve_options_context, ServerContextType,
},
nodejs::{
create_node_api_source, create_node_rendered_source,
node_entry::{NodeRenderingEntry, NodeRenderingEntryVc},
NodeEntry, NodeEntryVc,
},
util::regular_expression_for_path,
};

Expand Down
3 changes: 1 addition & 2 deletions crates/next-core/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use anyhow::{anyhow, bail, Result};
use turbo_tasks::ValueToString;
use turbo_tasks_fs::FileSystemPathVc;

use crate::path_regex::{PathRegexBuilder, PathRegexVc};
use turbopack_node::path_regex::{PathRegexBuilder, PathRegexVc};

/// Converts a filename within the server root to a regular expression with
/// named capture groups for every dynamic segment.
Expand Down
31 changes: 31 additions & 0 deletions crates/turbopack-node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "turbopack-node"
version = "0.1.0"
description = "TBD"
license = "MPL-2.0"
edition = "2021"
autobenches = false

[lib]
bench = false

[dependencies]
anyhow = "1.0.47"
futures = "0.3.21"
indexmap = { workspace = true, features = ["serde"] }
mime = "0.3.16"
regex = "1.6.0"
serde = "1.0.136"
serde_json = "1.0.85"
serde_qs = "0.10.1"
tokio = { version = "1.21.2", features = ["full"] }
turbo-tasks = { path = "../turbo-tasks" }
turbo-tasks-fs = { path = "../turbo-tasks-fs" }
turbopack = { path = "../turbopack" }
turbopack-core = { path = "../turbopack-core" }
turbopack-dev-server = { path = "../turbopack-dev-server" }
turbopack-ecmascript = { path = "../turbopack-ecmascript" }
url = "2.2.2"

[build-dependencies]
turbo-tasks-build = { path = "../turbo-tasks-build" }
5 changes: 5 additions & 0 deletions crates/turbopack-node/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use turbo_tasks_build::generate_register;

fn main() {
generate_register();
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![feature(async_closure)]
#![feature(min_specialization)]

use std::{
collections::{BTreeMap, HashMap, HashSet},
fmt::Write as _,
Expand Down Expand Up @@ -33,12 +36,14 @@ use self::{
};
use crate::source_map::{SourceMapTraceVc, StackFrame, TraceResult};

pub(crate) mod bootstrap;
pub(crate) mod issue;
pub(crate) mod node_api_source;
pub(crate) mod node_entry;
pub(crate) mod node_rendered_source;
pub(crate) mod pool;
pub mod bootstrap;
pub mod issue;
pub mod node_api_source;
pub mod node_entry;
pub mod node_rendered_source;
pub mod path_regex;
pub mod pool;
pub mod source_map;

#[turbo_tasks::function]
async fn emit(
Expand Down Expand Up @@ -229,7 +234,7 @@ pub async fn get_intermediate_asset(
}

#[turbo_tasks::value(shared)]
pub(super) struct RenderData {
pub struct RenderData {
params: IndexMap<String, String>,
method: String,
url: String,
Expand Down Expand Up @@ -451,7 +456,7 @@ async fn trace_stack(
}

#[turbo_tasks::value(shared)]
pub(super) struct ResponseHeaders {
pub struct ResponseHeaders {
status: u16,
headers: Vec<String>,
}
Expand Down Expand Up @@ -614,3 +619,11 @@ async fn proxy_error(
}
.cell())
}

pub fn register() {
turbo_tasks::register();
turbo_tasks_fs::register();
turbopack_dev_server::register();
turbopack::register();
include!(concat!(env!("OUT_DIR"), "/register.rs"));
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ded3566

Please sign in to comment.