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 = {
...
@@ -30,7 +30,8 @@ const defaultConfig = {
),
),
ampBindInitData
:
false
,
ampBindInitData
:
false
,
exportTrailingSlash
:
true
,
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[]) {
...
@@ -57,14 +57,15 @@ function getPossibleFiles(pageExtensions: string[], pages: string[]) {
export
async
function
getSpecifiedPages
(
export
async
function
getSpecifiedPages
(
dir
:
string
,
dir
:
string
,
pages
:
string
[],
pages
:
string
[],
pageExtensions
:
string
[]
pageExtensions
:
string
[],
assumeAll
:
boolean
)
{
)
{
const
pagesDir
=
path
.
join
(
dir
,
'pages'
)
const
pagesDir
=
path
.
join
(
dir
,
'pages'
)
const
reservedPages
=
[
'/_app'
,
'/_document'
,
'/_error'
]
const
reservedPages
=
[
'/_app'
,
'/_document'
,
'/_error'
]
pages
.
push
(...
reservedPages
)
pages
.
push
(...
reservedPages
)
const
searchAllPages
=
pages
.
some
(
p
=>
p
.
includes
(
'**'
))
const
searchAllPages
=
assumeAll
||
pages
.
some
(
p
=>
p
.
includes
(
'**'
))
let
pagePaths
:
string
[]
let
pagePaths
:
string
[]
const
explodedPages
=
[
const
explodedPages
=
[
...
@@ -157,17 +158,22 @@ export default async function build(
...
@@ -157,17 +158,22 @@ export default async function build(
?
[
process
.
env
.
__NEXT_BUILDER_EXPERIMENTAL_PAGE
]
?
[
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
(
throw
new
Error
(
'Cannot use selective page building without the serverless target.'
'Cannot use selective page building without the serverless target.'
)
)
}
}
let
pagePaths
let
pagePaths
if
(
__selectivePageBuilding
)
{
if
(
selectivePageBuilding
)
{
pagePaths
=
await
getSpecifiedPages
(
dir
,
pages
,
config
.
pageExtensions
)
pagePaths
=
await
getSpecifiedPages
(
dir
,
pages
,
config
.
pageExtensions
,
config
.
experimental
.
flyingShuttle
)
}
else
{
}
else
{
pagePaths
=
await
collectPages
(
pagesDir
,
config
.
pageExtensions
)
pagePaths
=
await
collectPages
(
pagesDir
,
config
.
pageExtensions
)
}
}
...
@@ -176,7 +182,7 @@ export default async function build(
...
@@ -176,7 +182,7 @@ export default async function build(
mappedPages
,
mappedPages
,
config
.
target
,
config
.
target
,
buildId
,
buildId
,
__
selectivePageBuilding
,
selectivePageBuilding
,
config
config
)
)
const
configs
=
await
Promise
.
all
([
const
configs
=
await
Promise
.
all
([
...
@@ -187,7 +193,7 @@ export default async function build(
...
@@ -187,7 +193,7 @@ export default async function build(
config
,
config
,
target
:
config
.
target
,
target
:
config
.
target
,
entrypoints
:
entrypoints
.
client
,
entrypoints
:
entrypoints
.
client
,
__
selectivePageBuilding
,
selectivePageBuilding
,
}),
}),
getBaseWebpackConfig
(
dir
,
{
getBaseWebpackConfig
(
dir
,
{
debug
,
debug
,
...
@@ -196,7 +202,7 @@ export default async function build(
...
@@ -196,7 +202,7 @@ export default async function build(
config
,
config
,
target
:
config
.
target
,
target
:
config
.
target
,
entrypoints
:
entrypoints
.
server
,
entrypoints
:
entrypoints
.
server
,
__
selectivePageBuilding
,
selectivePageBuilding
,
}),
}),
])
])
...
@@ -255,5 +261,5 @@ export default async function build(
...
@@ -255,5 +261,5 @@ export default async function build(
printTreeView
(
Object
.
keys
(
mappedPages
))
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'
...
@@ -18,7 +18,7 @@ import { ChunkGraphPlugin } from './webpack/plugins/chunk-graph-plugin'
import
{
WebpackEntrypoints
}
from
'./entries'
import
{
WebpackEntrypoints
}
from
'./entries'
type
ExcludesFalse
=
<
T
>
(
x
:
T
|
false
)
=>
x
is
T
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
=
{
const
defaultLoaders
=
{
babel
:
{
babel
:
{
loader
:
'next-babel-loader'
,
loader
:
'next-babel-loader'
,
...
@@ -135,7 +135,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
...
@@ -135,7 +135,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
splitChunks
:
false
,
splitChunks
:
false
,
minimize
:
false
minimize
:
false
}
:
{
}
:
{
runtimeChunk
:
__
selectivePageBuilding
?
false
:
{
runtimeChunk
:
selectivePageBuilding
?
false
:
{
name
:
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
name
:
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
},
},
splitChunks
:
dev
?
{
splitChunks
:
dev
?
{
...
@@ -143,7 +143,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
...
@@ -143,7 +143,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
default
:
false
,
default
:
false
,
vendors
:
false
vendors
:
false
}
}
}
:
__
selectivePageBuilding
?
{
}
:
selectivePageBuilding
?
{
cacheGroups
:
{
cacheGroups
:
{
default
:
false
,
default
:
false
,
vendors
:
false
,
vendors
:
false
,
...
@@ -175,11 +175,11 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
...
@@ -175,11 +175,11 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
new
TerserPlugin
({...
terserPluginConfig
,
new
TerserPlugin
({...
terserPluginConfig
,
terserOptions
:
{
terserOptions
:
{
safari10
:
true
,
safari10
:
true
,
...(
__
selectivePageBuilding
?
{
compress
:
false
,
mangle
:
true
}
:
undefined
)
...(
selectivePageBuilding
?
{
compress
:
false
,
mangle
:
true
}
:
undefined
)
}
}
})
})
]
:
undefined
,
]
:
undefined
,
},
__
selectivePageBuilding
?
{
},
selectivePageBuilding
?
{
providedExports
:
false
,
providedExports
:
false
,
usedExports
:
false
,
usedExports
:
false
,
concatenateModules
:
false
,
concatenateModules
:
false
,
...
@@ -224,7 +224,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
...
@@ -224,7 +224,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
// @ts-ignore this is filtered
// @ts-ignore this is filtered
module
:
{
module
:
{
rules
:
[
rules
:
[
__
selectivePageBuilding
&&
!
isServer
&&
{
selectivePageBuilding
&&
!
isServer
&&
{
test
:
/
\.(
js|mjs|jsx
)
$/
,
test
:
/
\.(
js|mjs|jsx
)
$/
,
use
:
{
use
:
{
loader
:
'next-minify-loader'
,
loader
:
'next-minify-loader'
,
...
@@ -277,7 +277,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
...
@@ -277,7 +277,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
!
isServer
&&
new
ReactLoadablePlugin
({
!
isServer
&&
new
ReactLoadablePlugin
({
filename
:
REACT_LOADABLE_MANIFEST
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
?
(()
=>
{
...(
dev
?
(()
=>
{
// Even though require.cache is server only we have to clear assets from both compilations
// 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
// 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 =
...
@@ -316,12 +316,12 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
!
dev
&&
new
webpack
.
HashedModuleIdsPlugin
(),
!
dev
&&
new
webpack
.
HashedModuleIdsPlugin
(),
// This must come after HashedModuleIdsPlugin (it sets any modules that
// This must come after HashedModuleIdsPlugin (it sets any modules that
// were missed by HashedModuleIdsPlugin)
// 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
// This sets chunk ids to be hashed versions of their names to reduce
// bundle churn
// bundle churn
!
dev
&&
new
HashedChunkIdsPlugin
(
buildId
),
!
dev
&&
new
HashedChunkIdsPlugin
(
buildId
),
// On the client we want to share the same runtime cache
// On the client we want to share the same runtime cache
!
isServer
&&
__
selectivePageBuilding
&&
new
SharedRuntimePlugin
(),
!
isServer
&&
selectivePageBuilding
&&
new
SharedRuntimePlugin
(),
!
dev
&&
new
webpack
.
IgnorePlugin
({
!
dev
&&
new
webpack
.
IgnorePlugin
({
checkResource
:
(
resource
:
string
)
=>
{
checkResource
:
(
resource
:
string
)
=>
{
return
/react-is/
.
test
(
resource
)
return
/react-is/
.
test
(
resource
)
...
@@ -330,7 +330,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
...
@@ -330,7 +330,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
return
/next-server
[\\/]
dist
[\\/]
/
.
test
(
context
)
||
/next
[\\/]
dist
[\\/]
/
.
test
(
context
)
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
PagesManifestPlugin
(),
target
!==
'serverless'
&&
isServer
&&
new
NextJsSSRModuleCachePlugin
({
outputPath
}),
target
!==
'serverless'
&&
isServer
&&
new
NextJsSSRModuleCachePlugin
({
outputPath
}),
isServer
&&
new
NextJsSsrImportPlugin
(),
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