Skip to content

Commit

Permalink
Merge branch 'canary' into sokra/node-style-default-import
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Apr 29, 2023
2 parents 48935ba + e66c625 commit d4b9bba
Show file tree
Hide file tree
Showing 48 changed files with 441 additions and 212 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.3.2-canary.12"
"version": "13.3.2-canary.13"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"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": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"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.12",
"@next/eslint-plugin-next": "13.3.2-canary.13",
"@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
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"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": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"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": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"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": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
Expand Up @@ -18,4 +18,8 @@ export {
renderToReadableStream,
decodeReply,
} from 'next/dist/compiled/react-server-dom-webpack/server.edge'
export { preloadStyle } from 'next/dist/server/app-render/rsc/preloads'
export {
preloadStyle,
preloadFont,
preconnect,
} from 'next/dist/server/app-render/rsc/preloads'
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"private": true,
"scripts": {
"clean": "rm -rf ./native/*",
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "13.3.2-canary.12",
"version": "13.3.2-canary.13",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -81,7 +81,7 @@
]
},
"dependencies": {
"@next/env": "13.3.2-canary.12",
"@next/env": "13.3.2-canary.13",
"@swc/helpers": "0.5.1",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406",
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.12",
"@next/polyfill-nomodule": "13.3.2-canary.12",
"@next/react-dev-overlay": "13.3.2-canary.12",
"@next/react-refresh-utils": "13.3.2-canary.12",
"@next/swc": "13.3.2-canary.12",
"@next/polyfill-module": "13.3.2-canary.13",
"@next/polyfill-nomodule": "13.3.2-canary.13",
"@next/react-dev-overlay": "13.3.2-canary.13",
"@next/react-refresh-utils": "13.3.2-canary.13",
"@next/swc": "13.3.2-canary.13",
"@opentelemetry/api": "1.4.1",
"@segment/ajv-human-errors": "2.1.2",
"@taskr/clear": "1.1.0",
Expand Down
26 changes: 23 additions & 3 deletions packages/next/src/build/analysis/get-page-static-info.ts
Expand Up @@ -35,6 +35,7 @@ export interface MiddlewareMatcher {

export interface PageStaticInfo {
runtime?: ServerRuntime
preferredRegion?: string | string[]
ssg?: boolean
ssr?: boolean
rsc?: RSCModuleType
Expand Down Expand Up @@ -81,10 +82,12 @@ function checkExports(swcAST: any): {
ssr: boolean
ssg: boolean
runtime?: string
preferredRegion?: string | string[]
} {
if (Array.isArray(swcAST?.body)) {
try {
let runtime: string | undefined
let preferredRegion: string | string[] | undefined
let ssr: boolean = false
let ssg: boolean = false

Expand All @@ -97,6 +100,22 @@ function checkExports(swcAST: any): {
if (declaration.id.value === 'runtime') {
runtime = declaration.init.value
}

if (declaration.id.value === 'preferredRegion') {
if (declaration.init.type === 'ArrayExpression') {
const elements: string[] = []
for (const element of declaration.init.elements) {
const { expression } = element
if (expression.type !== 'StringLiteral') {
continue
}
elements.push(expression.value)
}
preferredRegion = elements
} else {
preferredRegion = declaration.init.value
}
}
}
}

Expand Down Expand Up @@ -137,7 +156,7 @@ function checkExports(swcAST: any): {
}
}

return { ssr, ssg, runtime }
return { ssr, ssg, runtime, preferredRegion }
} catch (err) {}
}

Expand Down Expand Up @@ -322,12 +341,12 @@ export async function getPageStaticInfo(params: {

const fileContent = (await tryToReadFile(pageFilePath, !isDev)) || ''
if (
/runtime|getStaticProps|getServerSideProps|export const config/.test(
/runtime|preferredRegion|getStaticProps|getServerSideProps|export const config/.test(
fileContent
)
) {
const swcAST = await parseModule(pageFilePath, fileContent)
const { ssg, ssr, runtime } = checkExports(swcAST)
const { ssg, ssr, runtime, preferredRegion } = checkExports(swcAST)
const rsc = getRSCModuleInformation(fileContent).type

// default / failsafe value for config
Expand Down Expand Up @@ -420,6 +439,7 @@ export async function getPageStaticInfo(params: {
rsc,
...(middlewareConfig && { middleware: middlewareConfig }),
...(resolvedRuntime && { runtime: resolvedRuntime }),
preferredRegion,
}
}

Expand Down

0 comments on commit d4b9bba

Please sign in to comment.