Skip to content

Commit

Permalink
Merge branch 'canary' into shu/c8eb
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding authored Oct 24, 2023
2 parents d995197 + 8734a03 commit 339f5f2
Show file tree
Hide file tree
Showing 53 changed files with 754 additions and 328 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ jobs:
name: stable - ${{ matrix.settings.target }} - node@16
runs-on: ${{ matrix.settings.host }}
timeout-minutes: 45
timeout-minutes: 30
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ on:
required: false
description: 'whether to skip building native modules'
type: string
uploadAnalyzerArtifacts:
required: false
description: 'whether to upload analyzer artifacts'
type: string
skipForDocsOnly:
required: false
description: 'skip for docs only changes'
Expand Down Expand Up @@ -166,7 +170,7 @@ jobs:
- run: pnpm install
if: ${{ inputs.skipInstallBuild != 'yes' }}

- run: pnpm build
- run: ANALYZE=1 pnpm build
if: ${{ inputs.skipInstallBuild != 'yes' }}

- run: pnpm playwright install-deps
Expand All @@ -186,6 +190,13 @@ jobs:
name: turbo run summary
path: .turbo/runs

- name: Upload bundle analyzer artifacts
uses: actions/upload-artifact@v3
if: ${{ inputs.uploadAnalyzerArtifacts == 'yes' }}
with:
name: webpack bundle analysis stats
path: packages/next/dist/compiled/next-server/report.*.html

- name: Upload test reports artifact
uses: actions/upload-artifact@v3
if: ${{ inputs.afterBuild }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
secrets: inherit
with:
uploadSwcArtifact: 'yes'
uploadAnalyzerArtifacts: 'yes'

stats:
name: PR Stats
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.5.7-canary.21"
"version": "13.5.7-canary.23"
}
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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.7-canary.21",
"@next/eslint-plugin-next": "13.5.7-canary.23",
"@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.5.7-canary.21",
"version": "13.5.7-canary.23",
"description": "ESLint plugin for Next.js.",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"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.5.7-canary.21",
"version": "13.5.7-canary.23",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/next-swc/crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ where
};

chain!(
pure::pure_magic(comments.clone()),
disallow_re_export_all_in_page::disallow_re_export_all_in_page(opts.is_page_file),
match &opts.server_components {
Some(config) if config.truthy() =>
Expand Down Expand Up @@ -313,7 +312,7 @@ where
Some(config) => Either::Left(server_actions::server_actions(
&file.name,
config.clone(),
comments,
comments.clone(),
)),
None => Either::Right(noop()),
},
Expand All @@ -323,6 +322,7 @@ where
},
None => Either::Right(noop()),
},
pure::pure_magic(comments),
)
}

