Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial separated route resolving #47208

Merged
merged 75 commits into from Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
04aa052
Add initial separated route resolving
ijjk Mar 16, 2023
1cbf5e8
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 16, 2023
7f43e77
Fix 404 and log case
ijjk Mar 16, 2023
380751b
fix server ready log
ijjk Mar 16, 2023
f281262
ensure method and body are passed
ijjk Mar 16, 2023
4c923c1
fix lint
ijjk Mar 16, 2023
5e0d2ca
fix unit
ijjk Mar 16, 2023
57e117d
fix body
ijjk Mar 16, 2023
73edb2d
fix body more
ijjk Mar 16, 2023
d0bb40a
set keepAlive
ijjk Mar 16, 2023
3765189
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 17, 2023
5af800c
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 20, 2023
d3cd9e4
fix header overlap
ijjk Mar 20, 2023
f8d740b
remove experimental.config.experimental.preCompiledNextServer and fix…
ijjk Mar 20, 2023
1641502
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 27, 2023
a362881
Fix env and 404 case
ijjk Mar 27, 2023
617b17a
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 27, 2023
d5bf1d1
call preflight
ijjk Mar 27, 2023
89827e1
update initial env handling
ijjk Mar 27, 2023
0e784cf
fix middleware-body and next-font test cases
ijjk Mar 27, 2023
54ee868
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 27, 2023
72cd4eb
Ensure error stacks are resolved in dev
ijjk Mar 27, 2023
35be7c2
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 27, 2023
b95c2fc
handle dev server watching
ijjk Mar 28, 2023
f92aad3
Add additional IPC handling and fix missing middleware header
ijjk Mar 28, 2023
38d86b9
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 28, 2023
594d0da
lint fix
ijjk Mar 28, 2023
db2e70b
fix undici fetch header
shuding Mar 28, 2023
527eda5
update _next/data handling
ijjk Mar 28, 2023
7ec52c1
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 28, 2023
a83d08e
Update more test cases
ijjk Mar 28, 2023
f90e9a7
remove extra changes
ijjk Mar 28, 2023
ddca45f
more test cases
ijjk Mar 28, 2023
bc3b830
more tests
ijjk Mar 28, 2023
a19f34c
fix intialize error handling
ijjk Mar 28, 2023
2ba4984
more test cases
ijjk Mar 29, 2023
08f34a2
Update query handling
ijjk Mar 29, 2023
41edfdf
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 29, 2023
4eeb018
fix more test cases
ijjk Mar 29, 2023
41f7f85
repeated slashes test
ijjk Mar 29, 2023
bf442d5
etag test
ijjk Mar 29, 2023
274ec8d
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 29, 2023
79f6849
fix missing process.env.NODE_ENV
shuding Mar 29, 2023
aca86e9
fix streaming error case
ijjk Mar 29, 2023
de42d49
Merge branch 'update/separate-route-resolving' of github.com:ijjk/nex…
ijjk Mar 30, 2023
a73dbd1
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 30, 2023
25ddfe1
update middleware dev test
ijjk Mar 30, 2023
cf5d0b3
fix i18n cases
ijjk Mar 30, 2023
969014b
update i18n + basePath case
ijjk Mar 30, 2023
9f57f1b
Fix babel test case
ijjk Mar 30, 2023
33a82d0
fix query and WebSocket cases
ijjk Mar 30, 2023
5db66e1
fix middleware/cookie merging case
ijjk Mar 30, 2023
6f62bd7
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 30, 2023
7e6614d
fix prerender encoding case
ijjk Mar 30, 2023
7832f9c
fix fallback-false-rewrite case
ijjk Mar 30, 2023
b9d6b89
fix edge-render-gssp case
ijjk Mar 30, 2023
46488c2
update fallback false handling
ijjk Mar 30, 2023
82b1cb0
update trace ignore handling
ijjk Mar 30, 2023
460aca4
fix 404 page test
ijjk Mar 30, 2023
36e0461
update opentelemetry test
ijjk Mar 30, 2023
7adebbb
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 31, 2023
1b760ec
Merge branch 'canary' into update/separate-route-resolving
ijjk Mar 31, 2023
780049b
fix turbopack resolver
ijjk Mar 31, 2023
00c87b0
Merge branch 'canary' into update/separate-route-resolving
ijjk Apr 1, 2023
4d16fa8
Merge branch 'canary' into update/separate-route-resolving
ijjk Apr 1, 2023
3089ced
fix set-cookie case
ijjk Apr 1, 2023
cddf497
fix 404 case
ijjk Apr 1, 2023
b10fbd1
Merge branch 'canary' into update/separate-route-resolving
ijjk Apr 1, 2023
3cf6a8b
Fix optional fallback case
ijjk Apr 1, 2023
9093ede
Merge branch 'canary' into update/separate-route-resolving
ijjk Apr 1, 2023
21eb76f
cleanup IPC handling a bit
ijjk Apr 2, 2023
c773702
Merge branch 'canary' into update/separate-route-resolving
ijjk Apr 2, 2023
85bc1e2
Merge branch 'canary' into update/separate-route-resolving
ijjk Apr 2, 2023
94ca08e
fix lint
ijjk Apr 2, 2023
38f738b
Merge branch 'canary' into update/separate-route-resolving
kodiakhq[bot] Apr 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next-env/index.ts
Expand Up @@ -10,7 +10,7 @@ export type LoadedEnvFiles = Array<{
contents: string
}>

let initialEnv: Env | undefined = undefined
export let initialEnv: Env | undefined = undefined
let combinedEnv: Env | undefined = undefined
let cachedLoadedEnvFiles: LoadedEnvFiles = []
let previousLoadedEnvFiles: LoadedEnvFiles = []
Expand Down
84 changes: 10 additions & 74 deletions packages/next/src/build/index.ts
Expand Up @@ -1783,79 +1783,7 @@ export default async function build(
'next-server.js.nft.json'
)

