Skip to content

Commit

Permalink
Merge branch 'canary' into shu/7fvu
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding authored Apr 25, 2023
2 parents 5c6bc94 + f08cab3 commit dbd9850
Show file tree
Hide file tree
Showing 49 changed files with 197 additions and 92 deletions.
2 changes: 1 addition & 1 deletion errors/version-staleness.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ If you want to report a bug on GitHub, you should upgrade to the newest canary r
- [Video: How to Contribute to Open Source (Next.js)](https://www.youtube.com/watch?v=cuoNzXFLitc)
- [Contributing to Next.js](https://github.com/vercel/next.js/blob/canary/contributing.md)
- [Triaging issues](https://github.com/vercel/next.js/blob/canary/contributing/repository/triaging.md)
- [Verifiying canary](https://github.com/vercel/next.js/blob/canary/.github/actions/issue-validator/canary.md)
- [Verifying canary](https://github.com/vercel/next.js/blob/canary/.github/actions/issue-validator/canary.md)
- [Adding a reproduction](https://github.com/vercel/next.js/blob/canary/.github/actions/issue-validator/repro.md)
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.3.2-canary.3"
"version": "13.3.2-canary.6"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@svgr/webpack": "5.5.0",
"@swc/cli": "0.1.55",
"@swc/core": "1.3.51",
"@swc/helpers": "0.5.0",
"@swc/helpers": "0.5.1",
"@testing-library/react": "13.0.0",
"@types/cheerio": "0.22.16",
"@types/fs-extra": "8.1.0",
Expand Down
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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "13.3.2-canary.3",
"@next/eslint-plugin-next": "13.3.2-canary.6",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"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.3.2-canary.3",
"version": "13.3.2-canary.6",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
5 changes: 5 additions & 0 deletions packages/next-swc/crates/napi/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-darwin-arm64",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/darwin-arm64"
},
"os": [
"darwin"
],
Expand Down
5 changes: 5 additions & 0 deletions packages/next-swc/crates/napi/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-darwin-x64",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/darwin-x64"
},
"os": [
"darwin"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-linux-arm64-gnu",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-arm64-gnu"
},
"os": [
"linux"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-linux-arm64-musl",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-arm64-musl"
},
"os": [
"linux"
],
Expand Down
5 changes: 5 additions & 0 deletions packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-linux-x64-gnu",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-x64-gnu"
},
"os": [
"linux"
],
Expand Down
5 changes: 5 additions & 0 deletions packages/next-swc/crates/napi/npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-linux-x64-musl",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/linux-x64-musl"
},
"os": [
"linux"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-win32-arm64-msvc",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/win32-arm64-msvc"
},
"os": [
"win32"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-win32-ia32-msvc",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/win32-ia32-msvc"
},
"os": [
"win32"
],
Expand Down
5 changes: 5 additions & 0 deletions packages/next-swc/crates/napi/npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@next/swc-win32-x64-msvc",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/vercel/next.js",
"directory": "packages/next-swc/crates/napi/npm/win32-x64-msvc"
},
"os": [
"win32"
],
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.3.2-canary.3",
"version": "13.3.2-canary.6",
"private": true,
"scripts": {
"clean": "rm -rf ./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.3.2-canary.3",
"version": "13.3.2-canary.6",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -81,8 +81,8 @@
]
},
"dependencies": {
"@next/env": "13.3.2-canary.3",
"@swc/helpers": "0.5.0",
"@next/env": "13.3.2-canary.6",
"@swc/helpers": "0.5.1",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
Expand Down Expand Up @@ -140,11 +140,11 @@
"@jest/types": "29.5.0",
"@napi-rs/cli": "2.14.7",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.3.2-canary.3",
"@next/polyfill-nomodule": "13.3.2-canary.3",
"@next/react-dev-overlay": "13.3.2-canary.3",
"@next/react-refresh-utils": "13.3.2-canary.3",
"@next/swc": "13.3.2-canary.3",
"@next/polyfill-module": "13.3.2-canary.6",
"@next/polyfill-nomodule": "13.3.2-canary.6",
"@next/react-dev-overlay": "13.3.2-canary.6",
"@next/react-refresh-utils": "13.3.2-canary.6",
"@next/swc": "13.3.2-canary.6",
"@opentelemetry/api": "1.4.1",
"@segment/ajv-human-errors": "2.1.2",
"@taskr/clear": "1.1.0",
Expand Down
9 changes: 6 additions & 3 deletions packages/next/src/build/analysis/get-page-static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,12 @@ export async function getPageStaticInfo(params: {
}
if (pageType === 'app') {
if (config) {
Log.warnOnce(
`\`export const config\` in ${pageFilePath} is deprecated. Please change it to segment export config. See https://beta.nextjs.org/docs/api-reference/segment-config`
)
const message = `\`export const config\` in ${pageFilePath} is deprecated. Please change \`runtime\` property to segment export config. See https://beta.nextjs.org/docs/api-reference/segment-config`
if (isDev) {
Log.warnOnce(message)
} else {
throw new Error(message)
}
config = {}
}
}
Expand Down
12 changes: 8 additions & 4 deletions packages/next/src/build/webpack/loaders/utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { createHash } from 'crypto'

import { RSC_MODULE_TYPES } from '../../../shared/lib/constants'

const imageExtensions = ['jpg', 'jpeg', 'png', 'webp', 'avif', 'ico', 'svg']
const imageRegex = new RegExp(`\\.(${imageExtensions.join('|')})$`)

export function isClientComponentModule(mod: {
export function isClientComponentEntryModule(mod: {
resource: string
buildInfo: any
}) {
const hasClientDirective = mod.buildInfo.rsc?.type === RSC_MODULE_TYPES.client
return hasClientDirective || imageRegex.test(mod.resource)
const rscInfo = mod.buildInfo.rsc
const hasClientDirective = rscInfo?.isClientRef
const isActionLayerEntry =
rscInfo?.actions && rscInfo?.type === RSC_MODULE_TYPES.client
return (
hasClientDirective || isActionLayerEntry || imageRegex.test(mod.resource)
)
}

export const regexCSS = /\.(css|scss|sass)(\?.*)?$/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import {
generateActionId,
getActions,
isClientComponentModule,
isClientComponentEntryModule,
isCSSMod,
} from '../loaders/utils'
import { traverseModules, forEachEntryModule } from '../utils'
Expand Down Expand Up @@ -521,7 +521,7 @@ export class ClientReferenceEntryPlugin {
}
visitedBySegment[entryRequest].add(storeKey)

const isClientComponent = isClientComponentModule(mod)
const isClientComponent = isClientComponentEntryModule(mod)

const actions = getActions(mod)
if (actions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SYSTEM_ENTRYPOINTS,
} from '../../../shared/lib/constants'
import { relative, sep } from 'path'
import { isClientComponentModule, isCSSMod } from '../loaders/utils'
import { isClientComponentEntryModule, isCSSMod } from '../loaders/utils'
import { getProxiedPluginState } from '../../build-context'

import { traverseModules } from '../utils'
Expand Down Expand Up @@ -212,7 +212,10 @@ export class ClientReferenceManifestPlugin {

// Only apply following logic to client module requests from client entry,
// or if the module is marked as client module.
if (!clientRequestsSet.has(resource) && !isClientComponentModule(mod)) {
if (
!clientRequestsSet.has(resource) &&
!isClientComponentEntryModule(mod)
) {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function handleMutable(
mutable.hashFragment && mutable.hashFragment !== ''
? // Remove leading # and decode hash to make non-latin hashes work.
decodeURIComponent(mutable.hashFragment.slice(1))
: null,
: state.focusAndScrollRef.hashFragment,
segmentPaths:
mutable?.scrollableSegments ?? state.focusAndScrollRef.segmentPaths,
},
Expand Down
17 changes: 7 additions & 10 deletions packages/next/src/lib/metadata/generate/utils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
function resolveArray<T>(value: T): T[] {
function resolveArray<T>(value: T | T[]): T[] {
if (Array.isArray(value)) {
return value
return value as any
}
return [value]
return [value] as any
}

function resolveAsArrayOrUndefined<T extends unknown | readonly unknown[]>(
function resolveAsArrayOrUndefined<T>(
value: T | T[] | undefined | null
): undefined | T[] {
): T extends undefined | null ? undefined : T[] {
if (typeof value === 'undefined' || value === null) {
return undefined
return undefined as any
}
if (Array.isArray(value)) {
return value
}
return [value]
return resolveArray(value) as any
}

export { resolveAsArrayOrUndefined, resolveArray }
2 changes: 1 addition & 1 deletion packages/next/src/lib/metadata/get-metadata-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function normalizeMetadataRoute(page: string) {
page.startsWith('/manifest') ||
isStaticMetadataFile

route = path.join(
route = path.posix.join(
dir,
`${baseName}${suffix ? `-${suffix}` : ''}${ext}`,
isSingleRoute ? '' : '[[...__metadata_id__]]',
Expand Down
Loading

0 comments on commit dbd9850

Please sign in to comment.