2018-12-09 21:26:35 +08:00
/ *
MIT License http : //www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @ sokra
* /
"use strict" ;
2019-08-08 18:44:45 +08:00
const validate = require ( "schema-utils" ) ;
2018-12-09 21:26:35 +08:00
const util = require ( "util" ) ;
const { version } = require ( "../package.json" ) ;
const webpackOptionsSchema = require ( "../schemas/WebpackOptions.json" ) ;
const WebpackOptionsApply = require ( "./WebpackOptionsApply" ) ;
2020-02-17 17:27:46 +08:00
const memorize = require ( "./util/memorize" ) ;
2019-08-08 18:44:45 +08:00
const validateSchema = require ( "./validateSchema" ) ;
2018-12-09 21:26:35 +08:00
const webpack = require ( "./webpack" ) ;
2019-08-06 14:55:00 +08:00
module . exports = webpack ;
module . exports . WebpackOptionsApply = WebpackOptionsApply ;
module . exports . validate = validateSchema . bind ( null , webpackOptionsSchema ) ;
module . exports . validateSchema = validateSchema ;
module . exports . version = version ;
2018-12-09 21:26:35 +08:00
const exportPlugins = ( obj , mappings ) => {
for ( const name of Object . keys ( mappings ) ) {
Object . defineProperty ( obj , name , {
configurable : false ,
enumerable : true ,
2020-02-17 17:27:46 +08:00
get : memorize ( mappings [ name ] )
2018-12-09 21:26:35 +08:00
} ) ;
}
} ;
2019-08-06 14:55:00 +08:00
exportPlugins ( module . exports , {
2018-12-09 21:26:35 +08:00
AutomaticPrefetchPlugin : ( ) => require ( "./AutomaticPrefetchPlugin" ) ,
BannerPlugin : ( ) => require ( "./BannerPlugin" ) ,
2019-05-13 17:03:10 +08:00
Cache : ( ) => require ( "./Cache" ) ,
2019-10-09 23:11:34 +08:00
Compilation : ( ) => require ( "./Compilation" ) ,
2020-02-17 17:27:46 +08:00
Compiler : ( ) => require ( "./Compiler" ) ,
2018-12-09 21:26:35 +08:00
ContextExclusionPlugin : ( ) => require ( "./ContextExclusionPlugin" ) ,
ContextReplacementPlugin : ( ) => require ( "./ContextReplacementPlugin" ) ,
DefinePlugin : ( ) => require ( "./DefinePlugin" ) ,
2019-10-09 23:11:34 +08:00
DelegatedPlugin : ( ) => require ( "./DelegatedPlugin" ) ,
2018-12-09 21:26:35 +08:00
Dependency : ( ) => require ( "./Dependency" ) ,
DllPlugin : ( ) => require ( "./DllPlugin" ) ,
DllReferencePlugin : ( ) => require ( "./DllReferencePlugin" ) ,
EntryPlugin : ( ) => require ( "./EntryPlugin" ) ,
EnvironmentPlugin : ( ) => require ( "./EnvironmentPlugin" ) ,
EvalDevToolModulePlugin : ( ) => require ( "./EvalDevToolModulePlugin" ) ,
EvalSourceMapDevToolPlugin : ( ) => require ( "./EvalSourceMapDevToolPlugin" ) ,
ExternalsPlugin : ( ) => require ( "./ExternalsPlugin" ) ,
2019-10-09 23:11:34 +08:00
Generator : ( ) => require ( "./Generator" ) ,
2018-12-09 21:26:35 +08:00
HotModuleReplacementPlugin : ( ) => require ( "./HotModuleReplacementPlugin" ) ,
IgnorePlugin : ( ) => require ( "./IgnorePlugin" ) ,
2019-10-22 15:09:28 +08:00
JavascriptModulesPlugin : util . deprecate (
( ) => require ( "./javascript/JavascriptModulesPlugin" ) ,
"webpack.JavascriptModulesPlugin has moved to webpack.javascript.JavascriptModulesPlugin" ,
"DEP_WEBPACK_JAVASCRIPT_MODULES_PLUGIN"
) ,
2019-10-09 23:11:34 +08:00
LibManifestPlugin : ( ) => require ( "./LibManifestPlugin" ) ,
2020-02-20 03:25:49 +08:00
LibraryTemplatePlugin : util . deprecate (
( ) => require ( "./LibraryTemplatePlugin" ) ,
"webpack.LibraryTemplatePlugin is deprecated and has been replaced by compilation.outputOptions.library or compilation.addEntry + passing a library option" ,
"DEP_WEBPACK_LIBRARY_TEMPLATE_PLUGIN"
) ,
2018-12-09 21:26:35 +08:00
LoaderOptionsPlugin : ( ) => require ( "./LoaderOptionsPlugin" ) ,
LoaderTargetPlugin : ( ) => require ( "./LoaderTargetPlugin" ) ,
Module : ( ) => require ( "./Module" ) ,
ModuleFilenameHelpers : ( ) => require ( "./ModuleFilenameHelpers" ) ,
NoEmitOnErrorsPlugin : ( ) => require ( "./NoEmitOnErrorsPlugin" ) ,
2019-10-09 19:50:52 +08:00
NormalModule : ( ) => require ( "./NormalModule" ) ,
2018-12-09 21:26:35 +08:00
NormalModuleReplacementPlugin : ( ) =>
require ( "./NormalModuleReplacementPlugin" ) ,
2020-02-17 17:27:46 +08:00
MultiCompiler : ( ) => require ( "./MultiCompiler" ) ,
2019-11-30 03:24:13 +08:00
Parser : ( ) => require ( "./Parser" ) ,
2018-12-09 21:26:35 +08:00
PrefetchPlugin : ( ) => require ( "./PrefetchPlugin" ) ,
ProgressPlugin : ( ) => require ( "./ProgressPlugin" ) ,
ProvidePlugin : ( ) => require ( "./ProvidePlugin" ) ,
2019-10-09 23:11:34 +08:00
RuntimeGlobals : ( ) => require ( "./RuntimeGlobals" ) ,
RuntimeModule : ( ) => require ( "./RuntimeModule" ) ,
2018-12-09 21:26:35 +08:00
SingleEntryPlugin : util . deprecate (
( ) => require ( "./EntryPlugin" ) ,
2019-11-14 22:01:25 +08:00
"SingleEntryPlugin was renamed to EntryPlugin" ,
"DEP_WEBPACK_SINGLE_ENTRY_PLUGIN"
2018-12-09 21:26:35 +08:00
) ,
SourceMapDevToolPlugin : ( ) => require ( "./SourceMapDevToolPlugin" ) ,
Stats : ( ) => require ( "./Stats" ) ,
Template : ( ) => require ( "./Template" ) ,
2020-02-17 17:27:46 +08:00
WatchIgnorePlugin : ( ) => require ( "./WatchIgnorePlugin" ) ,
WebpackOptionsDefaulter : util . deprecate (
( ) => require ( "./WebpackOptionsDefaulter" ) ,
"webpack.WebpackOptionsDefaulter is deprecated and has been replaced by webpack.config.getNormalizedWebpackOptions and webpack.config.applyWebpackOptionsDefaults" ,
"DEP_WEBPACK_OPTIONS_DEFAULTER"
) ,
// TODO webpack 6 deprecate
WebpackOptionsValidationError : ( ) => validate . ValidationError ,
ValidationError : ( ) => validate . ValidationError
2018-12-09 21:26:35 +08:00
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . cache = { } ) , {
2018-12-09 21:26:35 +08:00
MemoryCachePlugin : ( ) => require ( "./cache/MemoryCachePlugin" )
} ) ;
2020-02-17 17:27:46 +08:00
exportPlugins ( ( module . exports . config = { } ) , {
getNormalizedWebpackOptions : ( ) =>
require ( "./config/normalization" ) . getNormalizedWebpackOptions ,
applyWebpackOptionsDefaults : ( ) =>
require ( "./config/defaults" ) . applyWebpackOptionsDefaults
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . ids = { } ) , {
2018-12-09 21:26:35 +08:00
ChunkModuleIdRangePlugin : ( ) => require ( "./ids/ChunkModuleIdRangePlugin" ) ,
NaturalModuleIdsPlugin : ( ) => require ( "./ids/NaturalModuleIdsPlugin" ) ,
OccurrenceModuleIdsPlugin : ( ) => require ( "./ids/OccurrenceModuleIdsPlugin" ) ,
NamedModuleIdsPlugin : ( ) => require ( "./ids/NamedModuleIdsPlugin" ) ,
DeterministicModuleIdsPlugin : ( ) =>
require ( "./ids/DeterministicModuleIdsPlugin" ) ,
NamedChunkIdsPlugin : ( ) => require ( "./ids/NamedChunkIdsPlugin" ) ,
OccurrenceChunkIdsPlugin : ( ) => require ( "./ids/OccurrenceChunkIdsPlugin" ) ,
HashedModuleIdsPlugin : ( ) => require ( "./ids/HashedModuleIdsPlugin" )
} ) ;
2019-10-22 15:09:28 +08:00
exportPlugins ( ( module . exports . javascript = { } ) , {
JavascriptModulesPlugin : ( ) => require ( "./javascript/JavascriptModulesPlugin" )
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . optimize = { } ) , {
2018-12-09 21:26:35 +08:00
AggressiveMergingPlugin : ( ) => require ( "./optimize/AggressiveMergingPlugin" ) ,
AggressiveSplittingPlugin : util . deprecate (
( ) => require ( "./optimize/AggressiveSplittingPlugin" ) ,
2019-11-14 22:01:25 +08:00
"AggressiveSplittingPlugin is deprecated in favor of SplitChunksPlugin" ,
"DEP_WEBPACK_AGGRESSIVE_SPLITTING_PLUGIN"
2018-12-09 21:26:35 +08:00
) ,
LimitChunkCountPlugin : ( ) => require ( "./optimize/LimitChunkCountPlugin" ) ,
MinChunkSizePlugin : ( ) => require ( "./optimize/MinChunkSizePlugin" ) ,
ModuleConcatenationPlugin : ( ) =>
require ( "./optimize/ModuleConcatenationPlugin" ) ,
RuntimeChunkPlugin : ( ) => require ( "./optimize/RuntimeChunkPlugin" ) ,
SideEffectsFlagPlugin : ( ) => require ( "./optimize/SideEffectsFlagPlugin" ) ,
SplitChunksPlugin : ( ) => require ( "./optimize/SplitChunksPlugin" )
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . web = { } ) , {
2018-12-09 21:26:35 +08:00
FetchCompileWasmPlugin : ( ) => require ( "./web/FetchCompileWasmPlugin" ) ,
JsonpTemplatePlugin : ( ) => require ( "./web/JsonpTemplatePlugin" )
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . webworker = { } ) , {
2018-12-09 21:26:35 +08:00
WebWorkerTemplatePlugin : ( ) => require ( "./webworker/WebWorkerTemplatePlugin" )
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . node = { } ) , {
2018-12-10 18:40:59 +08:00
NodeEnvironmentPlugin : ( ) => require ( "./node/NodeEnvironmentPlugin" ) ,
2018-12-09 21:26:35 +08:00
NodeTemplatePlugin : ( ) => require ( "./node/NodeTemplatePlugin" ) ,
ReadFileCompileWasmPlugin : ( ) => require ( "./node/ReadFileCompileWasmPlugin" )
} ) ;
2019-10-09 19:50:52 +08:00
exportPlugins ( ( module . exports . wasm = { } ) , {
AsyncWebAssemblyModulesPlugin : ( ) =>
require ( "./wasm-async/AsyncWebAssemblyModulesPlugin" )
} ) ;
2020-02-20 03:25:49 +08:00
exportPlugins ( ( module . exports . library = { } ) , {
AbstractLibraryPlugin : ( ) => require ( "./library/AbstractLibraryPlugin" ) ,
EnableLibraryPlugin : ( ) => require ( "./library/EnableLibraryPlugin" )
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . debug = { } ) , {
2018-12-09 21:26:35 +08:00
ProfilingPlugin : ( ) => require ( "./debug/ProfilingPlugin" )
} ) ;
2019-08-06 14:55:00 +08:00
exportPlugins ( ( module . exports . util = { } ) , {
2018-12-09 21:26:35 +08:00
createHash : ( ) => require ( "./util/createHash" ) ,
2018-12-28 20:18:02 +08:00
comparators : ( ) => require ( "./util/comparators" ) ,
serialization : ( ) => require ( "./util/serialization" )
2018-12-09 21:26:35 +08:00
} ) ;