Skip to content

Commit

Permalink
Merge branch 'canary' into fix/create-next-app-dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 30, 2023
2 parents 81ce8a9 + 6dc7c3c commit 9177cb2
Show file tree
Hide file tree
Showing 25 changed files with 210 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ All supported third-party libraries from Google can be imported from `@next/thir
### Google Tag Manager

The `GoogleTagManager` component can be used to instantiate a [Google Tag
Manager](https://developers.google.com/maps/documentation/embed/embedding-map) container to your
Manager](https://developers.google.com/tag-platform/tag-manager) container to your
page. By default, it fetches the original inline script after hydration occurs on the page.

<AppOnly>
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": "14.0.1-canary.3"
"version": "14.0.1-canary.4"
}
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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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": "14.0.1-canary.3",
"version": "14.0.1-canary.4",
"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": "14.0.1-canary.3",
"@next/eslint-plugin-next": "14.0.1-canary.4",
"@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": "14.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"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.0.1-canary.3",
"version": "14.0.1-canary.4",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
50 changes: 43 additions & 7 deletions packages/next-swc/crates/next-core/src/app_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,25 @@ pub struct LoaderTree {
pub global_metadata: Vc<GlobalMetadata>,
}

#[turbo_tasks::value_impl]
impl LoaderTree {
/// Returns true if there's a page match in this loader tree.
#[turbo_tasks::function]
pub async fn has_page(&self) -> Result<Vc<bool>> {
if self.segment == "__PAGE__" {
return Ok(Vc::cell(true));
}

for (_, tree) in &self.parallel_routes {
if *tree.has_page().await? {
return Ok(Vc::cell(true));
}
}

Ok(Vc::cell(false))
}
}

#[derive(
Clone, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs, ValueDebugFormat, Debug, TaskInput,
)]
Expand All @@ -425,6 +444,10 @@ fn is_parallel_route(name: &str) -> bool {
name.starts_with('@')
}

fn is_group_route(name: &str) -> bool {
name.starts_with('(') && name.ends_with(')')
}

fn match_parallel_route(name: &str) -> Option<&str> {
name.strip_prefix('@')
}
Expand Down Expand Up @@ -677,14 +700,10 @@ async fn directory_tree_to_loader_tree(
tree.segment = "children".to_string();
}

let mut has_page = false;

if let Some(page) = (app_path == for_app_path)
.then_some(components.page)
.flatten()
{
has_page = true;

// When resolving metadata with corresponding module
// (https://github.com/vercel/next.js/blob/aa1ee5995cdd92cc9a2236ce4b6aa2b67c9d32b2/packages/next/src/lib/metadata/resolve-metadata.ts#L340)
// layout takes precedence over page (https://github.com/vercel/next.js/blob/aa1ee5995cdd92cc9a2236ce4b6aa2b67c9d32b2/packages/next/src/server/lib/app-dir-module.ts#L22)
Expand Down Expand Up @@ -751,9 +770,26 @@ async fn directory_tree_to_loader_tree(
continue;
}

// TODO: detect duplicate page in group segment
if !has_page {
// skip groups which don't have a page match.
if is_group_route(subdir_name) && !*subtree.has_page().await? {
continue;
}

if !tree.parallel_routes.contains_key("children") {
tree.parallel_routes.insert("children".to_string(), subtree);
} else {
// TODO: improve error message to have the full paths
DirectoryTreeIssue {
app_dir,
message: Vc::cell(format!(
"You cannot have two parallel pages that resolve to the same path. Route \
{} has multiple matches in {}",
for_app_path, app_page
)),
severity: IssueSeverity::Error.cell(),
}
.cell()
.emit();
}
} else if let Some(key) = parallel_route_key {
bail!(
Expand All @@ -772,7 +808,7 @@ async fn directory_tree_to_loader_tree(
..Default::default()
}
.cell();
} else if components.layout.is_some() || current_level_is_parallel_route {
} else if current_level_is_parallel_route {
// default fallback component
tree.components = Components {
default: Some(
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": "14.0.1-canary.3",
"version": "14.0.1-canary.4",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "14.0.1-canary.3",
"version": "14.0.1-canary.4",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -92,7 +92,7 @@
]
},
"dependencies": {
"@next/env": "14.0.1-canary.3",
"@next/env": "14.0.1-canary.4",
"@swc/helpers": "0.5.2",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
Expand Down Expand Up @@ -146,11 +146,11 @@
"@mswjs/interceptors": "0.23.0",
"@napi-rs/cli": "2.16.2",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "14.0.1-canary.3",
"@next/polyfill-nomodule": "14.0.1-canary.3",
"@next/react-dev-overlay": "14.0.1-canary.3",
"@next/react-refresh-utils": "14.0.1-canary.3",
"@next/swc": "14.0.1-canary.3",
"@next/polyfill-module": "14.0.1-canary.4",
"@next/polyfill-nomodule": "14.0.1-canary.4",
"@next/react-dev-overlay": "14.0.1-canary.4",
"@next/react-refresh-utils": "14.0.1-canary.4",
"@next/swc": "14.0.1-canary.4",
"@opentelemetry/api": "1.4.1",
"@playwright/test": "^1.35.1",
"@taskr/clear": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/collect-build-traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ export async function collectBuildTraces({

const sharedIgnores = [
'**/next/dist/compiled/next-server/**/*.dev.js',
'**/node_modules/react{,-dom,-dom-server-turbopack}/**/*.development.js',
isStandalone ? null : '**/next/dist/compiled/jest-worker/**/*',
'**/next/dist/compiled/webpack/(bundle4|bundle5).js',
'**/node_modules/webpack5/**/*',
Expand Down Expand Up @@ -294,6 +293,7 @@ export async function collectBuildTraces({

const serverIgnores = [
...sharedIgnores,
'**/node_modules/react{,-dom,-dom-server-turbopack}/**/*.development.js',
'**/*.d.ts',
'**/*.map',
'**/next/dist/pages/**/*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import fs from 'fs'
import path from 'path'
import { imageExtMimeTypeMap } from '../../../lib/mime-type'

function errorOnBadHandler(resourcePath: string) {
return `
if (typeof handler !== 'function') {
throw new Error('Default export is missing in ${JSON.stringify(
resourcePath
)}')
}
`
}

const cacheHeader = {
none: 'no-cache, no-store',
longCache: 'public, immutable, no-transform, max-age=31536000',
Expand Down Expand Up @@ -78,6 +88,8 @@ import { resolveRouteData } from 'next/dist/build/webpack/loaders/metadata/resol
const contentType = ${JSON.stringify(getContentType(resourcePath))}
const fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}
${errorOnBadHandler(resourcePath)}
export async function GET() {
const data = await handler()
const content = resolveRouteData(data, fileType)
Expand All @@ -103,6 +115,8 @@ const imageModule = { ...userland }
const handler = imageModule.default
const generateImageMetadata = imageModule.generateImageMetadata
${errorOnBadHandler(resourcePath)}
export async function GET(_, ctx) {
const { __metadata_id__ = [], ...params } = ctx.params || {}
const targetId = __metadata_id__[0]
Expand Down Expand Up @@ -160,6 +174,8 @@ const generateSitemaps = sitemapModule.generateSitemaps
const contentType = ${JSON.stringify(getContentType(resourcePath))}
const fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}
${errorOnBadHandler(resourcePath)}
${'' /* re-export the userland route configs */}
export * from ${JSON.stringify(resourcePath)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class FlightClientEntryPlugin {
const modPath = mod.matchResource || mod.resourceResolveData?.path
const modQuery = mod.resourceResolveData?.query || ''
// query is already part of mod.resource
// so it's only neccessary to add it for matchResource or mod.resourceResolveData
// so it's only necessary to add it for matchResource or mod.resourceResolveData
const modResource = modPath ? modPath + modQuery : mod.resource

if (mod.layer !== WEBPACK_LAYERS.serverSideRendering) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "14.0.1-canary.3",
"version": "14.0.1-canary.4",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "14.0.1-canary.3",
"version": "14.0.1-canary.4",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/third-parties/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/third-parties",
"version": "14.0.1-canary.3",
"version": "14.0.1-canary.4",
"repository": {
"url": "vercel/next.js",
"directory": "packages/third-parties"
Expand All @@ -22,7 +22,7 @@
"third-party-capital": "1.0.20"
},
"devDependencies": {
"next": "14.0.1-canary.3",
"next": "14.0.1-canary.4",
"outdent": "0.8.0",
"prettier": "2.5.1"
},
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

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

0 comments on commit 9177cb2

Please sign in to comment.