Skip to content

Commit

Permalink
Merge branch 'canary' into fix-symlinks-with-standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
remorses committed Apr 14, 2022
2 parents c474595 + 6907519 commit b85c223
Show file tree
Hide file tree
Showing 33 changed files with 123 additions and 90 deletions.
4 changes: 2 additions & 2 deletions examples/with-electron-typescript/package.json
Expand Up @@ -10,7 +10,7 @@
"build": "npm run build-renderer && npm run build-electron",
"pack-app": "npm run build && electron-builder --dir",
"dist": "npm run build && electron-builder",
"type-check": "tsc"
"type-check": "tsc -p ./renderer/tsconfig.json && tsc -p ./electron-src/tsconfig.json"
},
"dependencies": {
"electron-is-dev": "^1.1.0",
Expand All @@ -23,7 +23,7 @@
"@types/react": "^16.9.9",
"@types/react-dom": "^16.9.9",
"electron": "^13",
"electron-builder": "^22.9.1",
"electron-builder": "^23.0.3",
"next": "latest",
"rimraf": "^3.0.0",
"typescript": "^4.0.5"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-electron/package.json
Expand Up @@ -18,7 +18,7 @@
},
"devDependencies": {
"electron": "^12.0.2",
"electron-builder": "^22.10.5",
"electron-builder": "^23.0.3",
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.1.6-canary.0"
"version": "12.1.6-canary.1"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"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": "12.1.6-canary.0",
"@next/eslint-plugin-next": "12.1.6-canary.1",
"@rushstack/eslint-patch": "1.0.8",
"@typescript-eslint/parser": "5.10.1",
"eslint-import-resolver-node": "0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"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
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"private": true,
"scripts": {
"build-native": "napi build --platform --cargo-name next_swc_napi native",
Expand Down
Expand Up @@ -8,9 +8,7 @@
import { promisify } from 'util'

import { parse } from '../../swc'
import { buildExports } from './utils'

const IS_NEXT_CLIENT_BUILT_IN = /[\\/]next[\\/](link|image)\.js$/
import { buildExports, isNextBuiltinClientComponent } from './utils'

function addExportNames(names: string[], node: any) {
if (!node) return
Expand Down Expand Up @@ -59,7 +57,7 @@ async function collectExports(
const names: string[] = []

// Next.js built-in client components
if (IS_NEXT_CLIENT_BUILT_IN.test(resourcePath)) {
if (isNextBuiltinClientComponent(resourcePath)) {
names.push('default')
}

Expand Down Expand Up @@ -160,7 +158,7 @@ export default async function transformSource(
const moduleRefDef =
"const MODULE_REFERENCE = Symbol.for('react.module.reference');\n"

const isNextClientBuiltIn = IS_NEXT_CLIENT_BUILT_IN.test(resourcePath)
const isNextClientBuiltIn = isNextBuiltinClientComponent(resourcePath)

const clientRefsExports = names.reduce((res: any, name) => {
const moduleRef =
Expand Down
29 changes: 5 additions & 24 deletions packages/next/build/webpack/loaders/next-flight-server-loader.ts
@@ -1,30 +1,11 @@
import { builtinModules } from 'module'

import { parse } from '../../swc'
import { buildExports } from './utils'

const imageExtensions = ['jpg', 'jpeg', 'png', 'webp', 'avif']

export const createClientComponentFilter = (extensions: string[]) => {
// Special cases for Next.js APIs that are considered as client components:
// - .client.[ext]
// - next built-in client components
// - .[imageExt]
const regex = new RegExp(
'(' +
`\\.client(\\.(${extensions.join('|')}))?|` +
`next/(link|image)(\\.js)?|` +
`\\.(${imageExtensions.join('|')})` +
')$'
)

return (importSource: string) => regex.test(importSource)
}

export const createServerComponentFilter = (extensions: string[]) => {
const regex = new RegExp(`\\.server(\\.(${extensions.join('|')}))?$`)
return (importSource: string) => regex.test(importSource)
}
import {
buildExports,
createClientComponentFilter,
createServerComponentFilter,
} from './utils'

function createFlightServerRequest(request: string, options: object) {
return `next-flight-server-loader?${JSON.stringify(options)}!${request}`
Expand Down
35 changes: 35 additions & 0 deletions packages/next/build/webpack/loaders/utils.ts
@@ -1,3 +1,15 @@
const defaultJsFileExtensions = ['js', 'mjs', 'jsx', 'ts', 'tsx', 'json']
const imageExtensions = ['jpg', 'jpeg', 'png', 'webp', 'avif']
const nextClientComponents = ['link', 'image', 'head', 'script']

const NEXT_BUILT_IN_CLIENT_RSC_REGEX = new RegExp(
`[\\\\/]next[\\\\/](${nextClientComponents.join('|')})\\.js$`
)

export function isNextBuiltinClientComponent(resourcePath: string) {
return NEXT_BUILT_IN_CLIENT_RSC_REGEX.test(resourcePath)
}

export function buildExports(moduleExports: any, isESM: boolean) {
let ret = ''
Object.keys(moduleExports).forEach((key) => {
Expand All @@ -11,3 +23,26 @@ export function buildExports(moduleExports: any, isESM: boolean) {
})
return ret
}

export const createClientComponentFilter = (
extensions: string[] = defaultJsFileExtensions
) => {
// Special cases for Next.js APIs that are considered as client components:
// - .client.[ext]
// - next built-in client components
// - .[imageExt]
const regex = new RegExp(
'(' +
`\\.client(\\.(${extensions.join('|')}))?|` +
`next/(${nextClientComponents.join('|')})(\\.js)?|` +
`\\.(${imageExtensions.join('|')})` +
')$'
)

return (importSource: string) => regex.test(importSource)
}

export const createServerComponentFilter = (extensions: string[]) => {
const regex = new RegExp(`\\.server(\\.(${extensions.join('|')}))?$`)
return (importSource: string) => regex.test(importSource)
}
Expand Up @@ -7,7 +7,7 @@

import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
import { MIDDLEWARE_FLIGHT_MANIFEST } from '../../../shared/lib/constants'
import { createClientComponentFilter } from '../loaders/next-flight-server-loader'
import { createClientComponentFilter } from '../loaders/utils'

// This is the module that will be used to anchor all client references to.
// I.e. it will have all the client files as async deps from this point on.
Expand Down
8 changes: 4 additions & 4 deletions packages/next/compiled/use-subscription/index.js

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

14 changes: 7 additions & 7 deletions packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -69,7 +69,7 @@
]
},
"dependencies": {
"@next/env": "12.1.6-canary.0",
"@next/env": "12.1.6-canary.1",
"caniuse-lite": "^1.0.30001283",
"postcss": "8.4.5",
"styled-jsx": "5.0.1"
Expand Down Expand Up @@ -117,11 +117,11 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.4.4",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "12.1.6-canary.0",
"@next/polyfill-nomodule": "12.1.6-canary.0",
"@next/react-dev-overlay": "12.1.6-canary.0",
"@next/react-refresh-utils": "12.1.6-canary.0",
"@next/swc": "12.1.6-canary.0",
"@next/polyfill-module": "12.1.6-canary.1",
"@next/polyfill-nomodule": "12.1.6-canary.1",
"@next/react-dev-overlay": "12.1.6-canary.1",
"@next/react-refresh-utils": "12.1.6-canary.1",
"@next/swc": "12.1.6-canary.1",
"@peculiar/webcrypto": "1.3.1",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
Expand Down
11 changes: 2 additions & 9 deletions packages/next/server/render.tsx
Expand Up @@ -431,14 +431,7 @@ function createServerComponentRenderer(
return root
}

// Although it's not allowed to attach some static methods to Component,
// we still re-assign all the component APIs to keep the behavior unchanged.
for (const methodName of [
'getInitialProps',
'getStaticProps',
'getServerSideProps',
'getStaticPaths',
]) {
for (const methodName of Object.keys(Component)) {
const method = (Component as any)[methodName]
if (method) {
;(ServerComponentWrapper as any)[methodName] = method
Expand Down Expand Up @@ -1375,7 +1368,7 @@ export async function renderToHTML(
<AppContainerWithIsomorphicFiberStructure>
{isServerComponent && !!AppMod.__next_rsc__ ? (
// _app.server.js is used.
<Component {...props.pageProps} router={router} />
<Component {...props.pageProps} />
) : (
<App {...props} Component={Component} router={router} />
)}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/web-server.ts
Expand Up @@ -125,7 +125,7 @@ export default class NextWebServer extends BaseServer {
): Promise<RenderResult | null> {
return renderToHTML(
{
url: pathname,
url: req.url,
cookies: req.cookies,
headers: req.headers,
} as any,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/server/web/spec-extension/request.ts
Expand Up @@ -13,7 +13,7 @@ export class NextRequest extends Request {
cookieParser(): { [key: string]: string }
geo: RequestData['geo']
ip?: string
page?: { name?: string; params?: { [key: string]: string } }
page?: { name?: string; params?: { [key: string]: string | string[] } }
ua?: UserAgent | null
url: NextURL
}
Expand Down Expand Up @@ -105,7 +105,7 @@ export interface RequestInit extends globalThis.RequestInit {
}
page?: {
name?: string
params?: { [key: string]: string }
params?: { [key: string]: string | string[] }
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/next/taskfile.js
Expand Up @@ -313,6 +313,7 @@ export async function ncc_use_subscription(task, opts) {
react: 'react',
'react-dom': 'react-dom',
},
target: 'es5',
})
.target('compiled/use-subscription')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"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
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "12.1.6-canary.0",
"version": "12.1.6-canary.1",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down

0 comments on commit b85c223

Please sign in to comment.