Skip to content

Commit

Permalink
Merge branch 'canary' into add/jest-module-mapping-from-tsconfig-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDaly committed Feb 28, 2023
2 parents cdeba5a + 0c0318e commit 89561ba
Show file tree
Hide file tree
Showing 127 changed files with 19,269 additions and 18,582 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ jobs:
testDevLTS,
testProdLTS,
testDevE2ELTS,
testprode2elts,
testProdE2ELTS,
]
steps:
- run: exit 0
Expand Down
2 changes: 1 addition & 1 deletion errors/middleware-parse-user-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export function middleware(request: NextRequest) {
const viewport = device.type === 'mobile' ? 'mobile' : 'desktop'

request.nextUrl.searchParams.set('viewport', viewport)
return NextResponse.rewrites(request.nextUrl)
return NextResponse.rewrite(request.nextUrl)
}
```
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.2.2-canary.2"
"version": "13.2.2-canary.3"
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@
"random-seed": "0.3.0",
"react": "18.2.0",
"react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@18.3.0-next-6ddcbd4f9-20230209",
"react-builtin": "npm:react@18.3.0-next-bfb9cbd8c-20230223",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@18.3.0-next-6ddcbd4f9-20230209",
"react-server-dom-webpack": "18.3.0-next-6ddcbd4f9-20230209",
"react-dom-builtin": "npm:react-dom@18.3.0-next-bfb9cbd8c-20230223",
"react-server-dom-webpack": "18.3.0-next-bfb9cbd8c-20230223",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -12,7 +12,7 @@
"test-pack": "cd ../../ && pnpm test-pack eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "13.2.2-canary.2",
"@next/eslint-plugin-next": "13.2.2-canary.3",
"@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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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.2.2-canary.2",
"version": "13.2.2-canary.3",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "13.2.2-canary.2",
"version": "13.2.2-canary.3",
"private": true,
"scripts": {
"clean": "rm -rf ./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": "13.2.2-canary.2",
"version": "13.2.2-canary.3",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -80,7 +80,7 @@
]
},
"dependencies": {
"@next/env": "13.2.2-canary.2",
"@next/env": "13.2.2-canary.3",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
Expand Down Expand Up @@ -135,11 +135,11 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.14.7",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.2.2-canary.2",
"@next/polyfill-nomodule": "13.2.2-canary.2",
"@next/react-dev-overlay": "13.2.2-canary.2",
"@next/react-refresh-utils": "13.2.2-canary.2",
"@next/swc": "13.2.2-canary.2",
"@next/polyfill-module": "13.2.2-canary.3",
"@next/polyfill-nomodule": "13.2.2-canary.3",
"@next/react-dev-overlay": "13.2.2-canary.3",
"@next/react-refresh-utils": "13.2.2-canary.3",
"@next/swc": "13.2.2-canary.3",
"@opentelemetry/api": "1.4.0",
"@segment/ajv-human-errors": "2.1.2",
"@taskr/clear": "1.1.0",
Expand Down
20 changes: 13 additions & 7 deletions packages/next/src/build/build-context.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { LoadedEnvFiles } from '@next/env'
import { Ora } from 'next/dist/compiled/ora'
import { Rewrite } from '../lib/load-custom-routes'
import { __ApiPreviewProps } from '../server/api-utils'
import { NextConfigComplete } from '../server/config-shared'
import { Span } from '../trace'
import type { LoadedEnvFiles } from '@next/env'
import type { Ora } from 'next/dist/compiled/ora'
import type { Rewrite, Redirect } from '../lib/load-custom-routes'
import type { __ApiPreviewProps } from '../server/api-utils'
import type { NextConfigComplete } from '../server/config-shared'
import type { Span } from '../trace'
import type getBaseWebpackConfig from './webpack-config'
import { TelemetryPlugin } from './webpack/plugins/telemetry-plugin'
import type { TelemetryPlugin } from './webpack/plugins/telemetry-plugin'

// a global object to store context for the current build
// this is used to pass data between different steps of the build without having
Expand All @@ -23,6 +23,12 @@ export const NextBuildContext: Partial<{
afterFiles: Rewrite[]
beforeFiles: Rewrite[]
}
originalRewrites: {
fallback: Rewrite[]
afterFiles: Rewrite[]
beforeFiles: Rewrite[]
}
originalRedirects: Redirect[]
loadedEnvFiles: LoadedEnvFiles
previewProps: __ApiPreviewProps
mappedPages:
Expand Down
19 changes: 15 additions & 4 deletions packages/next/src/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export function getEdgeServerEntry(opts: {

if (isInstrumentationHookFile(opts.page)) {
return {
import: opts.page,
import: opts.absolutePagePath,
filename: `edge-${INSTRUMENTATION_HOOK_FILENAME}.js`,
}
}
Expand Down Expand Up @@ -447,7 +447,15 @@ export async function createEntrypoints(params: CreateEntrypointsParams) {
assetPrefix: config.assetPrefix,
})
} else {
server[serverBundlePath] = [mappings[page]]
if (isInstrumentationHookFile(page) && pagesType === 'root') {
server[serverBundlePath.replace('src/', '')] = {
import: mappings[page],
// the '../' is needed to make sure the file is not chunked
filename: `../${INSTRUMENTATION_HOOK_FILENAME}.js`,
}
} else {
server[serverBundlePath] = [mappings[page]]
}
}
},
onEdgeServer: () => {
Expand All @@ -463,8 +471,11 @@ export async function createEntrypoints(params: CreateEntrypointsParams) {
assetPrefix: config.assetPrefix,
}).import
}

edgeServer[serverBundlePath] = getEdgeServerEntry({
const normalizedServerBundlePath =
isInstrumentationHookFile(page) && pagesType === 'root'
? serverBundlePath.replace('src/', '')
: serverBundlePath
edgeServer[normalizedServerBundlePath] = getEdgeServerEntry({
...params,
rootDir,
absolutePagePath: mappings[page],
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ export default async function build(

const { headers, rewrites, redirects } = customRoutes
NextBuildContext.rewrites = rewrites
NextBuildContext.originalRewrites = config._originalRewrites
NextBuildContext.originalRedirects = config._originalRedirects

const cacheDir = path.join(distDir, 'cache')
if (ciEnvironment.isCI && !ciEnvironment.hasNextSupport) {
Expand Down
12 changes: 9 additions & 3 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1877,9 +1877,15 @@ export function getPossibleInstrumentationHookFilenames(
folder: string,
extensions: string[]
) {
return extensions.map((extension) =>
path.join(folder, `${INSTRUMENTATION_HOOK_FILENAME}.${extension}`)
)
const files = []
for (const extension of extensions) {
files.push(
path.join(folder, `${INSTRUMENTATION_HOOK_FILENAME}.${extension}`),
path.join(folder, `src`, `${INSTRUMENTATION_HOOK_FILENAME}.${extension}`)
)
}

return files
}

export function getPossibleMiddlewareFilenames(
Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/build/webpack-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ async function webpackBuildImpl(): Promise<{
appDir: NextBuildContext.appDir!,
pagesDir: NextBuildContext.pagesDir!,
rewrites: NextBuildContext.rewrites!,
originalRewrites: NextBuildContext.originalRewrites!,
originalRedirects: NextBuildContext.originalRedirects!,
reactProductionProfiling: NextBuildContext.reactProductionProfiling!,
noMangling: NextBuildContext.noMangling!,
clientRouterFilters: NextBuildContext.clientRouterFilters!,
Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ export default async function getBaseWebpackConfig(
pagesDir,
reactProductionProfiling = false,
rewrites,
originalRewrites,
originalRedirects,
runWebpackSpan,
target = COMPILER_NAMES.server,
appDir,
Expand All @@ -634,6 +636,8 @@ export default async function getBaseWebpackConfig(
pagesDir?: string
reactProductionProfiling?: boolean
rewrites: CustomRoutes['rewrites']
originalRewrites: CustomRoutes['rewrites']
originalRedirects: CustomRoutes['redirects']
runWebpackSpan: Span
target?: string
appDir?: string
Expand Down Expand Up @@ -2201,6 +2205,8 @@ export default async function getBaseWebpackConfig(
isEdgeServer,
pageExtensions: config.pageExtensions,
typedRoutes: enableTypedRoutes,
originalRewrites,
originalRedirects,
}),
!dev &&
isClient &&
Expand Down

0 comments on commit 89561ba

Please sign in to comment.