Skip to content

Commit

Permalink
Merge branch 'canary' into sokra/resolve-endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Feb 22, 2024
2 parents b9af7d2 + 4545f3e commit dcbd651
Show file tree
Hide file tree
Showing 43 changed files with 545 additions and 404 deletions.
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": "14.1.1-canary.67"
"version": "14.1.1-canary.69"
}
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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"keywords": [
"react",
"next",
Expand Down
6 changes: 3 additions & 3 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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
Expand All @@ -10,9 +10,9 @@
},
"homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "14.1.1-canary.67",
"@next/eslint-plugin-next": "14.1.1-canary.69",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.1",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.28.1",
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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
48 changes: 29 additions & 19 deletions packages/next-swc/crates/next-api/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,31 +614,39 @@ impl PageEndpoint {

let client_chunking_context = this.pages_project.project().client_chunking_context();

let mut client_chunks = client_chunking_context
.evaluated_chunk_group_assets(
client_module.ident(),
this.pages_project
.client_runtime_entries()
.with_entry(Vc::upcast(client_main_module))
.with_entry(Vc::upcast(client_module)),
Value::new(AvailabilityInfo::Root),
)
.await?
.clone_value();

client_chunks.push(Vc::upcast(PageLoaderAsset::new(
this.pages_project.project().client_root(),
this.pathname,
self.client_relative_path(),
Vc::cell(client_chunks.clone()),
)));
let client_chunks = client_chunking_context.evaluated_chunk_group_assets(
client_module.ident(),
this.pages_project
.client_runtime_entries()
.with_entry(Vc::upcast(client_main_module))
.with_entry(Vc::upcast(client_module)),
Value::new(AvailabilityInfo::Root),
);

Ok(Vc::cell(client_chunks))
Ok(client_chunks)
}
.instrument(tracing::info_span!("page client side rendering"))
.await
}

#[turbo_tasks::function]
async fn page_loader(
self: Vc<Self>,
client_chunks: Vc<OutputAssets>,
) -> Result<Vc<Box<dyn OutputAsset>>> {
let this = self.await?;
let project = this.pages_project.project();
let node_root = project.client_root();
let client_relative_path = self.client_relative_path();
let page_loader = PageLoaderAsset::new(
node_root,
this.pathname,
client_relative_path,
client_chunks,
);
Ok(Vc::upcast(page_loader))
}

#[turbo_tasks::function]
async fn internal_ssr_chunk(
self: Vc<Self>,
Expand Down Expand Up @@ -989,6 +997,8 @@ impl PageEndpoint {
let client_chunks = self.client_chunks();
client_assets.extend(client_chunks.await?.iter().copied());
let build_manifest = self.build_manifest(client_chunks);
let page_loader = self.page_loader(client_chunks);
client_assets.push(page_loader);
server_assets.push(build_manifest);
self.ssr_chunk()
}
Expand Down
15 changes: 7 additions & 8 deletions packages/next-swc/crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,12 @@ impl Project {
Ok(Vc::upcast(virtual_fs))
}

// #[turbo_tasks::function]
// pub async fn node_fs(self: Vc<Self>) -> Result<Vc<Box<dyn FileSystem>>> {
// let this = self.await?;
// let disk_fs = DiskFileSystem::new("node".to_string(),
// this.project_path.clone(), vec![]); disk_fs.await?.
// start_watching_with_invalidation_reason()?; Ok(Vc::upcast(disk_fs))
// }
#[turbo_tasks::function]
pub async fn output_fs(self: Vc<Self>) -> Result<Vc<Box<dyn FileSystem>>> {
let this = self.await?;
let disk_fs = DiskFileSystem::new("output".to_string(), this.project_path.clone(), vec![]);
Ok(Vc::upcast(disk_fs))
}

#[turbo_tasks::function]
pub async fn dist_dir(self: Vc<Self>) -> Result<Vc<String>> {
Expand All @@ -399,7 +398,7 @@ impl Project {
#[turbo_tasks::function]
pub async fn node_root(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
let this = self.await?;
Ok(self.project_path().join(this.dist_dir.to_string()))
Ok(self.output_fs().root().join(this.dist_dir.to_string()))
}

#[turbo_tasks::function]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
use hex::encode as hex_encode;
use serde::Deserialize;
use sha1::{Digest, Sha1};
use swc_core::common::Span;
use turbopack_binding::swc::core::{
common::{
comments::{Comment, CommentKind, Comments},
Expand Down Expand Up @@ -125,18 +126,20 @@ impl<C: Comments> ServerActions<C> {
} else {
// Check if the function has `"use server"`
if let Some(body) = maybe_body {
let mut action_span = None;
remove_server_directive_index_in_fn(
&mut body.stmts,
remove_directive,
&mut is_action_fn,
&mut action_span,
self.config.enabled,
);

if is_action_fn && !self.config.is_react_server_layer && !self.in_action_file {
HANDLER.with(|handler| {
handler
.struct_span_err(
body.span,
action_span.unwrap_or(body.span),
"It is not allowed to define inline \"use server\" annotated Server Actions in Client Components.\nTo use Server Actions in a Client Component, you can either export them from a separate file with \"use server\" at the top, or pass them down through props from a Server Component.\n\nRead more: https://nextjs.org/docs/app/api-reference/functions/server-actions#with-client-components\n",
)
.emit()
Expand Down Expand Up @@ -1396,6 +1399,7 @@ fn remove_server_directive_index_in_fn(
stmts: &mut Vec<Stmt>,
remove_directive: bool,
is_action_fn: &mut bool,
action_span: &mut Option<Span>,
enabled: bool,
) {
let mut is_directive = true;
Expand All @@ -1407,6 +1411,8 @@ fn remove_server_directive_index_in_fn(
}) = stmt
{
if value == "use server" {
*action_span = Some(*span);

if is_directive {
*is_action_fn = true;
if !enabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
|
| Read more: https://nextjs.org/docs/app/api-reference/functions/server-actions#with-client-components
|
,-[input.js:3:1]
3 | export default function App() {
4 | ,-> async function fn() {
5 | | 'use server'
6 | `-> }
7 | return <div>App</div>
,-[input.js:4:1]
4 | async function fn() {
5 | 'use server'
: ^^^^^^^^^^^^
6 | }
`----
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": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
12 changes: 6 additions & 6 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "14.1.1-canary.67",
"version": "14.1.1-canary.69",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -92,7 +92,7 @@
]
},
"dependencies": {
"@next/env": "14.1.1-canary.67",
"@next/env": "14.1.1-canary.69",
"@swc/helpers": "0.5.5",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001579",
Expand Down Expand Up @@ -145,10 +145,10 @@
"@jest/types": "29.5.0",
"@mswjs/interceptors": "0.23.0",
"@napi-rs/triples": "1.2.0",
"@next/polyfill-module": "14.1.1-canary.67",
"@next/polyfill-nomodule": "14.1.1-canary.67",
"@next/react-refresh-utils": "14.1.1-canary.67",
"@next/swc": "14.1.1-canary.67",
"@next/polyfill-module": "14.1.1-canary.69",
"@next/polyfill-nomodule": "14.1.1-canary.69",
"@next/react-refresh-utils": "14.1.1-canary.69",
"@next/swc": "14.1.1-canary.69",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.41.2",
"@taskr/clear": "1.1.0",
Expand Down

0 comments on commit dcbd651

Please sign in to comment.