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
6a087c6a
Unverified
Commit
6a087c6a
authored
Jul 27, 2018
by
Tim Neutkens
Committed by
GitHub
Jul 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename commons directory to runtime (#4853)
parent
fc05c9c2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
14 deletions
+19
-14
webpack.js
build/webpack.js
+6
-6
build-manifest-plugin.js
build/webpack/plugins/build-manifest-plugin.js
+2
-2
hot-dev-client.js
client/dev-error-overlay/hot-dev-client.js
+1
-2
constants.js
lib/constants.js
+6
-0
index.js
server/index.js
+2
-2
index.test.js
test/integration/production/test/index.test.js
+2
-2
No files found.
build/webpack.js
View file @
6a087c6a
...
...
@@ -17,7 +17,7 @@ import PagesManifestPlugin from './webpack/plugins/pages-manifest-plugin'
import
BuildManifestPlugin
from
'./webpack/plugins/build-manifest-plugin'
import
ChunkNamesPlugin
from
'./webpack/plugins/chunk-names-plugin'
import
{
ReactLoadablePlugin
}
from
'./webpack/plugins/react-loadable-plugin'
import
{
SERVER_DIRECTORY
,
NEXT_PROJECT_ROOT
,
NEXT_PROJECT_ROOT_NODE_MODULES
,
NEXT_PROJECT_ROOT_DIST
,
DEFAULT_PAGES_DIR
,
REACT_LOADABLE_MANIFEST
}
from
'../lib/constants'
import
{
SERVER_DIRECTORY
,
NEXT_PROJECT_ROOT
,
NEXT_PROJECT_ROOT_NODE_MODULES
,
NEXT_PROJECT_ROOT_DIST
,
DEFAULT_PAGES_DIR
,
REACT_LOADABLE_MANIFEST
,
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
,
CLIENT_STATIC_FILES_RUNTIME_MAIN
}
from
'../lib/constants'
// The externals config makes sure that
// on the server side when modules are
...
...
@@ -67,7 +67,7 @@ function optimizationConfig ({dir, dev, isServer, totalPages}) {
const
config
:
any
=
{
runtimeChunk
:
{
name
:
'static/commons/runtime.js'
name
:
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
},
splitChunks
:
false
}
...
...
@@ -133,7 +133,7 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i
const
clientEntries
=
!
isServer
?
{
// Backwards compatibility
'main.js'
:
[],
'static/commons/main.js'
:
[
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
]
:
[
path
.
join
(
NEXT_PROJECT_ROOT_DIST
,
'client'
,
(
dev
?
`next-dev`
:
'next'
))
].
filter
(
Boolean
)
}
:
{}
...
...
@@ -160,7 +160,7 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i
path
:
outputPath
,
filename
:
({
chunk
})
=>
{
// Use `[name]-[chunkhash].js` in production
if
(
!
dev
&&
(
chunk
.
name
===
'static/commons/main.js'
||
chunk
.
name
===
'static/commons/runtime.js'
))
{
if
(
!
dev
&&
(
chunk
.
name
===
CLIENT_STATIC_FILES_RUNTIME_MAIN
||
chunk
.
name
===
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
))
{
return
chunk
.
name
.
replace
(
/
\.
js$/
,
'-'
+
chunk
.
renderedHash
+
'.js'
)
}
return
'[name]'
...
...
@@ -254,9 +254,9 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i
// Server compilation doesn't have main.js
if
(
typeof
entry
[
'main.js'
]
!==
'undefined'
)
{
entry
[
'static/commons/main.js'
]
=
[
entry
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
]
=
[
...
entry
[
'main.js'
],
...
entry
[
'static/commons/main.js'
]
...
entry
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
]
]
delete
entry
[
'main.js'
]
...
...
build/webpack/plugins/build-manifest-plugin.js
View file @
6a087c6a
// @flow
import
{
RawSource
}
from
'webpack-sources'
import
{
BUILD_MANIFEST
,
ROUTE_NAME_REGEX
,
IS_BUNDLED_PAGE_REGEX
}
from
'../../../lib/constants'
import
{
BUILD_MANIFEST
,
ROUTE_NAME_REGEX
,
IS_BUNDLED_PAGE_REGEX
,
CLIENT_STATIC_FILES_RUNTIME_MAIN
}
from
'../../../lib/constants'
// This plugin creates a build-manifest.json for all assets that are being output
// It has a mapping of "entry" filename to real filename. Because the real filename can be hashed in production
...
...
@@ -10,7 +10,7 @@ export default class BuildManifestPlugin {
const
{
chunks
}
=
compilation
const
assetMap
=
{
pages
:
{},
css
:
[]}
const
mainJsChunk
=
chunks
.
find
((
c
)
=>
c
.
name
===
'static/commons/main.js'
)
const
mainJsChunk
=
chunks
.
find
((
c
)
=>
c
.
name
===
CLIENT_STATIC_FILES_RUNTIME_MAIN
)
const
mainJsFiles
=
mainJsChunk
&&
mainJsChunk
.
files
.
length
>
0
?
mainJsChunk
.
files
.
filter
((
file
)
=>
/
\.
js$/
.
test
(
file
))
:
[]
// compilation.entrypoints is a Map object, so iterating over it 0 is the key and 1 is the value
...
...
client/dev-error-overlay/hot-dev-client.js
View file @
6a087c6a
...
...
@@ -39,8 +39,7 @@ export default function connect (options) {
ErrorOverlay
.
startReportingRuntimeErrors
({
onError
:
function
()
{
hadRuntimeError
=
true
},
filename
:
'/_next/static/commons/manifest.js'
}
})
if
(
module
.
hot
&&
typeof
module
.
hot
.
dispose
===
'function'
)
{
...
...
lib/constants.js
View file @
6a087c6a
...
...
@@ -23,3 +23,9 @@ export const NEXT_PROJECT_ROOT_DIST = join(NEXT_PROJECT_ROOT, 'dist')
export
const
NEXT_PROJECT_ROOT_NODE_MODULES
=
join
(
NEXT_PROJECT_ROOT
,
'node_modules'
)
export
const
DEFAULT_PAGES_DIR
=
join
(
NEXT_PROJECT_ROOT_DIST
,
'pages'
)
export
const
CLIENT_STATIC_FILES_PATH
=
'static'
export
const
CLIENT_STATIC_FILES_RUNTIME
=
'runtime'
export
const
CLIENT_STATIC_FILES_RUNTIME_PATH
=
`
${
CLIENT_STATIC_FILES_PATH
}
/
${
CLIENT_STATIC_FILES_RUNTIME
}
`
// static/runtime/main.js
export
const
CLIENT_STATIC_FILES_RUNTIME_MAIN
=
`
${
CLIENT_STATIC_FILES_RUNTIME_PATH
}
/main.js`
// static/runtime/webpack.js
export
const
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
=
`
${
CLIENT_STATIC_FILES_RUNTIME_PATH
}
/webpack.js`
server/index.js
View file @
6a087c6a
...
...
@@ -13,7 +13,7 @@ import {
import
Router
from
'./router'
import
{
isInternalUrl
}
from
'./utils'
import
loadConfig
from
'./config'
import
{
PHASE_PRODUCTION_SERVER
,
PHASE_DEVELOPMENT_SERVER
,
BLOCKED_PAGES
,
BUILD_ID_FILE
,
CLIENT_STATIC_FILES_PATH
}
from
'../lib/constants'
import
{
PHASE_PRODUCTION_SERVER
,
PHASE_DEVELOPMENT_SERVER
,
BLOCKED_PAGES
,
BUILD_ID_FILE
,
CLIENT_STATIC_FILES_PATH
,
CLIENT_STATIC_FILES_RUNTIME
}
from
'../lib/constants'
import
*
as
asset
from
'../lib/asset'
import
*
as
envConfig
from
'../lib/runtime-config'
import
{
isResSent
}
from
'../lib/utils'
...
...
@@ -129,7 +129,7 @@ export default class Server {
// The chunks folder holds dynamic entries
// The buildId folder holds pages and potentially other assets. As buildId changes per build it can be long-term cached.
// In development they don't have a hash, and shouldn't be cached by the browser.
if
(
params
.
path
[
0
]
===
'commons'
||
params
.
path
[
0
]
===
'chunks'
||
params
.
path
[
0
]
===
this
.
buildId
)
{
if
(
params
.
path
[
0
]
===
CLIENT_STATIC_FILES_RUNTIME
||
params
.
path
[
0
]
===
'chunks'
||
params
.
path
[
0
]
===
this
.
buildId
)
{
if
(
this
.
dev
)
{
res
.
setHeader
(
'Cache-Control'
,
'no-store, must-revalidate'
)
}
else
{
...
...
test/integration/production/test/index.test.js
View file @
6a087c6a
...
...
@@ -15,7 +15,7 @@ import webdriver from 'next-webdriver'
import
fetch
from
'node-fetch'
import
dynamicImportTests
from
'../../basic/test/dynamic'
import
security
from
'./security'
import
{
BUILD_MANIFEST
,
REACT_LOADABLE_MANIFEST
}
from
'next/constants'
import
{
BUILD_MANIFEST
,
REACT_LOADABLE_MANIFEST
,
CLIENT_STATIC_FILES_RUNTIME_MAIN
}
from
'next/constants'
const
appDir
=
join
(
__dirname
,
'../'
)
let
appPort
...
...
@@ -69,7 +69,7 @@ describe('Production Usage', () => {
resources
.
push
(
url
+
reactLoadableManifest
[
'../../components/hello1'
][
0
].
publicPath
)
// test main.js
resources
.
push
(
url
+
buildManifest
[
'static/commons/main.js'
][
0
])
resources
.
push
(
url
+
buildManifest
[
CLIENT_STATIC_FILES_RUNTIME_MAIN
][
0
])
const
responses
=
await
Promise
.
all
(
resources
.
map
((
resource
)
=>
fetch
(
resource
)))
...
...
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