Skip to content

Commit

Permalink
Merge branch 'canary' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Sep 18, 2023
2 parents 32a337d + ff36684 commit dd2ada1
Show file tree
Hide file tree
Showing 57 changed files with 875 additions and 598 deletions.
681 changes: 336 additions & 345 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ swc_core = { version = "0.83.12", features = [
testing = { version = "0.34.1" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230915.2" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230917.1" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230915.2" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230917.1" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230915.2" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230917.1" }

# General Deps

Expand Down Expand Up @@ -93,7 +93,7 @@ dialoguer = "0.10.3"
dunce = "1.0.3"
futures = "0.3.26"
futures-retry = "0.6.0"
httpmock = { version = "0.6.7", default-features = false }
httpmock = { version = "0.6.8", default-features = false }
indexmap = "1.9.2"
indicatif = "0.17.3"
indoc = "2.0.0"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.4.20-canary.35"
"version": "13.4.20-canary.36"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"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.4.20-canary.35",
"@next/eslint-plugin-next": "13.4.20-canary.36",
"@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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
7 changes: 4 additions & 3 deletions packages/next-swc/crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ use turbopack_binding::swc::{
SyntaxContext,
},
ecma::{
ast::EsVersion, parser::parse_file_as_module, transforms::base::pass::noop, visit::Fold,
ast::EsVersion, atoms::JsWord, parser::parse_file_as_module,
transforms::base::pass::noop, visit::Fold,
},
},
custom_transform::modularize_imports,
Expand Down Expand Up @@ -97,7 +98,7 @@ pub struct TransformOptions {
pub is_server: bool,

#[serde(default)]
pub disable_checks: bool,
pub bundle_target: JsWord,

#[serde(default)]
pub server_components: Option<react_server_components::Config>,
Expand Down Expand Up @@ -198,7 +199,7 @@ where
config.clone(),
comments.clone(),
opts.app_dir.clone(),
opts.disable_checks
opts.bundle_target.clone()
)),
_ => Either::Right(noop()),
},
Expand Down
38 changes: 20 additions & 18 deletions packages/next-swc/crates/core/src/react_server_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct ReactServerComponents<C: Comments> {
invalid_client_imports: Vec<JsWord>,
invalid_server_react_apis: Vec<JsWord>,
invalid_server_react_dom_apis: Vec<JsWord>,
disable_checks: bool,
bundle_target: String,
}

