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
1810cf5a
Unverified
Commit
1810cf5a
authored
Apr 10, 2019
by
Joe Haddad
Committed by
GitHub
Apr 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an experimental mode for flyingShuttle (#6985)
parent
f301c4f0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
21 deletions
+28
-21
config.js
packages/next-server/server/config.js
+2
-1
index.ts
packages/next/build/index.ts
+16
-10
webpack-config.ts
packages/next/build/webpack-config.ts
+10
-10
No files found.
packages/next-server/server/config.js
View file @
1810cf5a
...
...
@@ -30,7 +30,8 @@ const defaultConfig = {
),
ampBindInitData
:
false
,
exportTrailingSlash
:
true
,
profiling
:
false
profiling
:
false
,
flyingShuttle
:
false
}
}
...
...
packages/next/build/index.ts
View file @
1810cf5a
...
...
@@ -57,14 +57,15 @@ function getPossibleFiles(pageExtensions: string[], pages: string[]) {
export
async
function
getSpecifiedPages
(
dir
:
string
,
pages
:
string
[],
pageExtensions
:
string
[]
pageExtensions
:
string
[],
assumeAll
:
boolean
)
{
const
pagesDir
=
path
.
join
(
dir
,
'pages'
)
const
reservedPages
=
[
'/_app'
,
'/_document'
,
'/_error'
]
pages
.
push
(...
reservedPages
)
const
searchAllPages
=
pages
.
some
(
p
=>
p
.
includes
(
'**'
))
const
searchAllPages
=
assumeAll
||
pages
.
some
(
p
=>
p
.
includes
(
'**'
))
let
pagePaths
:
string
[]
const
explodedPages
=
[
...
...
@@ -157,17 +158,22 @@ export default async function build(
?
[
process
.
env
.
__NEXT_BUILDER_EXPERIMENTAL_PAGE
]
:
[]
const
__
selectivePageBuilding
=
pages
?
Boolean
(
pages
.
length
)
:
false
const
selectivePageBuilding
=
pages
?
Boolean
(
pages
.
length
)
:
false
if
(
__
selectivePageBuilding
&&
config
.
target
!==
'serverless'
)
{
if
(
selectivePageBuilding
&&
config
.
target
!==
'serverless'
)
{
throw
new
Error
(
'Cannot use selective page building without the serverless target.'
)
}
let
pagePaths
if
(
__selectivePageBuilding
)
{
pagePaths
=
await
getSpecifiedPages
(
dir
,
pages
,
config
.
pageExtensions
)
if
(
selectivePageBuilding
)
{
pagePaths
=
await
getSpecifiedPages
(
dir
,
pages
,
config
.
pageExtensions
,
config
.
experimental
.
flyingShuttle
)
}
else
{
pagePaths
=
await
collectPages
(
pagesDir
,
config
.
pageExtensions
)
}
...
...
@@ -176,7 +182,7 @@ export default async function build(
mappedPages
,
config
.
target
,
buildId
,
__
selectivePageBuilding
,
selectivePageBuilding
,
config
)
const
configs
=
await
Promise
.
all
([
...
...
@@ -187,7 +193,7 @@ export default async function build(
config
,
target
:
config
.
target
,
entrypoints
:
entrypoints
.
client
,
__
selectivePageBuilding
,
selectivePageBuilding
,
}),
getBaseWebpackConfig
(
dir
,
{
debug
,
...
...
@@ -196,7 +202,7 @@ export default async function build(
config
,
target
:
config
.
target
,
entrypoints
:
entrypoints
.
server
,
__
selectivePageBuilding
,
selectivePageBuilding
,
}),
])
...
...
@@ -255,5 +261,5 @@ export default async function build(
printTreeView
(
Object
.
keys
(
mappedPages
))
await
writeBuildId
(
distDir
,
buildId
,
__
selectivePageBuilding
)
await
writeBuildId
(
distDir
,
buildId
,
selectivePageBuilding
)
}
packages/next/build/webpack-config.ts
View file @
1810cf5a
...
...
@@ -18,7 +18,7 @@ import { ChunkGraphPlugin } from './webpack/plugins/chunk-graph-plugin'
import
{
WebpackEntrypoints
}
from
'./entries'
type
ExcludesFalse
=
<
T
>
(
x
:
T
|
false
)
=>
x
is
T
export
default
function
getBaseWebpackConfig
(
dir
:
string
,
{
dev
=
false
,
debug
=
false
,
isServer
=
false
,
buildId
,
config
,
target
=
'server'
,
entrypoints
,
__selectivePageBuilding
=
false
}:
{
dev
?:
boolean
,
debug
?:
boolean
,
isServer
?:
boolean
,
buildId
:
string
,
config
:
any
,
target
?:
string
,
entrypoints
:
WebpackEntrypoints
,
__
selectivePageBuilding
?:
boolean
}):
webpack
.
Configuration
{
export
default
function
getBaseWebpackConfig
(
dir
:
string
,
{
dev
=
false
,
debug
=
false
,
isServer
=
false
,
buildId
,
config
,
target
=
'server'
,
entrypoints
,
selectivePageBuilding
=
false
}:
{
dev
?:
boolean
,
debug
?:
boolean
,
isServer
?:
boolean
,
buildId
:
string
,
config
:
any
,
target
?:
string
,
entrypoints
:
WebpackEntrypoints
,
selectivePageBuilding
?:
boolean
}):
webpack
.
Configuration
{
const
defaultLoaders
=
{
babel
:
{
loader
:
'next-babel-loader'
,
...
...
@@ -135,7 +135,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
splitChunks
:
false
,
minimize
:
false
}
:
{
runtimeChunk
:
__
selectivePageBuilding
?
false
:
{
runtimeChunk
:
selectivePageBuilding
?
false
:
{
name
:
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
},
splitChunks
:
dev
?
{
...
...
@@ -143,7 +143,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
default
:
false
,
vendors
:
false
}
}
:
__
selectivePageBuilding
?
{
}
:
selectivePageBuilding
?
{
cacheGroups
:
{
default
:
false
,
vendors
:
false
,
...
...
@@ -175,11 +175,11 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
new
TerserPlugin
({...
terserPluginConfig
,
terserOptions
:
{
safari10
:
true
,
...(
__
selectivePageBuilding
?
{
compress
:
false
,
mangle
:
true
}
:
undefined
)
...(
selectivePageBuilding
?
{
compress
:
false
,
mangle
:
true
}
:
undefined
)
}
})
]
:
undefined
,
},
__
selectivePageBuilding
?
{
},
selectivePageBuilding
?
{
providedExports
:
false
,
usedExports
:
false
,
concatenateModules
:
false
,
...
...
@@ -224,7 +224,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
// @ts-ignore this is filtered
module
:
{
rules
:
[
__
selectivePageBuilding
&&
!
isServer
&&
{
selectivePageBuilding
&&
!
isServer
&&
{
test
:
/
\.(
js|mjs|jsx
)
$/
,
use
:
{
loader
:
'next-minify-loader'
,
...
...
@@ -277,7 +277,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
!
isServer
&&
new
ReactLoadablePlugin
({
filename
:
REACT_LOADABLE_MANIFEST
}),
!
isServer
&&
__
selectivePageBuilding
&&
new
ChunkGraphPlugin
(
buildId
,
path
.
resolve
(
dir
),
{
filename
:
CHUNK_GRAPH_MANIFEST
}),
!
isServer
&&
selectivePageBuilding
&&
new
ChunkGraphPlugin
(
buildId
,
path
.
resolve
(
dir
),
{
filename
:
CHUNK_GRAPH_MANIFEST
}),
...(
dev
?
(()
=>
{
// Even though require.cache is server only we have to clear assets from both compilations
// This is because the client compilation generates the build manifest that's used on the server side
...
...
@@ -316,12 +316,12 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
!
dev
&&
new
webpack
.
HashedModuleIdsPlugin
(),
// This must come after HashedModuleIdsPlugin (it sets any modules that
// were missed by HashedModuleIdsPlugin)
!
dev
&&
__
selectivePageBuilding
&&
new
AllModulesIdentifiedPlugin
(
dir
),
!
dev
&&
selectivePageBuilding
&&
new
AllModulesIdentifiedPlugin
(
dir
),
// This sets chunk ids to be hashed versions of their names to reduce
// bundle churn
!
dev
&&
new
HashedChunkIdsPlugin
(
buildId
),
// On the client we want to share the same runtime cache
!
isServer
&&
__
selectivePageBuilding
&&
new
SharedRuntimePlugin
(),
!
isServer
&&
selectivePageBuilding
&&
new
SharedRuntimePlugin
(),
!
dev
&&
new
webpack
.
IgnorePlugin
({
checkResource
:
(
resource
:
string
)
=>
{
return
/react-is/
.
test
(
resource
)
...
...
@@ -330,7 +330,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
return
/next-server
[\\/]
dist
[\\/]
/
.
test
(
context
)
||
/next
[\\/]
dist
[\\/]
/
.
test
(
context
)
}
}),
target
===
'serverless'
&&
(
isServer
||
__
selectivePageBuilding
)
&&
new
ServerlessPlugin
(
buildId
,
{
isServer
}),
target
===
'serverless'
&&
(
isServer
||
selectivePageBuilding
)
&&
new
ServerlessPlugin
(
buildId
,
{
isServer
}),
target
!==
'serverless'
&&
isServer
&&
new
PagesManifestPlugin
(),
target
!==
'serverless'
&&
isServer
&&
new
NextJsSSRModuleCachePlugin
({
outputPath
}),
isServer
&&
new
NextJsSsrImportPlugin
(),
...
...
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