Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/canary' into huozhi/metadata-dyn…
Browse files Browse the repository at this point in the history
…amic-convention-routes
  • Loading branch information
huozhi committed Jun 10, 2024
2 parents b93ca56 + 6cad923 commit 1ea9876
Show file tree
Hide file tree
Showing 67 changed files with 553 additions and 665 deletions.
157 changes: 89 additions & 68 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ next-core = { path = "packages/next-swc/crates/next-core" }
next-custom-transforms = { path = "packages/next-swc/crates/next-custom-transforms" }

# SWC crates
swc_core = { version = "0.92.10", features = [
swc_core = { version = "0.92.5", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
testing = { version = "0.35.25" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240607.1" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240607.3" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240607.1" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240607.3" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240607.1" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240607.3" }

# General Deps

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": "15.0.0-canary.18"
"version": "15.0.0-canary.22"
}
6 changes: 3 additions & 3 deletions packages/create-next-app/helpers/examples.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import tar from 'tar'
import { x } from 'tar'
import { Readable } from 'stream'
import { pipeline } from 'stream/promises'

Expand Down Expand Up @@ -103,7 +103,7 @@ export async function downloadAndExtractRepo(
await downloadTarStream(
`https://codeload.github.com/${username}/${name}/tar.gz/${branch}`
),
tar.x({
x({
cwd: root,
strip: filePath ? filePath.split('/').length + 1 : 1,
filter: (p) =>
Expand All @@ -125,7 +125,7 @@ export async function downloadAndExtractExample(root: string, name: string) {
await downloadTarStream(
'https://codeload.github.com/vercel/next.js/tar.gz/canary'
),
tar.x({
x({
cwd: root,
strip: 2 + name.split('/').length,
filter: (p) => p.includes(`next.js-canary/examples/${name}/`),
Expand Down
6 changes: 3 additions & 3 deletions 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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"keywords": [
"react",
"next",
Expand Down Expand Up @@ -34,7 +34,7 @@
"@types/cross-spawn": "6.0.0",
"@types/node": "^20.12.3",
"@types/prompts": "2.4.2",
"@types/tar": "6.1.5",
"@types/tar": "6.1.13",
"@types/validate-npm-package-name": "4.0.2",
"@vercel/ncc": "0.34.0",
"async-retry": "1.3.1",
Expand All @@ -46,7 +46,7 @@
"picocolors": "1.0.0",
"prettier-plugin-tailwindcss": "0.3.0",
"prompts": "2.4.2",
"tar": "6.1.15",
"tar": "7.2.0",
"update-check": "1.5.4",
"validate-npm-package-name": "5.0.1"
},
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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"@next/eslint-plugin-next": "15.0.0-canary.22",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || 7.0.0 - 7.2.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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"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": "15.0.0-canary.18",
"version": "15.0.0-canary.22",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -93,7 +93,7 @@
]
},
"dependencies": {
"@next/env": "15.0.0-canary.18",
"@next/env": "15.0.0-canary.22",
"@swc/helpers": "0.5.11",
"busboy": "1.6.0",
"caniuse-lite": "^1.0.30001579",
Expand Down Expand Up @@ -157,10 +157,10 @@
"@jest/types": "29.5.0",
"@mswjs/interceptors": "0.23.0",
"@napi-rs/triples": "1.2.0",
"@next/polyfill-module": "15.0.0-canary.18",
"@next/polyfill-nomodule": "15.0.0-canary.18",
"@next/react-refresh-utils": "15.0.0-canary.18",
"@next/swc": "15.0.0-canary.18",
"@next/polyfill-module": "15.0.0-canary.22",
"@next/polyfill-nomodule": "15.0.0-canary.22",
"@next/react-refresh-utils": "15.0.0-canary.22",
"@next/swc": "15.0.0-canary.22",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.41.2",
"@swc/core": "1.5.7",
Expand Down Expand Up @@ -206,7 +206,7 @@
"@types/ws": "8.2.0",
"@vercel/ncc": "0.34.0",
"@vercel/nft": "0.27.1",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240607.1",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240607.3",
"acorn": "8.11.3",
"amphtml-validator": "1.0.35",
"anser": "1.4.9",
Expand Down
92 changes: 6 additions & 86 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,12 @@ import { startTypeChecking } from './type-check'
import { generateInterceptionRoutesRewrites } from '../lib/generate-interception-routes-rewrites'

import { buildDataRoute } from '../server/lib/router-utils/build-data-route'
import { initialize as initializeIncrementalCache } from '../server/lib/incremental-cache-server'
import { nodeFs } from '../server/lib/node-fs-methods'
import { collectBuildTraces } from './collect-build-traces'
import type { BuildTraceContext } from './webpack/plugins/next-trace-entrypoints-plugin'
import { formatManifest } from './manifests/formatter/format-manifest'
import { getStartServerInfo, logStartInfo } from '../server/lib/app-info-log'
import type { NextEnabledDirectories } from '../server/base-server'
import { hasCustomExportOutput } from '../export/utils'
import { interopDefault } from '../lib/interop-default'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import { isInterceptionRouteAppPath } from '../server/lib/interception-routes'
import {
getTurbopackJsConfig,
Expand Down Expand Up @@ -575,11 +571,7 @@ type PageDataCollectionKeys = Exclude<
'exportPage'
>

function createStaticWorker(
config: NextConfigComplete,
incrementalCacheIpcPort?: number,
incrementalCacheIpcValidationKey?: string
): StaticWorker {
function createStaticWorker(config: NextConfigComplete): StaticWorker {
let infoPrinted = false
const timeout = config.staticPageGenerationTimeout || 0

Expand Down Expand Up @@ -619,13 +611,7 @@ function createStaticWorker(
},
numWorkers: getNumberOfWorkers(config),
forkOptions: {
env: {
...process.env,
__NEXT_INCREMENTAL_CACHE_IPC_PORT: incrementalCacheIpcPort
? incrementalCacheIpcPort + ''
: undefined,
__NEXT_INCREMENTAL_CACHE_IPC_KEY: incrementalCacheIpcValidationKey,
},
env: process.env,
},
enableWorkerThreads: config.experimental.workerThreads,
exposedMethods: staticWorkerExposedMethods,
Expand All @@ -634,8 +620,6 @@ function createStaticWorker(

async function writeFullyStaticExport(
config: NextConfigComplete,
incrementalCacheIpcPort: number | undefined,
incrementalCacheIpcValidationKey: string | undefined,
dir: string,
enabledDirectories: NextEnabledDirectories,
configOutDir: string,
Expand All @@ -644,16 +628,8 @@ async function writeFullyStaticExport(
const exportApp = require('../export')
.default as typeof import('../export').default

const pagesWorker = createStaticWorker(
config,
incrementalCacheIpcPort,
incrementalCacheIpcValidationKey
)
const appWorker = createStaticWorker(
config,
incrementalCacheIpcPort,
incrementalCacheIpcValidationKey
)
const pagesWorker = createStaticWorker(config)
const appWorker = createStaticWorker(config)

await exportApp(
dir,
Expand Down Expand Up @@ -1745,62 +1721,8 @@ export default async function build(

process.env.NEXT_PHASE = PHASE_PRODUCTION_BUILD

let incrementalCacheIpcPort
let incrementalCacheIpcValidationKey

if (config.experimental.staticWorkerRequestDeduping) {
let CacheHandler
if (cacheHandler) {
CacheHandler = interopDefault(
await import(formatDynamicImportPath(dir, cacheHandler)).then(
(mod) => mod.default || mod
)
)
}

const cacheInitialization = await initializeIncrementalCache({
fs: nodeFs,
dev: false,
pagesDir: true,
appDir: true,
fetchCache: true,
flushToDisk: ciEnvironment.hasNextSupport
? false
: config.experimental.isrFlushToDisk,
serverDistDir: path.join(distDir, 'server'),
fetchCacheKeyPrefix: config.experimental.fetchCacheKeyPrefix,
maxMemoryCacheSize: config.cacheMaxMemorySize,
getPrerenderManifest: () => ({
version: -1 as any, // letting us know this doesn't conform to spec
routes: {},
dynamicRoutes: {},
notFoundRoutes: [],
preview: null as any, // `preview` is special case read in next-dev-server
}),
requestHeaders: {},
CurCacheHandler: CacheHandler,
minimalMode: ciEnvironment.hasNextSupport,
allowedRevalidateHeaderKeys:
config.experimental.allowedRevalidateHeaderKeys,
})

incrementalCacheIpcPort = cacheInitialization.ipcPort
incrementalCacheIpcValidationKey = cacheInitialization.ipcValidationKey
}

const pagesStaticWorkers = createStaticWorker(
config,

incrementalCacheIpcPort,
incrementalCacheIpcValidationKey
)
const appStaticWorkers = appDir
? createStaticWorker(
config,
incrementalCacheIpcPort,
incrementalCacheIpcValidationKey
)
: undefined
const pagesStaticWorkers = createStaticWorker(config)
const appStaticWorkers = appDir ? createStaticWorker(config) : undefined

const analysisBegin = process.hrtime()
const staticCheckSpan = nextBuildSpan.traceChild('static-check')
Expand Down Expand Up @@ -3359,8 +3281,6 @@ export default async function build(
if (config.output === 'export') {
await writeFullyStaticExport(
config,
incrementalCacheIpcPort,
incrementalCacheIpcValidationKey,
dir,
enabledDirectories,
configOutDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,24 @@ export default function transformSource(
return
}

// `proxy` is the module proxy that we treat the module as a client boundary.
// For ESM, we access the property of the module proxy directly for each export.
// This is bit hacky that treating using a CJS like module proxy for ESM's exports,
// but this will avoid creating nested proxies for each export. It will be improved in the future.
let esmSource = `\
import { createProxy } from "${MODULE_PROXY_PATH}"
const proxy = createProxy(String.raw\`${resourceKey}\`)
`
let cnt = 0
for (const ref of clientRefs) {
if (ref === '') {
esmSource += `\nexports[''] = createProxy(String.raw\`${resourceKey}#\`);`
esmSource += `exports[''] = proxy['']\n`
} else if (ref === 'default') {
esmSource += `\
export default createProxy(String.raw\`${resourceKey}#default\`);
`
esmSource += `export default createProxy(String.raw\`${resourceKey}#default\`);\n`
} else {
esmSource += `
const e${cnt} = createProxy(String.raw\`${resourceKey}#${ref}\`);
export { e${cnt++} as ${ref} };`
esmSource += `const e${cnt} = proxy["${ref}"];\n`
esmSource += `export { e${cnt++} as ${ref} };\n`
}
}

Expand Down
Loading

0 comments on commit 1ea9876

Please sign in to comment.