Skip to content

Commit

Permalink
Merge branch 'canary' into 10-02-enable_source_maps_bundled
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Oct 2, 2023
2 parents b500f19 + 033e8a5 commit 6ec6c42
Show file tree
Hide file tree
Showing 30 changed files with 170 additions and 78 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.5.4-canary.8"
"version": "13.5.4-canary.9"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
},
"homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "13.5.4-canary.8",
"@next/eslint-plugin-next": "13.5.4-canary.9",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
27 changes: 23 additions & 4 deletions packages/next-swc/crates/napi/src/next_api/endpoint.rs
@@ -1,7 +1,10 @@
use std::ops::Deref;

use napi::{bindgen_prelude::External, JsFunction};
use next_api::route::{Endpoint, WrittenEndpoint};
use next_api::{
route::{Endpoint, WrittenEndpoint},
server_paths::ServerPath,
};
use turbo_tasks::Vc;
use turbopack_binding::turbopack::core::error::PrettyPrintError;

Expand All @@ -14,12 +17,28 @@ use super::utils::{
#[derive(Default)]
pub struct NapiEndpointConfig {}

#[napi(object)]
#[derive(Default)]
pub struct NapiServerPath {
pub path: String,
pub content_hash: String,
}

impl From<&ServerPath> for NapiServerPath {
fn from(server_path: &ServerPath) -> Self {
Self {
path: server_path.path.clone(),
content_hash: format!("{:x}", server_path.content_hash),
}
}
}

#[napi(object)]
#[derive(Default)]
pub struct NapiWrittenEndpoint {
pub r#type: String,
pub entry_path: Option<String>,
pub server_paths: Option<Vec<String>>,
pub server_paths: Option<Vec<NapiServerPath>>,
pub files: Option<Vec<String>>,
pub global_var_name: Option<String>,
pub config: NapiEndpointConfig,
Expand All @@ -34,7 +53,7 @@ impl From<&WrittenEndpoint> for NapiWrittenEndpoint {
} => Self {
r#type: "nodejs".to_string(),
entry_path: Some(server_entry_path.clone()),
server_paths: Some(server_paths.clone()),
server_paths: Some(server_paths.iter().map(From::from).collect()),
..Default::default()
},
WrittenEndpoint::Edge {
Expand All @@ -44,7 +63,7 @@ impl From<&WrittenEndpoint> for NapiWrittenEndpoint {
} => Self {
r#type: "edge".to_string(),
files: Some(files.clone()),
server_paths: Some(server_paths.clone()),
server_paths: Some(server_paths.iter().map(From::from).collect()),
global_var_name: Some(global_var_name.clone()),
..Default::default()
},
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/next-api/src/app.rs
@@ -1,6 +1,5 @@
use anyhow::{bail, Context, Result};
use next_core::{
all_server_paths,
app_structure::{
get_entrypoints, Entrypoint as AppEntrypoint, Entrypoints as AppEntrypoints, LoaderTree,
MetadataItem,
Expand Down Expand Up @@ -55,6 +54,7 @@ use turbopack_binding::{
use crate::{
project::Project,
route::{Endpoint, Route, Routes, WrittenEndpoint},
server_paths::all_server_paths,
};

#[turbo_tasks::value]
Expand Down
1 change: 1 addition & 0 deletions packages/next-swc/crates/next-api/src/lib.rs
Expand Up @@ -8,6 +8,7 @@ mod middleware;
mod pages;
pub mod project;
pub mod route;
pub mod server_paths;
mod versioned_content_map;

// Declare build-time information variables generated in build.rs
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/next-api/src/middleware.rs
@@ -1,6 +1,5 @@
use anyhow::{bail, Context, Result};
use next_core::{
all_server_paths,
middleware::get_middleware_module,
mode::NextMode,
next_edge::entry::wrap_edge_entry,
Expand All @@ -27,6 +26,7 @@ use turbopack_binding::{
use crate::{
project::Project,
route::{Endpoint, WrittenEndpoint},
server_paths::all_server_paths,
};

#[turbo_tasks::value]
Expand Down
3 changes: 2 additions & 1 deletion packages/next-swc/crates/next-api/src/pages.rs
@@ -1,7 +1,7 @@
use anyhow::{bail, Context, Result};
use indexmap::IndexMap;
use next_core::{
all_server_paths, create_page_loader_entry_module, get_asset_path_from_pathname,
create_page_loader_entry_module, get_asset_path_from_pathname,
get_edge_resolve_options_context,
mode::NextMode,
next_client::{
Expand Down Expand Up @@ -64,6 +64,7 @@ use turbopack_binding::{
use crate::{
project::Project,
route::{Endpoint, Route, Routes, WrittenEndpoint},
server_paths::all_server_paths,
};

#[turbo_tasks::value]
Expand Down
8 changes: 4 additions & 4 deletions packages/next-swc/crates/next-api/src/route.rs
@@ -1,6 +1,8 @@
use indexmap::IndexMap;
use turbo_tasks::{Completion, Vc};

use crate::server_paths::ServerPath;

#[turbo_tasks::value(shared)]
#[derive(Copy, Clone, Debug)]
pub enum Route {
Expand Down Expand Up @@ -34,15 +36,13 @@ pub enum WrittenEndpoint {
NodeJs {
/// Relative to the root_path
server_entry_path: String,
/// Relative to the root_path
server_paths: Vec<String>,
server_paths: Vec<ServerPath>,
},
Edge {
/// Relative to the root_path
files: Vec<String>,
global_var_name: String,
/// Relative to the root_path
server_paths: Vec<String>,
server_paths: Vec<ServerPath>,
},
}

Expand Down
57 changes: 57 additions & 0 deletions packages/next-swc/crates/next-api/src/server_paths.rs
@@ -0,0 +1,57 @@
use anyhow::Result;
use next_core::all_assets_from_entries;
use serde::{Deserialize, Serialize};
use turbo_tasks::{trace::TraceRawVcs, TryFlatJoinIterExt, Vc};
use turbopack_binding::{
turbo::tasks_fs::FileSystemPath,
turbopack::core::{
asset::{Asset, AssetContent},
output::{OutputAsset, OutputAssets},
},
};

/// A reference to a server file with content hash for change detection
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TraceRawVcs)]
pub struct ServerPath {
/// Relative to the root_path
pub path: String,
pub content_hash: u64,
}

/// A list of server paths
#[turbo_tasks::value(transparent)]
pub struct ServerPaths(Vec<ServerPath>);

/// Return a list of all server paths with filename and hash for all output
/// assets references from the `assets` list. Server paths are identified by
/// being inside of `node_root`.
#[turbo_tasks::function]
pub async fn all_server_paths(
assets: Vc<OutputAssets>,
node_root: Vc<FileSystemPath>,
) -> Result<Vc<ServerPaths>> {
let all_assets = all_assets_from_entries(assets).await?;
let node_root = &node_root.await?;
Ok(Vc::cell(
all_assets
.iter()
.map(|&asset| async move {
Ok(
if let Some(path) = node_root.get_path_to(&*asset.ident().path().await?) {
let content_hash = match *asset.content().await? {
AssetContent::File(file) => *file.hash().await?,
AssetContent::Redirect { .. } => 0,
};
Some(ServerPath {
path: path.to_string(),
content_hash,
})
} else {
None
},
)
})
.try_flat_join()
.await?,
))
}
25 changes: 1 addition & 24 deletions packages/next-swc/crates/next-core/src/emit.rs
@@ -1,37 +1,14 @@
use anyhow::Result;
use turbo_tasks::{
graph::{AdjacencyMap, GraphTraversal},
Completion, Completions, TryFlatJoinIterExt, TryJoinIterExt, Vc,
Completion, Completions, TryFlatJoinIterExt, Vc,
};
use turbo_tasks_fs::{rebase, FileSystemPath};
use turbopack_binding::turbopack::core::{
asset::Asset,
output::{OutputAsset, OutputAssets},
};

#[turbo_tasks::function]
pub async fn all_server_paths(
assets: Vc<OutputAssets>,
node_root: Vc<FileSystemPath>,
) -> Result<Vc<Vec<String>>> {
let all_assets = all_assets_from_entries(assets).await?;
let node_root = &node_root.await?;
Ok(Vc::cell(
all_assets
.iter()
.map(|&asset| async move {
Ok(node_root
.get_path_to(&*asset.ident().path().await?)
.map(|s| s.to_string()))
})
.try_join()
.await?
.into_iter()
.flatten()
.collect(),
))
}

/// Emits all assets transitively reachable from the given chunks, that are
/// inside the node root or the client root.
///
Expand Down
4 changes: 1 addition & 3 deletions packages/next-swc/crates/next-core/src/lib.rs
Expand Up @@ -46,9 +46,7 @@ pub mod util;
pub use app_segment_config::{
parse_segment_config_from_loader_tree, parse_segment_config_from_source,
};
pub use emit::{
all_assets_from_entries, all_server_paths, emit_all_assets, emit_assets, emit_client_assets,
};
pub use emit::{all_assets_from_entries, emit_all_assets, emit_assets, emit_client_assets};
pub use next_edge::context::{
get_edge_chunking_context, get_edge_compile_time_info, get_edge_resolve_options_context,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "13.5.4-canary.8",
"version": "13.5.4-canary.9",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -90,7 +90,7 @@
]
},
"dependencies": {
"@next/env": "13.5.4-canary.8",
"@next/env": "13.5.4-canary.9",
"@swc/helpers": "0.5.2",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
Expand Down Expand Up @@ -144,11 +144,11 @@
"@mswjs/interceptors": "0.23.0",
"@napi-rs/cli": "2.16.2",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.5.4-canary.8",
"@next/polyfill-nomodule": "13.5.4-canary.8",
"@next/react-dev-overlay": "13.5.4-canary.8",
"@next/react-refresh-utils": "13.5.4-canary.8",
"@next/swc": "13.5.4-canary.8",
"@next/polyfill-module": "13.5.4-canary.9",
"@next/polyfill-nomodule": "13.5.4-canary.9",
"@next/react-dev-overlay": "13.5.4-canary.9",
"@next/react-refresh-utils": "13.5.4-canary.9",
"@next/swc": "13.5.4-canary.9",
"@opentelemetry/api": "1.4.1",
"@playwright/test": "^1.35.1",
"@segment/ajv-human-errors": "2.1.2",
Expand Down

0 comments on commit 6ec6c42

Please sign in to comment.