Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
14babe5b
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
14babe5b
编写于
7月 15, 2020
作者:
T
Tim Neutkens
提交者:
GitHub
7月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make type checking compatible with webpack 5 (#15158)
Co-authored-by:
N
Joe Haddad
<
joe.haddad@zeit.co
>
上级
fc082b92
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
254 addition
and
258 deletion
+254
-258
packages/next/build/webpack/config/blocks/css/index.ts
packages/next/build/webpack/config/blocks/css/index.ts
+1
-0
packages/next/build/webpack/plugins/build-manifest-plugin.ts
packages/next/build/webpack/plugins/build-manifest-plugin.ts
+1
-1
packages/next/build/webpack/plugins/css-minimizer-plugin.ts
packages/next/build/webpack/plugins/css-minimizer-plugin.ts
+2
-2
packages/next/build/webpack/plugins/next-drop-client-page-plugin.ts
...ext/build/webpack/plugins/next-drop-client-page-plugin.ts
+1
-1
packages/next/build/webpack/plugins/next-esm-plugin.ts
packages/next/build/webpack/plugins/next-esm-plugin.ts
+3
-6
packages/next/build/webpack/plugins/webpack-conformance-plugin/index.ts
...build/webpack/plugins/webpack-conformance-plugin/index.ts
+1
-1
packages/next/compiled/terser-webpack-plugin/cjs.js
packages/next/compiled/terser-webpack-plugin/cjs.js
+1
-1
packages/next/compiled/terser/bundle.min.js
packages/next/compiled/terser/bundle.min.js
+1
-1
packages/next/package.json
packages/next/package.json
+0
-4
packages/next/server/on-demand-entry-handler.ts
packages/next/server/on-demand-entry-handler.ts
+1
-0
packages/next/types/misc.d.ts
packages/next/types/misc.d.ts
+1
-4
packages/next/types/webpack.d.ts
packages/next/types/webpack.d.ts
+223
-173
packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts
packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts
+7
-6
yarn.lock
yarn.lock
+11
-58
未找到文件。
packages/next/build/webpack/config/blocks/css/index.ts
浏览文件 @
14babe5b
...
...
@@ -280,6 +280,7 @@ export const css = curry(async function css(
// Extract CSS as CSS file(s) in the client-side production bundle.
fns
.
push
(
plugin
(
// @ts-ignore webpack 5 compat
new
MiniCssExtractPlugin
({
filename
:
'
static/css/[contenthash].css
'
,
chunkFilename
:
'
static/css/[contenthash].css
'
,
...
...
packages/next/build/webpack/plugins/build-manifest-plugin.ts
浏览文件 @
14babe5b
...
...
@@ -59,7 +59,7 @@ export default class BuildManifestPlugin {
apply
(
compiler
:
Compiler
)
{
compiler
.
hooks
.
emit
.
tapAsync
(
'
NextJsBuildManifest
'
,
(
compilation
,
callback
)
=>
{
(
compilation
:
any
,
callback
:
any
)
=>
{
const
chunks
:
CompilationType
.
Chunk
[]
=
compilation
.
chunks
const
assetMap
:
BuildManifest
=
{
polyfillFiles
:
[],
...
...
packages/next/build/webpack/plugins/css-minimizer-plugin.ts
浏览文件 @
14babe5b
...
...
@@ -21,10 +21,10 @@ export class CssMinimizerPlugin {
}
apply
(
compiler
:
webpack
.
Compiler
)
{
compiler
.
hooks
.
compilation
.
tap
(
'
CssMinimizerPlugin
'
,
(
compilation
)
=>
{
compiler
.
hooks
.
compilation
.
tap
(
'
CssMinimizerPlugin
'
,
(
compilation
:
any
)
=>
{
compilation
.
hooks
.
optimizeChunkAssets
.
tapPromise
(
'
CssMinimizerPlugin
'
,
(
chunks
)
=>
(
chunks
:
webpack
.
compilation
.
Chunk
[]
)
=>
Promise
.
all
(
chunks
.
reduce
(
...
...
packages/next/build/webpack/plugins/next-drop-client-page-plugin.ts
浏览文件 @
14babe5b
...
...
@@ -22,7 +22,7 @@ export class DropClientPage implements Plugin {
apply
(
compiler
:
Compiler
)
{
compiler
.
hooks
.
compilation
.
tap
(
PLUGIN_NAME
,
(
compilation
,
{
normalModuleFactory
}
)
=>
{
(
compilation
:
any
,
{
normalModuleFactory
}:
any
)
=>
{
// Recursively look up the issuer till it ends up at the root
function
findEntryModule
(
mod
:
any
):
CompilationType
.
Module
|
null
{
const
queue
=
new
Set
([
mod
])
...
...
packages/next/build/webpack/plugins/next-esm-plugin.ts
浏览文件 @
14babe5b
...
...
@@ -80,12 +80,9 @@ export class NextEsmPlugin implements Plugin {
}
apply
(
compiler
:
Compiler
)
{
compiler
.
hooks
.
make
.
tapAsync
(
PLUGIN_NAME
,
(
compilation
:
CompilationType
.
Compilation
,
callback
)
=>
{
this
.
runBuild
(
compiler
,
compilation
).
then
(
callback
)
}
)
compiler
.
hooks
.
make
.
tapAsync
(
PLUGIN_NAME
,
(
compilation
,
callback
)
=>
{
this
.
runBuild
(
compiler
,
compilation
).
then
(
callback
)
})
}
getLoaders
(
rules
:
RuleSetRule
[],
predicate
:
(
loader
:
string
)
=>
boolean
)
{
...
...
packages/next/build/webpack/plugins/webpack-conformance-plugin/index.ts
浏览文件 @
14babe5b
...
...
@@ -112,7 +112,7 @@ export default class WebpackConformancePlugin {
for
(
const
type
of
JS_TYPES
)
{
factory
.
hooks
.
parser
.
for
(
'
javascript/
'
+
type
)
.
tap
(
this
.
constructor
.
name
,
(
parser
)
=>
{
.
tap
(
this
.
constructor
.
name
,
(
parser
:
any
)
=>
{
parser
.
hooks
.
program
.
tap
(
this
.
constructor
.
name
,
(
ast
:
any
)
=>
{
const
visitors
:
VisitorMap
=
{}
const
that
=
this
...
...
packages/next/compiled/terser-webpack-plugin/cjs.js
浏览文件 @
14babe5b
此差异已折叠。
点击以展开。
packages/next/compiled/terser/bundle.min.js
浏览文件 @
14babe5b
此差异已折叠。
点击以展开。
packages/next/package.json
浏览文件 @
14babe5b
...
...
@@ -137,10 +137,8 @@
"@types/fresh"
:
"0.5.0"
,
"@types/json5"
:
"0.0.30"
,
"@types/jsonwebtoken"
:
"8.3.7"
,
"@types/loader-utils"
:
"1.1.3"
,
"@types/lodash.curry"
:
"4.1.6"
,
"@types/lru-cache"
:
"5.1.0"
,
"@types/mini-css-extract-plugin"
:
"0.8.0"
,
"@types/nanoid"
:
"2.0.0"
,
"@types/node-fetch"
:
"2.3.4"
,
"@types/path-to-regexp"
:
"1.7.0"
,
...
...
@@ -150,9 +148,7 @@
"@types/resolve"
:
"0.0.8"
,
"@types/send"
:
"0.14.4"
,
"@types/styled-jsx"
:
"2.2.8"
,
"@types/terser-webpack-plugin"
:
"2.2.0"
,
"@types/text-table"
:
"0.2.1"
,
"@types/webpack-hot-middleware"
:
"2.16.5"
,
"@types/webpack-sources"
:
"0.1.5"
,
"@zeit/ncc"
:
"0.22.0"
,
"amphtml-validator"
:
"1.0.31"
,
...
...
packages/next/server/on-demand-entry-handler.ts
浏览文件 @
14babe5b
...
...
@@ -296,6 +296,7 @@ class Invalidator {
// Work around a bug in webpack, calling `invalidate` on Watching.js
// doesn't trigger the invalid call used to keep track of the `.done` hook on multiCompiler
for
(
const
compiler
of
this
.
multiCompiler
.
compilers
)
{
// @ts-ignore TODO: Check if this is still needed with webpack 5
compiler
.
hooks
.
invalid
.
call
()
}
this
.
watcher
.
invalidate
()
...
...
packages/next/types/misc.d.ts
浏览文件 @
14babe5b
...
...
@@ -207,10 +207,7 @@ declare module 'next/dist/compiled/unistore' {
export
=
m
}
declare
module
'
next/dist/compiled/terser-webpack-plugin
'
{
import
m
from
'
terser-webpack-plugin
'
export
=
m
}
declare
module
'
next/dist/compiled/terser-webpack-plugin
'
declare
module
'
next/dist/compiled/comment-json
'
{
import
m
from
'
comment-json
'
export
=
m
...
...
packages/next/types/webpack.d.ts
浏览文件 @
14babe5b
...
...
@@ -23,22 +23,10 @@
/// <reference types="node" />
declare
module
'
mini-css-extract-plugin
'
declare
module
'
loader-utils
'
declare
module
'
webpack
'
{
import
{
Tapable
,
HookMap
,
SyncBailHook
,
SyncHook
,
SyncLoopHook
,
SyncWaterfallHook
,
AsyncParallelBailHook
,
AsyncParallelHook
,
AsyncSeriesBailHook
,
AsyncSeriesHook
,
AsyncSeriesWaterfallHook
,
}
from
'
tapable
'
import
*
as
UglifyJS
from
'
uglify-js
'
import
*
as
anymatch
from
'
anymatch
'
import
{
RawSourceMap
}
from
'
source-map
'
import
{
ConcatSource
}
from
'
webpack-sources
'
...
...
@@ -800,7 +788,7 @@ declare module 'webpack' {
/** Use the minimizer (optimization.minimizer, by default uglify-js) to minimize output assets. */
minimize
?:
boolean
/** Minimizer(s) to use for minimizing the output */
minimizer
?:
Array
<
Plugin
|
Tapable
.
Plugin
>
minimizer
?:
Array
<
Plugin
>
/** Generate records with relative paths to be able to move the context folder". */
portableRecords
?:
boolean
checkWasmTypes
?:
boolean
...
...
@@ -908,130 +896,150 @@ declare module 'webpack' {
}
interface
NormalModuleFactoryHooks
{
resolver
:
SyncWaterfallHook
factory
:
SyncWaterfallHook
beforeResolve
:
AsyncSeriesWaterfallHook
afterResolve
:
AsyncSeriesWaterfallHook
createModule
:
SyncBailHook
module
:
SyncWaterfallHook
createParser
:
HookMap
parser
:
HookMap
createGenerator
:
HookMap
generator
:
HookMap
resolver
:
any
factory
:
any
beforeResolve
:
any
afterResolve
:
any
createModule
:
any
module
:
any
createParser
:
any
parser
:
any
createGenerator
:
any
generator
:
any
}
class
NormalModuleFactory
extends
Tapable
{
class
NormalModuleFactory
{
hooks
:
NormalModuleFactoryHooks
}
interface
ContextModuleFactoryHooks
{
beforeResolve
:
AsyncSeriesWaterfallHook
afterResolve
:
AsyncSeriesWaterfallHook
contextModuleFiles
:
SyncWaterfallHook
alternatives
:
AsyncSeriesWaterfallHook
beforeResolve
:
any
afterResolve
:
any
contextModuleFiles
:
any
alternatives
:
any
}
class
ContextModuleFactory
extends
Tapable
{
class
ContextModuleFactory
{
hooks
:
ContextModuleFactoryHooks
}
class
DllModuleFactory
extends
Tapable
{
class
DllModuleFactory
{
hooks
:
{}
}
interface
CompilationHooks
{
buildModule
:
SyncHook
<
Module
>
rebuildModule
:
SyncHook
<
Module
>
failedModule
:
SyncHook
<
Module
,
Error
>
succeedModule
:
SyncHook
<
Module
>
buildModule
:
any
rebuildModule
:
any
failedModule
:
any
succeedModule
:
any
finishModules
:
any
finishRebuildingModule
:
any
finishModules
:
SyncHook
<
Module
[]
>
finishRebuildingModule
:
SyncHook
<
Module
>
unseal
:
any
seal
:
any
unseal
:
SyncHook
seal
:
SyncHook
optimizeDependenciesBasic
:
any
optimizeDependencies
:
any
optimizeDependenciesAdvanced
:
any
afterOptimizeDependencies
:
any
optimizeDependenciesBasic
:
SyncBailHook
<
Module
[]
>
optimizeDependencies
:
SyncBailHook
<
Module
[]
>
optimizeDependenciesAdvanced
:
SyncBailHook
<
Module
[]
>
afterOptimizeDependencies
:
SyncHook
<
Module
[]
>
optimize
:
any
optimize
:
SyncHook
optimizeModulesBasic
:
any
optimizeModules
:
any
optimizeModulesAdvanced
:
any
afterOptimizeModules
:
any
optimizeChunksBasic
:
{
tap
:
(
name
:
string
,
callback
:
(
chunks
:
compilation
.
Chunk
[])
=>
void
)
=>
void
optimizeModulesBasic
:
SyncBailHook
<
Module
[]
>
optimizeModules
:
SyncBailHook
<
Module
[]
>
optimizeModulesAdvanced
:
SyncBailHook
<
Module
[]
>
afterOptimizeModules
:
SyncHook
<
Module
[]
>
tapAsync
:
(
name
:
string
,
callback
:
(
chunks
:
compilation
.
Chunk
[],
callback
:
any
)
=>
void
)
=>
void
}
optimizeChunks
:
{
tap
:
(
name
:
string
,
callback
:
(
chunks
:
compilation
.
Chunk
[])
=>
void
)
=>
void
optimizeChunksBasic
:
SyncBailHook
<
Chunk
[],
ChunkGroup
[]
>
optimizeChunks
:
SyncBailHook
<
Chunk
[],
ChunkGroup
[]
>
optimizeChunksAdvanced
:
SyncBailHook
<
Chunk
[],
ChunkGroup
[]
>
afterOptimizeChunks
:
SyncHook
<
Chunk
[],
ChunkGroup
[]
>
tapAsync
:
(
name
:
string
,
callback
:
(
chunks
:
compilation
.
Chunk
[],
callback
:
any
)
=>
void
)
=>
void
}
optimizeChunksAdvanced
:
any
afterOptimizeChunks
:
any
optimizeTree
:
AsyncSeriesHook
<
Chunk
[],
Module
[]
>
afterOptimizeTree
:
SyncHook
<
Chunk
[],
Module
[]
>
optimizeTree
:
any
afterOptimizeTree
:
any
optimizeChunkModulesBasic
:
SyncBailHook
<
Chunk
[],
Module
[]
>
optimizeChunkModules
:
SyncBailHook
<
Chunk
[],
Module
[]
>
optimizeChunkModulesAdvanced
:
SyncBailHook
<
Chunk
[],
Module
[]
>
afterOptimizeChunkModules
:
SyncHook
<
Chunk
[],
Module
[]
>
shouldRecord
:
SyncBailHook
optimizeChunkModulesBasic
:
any
optimizeChunkModules
:
any
optimizeChunkModulesAdvanced
:
any
afterOptimizeChunkModules
:
any
shouldRecord
:
any
reviveModules
:
SyncHook
<
Module
[],
Record
[]
>
optimizeModuleOrder
:
SyncHook
<
Module
[]
>
advancedOptimizeModuleOrder
:
SyncHook
<
Module
[]
>
beforeModuleIds
:
SyncHook
<
Module
[]
>
moduleIds
:
SyncHook
<
Module
[]
>
optimizeModuleIds
:
SyncHook
<
Module
[]
>
afterOptimizeModuleIds
:
SyncHook
<
Module
[]
>
reviveModules
:
any
optimizeModuleOrder
:
any
advancedOptimizeModuleOrder
:
any
beforeModuleIds
:
any
moduleIds
:
any
optimizeModuleIds
:
any
afterOptimizeModuleIds
:
any
reviveChunks
:
SyncHook
<
Chunk
[],
Record
[]
>
optimizeChunkOrder
:
SyncHook
<
Chunk
[]
>
beforeChunkIds
:
SyncHook
<
Chunk
[]
>
optimizeChunkIds
:
SyncHook
<
Chunk
[]
>
afterOptimizeChunkIds
:
SyncHook
<
Chunk
[]
>
reviveChunks
:
any
optimizeChunkOrder
:
any
beforeChunkIds
:
any
optimizeChunkIds
:
any
afterOptimizeChunkIds
:
any
recordModules
:
SyncHook
<
Module
[],
Record
[]
>
recordChunks
:
SyncHook
<
Chunk
[],
Record
[]
>
recordModules
:
any
recordChunks
:
any
beforeHash
:
SyncHook
afterHash
:
SyncHook
beforeHash
:
any
afterHash
:
any
recordHash
:
SyncHook
<
Record
[]
>
recordHash
:
any
record
:
SyncHook
<
Compilation
,
Record
[]
>
record
:
any
beforeModuleAssets
:
SyncHook
shouldGenerateChunkAssets
:
SyncBailHook
beforeChunkAssets
:
SyncHook
additionalChunkAssets
:
SyncHook
<
Chunk
[]
>
beforeModuleAssets
:
any
shouldGenerateChunkAssets
:
any
beforeChunkAssets
:
any
additionalChunkAssets
:
any
records
:
SyncHook
<
Compilation
,
Record
[]
>
records
:
any
additionalAssets
:
AsyncSeriesHook
optimizeChunkAssets
:
AsyncSeriesHook
<
Chunk
[]
>
afterOptimizeChunkAssets
:
SyncHook
<
Chunk
[]
>
optimizeAssets
:
AsyncSeriesHook
<
Asset
[]
>
afterOptimizeAssets
:
SyncHook
<
Asset
[]
>
additionalAssets
:
any
optimizeChunkAssets
:
any
afterOptimizeChunkAssets
:
any
optimizeAssets
:
any
afterOptimizeAssets
:
any
needAdditionalSeal
:
SyncBailHook
afterSeal
:
AsyncSeriesHook
needAdditionalSeal
:
any
afterSeal
:
any
chunkHash
:
SyncHook
<
Chunk
,
ChunkHash
>
moduleAsset
:
SyncHook
<
Module
,
string
>
chunkAsset
:
SyncHook
<
Chunk
,
string
>
chunkHash
:
any
moduleAsset
:
any
chunkAsset
:
any
assetPath
:
SyncWaterfallHook
<
string
>
assetPath
:
any
needAdditionalPass
:
SyncBailHook
childCompiler
:
SyncHook
needAdditionalPass
:
any
childCompiler
:
any
normalModuleLoader
:
SyncHook
<
any
,
Module
>
normalModuleLoader
:
any
optimizeExtractedChunksBasic
:
SyncBailHook
<
Chunk
[]
>
optimizeExtractedChunks
:
SyncBailHook
<
Chunk
[]
>
optimizeExtractedChunksAdvanced
:
SyncBailHook
<
Chunk
[]
>
afterOptimizeExtractedChunks
:
SyncHook
<
Chunk
[]
>
optimizeExtractedChunksBasic
:
any
optimizeExtractedChunks
:
any
optimizeExtractedChunksAdvanced
:
any
afterOptimizeExtractedChunks
:
any
}
interface
CompilationModule
{
...
...
@@ -1041,32 +1049,32 @@ declare module 'webpack' {
dependencies
:
boolean
}
class
MainTemplate
extends
Tapable
{
class
MainTemplate
{
hooks
:
{
jsonpScript
?:
SyncWaterfallHook
<
string
,
Chunk
,
string
>
require
:
SyncWaterfallHook
<
string
,
Chunk
,
string
>
requireExtensions
:
SyncWaterfallHook
<
string
,
Chunk
,
string
>
jsonpScript
?:
any
require
:
any
requireExtensions
:
any
}
outputOptions
:
Output
requireFn
:
string
}
class
ChunkTemplate
extends
Tapable
{}
class
HotUpdateChunkTemplate
extends
Tapable
{}
class
ChunkTemplate
{}
class
HotUpdateChunkTemplate
{}
class
RuntimeTemplate
{}
interface
ModuleTemplateHooks
{
content
:
SyncWaterfallHook
module
:
SyncWaterfallHook
render
:
SyncWaterfallHook
package
:
SyncWaterfallHook
hash
:
SyncHook
content
:
any
module
:
any
render
:
any
package
:
any
hash
:
any
}
class
ModuleTemplate
extends
Tapable
{
class
ModuleTemplate
{
hooks
:
ModuleTemplateHooks
}
class
Compilation
extends
Tapable
{
class
Compilation
{
hooks
:
CompilationHooks
compiler
:
Compiler
...
...
@@ -1110,8 +1118,8 @@ declare module 'webpack' {
errors
:
any
[]
warnings
:
any
[]
children
:
any
[]
dependencyFactories
:
Map
<
typeof
Dependency
,
Tapable
>
dependencyTemplates
:
Map
<
typeof
Dependency
,
Tapable
>
dependencyFactories
:
Map
<
typeof
Dependency
,
any
>
dependencyTemplates
:
Map
<
typeof
Dependency
,
any
>
childrenCounters
:
any
usedChunkIds
:
any
usedModuleIds
:
any
...
...
@@ -1147,36 +1155,81 @@ declare module 'webpack' {
}
interface
CompilerHooks
{
shouldEmit
:
SyncBailHook
<
Compilation
>
done
:
AsyncSeriesHook
<
Stats
>
additionalPass
:
AsyncSeriesHook
beforeRun
:
AsyncSeriesHook
<
Compiler
>
run
:
AsyncSeriesHook
<
Compiler
>
emit
:
AsyncSeriesHook
<
Compilation
>
afterEmit
:
AsyncSeriesHook
<
Compilation
>
thisCompilation
:
SyncHook
<
Compilation
,
{
normalModuleFactory
:
NormalModuleFactory
}
>
compilation
:
SyncHook
<
Compilation
,
{
normalModuleFactory
:
NormalModuleFactory
}
>
normalModuleFactory
:
SyncHook
<
NormalModuleFactory
>
contextModuleFactory
:
SyncHook
<
ContextModuleFactory
>
beforeCompile
:
AsyncSeriesHook
<
{}
>
compile
:
SyncHook
<
{}
>
make
:
AsyncParallelHook
<
Compilation
>
afterCompile
:
AsyncSeriesHook
<
Compilation
>
watchRun
:
AsyncSeriesHook
<
Compiler
>
failed
:
SyncHook
<
Error
>
invalid
:
SyncHook
<
string
,
Date
>
watchClose
:
SyncHook
environment
:
SyncHook
afterEnvironment
:
SyncHook
afterPlugins
:
SyncHook
<
Compiler
>
afterResolvers
:
SyncHook
<
Compiler
>
entryOption
:
SyncBailHook
shouldEmit
:
any
done
:
{
tap
:
(
name
:
string
,
callback
:
(
stats
:
Stats
)
=>
void
)
=>
void
tapAsync
:
(
name
:
string
,
callback
:
(
stats
:
Stats
,
callback
:
any
)
=>
void
)
=>
void
}
additionalPass
:
any
beforeRun
:
any
run
:
any
emit
:
{
tap
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
)
=>
void
)
=>
void
tapAsync
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
,
callback
:
any
)
=>
void
)
=>
void
}
afterEmit
:
{
tap
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
)
=>
void
)
=>
void
tapAsync
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
,
callback
:
any
)
=>
void
)
=>
void
}
thisCompilation
:
any
compilation
:
{
tap
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
,
options
:
any
)
=>
void
)
=>
void
tapAsync
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
,
options
:
any
,
callback
:
any
)
=>
void
)
=>
void
}
normalModuleFactory
:
any
contextModuleFactory
:
any
beforeCompile
:
any
compile
:
any
make
:
{
tap
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
)
=>
void
)
=>
void
tapAsync
:
(
name
:
string
,
callback
:
(
compilation
:
Compilation
,
callback
:
any
)
=>
void
)
=>
void
}
afterCompile
:
any
watchRun
:
any
failed
:
any
invalid
:
any
watchClose
:
any
environment
:
any
afterEnvironment
:
any
afterPlugins
:
any
afterResolvers
:
any
entryOption
:
any
}
interface
MultiStats
{
...
...
@@ -1185,11 +1238,21 @@ declare module 'webpack' {
}
interface
MultiCompilerHooks
{
done
:
SyncHook
<
MultiStats
>
invalid
:
SyncHook
<
string
,
Date
>
run
:
AsyncSeriesHook
<
Compiler
>
watchClose
:
SyncHook
watchRun
:
AsyncSeriesHook
<
Compiler
>
done
:
{
tap
:
(
name
:
string
,
callback
:
(
multiStats
:
MultiStats
)
=>
void
)
=>
void
tapAsync
:
(
name
:
string
,
callback
:
(
multiStats
:
MultiStats
,
callback
:
any
)
=>
void
)
=>
void
}
invalid
:
any
run
:
any
watchClose
:
any
watchRun
:
any
}
}
// tslint:disable-next-line:interface-name
...
...
@@ -1221,7 +1284,7 @@ declare module 'webpack' {
* It is possible to exclude a huge folder like node_modules.
* It is also possible to use anymatch patterns.
*/
ignored
?:
any
match
.
Matcher
ignored
?:
any
/** Turn on polling by passing true, or specifying a poll interval in milliseconds. */
poll
?:
boolean
|
number
}
...
...
@@ -1285,11 +1348,11 @@ declare module 'webpack' {
):
any
}
class
Compiler
extends
Tapable
implements
ICompiler
{
class
Compiler
implements
ICompiler
{
constructor
()
hooks
:
compilation
.
CompilerHooks
_pluginCompat
:
SyncBailHook
<
compilation
.
Compilation
>
_pluginCompat
:
any
name
:
string
isChild
():
boolean
...
...
@@ -1330,7 +1393,7 @@ declare module 'webpack' {
}
}
abstract
class
MultiCompiler
extends
Tapable
implements
ICompiler
{
abstract
class
MultiCompiler
implements
ICompiler
{
compilers
:
Compiler
[]
hooks
:
compilation
.
MultiCompilerHooks
run
(
handler
:
MultiCompiler
.
Handler
):
void
...
...
@@ -1350,11 +1413,11 @@ declare module 'webpack' {
invalidate
():
void
}
abstract
class
Plugin
implements
Tapable
.
Plugin
{
abstract
class
Plugin
{
apply
(
compiler
:
Compiler
):
void
}
abstract
class
ResolvePlugin
implements
Tapable
.
Plugin
{
abstract
class
ResolvePlugin
{
apply
(
resolver
:
any
/* EnhancedResolve.Resolver */
):
void
}
...
...
@@ -1954,13 +2017,13 @@ declare module 'webpack' {
}
class
UglifyJsPlugin
extends
Plugin
{
constructor
(
options
?:
UglifyJsPlugin
.
Options
)
constructor
(
options
?:
any
)
}
namespace
UglifyJsPlugin
{
type
CommentFilter
=
(
astNode
:
any
,
comment
:
any
)
=>
boolean
interface
Options
extends
UglifyJS
.
MinifyOptions
{
interface
Options
{
beautify
?:
boolean
comments
?:
boolean
|
RegExp
|
CommentFilter
exclude
?:
Condition
|
Condition
[]
...
...
@@ -2322,18 +2385,5 @@ declare module 'webpack' {
/** @deprecated use webpack.Compiler.Handler */
type
CompilerCallback
=
Compiler
.
Handler
}
/** @deprecated use webpack.Options.Performance */
type
PerformanceOptions
=
Options
.
Performance
/** @deprecated use webpack.Options.WatchOptions */
type
WatchOptions
=
Options
.
WatchOptions
/** @deprecated use webpack.EvalSourceMapDevToolPlugin.Options */
type
EvalSourceMapDevToolPluginOptions
=
EvalSourceMapDevToolPlugin
.
Options
/** @deprecated use webpack.SourceMapDevToolPlugin.Options */
type
SourceMapDevToolPluginOptions
=
SourceMapDevToolPlugin
.
Options
/** @deprecated use webpack.optimize.UglifyJsPlugin.CommentFilter */
type
UglifyCommentFunction
=
optimize
.
UglifyJsPlugin
.
CommentFilter
/** @deprecated use webpack.optimize.UglifyJsPlugin.Options */
type
UglifyPluginOptions
=
optimize
.
UglifyJsPlugin
.
Options
}
}
packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts
浏览文件 @
14babe5b
...
...
@@ -11,10 +11,9 @@ import {
// Shared between webpack 4 and 5:
function
injectRefreshFunctions
(
compilation
:
Compilation
.
Compilation
)
{
const
hookVars
:
typeof
compilation
[
'
mainTemplate
'
][
'
hooks
'
][
'
requireExtensions
'
]
=
(
compilation
.
mainTemplate
.
hooks
as
any
).
localVars
const
hookVars
:
any
=
(
compilation
.
mainTemplate
.
hooks
as
any
).
localVars
hookVars
.
tap
(
'
ReactFreshWebpackPlugin
'
,
(
source
)
=>
hookVars
.
tap
(
'
ReactFreshWebpackPlugin
'
,
(
source
:
string
)
=>
Template
.
asString
([
source
,
''
,
...
...
@@ -41,10 +40,10 @@ function webpack4(compiler: Compiler) {
compiler
.
hooks
.
compilation
.
tap
(
'
ReactFreshWebpackPlugin
'
,
(
compilation
)
=>
{
injectRefreshFunctions
(
compilation
)
const
hookRequire
:
typeof
compilation
[
'
mainTemplate
'
][
'
hooks
'
][
'
requireExtensions
'
]
=
(
compilation
.
mainTemplate
.
hooks
as
any
).
require
const
hookRequire
:
any
=
(
compilation
.
mainTemplate
.
hooks
as
any
).
require
hookRequire
.
tap
(
'
ReactFreshWebpackPlugin
'
,
(
source
,
_chunk
,
_hash
)
=>
{
// @ts-ignore webpack 5 types compat
hookRequire
.
tap
(
'
ReactFreshWebpackPlugin
'
,
(
source
:
string
)
=>
{
// Webpack 4 evaluates module code on the following line:
// ```
// modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
...
...
@@ -52,6 +51,7 @@ function webpack4(compiler: Compiler) {
// https://github.com/webpack/webpack/blob/4c644bf1f7cb067c748a52614500e0e2182b2700/lib/MainTemplate.js#L200
const
lines
=
source
.
split
(
'
\n
'
)
// @ts-ignore webpack 5 types compat
const
evalIndex
=
lines
.
findIndex
((
l
)
=>
l
.
includes
(
'
modules[moduleId].call(
'
)
)
...
...
@@ -130,6 +130,7 @@ function webpack5(compiler: Compiler) {
}
}
// @ts-ignore webpack 5 types compat
compiler
.
hooks
.
compilation
.
tap
(
'
ReactFreshWebpackPlugin
'
,
(
compilation
)
=>
{
injectRefreshFunctions
(
compilation
)
...
...
yarn.lock
浏览文件 @
14babe5b
...
...
@@ -2498,10 +2498,6 @@
dependencies:
"@types/node" "*"
"@types/anymatch@*":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
"@types/async-retry@1.4.2":
version "1.4.2"
resolved "https://registry.yarnpkg.com/@types/async-retry/-/async-retry-1.4.2.tgz#7f910188cd3893b51e32df51765ee8d5646053e3"
...
...
@@ -2745,13 +2741,6 @@
dependencies:
"@types/node" "*"
"@types/loader-utils@1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@types/loader-utils/-/loader-utils-1.1.3.tgz#82b9163f2ead596c68a8c03e450fbd6e089df401"
dependencies:
"@types/node" "*"
"@types/webpack" "*"
"@types/lodash.curry@4.1.6":
version "4.1.6"
resolved "https://registry.yarnpkg.com/@types/lodash.curry/-/lodash.curry-4.1.6.tgz#f26c490c80c92d7cbaa2300d542e89781d44b1ff"
...
...
@@ -2774,12 +2763,6 @@
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d"
"@types/mini-css-extract-plugin@0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@types/mini-css-extract-plugin/-/mini-css-extract-plugin-0.8.0.tgz#6a5d3459d40cb51f14059e9aa410c9e970656103"
dependencies:
"@types/webpack" "*"
"@types/minimatch@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
...
...
@@ -2923,10 +2906,6 @@
dependencies:
"@types/react" "*"
"@types/tapable@*":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
"@types/tar@4.0.3":
version "4.0.3"
resolved "https://registry.yarnpkg.com/@types/tar/-/tar-4.0.3.tgz#e2cce0b8ff4f285293243f5971bd7199176ac489"
...
...
@@ -2934,23 +2913,10 @@
"@types/minipass" "*"
"@types/node" "*"
"@types/terser-webpack-plugin@2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@types/terser-webpack-plugin/-/terser-webpack-plugin-2.2.0.tgz#b1561e3118b9319d80ff65798c345877669b3e12"
dependencies:
"@types/webpack" "*"
terser "^4.3.9"
"@types/text-table@0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@types/text-table/-/text-table-0.2.1.tgz#39c4d4a058a82f677392dfd09976e83d9b4c9264"
"@types/uglify-js@*":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
dependencies:
source-map "^0.6.1"
"@types/unist@*", "@types/unist@^2.0.0":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"
...
...
@@ -2974,14 +2940,7 @@
"@types/unist" "*"
"@types/vfile-message" "*"
"@types/webpack-hot-middleware@2.16.5":
version "2.16.5"
resolved "https://registry.yarnpkg.com/@types/webpack-hot-middleware/-/webpack-hot-middleware-2.16.5.tgz#5271eada42f34670a7ae79ddb6f1c419a19c985f"
dependencies:
"@types/connect" "*"
"@types/webpack" "*"
"@types/webpack-sources@*", "@types/webpack-sources@0.1.5":
"@types/webpack-sources@0.1.5":
version "0.1.5"
resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-0.1.5.tgz#be47c10f783d3d6efe1471ff7f042611bd464a92"
dependencies:
...
...
@@ -2989,17 +2948,6 @@
"@types/source-list-map" "*"
source-map "^0.6.1"
"@types/webpack@*":
version "4.41.1"
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.1.tgz#571f0e137ce698710dd2637f7d222811eb83e274"
dependencies:
"@types/anymatch" "*"
"@types/node" "*"
"@types/tapable" "*"
"@types/uglify-js" "*"
"@types/webpack-sources" "*"
source-map "^0.6.0"
"@types/yargs-parser@*":
version "13.1.0"
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-13.1.0.tgz#c563aa192f39350a1d18da36c5a8da382bbd8228"
...
...
@@ -6243,9 +6191,9 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1:
once "^1.4.0"
enhanced-resolve@^4.1.0:
version "4.
2
.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.
2.0.tgz#5d43bda4a0fd447cb0ebbe71bef8deff8805ad0d
"
integrity sha512-
S7eiFb/erugyd1rLb6mQ3Vuq+EXHv5cpCkNqqIkYkBgN2QdFnyCZzFBleqwGEx4lgNGYij81BWnCrFNK7vxvj
Q==
version "4.
3
.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.
3.0.tgz#3b806f3bfafc1ec7de69551ef93cca46c1704126
"
integrity sha512-
3e87LvavsdxyoCfGusJnrZ5G8SLPOFeHSNpZI/ATL9a5leXo2k0w6MKnbqhdBad9qTobSfB20Ld7UmgoNbAZk
Q==
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.5.0"
...
...
@@ -10732,10 +10680,15 @@ negotiator@0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
neo-async@2.6.1, neo-async@^2.
5.0, neo-async@^2.
6.0, neo-async@^2.6.1:
neo-async@2.6.1, neo-async@^2.6.0, neo-async@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
neo-async@^2.5.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==
nested-error-stacks@^2.0.0, nested-error-stacks@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz#0fbdcf3e13fe4994781280524f8b96b0cdff9c61"
...
...
@@ -15281,7 +15234,7 @@ terser@^4.1.2:
source-map "~0.6.1"
source-map-support "~0.5.12"
terser@^4.
3.9, terser@^4.
4.3:
terser@^4.4.3:
version "4.6.11"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.6.11.tgz#12ff99fdd62a26de2a82f508515407eb6ccd8a9f"
dependencies:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录