if (config.experimental.preCompiledNextServer) {
if (!ciEnvironment.hasNextSupport) {
Log.warn(
`"experimental.preCompiledNextServer" is currently optimized for environments with Next.js support, some features may not be supported`
)
}
const nextServerPath = require.resolve('next/dist/server/next-server')
await promises.rename(nextServerPath, `${nextServerPath}.bak`)

await promises.writeFile(
nextServerPath,
`module.exports = require('next/dist/compiled/next-server/next-server.js')`
)
const glob =
require('next/dist/compiled/glob') as typeof import('next/dist/compiled/glob')
const compiledFiles: string[] = []
const compiledNextServerFolder = path.dirname(
require.resolve('next/dist/compiled/next-server/next-server.js')
)

for (const compiledFolder of [
compiledNextServerFolder,
path.join(compiledNextServerFolder, '../react'),
path.join(compiledNextServerFolder, '../react-dom'),
path.join(compiledNextServerFolder, '../scheduler'),
]) {
const globResult = glob.sync('**/*', {
cwd: compiledFolder,
dot: true,
})

await Promise.all(
globResult.map(async (file) => {
const absolutePath = path.join(compiledFolder, file)
const statResult = await promises.stat(absolutePath)

if (statResult.isFile()) {
compiledFiles.push(absolutePath)
}
})
)
}

const externalLibFiles = [
'next/dist/shared/lib/server-inserted-html.js',
'next/dist/shared/lib/router-context.js',
'next/dist/shared/lib/loadable-context.js',
'next/dist/shared/lib/image-config-context.js',
'next/dist/shared/lib/image-config.js',
'next/dist/shared/lib/head-manager-context.js',
'next/dist/shared/lib/app-router-context.js',
'next/dist/shared/lib/amp-context.js',
'next/dist/shared/lib/hooks-client-context.js',
'next/dist/shared/lib/html-context.js',
]
for (const file of externalLibFiles) {
compiledFiles.push(require.resolve(file))
}
compiledFiles.push(nextServerPath)

await promises.writeFile(
nextServerTraceOutput,
JSON.stringify({
version: 1,
files: [...new Set(compiledFiles)].map((file) =>
path.relative(distDir, file)
),
} as {
version: number
files: string[]
})
)
} else if (config.outputFileTracing) {
if (config.outputFileTracing) {
let nodeFileTrace: any
if (config.experimental.turbotrace) {
if (!binding?.isWasm) {
Expand Down Expand Up @@ -2064,6 +1992,7 @@ export default async function build(
'**/*.d.ts',
'**/*.map',
'**/next/dist/pages/**/*',
'**/next/dist/compiled/jest-worker/**/*',
'**/next/dist/compiled/webpack/(bundle4|bundle5).js',
'**/node_modules/webpack5/**/*',
'**/next/dist/server/lib/squoosh/**/*.wasm',
Expand All @@ -2082,7 +2011,14 @@ export default async function build(
...additionalIgnores,
]
const ignoreFn = (pathname: string) => {
return isMatch(pathname, ignores, { contains: true, dot: true })
if (path.isAbsolute(pathname) && !pathname.startsWith(root)) {
return true
}

return isMatch(pathname, ignores, {
contains: true,
dot: true,
})
}
const traceContext = path.join(nextServerEntry, '..', '..')
const tracedFiles = new Set<string>()
Expand Down
9 changes: 8 additions & 1 deletion packages/next/src/build/output/index.ts
Expand Up @@ -95,7 +95,14 @@ export function formatAmpMessages(amp: AmpPageStatus) {
return output
}

const buildStore = createStore<BuildStatusStore>()
const buildStore = createStore<BuildStatusStore>({
// @ts-expect-error initial value
client: {},
// @ts-expect-error initial value
server: {},
// @ts-expect-error initial value
edgeServer: {},
})
let buildWasDone = false
let clientWasLoading = true
let serverWasLoading = true
Expand Down
Expand Up @@ -16,7 +16,30 @@ const originModules = [

const RUNTIME_NAMES = ['webpack-runtime', 'webpack-api-runtime']

function deleteCache(filePath: string) {
export function deleteAppClientCache() {
if ((global as any)._nextDeleteAppClientCache) {
;(global as any)._nextDeleteAppClientCache()
}
// ensure we reset the cache for sc_server components
// loaded via react-server-dom-webpack
const reactServerDomModId = require.resolve(
'next/dist/compiled/react-server-dom-webpack/client.edge'
)
const reactServerDomMod = require.cache[reactServerDomModId]

if (reactServerDomMod) {
for (const child of reactServerDomMod.children) {
child.parent = null
delete require.cache[child.id]
}
}
delete require.cache[reactServerDomModId]
}

export function deleteCache(filePath: string) {
if ((global as any)._nextDeleteCache) {
;(global as any)._nextDeleteCache(filePath)
}
try {
filePath = realpathSync(filePath)
} catch (e) {
Expand Down Expand Up @@ -82,20 +105,6 @@ export class NextJsRequireCacheHotReloader implements WebpackPluginInstance {
})

if (hasAppPath) {
// ensure we reset the cache for sc_server components
// loaded via react-server-dom-webpack
const reactServerDomModId = require.resolve(
'next/dist/compiled/react-server-dom-webpack/client.edge'
)
const reactServerDomMod = require.cache[reactServerDomModId]

if (reactServerDomMod) {
for (const child of reactServerDomMod.children) {
child.parent = null
delete require.cache[child.id]
}
}
delete require.cache[reactServerDomModId]
}

entries.forEach((page) => {
Expand Down