struct ModuleImports {
Expand All @@ -67,15 +67,25 @@ impl<C: Comments> VisitMut for ReactServerComponents<C> {
let is_cjs = contains_cjs(module);

if self.is_server {
if !is_client_entry {
self.assert_server_graph(&imports, module);
} else {
if is_client_entry {
self.to_module_ref(module, is_cjs);
return;
} else if self.bundle_target == "server" {
// Only assert server graph if file's bundle target is "server", e.g.
// * server components pages
// * pages bundles on SSR layer
// * middleware
// * app/pages api routes
self.assert_server_graph(&imports, module);
}
} else {
if !is_action_file {
self.assert_client_graph(&imports, module);
// Only assert client graph if the file is not an action file,
// and bundle target is "client" e.g.
// * client components pages
// * pages bundles on browser layer
if !is_action_file && self.bundle_target == "client" {
self.assert_client_graph(&imports);
self.assert_invalid_api(module, true);
}
if is_client_entry {
self.prepend_comment_node(module, is_cjs);
Expand Down Expand Up @@ -129,7 +139,7 @@ impl<C: Comments> ReactServerComponents<C> {
if is_action_file {
panic_both_directives(expr_stmt.span)
}
} else if !self.disable_checks {
} else if self.bundle_target != "default" {
HANDLER.with(|handler| {
handler
.struct_span_err(
Expand Down Expand Up @@ -334,9 +344,6 @@ impl<C: Comments> ReactServerComponents<C> {
}

fn assert_server_graph(&self, imports: &[ModuleImports], module: &Module) {
if self.disable_checks {
return;
}
for import in imports {
let source = import.source.0.clone();
if self.invalid_server_imports.contains(&source) {
Expand Down Expand Up @@ -408,10 +415,7 @@ impl<C: Comments> ReactServerComponents<C> {
}
}

fn assert_client_graph(&self, imports: &[ModuleImports], module: &Module) {
if self.disable_checks {
return;
}
fn assert_client_graph(&self, imports: &[ModuleImports]) {
for import in imports {
let source = import.source.0.clone();
if self.invalid_client_imports.contains(&source) {
Expand All @@ -425,8 +429,6 @@ impl<C: Comments> ReactServerComponents<C> {
})
}
}

self.assert_invalid_api(module, true);
}

fn assert_invalid_api(&self, module: &Module, is_client_entry: bool) {
Expand Down Expand Up @@ -567,17 +569,17 @@ pub fn server_components<C: Comments>(
config: Config,
comments: C,
app_dir: Option<PathBuf>,
disable_checks: bool,
bundle_target: JsWord,
) -> impl Fold + VisitMut {
let is_server: bool = match &config {
Config::WithOptions(x) => x.is_server,
_ => true,
};
as_folder(ReactServerComponents {
disable_checks,
is_server,
comments,
filepath: filename.to_string(),
bundle_target: bundle_target.to_string(),
app_dir,
export_names: vec![],
invalid_server_imports: vec![
Expand Down
8 changes: 4 additions & 4 deletions packages/next-swc/crates/core/tests/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn react_server_components_server_graph_errors(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
false,
String::from("server").into(),
)
},
&input,
Expand All @@ -122,7 +122,7 @@ fn react_server_components_client_graph_errors(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
false,
String::from("client").into(),
)
},
&input,
Expand Down Expand Up @@ -169,7 +169,7 @@ fn react_server_actions_server_errors(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
false
String::from("default").into(),
),
server_actions(
&FileName::Real("/app/item.js".into()),
Expand Down Expand Up @@ -205,7 +205,7 @@ fn react_server_actions_client_errors(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
false
String::from("client").into(),
),
server_actions(
&FileName::Real("/app/item.js".into()),
Expand Down
8 changes: 4 additions & 4 deletions packages/next-swc/crates/core/tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ fn react_server_components_server_graph_fixture(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
false,
String::from("default").into(),
)
},
&input,
Expand All @@ -348,7 +348,7 @@ fn react_server_components_no_checks_server_graph_fixture(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
true,
String::from("default").into(),
)
},
&input,
Expand All @@ -370,7 +370,7 @@ fn react_server_components_client_graph_fixture(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
false,
String::from("default").into(),
)
},
&input,
Expand All @@ -392,7 +392,7 @@ fn react_server_components_no_checks_client_graph_fixture(input: PathBuf) {
),
tr.comments.as_ref().clone(),
None,
true,
String::from("default").into(),
)
},
&input,
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/core/tests/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn test(input: &Path, minify: bool) {
auto_modularize_imports: None,
optimize_barrel_exports: None,
optimize_server_react: None,
disable_checks: false,
bundle_target: String::from("default").into(),
};

let unresolved_mark = Mark::new();
Expand Down
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-core/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"check": "tsc --noEmit"
},
"dependencies": {
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230915.2",
"@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230915.2",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230917.1",
"@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230917.1",
"anser": "^2.1.1",
"css.escape": "^1.5.1",
"next": "*",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
16 changes: 8 additions & 8 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "13.4.20-canary.35",
"version": "13.4.20-canary.36",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -90,7 +90,7 @@
]
},
"dependencies": {
"@next/env": "13.4.20-canary.35",
"@next/env": "13.4.20-canary.36",
"@swc/helpers": "0.5.2",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
Expand Down Expand Up @@ -145,11 +145,11 @@
"@mswjs/interceptors": "0.23.0",
"@napi-rs/cli": "2.16.2",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.4.20-canary.35",
"@next/polyfill-nomodule": "13.4.20-canary.35",
"@next/react-dev-overlay": "13.4.20-canary.35",
"@next/react-refresh-utils": "13.4.20-canary.35",
"@next/swc": "13.4.20-canary.35",
"@next/polyfill-module": "13.4.20-canary.36",
"@next/polyfill-nomodule": "13.4.20-canary.36",
"@next/react-dev-overlay": "13.4.20-canary.36",
"@next/react-refresh-utils": "13.4.20-canary.36",
"@next/swc": "13.4.20-canary.36",
"@opentelemetry/api": "1.4.1",
"@playwright/test": "^1.35.1",
"@segment/ajv-human-errors": "2.1.2",
Expand Down Expand Up @@ -193,7 +193,7 @@
"@types/ws": "8.2.0",
"@vercel/ncc": "0.34.0",
"@vercel/nft": "0.22.6",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230915.2",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-230917.1",
"acorn": "8.5.0",
"ajv": "8.11.0",
"amphtml-validator": "1.0.35",
Expand Down
Loading

0 comments on commit dd2ada1

Please sign in to comment.