Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
affbe743
Unverified
Commit
affbe743
authored
Dec 10, 2024
by
JJ Kasper
Committed by
GitHub
Dec 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete code from flying shuttle experiment (#73710)
parent
657c2cbd
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
9 additions
and
2025 deletions
+9
-2025
collect-build-traces.ts
packages/next/src/build/collect-build-traces.ts
+1
-26
entries.ts
packages/next/src/build/entries.ts
+0
-2
detect-changed-entries.ts
...s/next/src/build/flying-shuttle/detect-changed-entries.ts
+0
-311
inline-static-env.ts
packages/next/src/build/flying-shuttle/inline-static-env.ts
+0
-72
stitch-builds.ts
packages/next/src/build/flying-shuttle/stitch-builds.ts
+0
-483
store-shuttle.ts
packages/next/src/build/flying-shuttle/store-shuttle.ts
+0
-113
index.ts
packages/next/src/build/index.ts
+1
-197
webpack-config.ts
packages/next/src/build/webpack-config.ts
+2
-42
index.ts
...s/next/src/build/webpack/loaders/next-app-loader/index.ts
+3
-19
define-env-plugin.ts
packages/next/src/build/webpack/plugins/define-env-plugin.ts
+1
-19
next-trace-entrypoints-plugin.ts
...rc/build/webpack/plugins/next-trace-entrypoints-plugin.ts
+0
-193
config-schema.ts
packages/next/src/server/config-schema.ts
+0
-7
config-shared.ts
packages/next/src/server/config-shared.ts
+1
-7
router.ts
packages/next/src/shared/lib/router/router.ts
+0
-7
flying-shuttle.test.ts
test/e2e/app-dir/app/flying-shuttle.test.ts
+0
-455
next.config.js
test/e2e/app-dir/app/next.config.js
+0
-11
page.js
.../e2e/instrumentation-hook/flying-shuttle/app/edge/page.js
+0
-5
layout.js
test/e2e/instrumentation-hook/flying-shuttle/app/layout.js
+0
-7
page.js
test/e2e/instrumentation-hook/flying-shuttle/app/page.js
+0
-5
flying-shuttle.test.ts
...nstrumentation-hook/flying-shuttle/flying-shuttle.test.ts
+0
-31
instrumentation.js
...2e/instrumentation-hook/flying-shuttle/instrumentation.js
+0
-3
next.config.js
test/e2e/instrumentation-hook/flying-shuttle/next.config.js
+0
-10
No files found.
packages/next/src/build/collect-build-traces.ts
View file @
affbe743
...
@@ -5,7 +5,6 @@ import {
...
@@ -5,7 +5,6 @@ import {
TRACE_IGNORES
,
TRACE_IGNORES
,
type
BuildTraceContext
,
type
BuildTraceContext
,
getFilesMapFromReasons
,
getFilesMapFromReasons
,
getHash
,
}
from
'./webpack/plugins/next-trace-entrypoints-plugin'
}
from
'./webpack/plugins/next-trace-entrypoints-plugin'
import
path
from
'path'
import
path
from
'path'
...
@@ -24,8 +23,6 @@ import type { RoutesUsingEdgeRuntime } from './utils'
...
@@ -24,8 +23,6 @@ import type { RoutesUsingEdgeRuntime } from './utils'
const
debug
=
debugOriginal
(
'next:build:build-traces'
)
const
debug
=
debugOriginal
(
'next:build:build-traces'
)
const
hashCache
:
Record
<
string
,
string
>
=
{}
function
shouldIgnore
(
function
shouldIgnore
(
file
:
string
,
file
:
string
,
serverIgnoreFn
:
(
file
:
string
)
=>
boolean
,
serverIgnoreFn
:
(
file
:
string
)
=>
boolean
,
...
@@ -85,13 +82,11 @@ export async function collectBuildTraces({
...
@@ -85,13 +82,11 @@ export async function collectBuildTraces({
hasSsrAmpPages
,
hasSsrAmpPages
,
buildTraceContext
,
buildTraceContext
,
outputFileTracingRoot
,
outputFileTracingRoot
,
isFlyingShuttle
,
}:
{
}:
{
dir
:
string
dir
:
string
distDir
:
string
distDir
:
string
staticPages
:
string
[]
staticPages
:
string
[]
hasSsrAmpPages
:
boolean
hasSsrAmpPages
:
boolean
isFlyingShuttle
?:
boolean
outputFileTracingRoot
:
string
outputFileTracingRoot
:
string
// pageInfos is serialized when this function runs in a worker.
// pageInfos is serialized when this function runs in a worker.
edgeRuntimeRoutes
:
RoutesUsingEdgeRuntime
edgeRuntimeRoutes
:
RoutesUsingEdgeRuntime
...
@@ -421,7 +416,7 @@ export async function collectBuildTraces({
...
@@ -421,7 +416,7 @@ export async function collectBuildTraces({
// pages as they don't have server bundles, note there is
// pages as they don't have server bundles, note there is
// the caveat with flying shuttle mode as it needs this for
// the caveat with flying shuttle mode as it needs this for
// detecting changed entries
// detecting changed entries
if
(
staticPages
.
includes
(
route
)
&&
!
isFlyingShuttle
)
{
if
(
staticPages
.
includes
(
route
))
{
return
return
}
}
const
entryOutputPath
=
path
.
join
(
const
entryOutputPath
=
path
.
join
(
...
@@ -439,8 +434,6 @@ export async function collectBuildTraces({
...
@@ -439,8 +434,6 @@ export async function collectBuildTraces({
}
}
const
traceOutputDir
=
path
.
dirname
(
traceOutputPath
)
const
traceOutputDir
=
path
.
dirname
(
traceOutputPath
)
const
curTracedFiles
=
new
Set
<
string
>
()
const
curTracedFiles
=
new
Set
<
string
>
()
const
curFileHashes
:
Record
<
string
,
string
>
=
existingTrace
.
fileHashes
for
(
const
file
of
[...
entryNameFiles
,
entryOutputPath
])
{
for
(
const
file
of
[...
entryNameFiles
,
entryOutputPath
])
{
const
curFiles
=
[
const
curFiles
=
[
...
@@ -462,19 +455,6 @@ export async function collectBuildTraces({
...
@@ -462,19 +455,6 @@ export async function collectBuildTraces({
.
relative
(
traceOutputDir
,
filePath
)
.
relative
(
traceOutputDir
,
filePath
)
.
replace
(
/
\\
/g
,
'/'
)
.
replace
(
/
\\
/g
,
'/'
)
curTracedFiles
.
add
(
outputFile
)
curTracedFiles
.
add
(
outputFile
)
if
(
isFlyingShuttle
)
{
try
{
let
hash
=
hashCache
[
filePath
]
if
(
!
hash
)
{
hash
=
getHash
(
await
fs
.
readFile
(
filePath
))
}
curFileHashes
[
outputFile
]
=
hash
}
catch
(
err
:
any
)
{
// handle symlink errors or similar
}
}
}
}
}
}
}
}
...
@@ -488,11 +468,6 @@ export async function collectBuildTraces({
...
@@ -488,11 +468,6 @@ export async function collectBuildTraces({
JSON
.
stringify
({
JSON
.
stringify
({
...
existingTrace
,
...
existingTrace
,
files
:
[...
curTracedFiles
].
sort
(),
files
:
[...
curTracedFiles
].
sort
(),
...(
isFlyingShuttle
?
{
fileHashes
:
curFileHashes
,
}
:
{}),
})
})
)
)
})
})
...
...
packages/next/src/build/entries.ts
View file @
affbe743
...
@@ -675,7 +675,6 @@ export async function createEntrypoints(
...
@@ -675,7 +675,6 @@ export async function createEntrypoints(
basePath
:
config
.
basePath
,
basePath
:
config
.
basePath
,
assetPrefix
:
config
.
assetPrefix
,
assetPrefix
:
config
.
assetPrefix
,
nextConfigOutput
:
config
.
output
,
nextConfigOutput
:
config
.
output
,
flyingShuttle
:
Boolean
(
config
.
experimental
.
flyingShuttle
),
nextConfigExperimentalUseEarlyImport
:
config
.
experimental
nextConfigExperimentalUseEarlyImport
:
config
.
experimental
.
useEarlyImport
.
useEarlyImport
?
true
?
true
...
@@ -741,7 +740,6 @@ export async function createEntrypoints(
...
@@ -741,7 +740,6 @@ export async function createEntrypoints(
basePath
:
config
.
basePath
,
basePath
:
config
.
basePath
,
assetPrefix
:
config
.
assetPrefix
,
assetPrefix
:
config
.
assetPrefix
,
nextConfigOutput
:
config
.
output
,
nextConfigOutput
:
config
.
output
,
flyingShuttle
:
Boolean
(
config
.
experimental
.
flyingShuttle
),
// This isn't used with edge as it needs to be set on the entry module, which will be the `edgeServerEntry` instead.
// This isn't used with edge as it needs to be set on the entry module, which will be the `edgeServerEntry` instead.
// Still passing it here for consistency.
// Still passing it here for consistency.
preferredRegion
:
staticInfo
.
preferredRegion
,
preferredRegion
:
staticInfo
.
preferredRegion
,
...
...
packages/next/src/build/flying-shuttle/detect-changed-entries.ts
deleted
100644 → 0
View file @
657c2cbd
import
fs
from
'fs'
import
path
from
'path'
import
crypto
from
'crypto'
import
{
execSync
}
from
'child_process'
import
{
getPageFromPath
}
from
'../entries'
import
originalDebug
from
'next/dist/compiled/debug'
import
{
Sema
}
from
'next/dist/compiled/async-sema'
import
{
generateShuttleManifest
,
type
ShuttleManifest
}
from
'./store-shuttle'
import
type
{
NextConfigComplete
}
from
'../../server/config-shared'
import
{
updateIncrementalBuildMetrics
}
from
'../../diagnostics/build-diagnostics'
const
debug
=
originalDebug
(
'next:build:flying-shuttle'
)
export
interface
DetectedEntriesResult
{
app
:
string
[]
pages
:
string
[]
}
function
deepEqual
(
obj1
:
any
,
obj2
:
any
)
{
if
(
obj1
===
obj2
)
return
true
if
(
typeof
obj1
!==
'object'
||
obj1
===
null
||
typeof
obj2
!==
'object'
||
obj2
===
null
)
{
return
false
}
let
keys1
=
Object
.
keys
(
obj1
)
let
keys2
=
Object
.
keys
(
obj2
)
if
(
keys1
.
length
!==
keys2
.
length
)
return
false
for
(
let
key
of
keys1
)
{
if
(
!
keys2
.
includes
(
key
)
||
!
deepEqual
(
obj1
[
key
],
obj2
[
key
]))
{
return
false
}
}
return
true
}
let
_hasShuttle
:
undefined
|
boolean
=
undefined
export
async
function
hasShuttle
(
config
:
NextConfigComplete
,
shuttleDir
:
string
)
{
if
(
typeof
_hasShuttle
===
'boolean'
)
{
return
_hasShuttle
}
let
foundShuttleManifest
:
ShuttleManifest
async
function
pruneCache
()
{
await
fs
.
promises
.
rm
(
shuttleDir
,
{
force
:
true
,
recursive
:
true
})
await
fs
.
promises
.
mkdir
(
shuttleDir
,
{
recursive
:
true
})
}
try
{
foundShuttleManifest
=
JSON
.
parse
(
await
fs
.
promises
.
readFile
(
path
.
join
(
shuttleDir
,
'shuttle-manifest.json'
),
'utf8'
)
)
_hasShuttle
=
true
}
catch
(
err
:
unknown
)
{
_hasShuttle
=
false
console
.
log
(
`Failed to read shuttle manifest`
)
// prune potentially corrupted cache
await
pruneCache
()
return
_hasShuttle
}
const
currentShuttleManifest
=
JSON
.
parse
(
generateShuttleManifest
(
config
)
)
as
ShuttleManifest
if
(
currentShuttleManifest
.
nextVersion
!==
foundShuttleManifest
.
nextVersion
)
{
// we don't allow using shuttle from differing Next.js version
// as it could have internal changes
console
.
log
(
`shuttle has differing Next.js version
${
foundShuttleManifest
.
nextVersion
}
versus current
${
currentShuttleManifest
.
nextVersion
}
, skipping.`
)
_hasShuttle
=
false
}
if
(
!
deepEqual
(
currentShuttleManifest
.
config
,
foundShuttleManifest
.
config
))
{
_hasShuttle
=
false
console
.
log
(
`Mismatching shuttle configs`
,
currentShuttleManifest
.
config
,
foundShuttleManifest
.
config
)
}
if
(
_hasShuttle
)
{
let
currentGitSha
=
''
try
{
currentGitSha
=
execSync
(
'git rev-parse HEAD'
).
toString
().
trim
()
}
catch
(
_
)
{}
await
updateIncrementalBuildMetrics
({
currentGitSha
,
shuttleGitSha
:
currentShuttleManifest
.
gitSha
,
})
}
else
{
// prune mis-matching cache
await
pruneCache
()
}
return
_hasShuttle
}
export
async
function
detectChangedEntries
({
appPaths
,
pagesPaths
,
pageExtensions
,
distDir
,
shuttleDir
,
config
,
}:
{
appPaths
?:
string
[]
pagesPaths
?:
string
[]
pageExtensions
:
string
[]
distDir
:
string
shuttleDir
:
string
config
:
NextConfigComplete
}):
Promise
<
{
changed
:
DetectedEntriesResult
unchanged
:
DetectedEntriesResult
}
>
{
const
changedEntries
:
{
app
:
string
[]
pages
:
string
[]
}
=
{
app
:
[],
pages
:
[],
}
const
unchangedEntries
:
typeof
changedEntries
=
{
app
:
[],
pages
:
[],
}
if
(
!
(
await
hasShuttle
(
config
,
shuttleDir
)))
{
// no shuttle so consider everything changed
console
.
log
(
`no shuttle. can't detect changes`
)
return
{
changed
:
{
pages
:
pagesPaths
||
[],
app
:
appPaths
||
[],
},
unchanged
:
{
pages
:
[],
app
:
[],
},
}
}
const
hashCache
=
new
Map
<
string
,
string
>
()
async
function
computeHash
(
p
:
string
):
Promise
<
string
>
{
let
hash
=
hashCache
.
get
(
p
)
if
(
hash
)
{
return
hash
}
return
new
Promise
((
resolve
,
reject
)
=>
{
const
hashInst
=
crypto
.
createHash
(
'sha1'
)
const
stream
=
fs
.
createReadStream
(
p
)
stream
.
on
(
'error'
,
(
err
)
=>
reject
(
err
))
stream
.
on
(
'data'
,
(
chunk
)
=>
hashInst
.
update
(
chunk
))
stream
.
on
(
'end'
,
()
=>
{
const
digest
=
hashInst
.
digest
(
'hex'
)
resolve
(
digest
)
hashCache
.
set
(
p
,
digest
)
})
})
}
const
hashSema
=
new
Sema
(
16
)
let
globalEntryChanged
=
false
const
changedDependencies
:
Record
<
string
,
string
>
=
{}
async
function
detectChange
({
normalizedEntry
,
entry
,
type
,
}:
{
entry
:
string
normalizedEntry
:
string
type
:
keyof
typeof
changedEntries
})
{
const
traceFile
=
path
.
join
(
shuttleDir
,
'server'
,
type
,
`
${
normalizedEntry
}
.js.nft.json`
)
let
changed
=
true
// we don't need to check any further entry's dependencies if
// a global entry changed since that invalidates everything
if
(
!
globalEntryChanged
)
{
try
{
const
traceData
:
{
fileHashes
:
Record
<
string
,
string
>
}
=
JSON
.
parse
(
await
fs
.
promises
.
readFile
(
traceFile
,
'utf8'
))
if
(
traceData
)
{
let
changedDependency
=
false
await
Promise
.
all
(
Object
.
keys
(
traceData
.
fileHashes
).
map
(
async
(
file
)
=>
{
try
{
if
(
changedDependency
)
return
await
hashSema
.
acquire
()
const
relativeTraceFile
=
path
.
relative
(
path
.
join
(
shuttleDir
,
'server'
,
type
),
traceFile
)
const
originalTraceFile
=
path
.
join
(
distDir
,
'server'
,
type
,
relativeTraceFile
)
const
absoluteFile
=
path
.
join
(
path
.
dirname
(
originalTraceFile
),
file
)
if
(
absoluteFile
.
startsWith
(
distDir
))
{
return
}
const
prevHash
=
traceData
.
fileHashes
[
file
]
const
curHash
=
await
computeHash
(
absoluteFile
)
if
(
prevHash
!==
curHash
)
{
changedDependencies
[
normalizedEntry
]
=
file
debug
(
'detected change on'
,
{
prevHash
,
curHash
,
file
,
entry
:
normalizedEntry
,
})
changedDependency
=
true
}
}
finally
{
hashSema
.
release
()
}
})
)
if
(
!
changedDependency
)
{
changed
=
false
}
}
else
{
console
.
error
(
'missing trace data'
,
traceFile
,
normalizedEntry
)
}
}
catch
(
err
)
{
console
.
error
(
`Failed to detect change for
${
entry
}
${
normalizedEntry
}
`
,
err
)
}
}
// we always rebuild global entries so we have a version
// that matches the newest build/runtime
const
isGlobalEntry
=
/
(
_app|_document|_error
)
/
.
test
(
entry
)
if
(
changed
||
isGlobalEntry
)
{
// if a global entry changed all entries are changed
if
(
changed
&&
!
globalEntryChanged
&&
isGlobalEntry
)
{
console
.
log
(
`global entry
${
entry
}
changed invalidating all entries`
)
globalEntryChanged
=
true
// move unchanged to changed
changedEntries
[
type
].
push
(...
unchangedEntries
[
type
])
}
changedEntries
[
type
].
push
(
entry
)
}
else
{
unchangedEntries
[
type
].
push
(
entry
)
}
}
// loop over entries and their dependency's hashes
// to detect which changed
for
(
const
entry
of
pagesPaths
||
[])
{
let
normalizedEntry
=
getPageFromPath
(
entry
,
pageExtensions
)
if
(
normalizedEntry
===
'/'
)
{
normalizedEntry
=
'/index'
}
await
detectChange
({
entry
,
normalizedEntry
,
type
:
'pages'
})
}
for
(
const
entry
of
appPaths
||
[])
{
let
normalizedEntry
=
getPageFromPath
(
entry
,
pageExtensions
)
if
(
normalizedEntry
===
'/not-found'
)
{
normalizedEntry
=
'/_not-found/page'
}
await
detectChange
({
entry
,
normalizedEntry
,
type
:
'app'
})
}
await
updateIncrementalBuildMetrics
({
changedDependencies
})
return
{
changed
:
changedEntries
,
unchanged
:
unchangedEntries
,
}
}
packages/next/src/build/flying-shuttle/inline-static-env.ts
deleted
100644 → 0
View file @
657c2cbd
import
fs
from
'fs'
import
path
from
'path'
import
{
promisify
}
from
'util'
import
globOriginal
from
'next/dist/compiled/glob'
import
{
getNextConfigEnv
,
getNextPublicEnvironmentVariables
,
}
from
'../webpack/plugins/define-env-plugin'
import
{
Sema
}
from
'next/dist/compiled/async-sema'
import
type
{
NextConfigComplete
}
from
'../../server/config-shared'
const
glob
=
promisify
(
globOriginal
)
export
async
function
inlineStaticEnv
({
distDir
,
config
,
}:
{
distDir
:
string
config
:
NextConfigComplete
})
{
const
nextConfigEnv
=
getNextConfigEnv
(
config
)
const
staticEnv
=
{
...
getNextPublicEnvironmentVariables
(),
...
nextConfigEnv
,
}
const
serverDir
=
path
.
join
(
distDir
,
'server'
)
const
serverChunks
=
await
glob
(
'**/*.js'
,
{
cwd
:
serverDir
,
})
const
clientDir
=
path
.
join
(
distDir
,
'static'
)
const
clientChunks
=
await
glob
(
'**/*.js'
,
{
cwd
:
clientDir
,
})
const
inlineSema
=
new
Sema
(
8
)
const
nextConfigEnvKeys
=
Object
.
keys
(
nextConfigEnv
).
map
((
item
)
=>
item
.
split
(
'process.env.'
).
pop
()
)
const
builtRegEx
=
new
RegExp
(
`[\\w]{1,}\\.env\\.(?:NEXT_PUBLIC_[\\w]{1,}
${
nextConfigEnvKeys
.
length
?
'|'
+
nextConfigEnvKeys
.
join
(
'|'
)
:
''
}
)`
,
'g'
)
for
(
const
[
parentDir
,
files
]
of
[
[
serverDir
,
serverChunks
],
[
clientDir
,
clientChunks
],
]
as
const
)
{
await
Promise
.
all
(
files
.
map
(
async
(
file
)
=>
{
await
inlineSema
.
acquire
()
const
filepath
=
path
.
join
(
parentDir
,
file
)
const
content
=
await
fs
.
promises
.
readFile
(
filepath
,
'utf8'
)
await
fs
.
promises
.
writeFile
(
filepath
,
content
.
replace
(
builtRegEx
,
(
match
)
=>
{
let
normalizedMatch
=
`process.env.
${
match
.
split
(
'.'
).
pop
()}
`
if
(
staticEnv
[
normalizedMatch
])
{
return
JSON
.
stringify
(
staticEnv
[
normalizedMatch
])
}
return
match
})
)
inlineSema
.
release
()
})
)
}
}
packages/next/src/build/flying-shuttle/stitch-builds.ts
deleted
100644 → 0
View file @
657c2cbd
This diff is collapsed.
Click to expand it.
packages/next/src/build/flying-shuttle/store-shuttle.ts
deleted
100644 → 0
View file @
657c2cbd
import
fs
from
'fs'
import
path
from
'path'
import
{
execSync
}
from
'child_process'
import
{
recursiveCopy
}
from
'../../lib/recursive-copy'
import
{
version
as
nextVersion
}
from
'next/package.json'
import
type
{
NextConfigComplete
}
from
'../../server/config-shared'
import
{
BUILD_MANIFEST
,
APP_BUILD_MANIFEST
,
REACT_LOADABLE_MANIFEST
,
APP_PATH_ROUTES_MANIFEST
,
PAGES_MANIFEST
,
ROUTES_MANIFEST
,
}
from
'../../shared/lib/constants'
export
interface
ShuttleManifest
{
nextVersion
:
string
config
:
Record
<
string
,
any
>
gitSha
?:
string
}
export
function
generateShuttleManifest
(
config
:
NextConfigComplete
)
{
let
gitSha
=
''
try
{
gitSha
=
execSync
(
'git rev-parse HEAD'
).
toString
().
trim
()
}
catch
(
_
)
{}
return
JSON
.
stringify
({
gitSha
,
nextVersion
,
config
:
{
i18n
:
config
.
i18n
,
basePath
:
config
.
basePath
,
sassOptions
:
config
.
sassOptions
,
trailingSlash
:
config
.
trailingSlash
,
experimental
:
{
ppr
:
config
.
experimental
.
ppr
,
reactCompiler
:
config
.
experimental
.
reactCompiler
,
},
},
}
satisfies
ShuttleManifest
)
}
// we can create a new shuttle with the outputs before env values have
// been inlined, can be done after stitching takes place
export
async
function
storeShuttle
({
config
,
distDir
,
shuttleDir
,
}:
{
distDir
:
string
shuttleDir
:
string
config
:
NextConfigComplete
})
{
await
fs
.
promises
.
rm
(
shuttleDir
,
{
force
:
true
,
recursive
:
true
})
await
fs
.
promises
.
mkdir
(
shuttleDir
,
{
recursive
:
true
})
await
fs
.
promises
.
writeFile
(
path
.
join
(
shuttleDir
,
'shuttle-manifest.json'
),
generateShuttleManifest
(
config
)
)
// copy all server entries
await
recursiveCopy
(
path
.
join
(
distDir
,
'server'
),
path
.
join
(
shuttleDir
,
'server'
),
{
filter
(
item
)
{
return
!
item
.
match
(
/
\.(
rsc|meta|html
)
$/
)
},
}
)
const
pagesManifest
=
JSON
.
parse
(
await
fs
.
promises
.
readFile
(
path
.
join
(
shuttleDir
,
'server'
,
PAGES_MANIFEST
),
'utf8'
)
)
// ensure manifest isn't modified to .html as it's before static gen
for
(
const
key
of
Object
.
keys
(
pagesManifest
))
{
pagesManifest
[
key
]
=
pagesManifest
[
key
].
replace
(
/
\.
html$/
,
'.js'
)
}
await
fs
.
promises
.
writeFile
(
path
.
join
(
shuttleDir
,
'server'
,
PAGES_MANIFEST
),
JSON
.
stringify
(
pagesManifest
)
)
// copy static assets
await
recursiveCopy
(
path
.
join
(
distDir
,
'static'
),
path
.
join
(
shuttleDir
,
'static'
)
)
// copy manifests not nested in {distDir}/server/
await
fs
.
promises
.
mkdir
(
path
.
join
(
shuttleDir
,
'manifests'
),
{
recursive
:
true
,
})
for
(
const
item
of
[
BUILD_MANIFEST
,
ROUTES_MANIFEST
,
APP_BUILD_MANIFEST
,
REACT_LOADABLE_MANIFEST
,
APP_PATH_ROUTES_MANIFEST
,
])
{
const
outputPath
=
path
.
join
(
shuttleDir
,
'manifests'
,
item
)
await
fs
.
promises
.
mkdir
(
path
.
dirname
(
outputPath
),
{
recursive
:
true
})
await
fs
.
promises
.
copyFile
(
path
.
join
(
distDir
,
item
),
outputPath
)
}
}
packages/next/src/build/index.ts
View file @
affbe743
This diff is collapsed.
Click to expand it.
packages/next/src/build/webpack-config.ts
View file @
affbe743
...
@@ -707,10 +707,6 @@ export default async function getBaseWebpackConfig(
...
@@ -707,10 +707,6 @@ export default async function getBaseWebpackConfig(
isNodeServer
?
new
OptionalPeerDependencyResolverPlugin
()
:
undefined
,
isNodeServer
?
new
OptionalPeerDependencyResolverPlugin
()
:
undefined
,
].
filter
(
Boolean
)
as
webpack
.
ResolvePluginInstance
[],
].
filter
(
Boolean
)
as
webpack
.
ResolvePluginInstance
[],
}
}
// we don't want to modify the outputs naming if we're
// in store-only mode
const
{
flyingShuttle
}
=
config
.
experimental
const
isFullFlyingShuttle
=
flyingShuttle
?.
mode
===
'full'
// Packages which will be split into the 'framework' chunk.
// Packages which will be split into the 'framework' chunk.
// Only top-level packages are included, e.g. nested copies like
// Only top-level packages are included, e.g. nested copies like
...
@@ -954,7 +950,7 @@ export default async function getBaseWebpackConfig(
...
@@ -954,7 +950,7 @@ export default async function getBaseWebpackConfig(
if
(
isNodeServer
||
isEdgeServer
)
{
if
(
isNodeServer
||
isEdgeServer
)
{
return
{
return
{
filename
:
`
${
isEdgeServer
?
`edge-chunks
${
isFullFlyingShuttle
?
`-
${
buildId
}
`
:
''
}
/`
:
''
}
[name].js`
,
filename
:
`
${
isEdgeServer
?
`edge-chunks/`
:
''
}
[name].js`
,
chunks
:
'all'
,
chunks
:
'all'
,
minChunks
:
2
,
minChunks
:
2
,
}
}
...
@@ -1131,35 +1127,6 @@ export default async function getBaseWebpackConfig(
...
@@ -1131,35 +1127,6 @@ export default async function getBaseWebpackConfig(
webassemblyModuleFilename
:
'static/wasm/[modulehash].wasm'
,
webassemblyModuleFilename
:
'static/wasm/[modulehash].wasm'
,
hashFunction
:
'xxhash64'
,
hashFunction
:
'xxhash64'
,
hashDigestLength
:
16
,
hashDigestLength
:
16
,
...(
isFullFlyingShuttle
?
{
// ensure we only use contenthash as it's more deterministic
filename
:
(
p
)
=>
{
if
(
isNodeOrEdgeCompilation
)
{
// runtime chunk needs hash so it can be isolated
// across builds
const
isRuntimeChunk
=
p
.
chunk
?.
name
?.
match
(
/webpack-
(
api-runtime|runtime
)
/
)
return
`
${
isEdgeServer
?
''
:
'../'
}
[name]
${
isRuntimeChunk
?
`-
${
buildId
}
`
:
''
}
.js`
}
// client filename
return
`static/chunks/[name]-[contenthash].js`
},
path
:
!
dev
&&
isNodeServer
?
path
.
join
(
outputPath
,
`chunks-
${
buildId
}
`
)
:
outputPath
,
chunkFilename
:
isNodeOrEdgeCompilation
?
`[name].js`
:
`static/chunks/[contenthash].js`
,
webassemblyModuleFilename
:
'static/wasm/[contenthash].wasm'
,
}
:
{}),
},
},
performance
:
false
,
performance
:
false
,
resolve
:
resolveConfig
,
resolve
:
resolveConfig
,
...
@@ -1795,7 +1762,7 @@ export default async function getBaseWebpackConfig(
...
@@ -1795,7 +1762,7 @@ export default async function getBaseWebpackConfig(
dev
,
dev
,
}),
}),
(
isClient
||
isEdgeServer
)
&&
new
DropClientPage
(),
(
isClient
||
isEdgeServer
)
&&
new
DropClientPage
(),
(
isNodeServer
||
(
flyingShuttle
&&
isEdgeServer
))
&&
isNodeServer
&&
!
dev
&&
!
dev
&&
new
(
require
(
'./webpack/plugins/next-trace-entrypoints-plugin'
)
new
(
require
(
'./webpack/plugins/next-trace-entrypoints-plugin'
)
.
TraceEntryPointsPlugin
as
typeof
import
(
'./webpack/plugins/next-trace-entrypoints-plugin'
).
TraceEntryPointsPlugin
)(
.
TraceEntryPointsPlugin
as
typeof
import
(
'./webpack/plugins/next-trace-entrypoints-plugin'
).
TraceEntryPointsPlugin
)(
...
@@ -1808,7 +1775,6 @@ export default async function getBaseWebpackConfig(
...
@@ -1808,7 +1775,6 @@ export default async function getBaseWebpackConfig(
appDirEnabled
:
hasAppDir
,
appDirEnabled
:
hasAppDir
,
optOutBundlingPackages
,
optOutBundlingPackages
,
traceIgnores
:
[],
traceIgnores
:
[],
flyingShuttle
:
Boolean
(
flyingShuttle
),
compilerType
,
compilerType
,
swcLoaderConfig
:
swcDefaultLoader
,
swcLoaderConfig
:
swcDefaultLoader
,
}
}
...
@@ -2101,7 +2067,6 @@ export default async function getBaseWebpackConfig(
...
@@ -2101,7 +2067,6 @@ export default async function getBaseWebpackConfig(
imageLoaderFile
:
config
.
images
.
loaderFile
,
imageLoaderFile
:
config
.
images
.
loaderFile
,
clientTraceMetadata
:
config
.
experimental
.
clientTraceMetadata
,
clientTraceMetadata
:
config
.
experimental
.
clientTraceMetadata
,
serverSourceMaps
:
config
.
experimental
.
serverSourceMaps
,
serverSourceMaps
:
config
.
experimental
.
serverSourceMaps
,
flyingShuttle
:
config
.
experimental
.
flyingShuttle
,
serverReferenceHashSalt
:
encryptionKey
,
serverReferenceHashSalt
:
encryptionKey
,
})
})
...
@@ -2281,11 +2246,6 @@ export default async function getBaseWebpackConfig(
...
@@ -2281,11 +2246,6 @@ export default async function getBaseWebpackConfig(
)
)
}
}
}
}
if
(
isFullFlyingShuttle
&&
!
dev
)
{
webpack5Config
.
cache
=
false
}
const
rules
=
webpackConfig
.
module
?.
rules
||
[]
const
rules
=
webpackConfig
.
module
?.
rules
||
[]
const
customSvgRule
=
rules
.
find
(
const
customSvgRule
=
rules
.
find
(
...
...
packages/next/src/build/webpack/loaders/next-app-loader/index.ts
View file @
affbe743
...
@@ -47,7 +47,6 @@ export type AppLoaderOptions = {
...
@@ -47,7 +47,6 @@ export type AppLoaderOptions = {
tsconfigPath
?:
string
tsconfigPath
?:
string
isDev
?:
true
isDev
?:
true
basePath
:
string
basePath
:
string
flyingShuttle
?:
boolean
nextConfigOutput
?:
NextConfig
[
'output'
]
nextConfigOutput
?:
NextConfig
[
'output'
]
nextConfigExperimentalUseEarlyImport
?:
true
nextConfigExperimentalUseEarlyImport
?:
true
middlewareConfig
:
string
middlewareConfig
:
string
...
@@ -123,13 +122,9 @@ async function createTreeCodeFromPath(
...
@@ -123,13 +122,9 @@ async function createTreeCodeFromPath(
metadataResolver
,
metadataResolver
,
pageExtensions
,
pageExtensions
,
basePath
,
basePath
,
buildInfo
,
flyingShuttle
,
collectedDeclarations
,
collectedDeclarations
,
}:
{
}:
{
page
:
string
page
:
string
flyingShuttle
?:
boolean
buildInfo
:
ReturnType
<
typeof
getModuleBuildInfo
>
resolveDir
:
DirResolver
resolveDir
:
DirResolver
resolver
:
PathResolver
resolver
:
PathResolver
metadataResolver
:
MetadataResolver
metadataResolver
:
MetadataResolver
...
@@ -299,15 +294,9 @@ async function createTreeCodeFromPath(
...
@@ -299,15 +294,9 @@ async function createTreeCodeFromPath(
})
})
)
)
const
definedFilePaths
=
filePaths
.
filter
(([,
filePath
])
=>
{
const
definedFilePaths
=
filePaths
.
filter
(
if
(
filePath
!==
undefined
)
{
([,
filePath
])
=>
filePath
!==
undefined
if
(
flyingShuttle
&&
buildInfo
.
route
?.
relatedModules
)
{
)
as
[
ValueOf
<
typeof
FILE_TYPES
>
,
string
][]
buildInfo
.
route
.
relatedModules
.
push
(
filePath
)
}
return
true
}
return
false
})
as
[
ValueOf
<
typeof
FILE_TYPES
>
,
string
][]
// Add default access fallback as root fallback if not present
// Add default access fallback as root fallback if not present
const
existedConventionNames
=
new
Set
(
const
existedConventionNames
=
new
Set
(
...
@@ -502,7 +491,6 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
...
@@ -502,7 +491,6 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
nextConfigOutput
,
nextConfigOutput
,
preferredRegion
,
preferredRegion
,
basePath
,
basePath
,
flyingShuttle
,
middlewareConfig
:
middlewareConfigBase64
,
middlewareConfig
:
middlewareConfigBase64
,
nextConfigExperimentalUseEarlyImport
,
nextConfigExperimentalUseEarlyImport
,
}
=
loaderOptions
}
=
loaderOptions
...
@@ -698,8 +686,6 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
...
@@ -698,8 +686,6 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
pageExtensions
,
pageExtensions
,
basePath
,
basePath
,
collectedDeclarations
,
collectedDeclarations
,
buildInfo
,
flyingShuttle
,
})
})
if
(
!
treeCodeResult
.
rootLayout
)
{
if
(
!
treeCodeResult
.
rootLayout
)
{
...
@@ -749,8 +735,6 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
...
@@ -749,8 +735,6 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
pageExtensions,
pageExtensions,
basePath,
basePath,
collectedDeclarations,
collectedDeclarations,
buildInfo,
flyingShuttle,
})
})
}
}
}
}
...
...
packages/next/src/build/webpack/plugins/define-env-plugin.ts
View file @
affbe743
...
@@ -207,9 +207,6 @@ export function getDefineEnv({
...
@@ -207,9 +207,6 @@ export function getDefineEnv({
?
5
*
60
// 5 minutes
?
5
*
60
// 5 minutes
:
config
.
experimental
.
staleTimes
?.
static
:
config
.
experimental
.
staleTimes
?.
static
),
),
'process.env.__NEXT_FLYING_SHUTTLE'
:
Boolean
(
config
.
experimental
.
flyingShuttle
),
'process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED'
:
'process.env.__NEXT_CLIENT_ROUTER_FILTER_ENABLED'
:
config
.
experimental
.
clientRouterFilter
??
true
,
config
.
experimental
.
clientRouterFilter
??
true
,
'process.env.__NEXT_CLIENT_ROUTER_S_FILTER'
:
'process.env.__NEXT_CLIENT_ROUTER_S_FILTER'
:
...
@@ -303,22 +300,7 @@ export function getDefineEnv({
...
@@ -303,22 +300,7 @@ export function getDefineEnv({
defineEnv
[
key
]
=
userDefines
[
key
]
defineEnv
[
key
]
=
userDefines
[
key
]
}
}
const
serializedDefineEnv
=
serializeDefineEnv
(
defineEnv
)
return
serializeDefineEnv
(
defineEnv
)
if
(
!
dev
&&
Boolean
(
config
.
experimental
.
flyingShuttle
))
{
// we delay inlining these values until after the build
// with flying shuttle enabled so we can update them
// without invalidating entries
for
(
const
key
in
nextPublicEnv
)
{
serializedDefineEnv
[
key
]
=
key
}
for
(
const
key
in
nextConfigEnv
)
{
serializedDefineEnv
[
key
]
=
key
}
}
return
serializedDefineEnv
}
}
export
function
getDefineEnvPlugin
(
options
:
DefineEnvPluginOptions
)
{
export
function
getDefineEnvPlugin
(
options
:
DefineEnvPluginOptions
)
{
...
...
packages/next/src/build/webpack/plugins/next-trace-entrypoints-plugin.ts
View file @
affbe743
This diff is collapsed.
Click to expand it.
packages/next/src/server/config-schema.ts
View file @
affbe743
...
@@ -307,13 +307,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
...
@@ -307,13 +307,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
externalMiddlewareRewritesResolve
:
z
.
boolean
().
optional
(),
externalMiddlewareRewritesResolve
:
z
.
boolean
().
optional
(),
fallbackNodePolyfills
:
z
.
literal
(
false
).
optional
(),
fallbackNodePolyfills
:
z
.
literal
(
false
).
optional
(),
fetchCacheKeyPrefix
:
z
.
string
().
optional
(),
fetchCacheKeyPrefix
:
z
.
string
().
optional
(),
flyingShuttle
:
z
.
strictObject
({
mode
:
z
.
union
([
z
.
literal
(
'full'
),
z
.
literal
(
'store-only'
)])
.
optional
(),
})
.
optional
(),
forceSwcTransforms
:
z
.
boolean
().
optional
(),
forceSwcTransforms
:
z
.
boolean
().
optional
(),
fullySpecified
:
z
.
boolean
().
optional
(),
fullySpecified
:
z
.
boolean
().
optional
(),
gzipSize
:
z
.
boolean
().
optional
(),
gzipSize
:
z
.
boolean
().
optional
(),
...
...
packages/next/src/server/config-shared.ts
View file @
affbe743
...
@@ -243,7 +243,6 @@ export interface ExperimentalConfig {
...
@@ -243,7 +243,6 @@ export interface ExperimentalConfig {
}
}
multiZoneDraftMode
?:
boolean
multiZoneDraftMode
?:
boolean
appNavFailHandling
?:
boolean
appNavFailHandling
?:
boolean
flyingShuttle
?:
{
mode
?:
'full'
|
'store-only'
}
prerenderEarlyExit
?:
boolean
prerenderEarlyExit
?:
boolean
linkNoTouchStart
?:
boolean
linkNoTouchStart
?:
boolean
caseSensitiveRoutes
?:
boolean
caseSensitiveRoutes
?:
boolean
...
@@ -1087,12 +1086,7 @@ export const defaultConfig: NextConfig = {
...
@@ -1087,12 +1086,7 @@ export const defaultConfig: NextConfig = {
},
},
cssChunking
:
true
,
cssChunking
:
true
,
multiZoneDraftMode
:
false
,
multiZoneDraftMode
:
false
,
appNavFailHandling
:
Boolean
(
process
.
env
.
NEXT_PRIVATE_FLYING_SHUTTLE
),
appNavFailHandling
:
false
,
flyingShuttle
:
Boolean
(
process
.
env
.
NEXT_PRIVATE_FLYING_SHUTTLE
)
?
{
mode
:
'full'
,
}
:
undefined
,
prerenderEarlyExit
:
true
,
prerenderEarlyExit
:
true
,
serverMinification
:
true
,
serverMinification
:
true
,
serverSourceMaps
:
false
,
serverSourceMaps
:
false
,
...
...
packages/next/src/shared/lib/router/router.ts
View file @
affbe743
...
@@ -1095,13 +1095,6 @@ export default class Router implements BaseRouter {
...
@@ -1095,13 +1095,6 @@ export default class Router implements BaseRouter {
const
pathsToCheck
:
Array
<
{
as
?:
string
;
allowMatchCurrent
?:
boolean
}
>
=
const
pathsToCheck
:
Array
<
{
as
?:
string
;
allowMatchCurrent
?:
boolean
}
>
=
[{
as
},
{
as
:
resolvedAs
}]
[{
as
},
{
as
:
resolvedAs
}]
if
(
process
.
env
.
__NEXT_FLYING_SHUTTLE
)
{
// if existing page changed we hard navigate to
// avoid runtime conflict with new page
// TODO: check buildManifest files instead?
pathsToCheck
.
push
({
as
:
this
.
asPath
,
allowMatchCurrent
:
true
})
}
for
(
const
{
as
:
curAs
,
allowMatchCurrent
}
of
pathsToCheck
)
{
for
(
const
{
as
:
curAs
,
allowMatchCurrent
}
of
pathsToCheck
)
{
if
(
curAs
)
{
if
(
curAs
)
{
const
asNoSlash
=
removeTrailingSlash
(
const
asNoSlash
=
removeTrailingSlash
(
...
...
test/e2e/app-dir/app/flying-shuttle.test.ts
deleted
100644 → 0
View file @
657c2cbd
This diff is collapsed.
Click to expand it.
test/e2e/app-dir/app/next.config.js
View file @
affbe743
...
@@ -10,17 +10,6 @@ module.exports = {
...
@@ -10,17 +10,6 @@ module.exports = {
parallelServerCompiles
:
true
,
parallelServerCompiles
:
true
,
parallelServerBuildTraces
:
true
,
parallelServerBuildTraces
:
true
,
webpackBuildWorker
:
true
,
webpackBuildWorker
:
true
,
appNavFailHandling
:
Boolean
(
process
.
env
.
NEXT_PRIVATE_FLYING_SHUTTLE_STORE_ONLY
||
process
.
env
.
NEXT_PRIVATE_FLYING_SHUTTLE
),
flyingShuttle
:
Boolean
(
process
.
env
.
NEXT_PRIVATE_FLYING_SHUTTLE_STORE_ONLY
)
?
{
mode
:
'store-only'
}
:
Boolean
(
process
.
env
.
NEXT_PRIVATE_FLYING_SHUTTLE
)
?
{
mode
:
'full'
,
}
:
undefined
,
},
},
// output: 'standalone',
// output: 'standalone',
rewrites
:
async
()
=>
{
rewrites
:
async
()
=>
{
...
...
test/e2e/instrumentation-hook/flying-shuttle/app/edge/page.js
deleted
100644 → 0
View file @
657c2cbd
export
default
function
Page
()
{
return
'edge'
}
export
const
runtime
=
'edge'
test/e2e/instrumentation-hook/flying-shuttle/app/layout.js
deleted
100644 → 0
View file @
657c2cbd
export
default
function
Layout
({
children
})
{
return
(
<
html
>
<
body
>
{
children
}
<
/body
>
<
/html
>
)
}
test/e2e/instrumentation-hook/flying-shuttle/app/page.js
deleted
100644 → 0
View file @
657c2cbd
export
default
function
Page
()
{
return
'node'
}
export
const
dynamic
=
'force-dynamic'
test/e2e/instrumentation-hook/flying-shuttle/flying-shuttle.test.ts
deleted
100644 → 0
View file @
657c2cbd
import
fs
from
'fs-extra'
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
retry
}
from
'next-test-utils'
describe
(
'instrumentation-hook - flying-shuttle'
,
()
=>
{
const
{
next
,
skipped
}
=
nextTestSetup
({
files
:
__dirname
,
skipDeployment
:
true
,
})
if
(
skipped
)
{
return
}
beforeAll
(
async
()
=>
{
await
fs
.
remove
(
'.next'
)
})
it
(
'should only register without errors'
,
async
()
=>
{
await
next
.
fetch
(
'/'
)
await
next
.
fetch
(
'/edge'
)
await
retry
(()
=>
{
expect
(
next
.
cliOutput
).
toIncludeRepeated
(
'register:edge'
,
1
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'An error occurred while loading instrumentation hook'
)
expect
(
next
.
cliOutput
).
toIncludeRepeated
(
'register:nodejs'
,
1
)
})
})
})
test/e2e/instrumentation-hook/flying-shuttle/instrumentation.js
deleted
100644 → 0
View file @
657c2cbd
export
function
register
()
{
console
.
trace
(
'register:'
+
process
.
env
.
NEXT_RUNTIME
)
}
test/e2e/instrumentation-hook/flying-shuttle/next.config.js
deleted
100644 → 0
View file @
657c2cbd
/**
* @type {import('next').NextConfig}
*/
module
.
exports
=
{
experimental
:
{
flyingShuttle
:
{
mode
:
'full'
,
},
},
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment