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
f66546f9
Unverified
Commit
f66546f9
authored
Apr 26, 2019
by
Connor Davis
Committed by
GitHub
Apr 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ncc to bundle webpack (#6347)
parent
00e8ba49
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
758 additions
and
589 deletions
+758
-589
package.json
packages/next-server/package.json
+3
-3
compiler.ts
packages/next/build/compiler.ts
+1
-1
webpack-config.ts
packages/next/build/webpack-config.ts
+28
-1
next-client-pages-loader.ts
...es/next/build/webpack/loaders/next-client-pages-loader.ts
+1
-1
next-data-loader.ts
packages/next/build/webpack/loaders/next-data-loader.ts
+2
-2
next-minify-loader.ts
packages/next/build/webpack/loaders/next-minify-loader.ts
+1
-1
next-serverless-loader.ts
...ages/next/build/webpack/loaders/next-serverless-loader.ts
+1
-1
all-modules-identified-plugin.ts
...xt/build/webpack/plugins/all-modules-identified-plugin.ts
+1
-1
build-manifest-plugin.ts
packages/next/build/webpack/plugins/build-manifest-plugin.ts
+1
-1
chunk-graph-plugin.ts
packages/next/build/webpack/plugins/chunk-graph-plugin.ts
+1
-1
chunk-names-plugin.ts
packages/next/build/webpack/plugins/chunk-names-plugin.ts
+1
-1
hashed-chunk-ids-plugin.ts
...ges/next/build/webpack/plugins/hashed-chunk-ids-plugin.ts
+1
-1
next-drop-client-page-plugin.ts
...ext/build/webpack/plugins/next-drop-client-page-plugin.ts
+1
-1
nextjs-require-cache-hot-reloader.ts
...uild/webpack/plugins/nextjs-require-cache-hot-reloader.ts
+1
-1
nextjs-ssr-import.ts
packages/next/build/webpack/plugins/nextjs-ssr-import.ts
+1
-1
nextjs-ssr-module-cache.ts
...ges/next/build/webpack/plugins/nextjs-ssr-module-cache.ts
+1
-1
pages-manifest-plugin.ts
packages/next/build/webpack/plugins/pages-manifest-plugin.ts
+1
-1
react-loadable-plugin.ts
packages/next/build/webpack/plugins/react-loadable-plugin.ts
+1
-1
serverless-plugin.ts
packages/next/build/webpack/plugins/serverless-plugin.ts
+15
-18
shared-runtime-plugin.ts
packages/next/build/webpack/plugins/shared-runtime-plugin.ts
+1
-1
index.js
.../build/webpack/plugins/terser-webpack-plugin/src/index.js
+1
-1
unlink-removed-pages-plugin.ts
...next/build/webpack/plugins/unlink-removed-pages-plugin.ts
+1
-1
package.json
packages/next/package.json
+6
-5
hot-reloader.js
packages/next/server/hot-reloader.js
+3
-3
on-demand-entry-handler.js
packages/next/server/on-demand-entry-handler.js
+6
-7
taskfile.js
packages/next/taskfile.js
+72
-1
loader-utils.d.ts
packages/next/types/loader-utils.d.ts
+34
-0
misc.d.ts
packages/next/types/misc.d.ts
+10
-1
webpack.d.ts
packages/next/types/webpack.d.ts
+1
-1
next.config.js
test/integration/config/next.config.js
+1
-1
yarn.lock
yarn.lock
+559
-528
No files found.
packages/next-server/package.json
View file @
f66546f9
...
@@ -56,9 +56,9 @@
...
@@ -56,9 +56,9 @@
"devDependencies"
:
{
"devDependencies"
:
{
"@taskr/clear"
:
"1.1.0"
,
"@taskr/clear"
:
"1.1.0"
,
"@taskr/watch"
:
"1.1.0"
,
"@taskr/watch"
:
"1.1.0"
,
"@types/react"
:
"16.8.
4
"
,
"@types/react"
:
"16.8.
10
"
,
"@types/react-dom"
:
"16.8.
2
"
,
"@types/react-dom"
:
"16.8.
3
"
,
"@types/react-is"
:
"16.
5.0
"
,
"@types/react-is"
:
"16.
7.1
"
,
"@types/send"
:
"0.14.4"
,
"@types/send"
:
"0.14.4"
,
"taskr"
:
"1.1.0"
,
"taskr"
:
"1.1.0"
,
"typescript"
:
"3.1.6"
"typescript"
:
"3.1.6"
...
...
packages/next/build/compiler.ts
View file @
f66546f9
import
webpack
,
{
Stats
}
from
'webpack'
import
webpack
,
{
Stats
}
from
'
next/dist/compiled/
webpack'
export
type
CompilerResult
=
{
export
type
CompilerResult
=
{
errors
:
Error
[]
errors
:
Error
[]
...
...
packages/next/build/webpack-config.ts
View file @
f66546f9
import
fs
from
'fs'
import
fs
from
'fs'
import
nodeLibsBrowser
from
'node-libs-browser'
import
{
import
{
CLIENT_STATIC_FILES_RUNTIME_MAIN
,
CLIENT_STATIC_FILES_RUNTIME_MAIN
,
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
,
CLIENT_STATIC_FILES_RUNTIME_WEBPACK
,
...
@@ -8,7 +9,7 @@ import {
...
@@ -8,7 +9,7 @@ import {
import
resolve
from
'next/dist/compiled/resolve/index.js'
import
resolve
from
'next/dist/compiled/resolve/index.js'
import
path
from
'path'
import
path
from
'path'
import
{
promisify
}
from
'util'
import
{
promisify
}
from
'util'
import
webpack
from
'webpack'
import
webpack
from
'
next/dist/compiled/
webpack'
import
{
import
{
DOT_NEXT_ALIAS
,
DOT_NEXT_ALIAS
,
...
@@ -75,6 +76,20 @@ export default async function getBaseWebpackConfig(
...
@@ -75,6 +76,20 @@ export default async function getBaseWebpackConfig(
},
},
}
}
// manually map node-libs-browser to fix ncced webpack resolving
const
nodeLibs
:
any
=
{}
if
(
!
isServer
)
{
for
(
const
key
in
nodeLibsBrowser
)
{
if
(
key
===
'module'
)
continue
const
lib
=
nodeLibsBrowser
[
key
]
if
(
typeof
lib
===
'string'
)
{
nodeLibs
[
key
]
=
lib
}
}
}
// Support for NODE_PATH
// Support for NODE_PATH
const
nodePathList
=
(
process
.
env
.
NODE_PATH
||
''
)
const
nodePathList
=
(
process
.
env
.
NODE_PATH
||
''
)
.
split
(
process
.
platform
===
'win32'
?
';'
:
':'
)
.
split
(
process
.
platform
===
'win32'
?
';'
:
':'
)
...
@@ -125,6 +140,7 @@ export default async function getBaseWebpackConfig(
...
@@ -125,6 +140,7 @@ export default async function getBaseWebpackConfig(
...
nodePathList
,
// Support for NODE_PATH environment variable
...
nodePathList
,
// Support for NODE_PATH environment variable
],
],
alias
:
{
alias
:
{
...
nodeLibs
,
// These aliases make sure the wrapper module is not included in the bundles
// These aliases make sure the wrapper module is not included in the bundles
// Which makes bundles slightly smaller, but also skips parsing a module that we know will result in this alias
// Which makes bundles slightly smaller, but also skips parsing a module that we know will result in this alias
'next/head'
:
'next-server/dist/lib/head.js'
,
'next/head'
:
'next-server/dist/lib/head.js'
,
...
@@ -149,6 +165,7 @@ export default async function getBaseWebpackConfig(
...
@@ -149,6 +165,7 @@ export default async function getBaseWebpackConfig(
}
}
let
webpackConfig
:
webpack
.
Configuration
=
{
let
webpackConfig
:
webpack
.
Configuration
=
{
node
:
false
,
// handle node libs manually
mode
:
webpackMode
,
mode
:
webpackMode
,
devtool
:
dev
||
debug
?
'cheap-module-source-map'
:
false
,
devtool
:
dev
||
debug
?
'cheap-module-source-map'
:
false
,
name
:
isServer
?
'server'
:
'client'
,
name
:
isServer
?
'server'
:
'client'
,
...
@@ -408,6 +425,16 @@ export default async function getBaseWebpackConfig(
...
@@ -408,6 +425,16 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_EXPORT_TRAILING_SLASH'
:
JSON
.
stringify
(
'process.env.__NEXT_EXPORT_TRAILING_SLASH'
:
JSON
.
stringify
(
config
.
experimental
.
exportTrailingSlash
config
.
experimental
.
exportTrailingSlash
),
),
...(
isServer
?
{}
:
{
'global'
:
'window'
}),
'process'
:
{
env
:
{},
argv
:
[],
browser
:
!
isServer
,
pid
:
1
,
execPath
:
'browser'
,
platform
:
'browser'
,
features
:
{},
}
}),
}),
!
isServer
&&
!
isServer
&&
new
ReactLoadablePlugin
({
new
ReactLoadablePlugin
({
...
...
packages/next/build/webpack/loaders/next-client-pages-loader.ts
View file @
f66546f9
import
{
loader
}
from
'webpack'
import
{
loader
}
from
'
next/dist/compiled/
webpack'
import
loaderUtils
from
'loader-utils'
import
loaderUtils
from
'loader-utils'
export
type
ClientPagesLoaderOptions
=
{
export
type
ClientPagesLoaderOptions
=
{
...
...
packages/next/build/webpack/loaders/next-data-loader.ts
View file @
f66546f9
import
{
loader
}
from
'webpack'
import
{
loader
}
from
'
next/dist/compiled/
webpack'
import
hash
from
'string-hash'
import
hash
from
'string-hash'
import
{
basename
}
from
'path'
import
{
basename
}
from
'path'
const
nextDataLoader
:
loader
.
Loader
=
function
(
source
)
{
const
nextDataLoader
:
loader
.
Loader
=
function
(
source
)
{
const
filename
=
this
.
resourcePath
const
filename
=
this
.
resourcePath
return
`
return
`
import {createHook} from 'next/data'
import {createHook} from 'next/data'
export default createHook(undefined, {key:
${
JSON
.
stringify
(
basename
(
filename
)
+
'-'
+
hash
(
filename
))}
})
export default createHook(undefined, {key:
${
JSON
.
stringify
(
basename
(
filename
)
+
'-'
+
hash
(
filename
))}
})
`
`
}
}
...
...
packages/next/build/webpack/loaders/next-minify-loader.ts
View file @
f66546f9
import
loaderUtils
from
'loader-utils'
import
loaderUtils
from
'loader-utils'
import
{
loader
}
from
'webpack'
import
{
loader
}
from
'
next/dist/compiled/
webpack'
import
minify
from
'../plugins/terser-webpack-plugin/src/minify'
import
minify
from
'../plugins/terser-webpack-plugin/src/minify'
const
nextMiniferLoader
:
loader
.
Loader
=
function
(
source
)
{
const
nextMiniferLoader
:
loader
.
Loader
=
function
(
source
)
{
...
...
packages/next/build/webpack/loaders/next-serverless-loader.ts
View file @
f66546f9
import
{
loader
}
from
'webpack'
import
{
loader
}
from
'
next/dist/compiled/
webpack'
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
{
parse
}
from
'querystring'
import
{
parse
}
from
'querystring'
import
{
BUILD_MANIFEST
,
REACT_LOADABLE_MANIFEST
}
from
'next-server/constants'
import
{
BUILD_MANIFEST
,
REACT_LOADABLE_MANIFEST
}
from
'next-server/constants'
...
...
packages/next/build/webpack/plugins/all-modules-identified-plugin.ts
View file @
f66546f9
import
{
Compiler
,
Plugin
}
from
'next/dist/compiled/webpack'
import
{
createHash
}
from
'crypto'
import
{
createHash
}
from
'crypto'
import
path
from
'path'
import
path
from
'path'
import
{
Compiler
,
Plugin
}
from
'webpack'
/**
/**
* From escape-string-regexp: https://github.com/sindresorhus/escape-string-regexp
* From escape-string-regexp: https://github.com/sindresorhus/escape-string-regexp
...
...
packages/next/build/webpack/plugins/build-manifest-plugin.ts
View file @
f66546f9
import
{
Compiler
}
from
'webpack'
import
{
Compiler
}
from
'
next/dist/compiled/
webpack'
import
{
RawSource
}
from
'webpack-sources'
import
{
RawSource
}
from
'webpack-sources'
import
{
import
{
BUILD_MANIFEST
,
BUILD_MANIFEST
,
...
...
packages/next/build/webpack/plugins/chunk-graph-plugin.ts
View file @
f66546f9
...
@@ -4,7 +4,7 @@ import { CLIENT_STATIC_FILES_RUNTIME_MAIN } from 'next-server/constants'
...
@@ -4,7 +4,7 @@ import { CLIENT_STATIC_FILES_RUNTIME_MAIN } from 'next-server/constants'
import
{
EOL
}
from
'os'
import
{
EOL
}
from
'os'
import
path
from
'path'
import
path
from
'path'
import
{
parse
}
from
'querystring'
import
{
parse
}
from
'querystring'
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'
next/dist/compiled/
webpack'
type
StringDictionary
=
{
[
pageName
:
string
]:
string
[]
}
type
StringDictionary
=
{
[
pageName
:
string
]:
string
[]
}
const
manifest
:
{
const
manifest
:
{
...
...
packages/next/build/webpack/plugins/chunk-names-plugin.ts
View file @
f66546f9
import
{
Compiler
}
from
'webpack'
import
{
Compiler
}
from
'
next/dist/compiled/
webpack'
// This plugin mirrors webpack 3 `filename` and `chunkfilename` behavior
// This plugin mirrors webpack 3 `filename` and `chunkfilename` behavior
// This fixes https://github.com/webpack/webpack/issues/6598
// This fixes https://github.com/webpack/webpack/issues/6598
// This plugin is based on https://github.com/researchgate/webpack/commit/2f28947fa0c63ccbb18f39c0098bd791a2c37090
// This plugin is based on https://github.com/researchgate/webpack/commit/2f28947fa0c63ccbb18f39c0098bd791a2c37090
...
...
packages/next/build/webpack/plugins/hashed-chunk-ids-plugin.ts
View file @
f66546f9
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'
next/dist/compiled/
webpack'
import
{
createHash
}
from
'crypto'
import
{
createHash
}
from
'crypto'
export
class
HashedChunkIdsPlugin
implements
Plugin
{
export
class
HashedChunkIdsPlugin
implements
Plugin
{
...
...
packages/next/build/webpack/plugins/next-drop-client-page-plugin.ts
View file @
f66546f9
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'
next/dist/compiled/
webpack'
import
{
extname
}
from
'path'
import
{
extname
}
from
'path'
// Prevents outputting client pages when they are not needed
// Prevents outputting client pages when they are not needed
...
...
packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts
View file @
f66546f9
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'
next/dist/compiled/
webpack'
import
{
realpathSync
}
from
'fs'
import
{
realpathSync
}
from
'fs'
function
deleteCache
(
path
:
string
)
{
function
deleteCache
(
path
:
string
)
{
...
...
packages/next/build/webpack/plugins/nextjs-ssr-import.ts
View file @
f66546f9
import
{
join
,
resolve
,
relative
,
dirname
}
from
'path'
import
{
join
,
resolve
,
relative
,
dirname
}
from
'path'
import
{
Compiler
}
from
'webpack'
import
{
Compiler
}
from
'
next/dist/compiled/
webpack'
// This plugin modifies the require-ensure code generated by Webpack
// This plugin modifies the require-ensure code generated by Webpack
// to work with Next.js SSR
// to work with Next.js SSR
...
...
packages/next/build/webpack/plugins/nextjs-ssr-module-cache.ts
View file @
f66546f9
import
webpack
from
'webpack'
import
webpack
from
'
next/dist/compiled/
webpack'
import
{
RawSource
}
from
'webpack-sources'
import
{
RawSource
}
from
'webpack-sources'
import
{
join
,
relative
,
dirname
}
from
'path'
import
{
join
,
relative
,
dirname
}
from
'path'
import
{
IS_BUNDLED_PAGE_REGEX
}
from
'next-server/constants'
import
{
IS_BUNDLED_PAGE_REGEX
}
from
'next-server/constants'
...
...
packages/next/build/webpack/plugins/pages-manifest-plugin.ts
View file @
f66546f9
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'
next/dist/compiled/
webpack'
import
{
RawSource
}
from
'webpack-sources'
import
{
RawSource
}
from
'webpack-sources'
import
{
PAGES_MANIFEST
,
ROUTE_NAME_REGEX
}
from
'next-server/constants'
import
{
PAGES_MANIFEST
,
ROUTE_NAME_REGEX
}
from
'next-server/constants'
...
...
packages/next/build/webpack/plugins/react-loadable-plugin.ts
View file @
f66546f9
...
@@ -22,7 +22,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR
...
@@ -22,7 +22,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR
// Modified to strip out unneeded results for Next's specific use case
// Modified to strip out unneeded results for Next's specific use case
import
url
from
'url'
import
url
from
'url'
import
{
Compiler
,
compilation
}
from
'webpack'
import
{
Compiler
,
compilation
}
from
'
next/dist/compiled/
webpack'
function
buildManifest
(
compiler
:
Compiler
,
compilation
:
compilation
.
Compilation
)
{
function
buildManifest
(
compiler
:
Compiler
,
compilation
:
compilation
.
Compilation
)
{
let
context
=
compiler
.
options
.
context
let
context
=
compiler
.
options
.
context
...
...
packages/next/build/webpack/plugins/serverless-plugin.ts
View file @
f66546f9
import
{
Compiler
}
from
'webpack'
import
{
Compiler
}
from
'
next/dist/compiled/
webpack'
import
GraphHelpers
from
'
webpack/lib/GraphHelpers'
import
{
connectChunkAndModule
}
from
'next/dist/compiled/
webpack/lib/GraphHelpers'
/**
/**
* Makes sure there are no dynamic chunks when the target is serverless
* Makes sure there are no dynamic chunks when the target is serverless
...
@@ -66,25 +66,22 @@ export class ServerlessPlugin {
...
@@ -66,25 +66,22 @@ export class ServerlessPlugin {
replaceInBuffer
(
content
,
NEXT_REPLACE_BUILD_ID
,
this
.
buildId
)
replaceInBuffer
(
content
,
NEXT_REPLACE_BUILD_ID
,
this
.
buildId
)
)
)
compiler
.
hooks
.
compilation
.
tap
(
'ServerlessPlugin'
,
compilation
=>
{
compiler
.
hooks
.
compilation
.
tap
(
'ServerlessPlugin'
,
compilation
=>
{
compilation
.
hooks
.
optimizeChunksBasic
.
tap
(
compilation
.
hooks
.
optimizeChunksBasic
.
tap
(
'ServerlessPlugin'
,
chunks
=>
{
'ServerlessPlugin'
,
chunks
.
forEach
(
chunk
=>
{
chunks
=>
{
// If chunk is not an entry point skip them
chunks
.
forEach
(
chunk
=>
{
if
(
chunk
.
hasEntryModule
())
{
// If chunk is not an entry point skip them
const
dynamicChunks
=
chunk
.
getAllAsyncChunks
()
if
(
chunk
.
hasEntryModule
())
{
if
(
dynamicChunks
.
size
!==
0
)
{
const
dynamicChunks
=
chunk
.
getAllAsyncChunks
()
for
(
const
dynamicChunk
of
dynamicChunks
)
{
if
(
dynamicChunks
.
size
!==
0
)
{
for
(
const
module
of
dynamicChunk
.
modulesIterable
)
{
for
(
const
dynamicChunk
of
dynamicChunks
)
{
connectChunkAndModule
(
chunk
,
module
)
for
(
const
module
of
dynamicChunk
.
modulesIterable
)
{
GraphHelpers
.
connectChunkAndModule
(
chunk
,
module
)
}
}
}
}
}
}
}
)
}
}
}
)
})
})
})
})
}
else
{
}
else
{
compiler
.
hooks
.
emit
.
tap
(
'ServerlessPlugin'
,
compilation
=>
{
compiler
.
hooks
.
emit
.
tap
(
'ServerlessPlugin'
,
compilation
=>
{
...
...
packages/next/build/webpack/plugins/shared-runtime-plugin.ts
View file @
f66546f9
import
{
Compiler
,
Plugin
}
from
'webpack'
import
{
Compiler
,
Plugin
}
from
'
next/dist/compiled/
webpack'
export
class
SharedRuntimePlugin
implements
Plugin
{
export
class
SharedRuntimePlugin
implements
Plugin
{
apply
(
compiler
:
Compiler
)
{
apply
(
compiler
:
Compiler
)
{
...
...
packages/next/build/webpack/plugins/terser-webpack-plugin/src/index.js
View file @
f66546f9
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
import
stringHash
from
'string-hash'
import
stringHash
from
'string-hash'
import
{
SourceMapConsumer
}
from
'source-map'
import
{
SourceMapConsumer
}
from
'source-map'
import
{
SourceMapSource
,
RawSource
}
from
'webpack-sources'
import
{
SourceMapSource
,
RawSource
}
from
'webpack-sources'
import
RequestShortener
from
'webpack/lib/RequestShortener'
import
{
RequestShortener
}
from
'next/dist/compiled/webpack'
;
import
TaskRunner
from
'./TaskRunner'
import
TaskRunner
from
'./TaskRunner'
const
warningRegex
=
/
\[
.+:
([
0-9
]
+
)
,
([
0-9
]
+
)\]
/
const
warningRegex
=
/
\[
.+:
([
0-9
]
+
)
,
([
0-9
]
+
)\]
/
...
...
packages/next/build/webpack/plugins/unlink-removed-pages-plugin.ts
View file @
f66546f9
...
@@ -2,7 +2,7 @@ import { join } from 'path'
...
@@ -2,7 +2,7 @@ import { join } from 'path'
import
{
promisify
}
from
'util'
import
{
promisify
}
from
'util'
import
fs
from
'fs'
import
fs
from
'fs'
import
{
IS_BUNDLED_PAGE_REGEX
}
from
'next-server/constants'
import
{
IS_BUNDLED_PAGE_REGEX
}
from
'next-server/constants'
import
{
Compiler
}
from
'webpack'
import
{
Compiler
}
from
'
next/dist/compiled/
webpack'
const
unlink
=
promisify
(
fs
.
unlink
)
const
unlink
=
promisify
(
fs
.
unlink
)
...
...
packages/next/package.json
View file @
f66546f9
...
@@ -68,7 +68,6 @@
...
@@ -68,7 +68,6 @@
"@babel/runtime-corejs2"
:
"7.1.2"
,
"@babel/runtime-corejs2"
:
"7.1.2"
,
"amphtml-validator"
:
"1.0.23"
,
"amphtml-validator"
:
"1.0.23"
,
"async-sema"
:
"2.2.0"
,
"async-sema"
:
"2.2.0"
,
"autodll-webpack-plugin"
:
"0.4.2"
,
"babel-core"
:
"7.0.0-bridge.0"
,
"babel-core"
:
"7.0.0-bridge.0"
,
"babel-loader"
:
"8.0.2"
,
"babel-loader"
:
"8.0.2"
,
"babel-plugin-react-require"
:
"3.0.0"
,
"babel-plugin-react-require"
:
"3.0.0"
,
...
@@ -81,6 +80,7 @@
...
@@ -81,6 +80,7 @@
"loader-utils"
:
"1.1.0"
,
"loader-utils"
:
"1.1.0"
,
"mkdirp"
:
"0.5.1"
,
"mkdirp"
:
"0.5.1"
,
"next-server"
:
"8.1.1-canary.16"
,
"next-server"
:
"8.1.1-canary.16"
,
"node-libs-browser"
:
"2.2.0"
,
"prop-types"
:
"15.6.2"
,
"prop-types"
:
"15.6.2"
,
"prop-types-exact"
:
"1.2.0"
,
"prop-types-exact"
:
"1.2.0"
,
"react-error-overlay"
:
"5.1.4"
,
"react-error-overlay"
:
"5.1.4"
,
...
@@ -95,9 +95,6 @@
...
@@ -95,9 +95,6 @@
"tty-aware-progress"
:
"1.0.3"
,
"tty-aware-progress"
:
"1.0.3"
,
"unfetch"
:
"4.1.0"
,
"unfetch"
:
"4.1.0"
,
"url"
:
"0.11.0"
,
"url"
:
"0.11.0"
,
"webpack"
:
"4.29.0"
,
"webpack-dev-middleware"
:
"3.6.0"
,
"webpack-hot-middleware"
:
"2.24.3"
,
"webpack-sources"
:
"1.3.0"
,
"webpack-sources"
:
"1.3.0"
,
"worker-farm"
:
"1.5.2"
"worker-farm"
:
"1.5.2"
},
},
...
@@ -131,13 +128,17 @@
...
@@ -131,13 +128,17 @@
"@types/webpack-sources"
:
"0.1.5"
,
"@types/webpack-sources"
:
"0.1.5"
,
"@zeit/ncc"
:
"0.15.2"
,
"@zeit/ncc"
:
"0.15.2"
,
"arg"
:
"4.1.0"
,
"arg"
:
"4.1.0"
,
"autodll-webpack-plugin"
:
"0.4.2"
,
"babel-plugin-dynamic-import-node"
:
"2.2.0"
,
"babel-plugin-dynamic-import-node"
:
"2.2.0"
,
"nanoid"
:
"2.0.1"
,
"nanoid"
:
"2.0.1"
,
"resolve"
:
"1.5.0"
,
"resolve"
:
"1.5.0"
,
"taskr"
:
"1.1.0"
,
"taskr"
:
"1.1.0"
,
"text-table"
:
"0.2.0"
,
"text-table"
:
"0.2.0"
,
"typescript"
:
"3.1.6"
,
"typescript"
:
"3.1.6"
,
"unistore"
:
"3.2.1"
"unistore"
:
"3.2.1"
,
"webpack"
:
"4.29.0"
,
"webpack-dev-middleware"
:
"3.6.0"
,
"webpack-hot-middleware"
:
"2.24.3"
},
},
"engines"
:
{
"engines"
:
{
"node"
:
">= 8.0.0"
"node"
:
">= 8.0.0"
...
...
packages/next/server/hot-reloader.js
View file @
f66546f9
import
{
relative
as
relativePath
,
join
,
normalize
,
sep
}
from
'path'
import
{
relative
as
relativePath
,
join
,
normalize
,
sep
}
from
'path'
import
WebpackDevMiddleware
from
'webpack-dev-middleware'
import
WebpackDevMiddleware
from
'
next/dist/compiled/
webpack-dev-middleware'
import
WebpackHotMiddleware
from
'webpack-hot-middleware'
import
WebpackHotMiddleware
from
'
next/dist/compiled/
webpack-hot-middleware'
import
errorOverlayMiddleware
from
'./lib/error-overlay-middleware'
import
errorOverlayMiddleware
from
'./lib/error-overlay-middleware'
import
onDemandEntryHandler
,
{
normalizePage
}
from
'./on-demand-entry-handler'
import
onDemandEntryHandler
,
{
normalizePage
}
from
'./on-demand-entry-handler'
import
webpack
from
'webpack'
import
webpack
from
'
next/dist/compiled/
webpack'
import
getBaseWebpackConfig
from
'../build/webpack-config'
import
getBaseWebpackConfig
from
'../build/webpack-config'
import
{
IS_BUNDLED_PAGE_REGEX
,
ROUTE_NAME_REGEX
,
BLOCKED_PAGES
,
CLIENT_STATIC_FILES_RUNTIME_AMP
}
from
'next-server/constants'
import
{
IS_BUNDLED_PAGE_REGEX
,
ROUTE_NAME_REGEX
,
BLOCKED_PAGES
,
CLIENT_STATIC_FILES_RUNTIME_AMP
}
from
'next-server/constants'
import
{
NEXT_PROJECT_ROOT_DIST_CLIENT
}
from
'../lib/constants'
import
{
NEXT_PROJECT_ROOT_DIST_CLIENT
}
from
'../lib/constants'
...
...
packages/next/server/on-demand-entry-handler.js
View file @
f66546f9
import
DynamicEntryPlugin
from
'webpack/lib/DynamicEntryPlugin
'
import
webpack
from
'next/dist/compiled/webpack
'
import
{
EventEmitter
}
from
'events'
import
{
EventEmitter
}
from
'events'
import
{
join
,
posix
}
from
'path'
import
{
join
,
posix
}
from
'path'
import
{
parse
}
from
'url'
import
{
parse
}
from
'url'
...
@@ -17,7 +17,8 @@ const BUILT = Symbol('built')
...
@@ -17,7 +17,8 @@ const BUILT = Symbol('built')
// Based on https://github.com/webpack/webpack/blob/master/lib/DynamicEntryPlugin.js#L29-L37
// Based on https://github.com/webpack/webpack/blob/master/lib/DynamicEntryPlugin.js#L29-L37
function
addEntry
(
compilation
,
context
,
name
,
entry
)
{
function
addEntry
(
compilation
,
context
,
name
,
entry
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
dep
=
DynamicEntryPlugin
.
createDependency
(
entry
,
name
)
const
dep
=
webpack
.
SingleEntryPlugin
.
createDependency
(
entry
,
name
)
compilation
.
addEntry
(
context
,
dep
,
name
,
(
err
)
=>
{
compilation
.
addEntry
(
context
,
dep
,
name
,
(
err
)
=>
{
if
(
err
)
return
reject
(
err
)
if
(
err
)
return
reject
(
err
)
resolve
()
resolve
()
...
@@ -28,13 +29,10 @@ function addEntry (compilation, context, name, entry) {
...
@@ -28,13 +29,10 @@ function addEntry (compilation, context, name, entry) {
export
default
function
onDemandEntryHandler
(
devMiddleware
,
multiCompiler
,
{
export
default
function
onDemandEntryHandler
(
devMiddleware
,
multiCompiler
,
{
buildId
,
buildId
,
dir
,
dir
,
distDir
,
reload
,
reload
,
pageExtensions
,
pageExtensions
,
maxInactiveAge
,
maxInactiveAge
,
pagesBufferLength
,
pagesBufferLength
publicRuntimeConfig
,
serverRuntimeConfig
})
{
})
{
const
pagesDir
=
join
(
dir
,
'pages'
)
const
pagesDir
=
join
(
dir
,
'pages'
)
const
{
compilers
}
=
multiCompiler
const
{
compilers
}
=
multiCompiler
...
@@ -61,10 +59,11 @@ export default function onDemandEntryHandler (devMiddleware, multiCompiler, {
...
@@ -61,10 +59,11 @@ export default function onDemandEntryHandler (devMiddleware, multiCompiler, {
}
}
entries
[
page
].
status
=
BUILDING
entries
[
page
].
status
=
BUILDING
return
addEntry
(
compilation
,
compiler
.
context
,
name
,
[
compiler
.
name
===
'client'
?
`next-client-pages-loader?
${
stringify
({
page
,
absolutePagePath
})}
!`
:
absolutePagePath
]
)
return
addEntry
(
compilation
,
compiler
.
context
,
name
,
compiler
.
name
===
'client'
?
`next-client-pages-loader?
${
stringify
({
page
,
absolutePagePath
})}
!`
:
absolutePagePath
)
})
})
return
Promise
.
all
(
allEntries
)
return
Promise
.
all
(
allEntries
)
.
catch
(
err
=>
console
.
error
(
err
))
})
})
}
}
...
...
packages/next/taskfile.js
View file @
f66546f9
...
@@ -45,6 +45,77 @@ const babelServerOpts = {
...
@@ -45,6 +45,77 @@ const babelServerOpts = {
]
]
}
}
// eslint-disable-next-line camelcase
export
async
function
ncc_webpack
(
task
,
opts
)
{
await
task
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'webpack'
)))
.
ncc
({
packageName
:
'webpack'
})
.
target
(
'dist/compiled/webpack'
)
notify
(
'Compiled webpack'
)
}
// eslint-disable-next-line camelcase
export
async
function
ncc_webpack_module
(
task
,
opts
)
{
await
task
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'webpack/buildin/module'
)))
.
ncc
()
.
target
(
'dist/compiled/webpack/buildin'
)
notify
(
'Compiled webpack/buildin/module'
)
}
// eslint-disable-next-line camelcase
export
async
function
ncc_webpack_graph_helpers
(
task
,
opts
)
{
await
task
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'webpack/lib/GraphHelpers'
)))
.
ncc
()
.
target
(
'dist/compiled/webpack/lib'
)
notify
(
'Compiled webpack/lib/GraphHelpers'
)
}
// eslint-disable-next-line camelcase
export
async
function
ncc_webpack_hot_middleware
(
task
,
opts
)
{
await
task
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'webpack-hot-middleware'
)))
.
ncc
({
externals
:
[
'chokidar'
,
'webpack'
],
packageName
:
'webpack-hot-middleware'
})
.
target
(
'dist/compiled/webpack-hot-middleware'
)
notify
(
'Compiled webpack-hot-middleware'
)
}
// eslint-disable-next-line camelcase
export
async
function
ncc_autodll_webpack_plugin
(
task
,
opts
)
{
await
task
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'autodll-webpack-plugin'
)))
.
ncc
({
externals
:
[
'chokidar'
,
'webpack'
],
packageName
:
'autodll-webpack-plugin'
})
.
target
(
'dist/compiled/autodll-webpack-plugin'
)
notify
(
'Compiled autodll-webpack-plugin'
)
}
// eslint-disable-next-line camelcase
export
async
function
ncc_webpack_dev_middleware
(
task
,
opts
)
{
await
task
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'webpack-dev-middleware'
)))
.
ncc
({
externals
:
[
'chokidar'
,
'webpack'
],
packageName
:
'webpack-dev-middleware'
})
.
target
(
'dist/compiled/webpack-dev-middleware'
)
notify
(
'Compiled webpack-dev-middleware'
)
}
// eslint-disable-next-line camelcase
// eslint-disable-next-line camelcase
export
async
function
ncc_arg
(
task
,
opts
)
{
export
async
function
ncc_arg
(
task
,
opts
)
{
await
task
await
task
...
@@ -86,7 +157,7 @@ export async function ncc_text_table (task, opts) {
...
@@ -86,7 +157,7 @@ export async function ncc_text_table (task, opts) {
}
}
export
async
function
precompile
(
task
)
{
export
async
function
precompile
(
task
)
{
await
task
.
parallel
([
'ncc_unistore'
,
'ncc_resolve'
,
'ncc_arg'
,
'ncc_nanoid'
,
'ncc_text_table'
])
await
task
.
parallel
([
'ncc_
webpack'
,
'ncc_webpack_module'
,
'ncc_webpack_graph_helpers'
,
'ncc_webpack_hot_middleware'
,
'ncc_autodll_webpack_plugin'
,
'ncc_webpack_dev_middleware'
,
'ncc_
unistore'
,
'ncc_resolve'
,
'ncc_arg'
,
'ncc_nanoid'
,
'ncc_text_table'
])
}
}
export
async
function
compile
(
task
)
{
export
async
function
compile
(
task
)
{
...
...
packages/next/types/loader-utils.d.ts
0 → 100644
View file @
f66546f9
// Type definitions for loader-utils 1.1
// Project: https://github.com/webpack/loader-utils#readme
// Definitions by: Gyusun Yeom <https://github.com/Perlmint>
// Totooria Hyperion <https://github.com/TotooriaHyperion>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
declare
module
"loader-utils"
{
import
{
loader
}
from
'next/dist/compiled/webpack'
;
export
interface
InterpolateOption
{
context
?:
string
;
content
?:
string
|
Buffer
;
regExp
?:
string
|
RegExp
;
}
export
interface
OptionObject
{
[
key
:
string
]:
any
;
}
export
type
HashType
=
"sha1"
|
"md5"
|
"sha256"
|
"sha512"
;
export
type
DigestType
=
"hex"
|
"base26"
|
"base32"
|
"base36"
|
"base49"
|
"base52"
|
"base58"
|
"base62"
|
"base64"
;
export
function
getOptions
(
loaderContext
:
loader
.
LoaderContext
):
OptionObject
;
export
function
parseQuery
(
optionString
:
string
):
OptionObject
;
export
function
stringifyRequest
(
loaderContext
:
loader
.
LoaderContext
,
resource
:
string
):
string
;
export
function
getRemainingRequest
(
loaderContext
:
loader
.
LoaderContext
):
string
;
export
function
getCurrentRequest
(
loaderContext
:
loader
.
LoaderContext
):
string
;
export
function
isUrlRequest
(
url
:
string
,
root
?:
string
):
boolean
;
export
function
parseString
(
str
:
string
):
string
;
export
function
urlToRequest
(
url
:
string
,
root
?:
string
):
string
;
export
function
interpolateName
(
loaderContext
:
loader
.
LoaderContext
,
name
:
string
,
options
?:
any
):
string
;
export
function
getHashDigest
(
buffer
:
Buffer
,
hashType
:
HashType
,
digestType
:
DigestType
,
maxLength
:
number
):
string
;
}
packages/next/types/misc.d.ts
View file @
f66546f9
...
@@ -5,6 +5,15 @@ declare module 'webpack/lib/GraphHelpers';
...
@@ -5,6 +5,15 @@ declare module 'webpack/lib/GraphHelpers';
declare
module
'unfetch'
;
declare
module
'unfetch'
;
declare
module
'styled-jsx/server'
;
declare
module
'styled-jsx/server'
;
declare
module
'node-libs-browser'
{
const
nodeLibs
:
any
export
=
nodeLibs
;
}
declare
module
'next/dist/compiled/webpack/lib/GraphHelpers'
{
export
const
connectChunkAndModule
:
any
}
declare
module
'next/dist/compiled/nanoid/index.js'
{
declare
module
'next/dist/compiled/nanoid/index.js'
{
function
nanoid
(
size
?:
number
):
string
;
function
nanoid
(
size
?:
number
):
string
;
...
@@ -58,7 +67,7 @@ declare module 'next/dist/compiled/arg/index.js' {
...
@@ -58,7 +67,7 @@ declare module 'next/dist/compiled/arg/index.js' {
}
}
declare
module
'autodll-webpack-plugin'
{
declare
module
'autodll-webpack-plugin'
{
import
webpack
from
'webpack'
import
webpack
from
'
next/dist/compiled/
webpack'
class
AutoDllPlugin
implements
webpack
.
Plugin
{
class
AutoDllPlugin
implements
webpack
.
Plugin
{
constructor
(
settings
?:
{
constructor
(
settings
?:
{
inject
?:
boolean
,
inject
?:
boolean
,
...
...
packages/next/types/webpack.d.ts
View file @
f66546f9
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
/// <reference types="node" />
/// <reference types="node" />
declare
module
'webpack'
{
declare
module
'
next/dist/compiled/
webpack'
{
import
{
Tapable
,
HookMap
,
import
{
Tapable
,
HookMap
,
SyncBailHook
,
SyncHook
,
SyncLoopHook
,
SyncWaterfallHook
,
SyncBailHook
,
SyncHook
,
SyncLoopHook
,
SyncWaterfallHook
,
AsyncParallelBailHook
,
AsyncParallelHook
,
AsyncSeriesBailHook
,
AsyncSeriesHook
,
AsyncSeriesWaterfallHook
}
from
'tapable'
;
AsyncParallelBailHook
,
AsyncParallelHook
,
AsyncSeriesBailHook
,
AsyncSeriesHook
,
AsyncSeriesWaterfallHook
}
from
'tapable'
;
...
...
test/integration/config/next.config.js
View file @
f66546f9
const
withCSS
=
require
(
'@zeit/next-css'
)
const
withCSS
=
require
(
'@zeit/next-css'
)
const
withSass
=
require
(
'@zeit/next-sass'
)
const
withSass
=
require
(
'@zeit/next-sass'
)
const
webpack
=
require
(
'webpack'
)
const
webpack
=
require
(
'
next/dist/compiled/
webpack'
)
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
module
.
exports
=
withCSS
(
withSass
({
module
.
exports
=
withCSS
(
withSass
({
onDemandEntries
:
{
onDemandEntries
:
{
...
...
yarn.lock
View file @
f66546f9
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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