Expand Down
11 changes: 8 additions & 3 deletions packages/next-swc/crates/core/src/pure.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use turbopack_binding::swc::core::{
common::{comments::Comments, errors::HANDLER, util::take::Take, Spanned, DUMMY_SP},
common::{comments::Comments, errors::HANDLER, util::take::Take, Span, Spanned, DUMMY_SP},
ecma::{
ast::{CallExpr, Callee, EmptyStmt, Expr, Module, ModuleDecl, ModuleItem, Stmt},
visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith},
Expand All @@ -8,7 +8,7 @@ use turbopack_binding::swc::core::{

use crate::import_analyzer::ImportMap;

pub fn pure_magic<C>(comments: C) -> impl VisitMut + Fold
pub fn pure_magic<C>(comments: C) -> impl Fold
where
C: Comments,
{
Expand Down Expand Up @@ -58,7 +58,12 @@ where

*e = *args[0].expr.take();

self.comments.add_pure_comment(e.span().lo);
let mut lo = e.span().lo;
if lo.is_dummy() {
lo = Span::dummy_with_cmt().lo;
}

self.comments.add_pure_comment(lo);
}
}

Expand Down
8 changes: 0 additions & 8 deletions packages/next-swc/crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,6 @@ impl AppEndpoint {
NextRuntime::Edge,
Vc::upcast(this.app_project.edge_rsc_module_context()),
Vc::upcast(chunking_context),
this.app_project
.project()
.next_config()
.enable_server_actions(),
)
.await?;
server_assets.push(manifest);
Expand Down Expand Up @@ -984,10 +980,6 @@ impl AppEndpoint {
NextRuntime::NodeJs,
Vc::upcast(this.app_project.rsc_module_context()),
Vc::upcast(this.app_project.project().server_chunking_context()),
this.app_project
.project()
.next_config()
.enable_server_actions(),
)
.await?;
server_assets.push(manifest);
Expand Down
17 changes: 0 additions & 17 deletions packages/next-swc/crates/next-api/src/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,10 @@ pub(crate) async fn create_server_actions_manifest(
runtime: NextRuntime,
asset_context: Vc<Box<dyn AssetContext>>,
chunking_context: Vc<Box<dyn EcmascriptChunkingContext>>,
enable_server_actions: Vc<bool>,
) -> Result<(
Option<Vc<Box<dyn EvaluatableAsset>>>,
Vc<Box<dyn OutputAsset>>,
)> {
// If actions aren't enabled, then there's no need to scan the module graph. We
// still need to generate an empty manifest so that the TS side can merge
// the manifest later on.
if !*enable_server_actions.await? {
let manifest = build_manifest(
node_root,
pathname,
page_name,
runtime,
ModuleActionMap::empty(),
Default::default(),
)
.await?;
return Ok((None, manifest));
}

let actions = get_actions(Vc::upcast(entry));
let loader = build_server_actions_loader(node_root, page_name, actions, asset_context).await?;
let Some(evaluable) = Vc::try_resolve_sidecast::<Box<dyn EvaluatableAsset>>(loader).await?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub async fn get_next_client_transforms_rules(
let mut rules = vec![];

let modularize_imports_config = &next_config.await?.modularize_imports;
let enable_server_actions = *next_config.enable_server_actions().await?;
if let Some(modularize_imports_config) = modularize_imports_config {
rules.push(get_next_modularize_imports_rule(modularize_imports_config));
}
Expand All @@ -39,9 +38,7 @@ pub async fn get_next_client_transforms_rules(
Some(pages_dir)
}
ClientContextType::App { .. } => {
if enable_server_actions {
rules.push(get_server_actions_transform_rule(ActionsTransform::Client));
}
rules.push(get_server_actions_transform_rule(ActionsTransform::Client));
None
}
ClientContextType::Fallback | ClientContextType::Other => None,
Expand Down
10 changes: 4 additions & 6 deletions packages/next-swc/crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,15 +743,13 @@ impl NextConfig {
}

#[turbo_tasks::function]
pub async fn enable_server_actions(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(
self.await?.experimental.server_actions.unwrap_or(false),
))
pub async fn enable_ppr(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(self.await?.experimental.ppr.unwrap_or(false)))
}

#[turbo_tasks::function]
pub async fn enable_ppr(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(self.await?.experimental.ppr.unwrap_or(false)))
pub async fn enable_taint(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(self.await?.experimental.taint.unwrap_or(false)))
}
}

Expand Down
21 changes: 8 additions & 13 deletions packages/next-swc/crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ pub async fn get_next_client_import_map(
);
}
ClientContextType::App { app_dir } => {
let react_flavor = if *next_config.enable_server_actions().await?
|| *next_config.enable_ppr().await?
{
"-experimental"
} else {
""
};
let react_flavor =
if *next_config.enable_ppr().await? || *next_config.enable_taint().await? {
"-experimental"
} else {
""
};

import_map.insert_exact_alias(
"react",
Expand Down Expand Up @@ -644,13 +643,9 @@ async fn rsc_aliases(
runtime: NextRuntime,
next_config: Vc<NextConfig>,
) -> Result<()> {
let server_actions = *next_config.enable_server_actions().await?;
let ppr = *next_config.enable_ppr().await?;
let react_channel = if server_actions || ppr {
"-experimental"
} else {
""
};
let taint = *next_config.enable_taint().await?;
let react_channel = if ppr || taint { "-experimental" } else { "" };

let mut alias = indexmap! {
"react" => format!("next/dist/compiled/react{react_channel}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub async fn get_next_server_transforms_rules(
let mut rules = vec![];

let modularize_imports_config = &next_config.await?.modularize_imports;
let enable_server_actions = *next_config.enable_server_actions().await?;
if let Some(modularize_imports_config) = modularize_imports_config {
rules.push(get_next_modularize_imports_rule(modularize_imports_config));
}
Expand All @@ -40,17 +39,13 @@ pub async fn get_next_server_transforms_rules(
(false, Some(pages_dir))
}
ServerContextType::AppSSR { .. } => {
if enable_server_actions {
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
}
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
(false, None)
}
ServerContextType::AppRSC {
client_transition, ..
} => {
if enable_server_actions {
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
}
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
if let Some(client_transition) = client_transition {
rules.push(get_next_css_client_reference_transforms_rule(
client_transition,
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.5.7-canary.21",
"version": "13.5.7-canary.23",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
Loading

0 comments on commit 339f5f2

Please sign in to comment.