-
Notifications
You must be signed in to change notification settings - Fork 0
internal webpack plugins.cn
These is a list of plugins, which are internally used by webpack. You should only care about them if you are building a own compiler based on webpack, or introspect the internals.
webpack 内部使用了一组插件。你只应在基于 webpack 构建自己的编译器时才关注它们,或者研究内部对象。
categories of internal plugins:
内部插件类型列表:
- environment
- compiler
- entry
- output
- source
- optimize
Plugins affecting the environment of the compiler.
影响编译器环境的插件。
Applies node.js style filesystem to the compiler.
把 node.js 风格的文件系统应用到编译器。
Plugins affecting the compiler
影响编译器的插件。
Adds a cache to the compiler, where modules are cached.
向编译器加入缓存,用于缓存模块
You can pass a cache
object, where the modules are cached. Otherwise one is created per plugin instance.
你可以传入一个cache
对象,来缓存模块。否则,每个插件实例都会创建一个。
Hook into the compiler to extract progress information. The handler
must have the signature function(percentage, message)
. It's called with 0 <= percentage <= 1
. percentage == 0
indicates the start. percentage == 1
indicates the end.
挂接进编译器以提取进度信息。handler
必须具备这样的函数签名function(percentage, message)
。它会在0 <= percentage <= 1
时被调用。percentage == 0
表示开始。 percentage == 1
表示结束。
Saves and restores module and chunk ids from records.
向记录/从记录,保存/恢复模块和 chunk 的 id
Plugins, which add entry chunks to the compilation.
向 compilation 添加入口块的插件
Adds a entry chunk on compilation. The chunk is named chunkName
and contains only one module (plus dependencies). The module is resolved from request
in context
(absolute path).
在编译期添加一个入口块。该块以chunkName
命名,且只包含一个模块(加上依赖)。这个模块根据context
(绝对路径)的request
解析
Adds a entry chunk on compilation. The chunk is named chunkName
and contains a module for each item in the requests
array (plus dependencies). Each item in requests
is resolved in context
(absolute path).
在编译过程添加一个入口块。该块以chunkName
命名,包含一个含有requests
数组中所有项的模块(加上依赖)。requests
中的每一项都通过context
(绝对路径)解析得到
Prefetches request
and dependencies to enables more parallel compilation. It doesn't create any chunk. The module is resolved from request
in context
(absolute path).
预取request
和依赖模块以便开启更多并行的编译过程。它不会产生任何 chunk。该模块是根据context
(绝对路径)的request
解析的。
Each emitted module is wrapped in a function.
每个生成的模块都以一个函数包裹。
options
are the output options.
options
就是配置中的输出选项
If options.pathinfo
is set, each module function is annotated with a comment containing the module identifier shortened to context
(absolute path).
如果设置了options.pathinfo
,每个模块函数都会以一份注释标注,内含相对于context
(绝对路径)模块标识符
Chunks are wrapped into JSONP-calls. A loading algorithm is included in entry chunks. It loads chunks by adding a <script>
tag.
chunk 被包装成 JSONP 回调。一个加载算法被包含进入口块,其通过添加一个<script>
标签加载分块。
options
are the output options.
options
输出选项
options.jsonpFunction
is the JSONP function.
options.jsonpFunction
JSONP函数
options.publicPath
is uses as path for loading the chunks.
options.publicPath
用来加载分块的路径。
options.chunkFilename
is the filename under that chunks are expected.
options.chunkFilename
目标块的文件名
Chunks are wrapped into node.js modules exporting the bundled modules. The entry chunks loads chunks by requiring them.
分块被包装成Node.js的模块,并输出捆绑了的模块。入口块通过引用它们来加载分块。
options
are the output options.
options
输出选项
options.chunkFilename
is the filename under that chunks are expected.
options.chunkFilename
目标块的文件名
The entries chunks are decorated to form a library name
of type type
.
入口块以一个类型为type
的库name
包装。
Chunks are loaded by importScripts
. Else it's similar to JsonpTemplatePlugin
.
分块是由importScripts
加载。否则它类似于JsonpTemplatePlugin
。
options
are the output options.
options
输出选项
Decorates the module template by wrapping each module in a eval
annotated with // @sourceURL
.
通过包装在一个以// @ sourceURL
注明的eval
方法来包装每个模块模板。
SourceMapDevToolPlugin(sourceMapFilename, sourceMappingURLComment, moduleFilenameTemplate, fallbackModuleFilenameTemplate)
Decorates the templates by generating a SourceMap for each chunk.
通过为每个 chunk 生成一个 SourceMap 来包装模板
sourceMapFilename
the filename template of the SourceMap. [hash]
, [name]
, [id]
, [file]
and [filebase]
are replaced. If this argument is missing, the SourceMap will be inlined as DataUrl.
sourceMapFilename
SourceMap 的文件名模板。[hash]
, [name]
, [id]
, [file]
和 [filebase]
会被替换。如果此参数缺失,SourceMap 被内联为 DataUrl
Defines module.hot
as false
to remove hot module replacement code.
定义module.hot
为false
,以移除模块热替换的代码。
Add support for hot module replacement. Decorates the templates to add runtime code. Adds module.hot
API.
添加模块热替换的支持。包装模板来添加运行时代码。添加module.hot
的API。
options.hotUpdateChunkFilename
The filename for hot update chunks
options.hotUpdateChunkFilename
热更新分块的文件名
options.hotUpdateMainFilename
The filename for the hot update manifest
options.hotUpdateMainFilename
热更新清单的文件名
options.hotUpdateFunction
JSON function name for the hot update
options.hotUpdateFunction
热更新的 JSONP 函数名
Plugins affecting the source code of modules.
影响模块的源代码的插件
Make __webpack_public_path__
, __webpack_require__
, __webpack_modules__
, __webpack_chunk_load__
accessible. Ensures that require.valueOf
and require.onError
are not processed by other plugins.
让__webpack_public_path__
,__webpack_require__
,__webpack_modules__
,__webpack_chunk_load__
在模块中可访问。确保require.valueOf
和require.onError
不被其他插件处理。
Currently useless. Ensures compatibility with other module loaders.
目前没有用。确保与其他模块加载器的兼容性。
Offers a pseudo console
if it is not available.
如果console
不可用,提供了一个伪console
。
Try to evaluate expressions in if(...)
and replace it with true
/false
.
尝试计算if(...)
中的表达式并以true
/false
替换。
If name
is used in a module it is filled by a module loaded by require(<request>)
.
如果name
在一个模块中使用,它将由一个通过require(<request>)
加载的模块填充。
Provide stuff that is normally available in node.js modules.
提供在Node.js模块能正常使用的对象。
It also ensures that module
is filled with some node.js stuff if you use it.
如果你使用了module
,它还保证了module
含有部分node.js的相关属性
Provide stuff that is normally available in require.js.
提供在require.js中能正常使用的对象。
require[js].config
is removed. require.version
is 0.0.0
. requirejs.onError
is mapped to require.onError
.
require[js].config
被移除了。require.version
是 0.0.0
。requirejs.onError
映射为 require.onError
This module adds stuff from node.js that is not available in non-node.js environments.
这个模块添加某些在 node.js 有而在其他非 node.js环境中没有的东西。
It adds polyfills for process
, console
, Buffer
and global
if used. It also binds the built in Node.js replacement modules.
如果使用了的话,它会对process
, console
, Buffer
和 global
对象添加 polyfill。它也绑定了Node.js内置的替换模块。
The plugins should be used if you run the bundle in a node.js environment.
如果您在 Node.js 的环境中运行 bundle,插件应该被使用。
It ensures that native modules are loaded correctly even if bundled.
其保证了,即使经过打包,本地模块依然被正确加载。
Provides AMD-style define
and require
to modules. Also bind require.amd
, define.amd
and __webpack_amd_options__
to the options
passed as parameter.
向模块提供 AMD-风格的 define
and require
。同时将require.amd
, define.amd
和 __webpack_amd_options__
绑定给作为参数传入的options
。
Provides CommonJs-style require
to modules.
向模块提供CommonJS的风格require
。
Provide labels require:
and exports:
to modules.
向模块提供标签特性require:
and exports:
Provides require.context
. The parameter modulesDirectories
and extensions
are used to find alternative requests for files. It's useful to provide the same arrays as you provide to the resolver.
提供 require.context
。modulesDirectories
和extensions
参数是用来寻找额外的文件请求的。提供同样的与之前提供给解析器的数组会很有用。
Provides require.ensure
.
提供require.ensure
。
Provides require.include
.
提供 require.include
。
Define constants for identifier.
为标识符定义常量。
definitions
is an object.
definitions
是一个对象。
Merge chunks limit chunk count is lower than options.maxChunks
.
合并的分块的限制数量需小于options.maxChunks
The overhead for each chunks is provided by options.chunkOverhead
or defaults to 10000. Entry chunks sizes are multiplied by options.entryChunkMultiplicator
(or 10).
每个块的开销是由options.chunkOverhead
提供或默认为10000。入口块的大小由options.entryChunkMultiplicator
(或者 10)倍乘
Chunks that reduce the total size the most are merged first. If multiple combinations are equal the minimal merged size wins.
最大限度降低总大小的块最先被合并。如果多个组合是相等,采用最小合并尺寸。
Chunks with the same modules are merged.
命名相同的分块被合并。
Modules that are included in every parent chunk are removed from the chunk.
被包含在父级分块的模块会从当前分块中移除
Merges chunks until each chunk has the minimum size of minChunkSize
.
合并分块直到每个分块大小不小于minChunkSize
。
Adds chunk ids of chunks which are included in the chunk. This eliminates unnecessary chunk loads.
增加被包括在所述块的分块的分块标识。这消除了不必要的分块加载。
Minimizes the chunks with uglify.js
.
使用uglify.js
压缩分块
options
are uglifyjs options.
options
是uglify.js
的选项。
Order the modules and chunks by occurrence. This saves space, because often referenced modules and chunks get smaller ids.
将模块与分块按出现顺序排序。这可以节省控件,因为经常引用的模块和分块会得到更小的id
preferEntry
If true, references in entry chunks have higher priority
如果preferEntry
为真,入口块中的引用优先级更高。
Deduplicates modules and adds runtime code.
删除重复的模块并增加运行时代码。