@eriche/webpack 4.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +784 -0
- package/SECURITY.md +9 -0
- package/bin/webpack.js +171 -0
- package/buildin/amd-define.js +3 -0
- package/buildin/amd-options.js +2 -0
- package/buildin/global.js +20 -0
- package/buildin/harmony-module.js +24 -0
- package/buildin/module.js +22 -0
- package/buildin/system.js +7 -0
- package/declarations/WebpackOptions.d.ts +1466 -0
- package/declarations/plugins/BannerPlugin.d.ts +49 -0
- package/declarations/plugins/DllPlugin.d.ts +32 -0
- package/declarations/plugins/DllReferencePlugin.d.ts +126 -0
- package/declarations/plugins/HashedModuleIdsPlugin.d.ts +24 -0
- package/declarations/plugins/IgnorePlugin.d.ts +27 -0
- package/declarations/plugins/LoaderOptionsPlugin.d.ts +27 -0
- package/declarations/plugins/ProgressPlugin.d.ts +42 -0
- package/declarations/plugins/SourceMapDevToolPlugin.d.ts +94 -0
- package/declarations/plugins/WatchIgnorePlugin.d.ts +10 -0
- package/declarations/plugins/debug/ProfilingPlugin.d.ts +12 -0
- package/declarations/plugins/optimize/AggressiveSplittingPlugin.d.ts +24 -0
- package/declarations/plugins/optimize/LimitChunkCountPlugin.d.ts +16 -0
- package/declarations/plugins/optimize/MinChunkSizePlugin.d.ts +12 -0
- package/declarations/plugins/optimize/OccurrenceOrderChunkIdsPlugin.d.ts +12 -0
- package/declarations/plugins/optimize/OccurrenceOrderModuleIdsPlugin.d.ts +12 -0
- package/hot/dev-server.js +61 -0
- package/hot/emitter.js +2 -0
- package/hot/log-apply-result.js +44 -0
- package/hot/log.js +59 -0
- package/hot/only-dev-server.js +102 -0
- package/hot/poll.js +37 -0
- package/hot/signal.js +62 -0
- package/lib/APIPlugin.js +84 -0
- package/lib/AbstractMethodError.js +43 -0
- package/lib/AmdMainTemplatePlugin.js +106 -0
- package/lib/AsyncDependenciesBlock.js +110 -0
- package/lib/AsyncDependencyToInitialChunkError.js +31 -0
- package/lib/AutomaticPrefetchPlugin.js +57 -0
- package/lib/BannerPlugin.js +122 -0
- package/lib/BasicEvaluatedExpression.js +248 -0
- package/lib/CachePlugin.js +100 -0
- package/lib/CaseSensitiveModulesWarning.js +67 -0
- package/lib/Chunk.js +875 -0
- package/lib/ChunkGroup.js +513 -0
- package/lib/ChunkRenderError.js +32 -0
- package/lib/ChunkTemplate.js +87 -0
- package/lib/CommentCompilationWarning.js +32 -0
- package/lib/CommonJsStuffPlugin.js +116 -0
- package/lib/CompatibilityPlugin.js +70 -0
- package/lib/Compilation.js +2327 -0
- package/lib/Compiler.js +735 -0
- package/lib/ConcurrentCompilationError.js +19 -0
- package/lib/ConstPlugin.js +348 -0
- package/lib/ContextExclusionPlugin.js +28 -0
- package/lib/ContextModule.js +872 -0
- package/lib/ContextModuleFactory.js +262 -0
- package/lib/ContextReplacementPlugin.js +133 -0
- package/lib/DefinePlugin.js +289 -0
- package/lib/DelegatedModule.js +114 -0
- package/lib/DelegatedModuleFactoryPlugin.js +95 -0
- package/lib/DelegatedPlugin.js +39 -0
- package/lib/DependenciesBlock.js +124 -0
- package/lib/DependenciesBlockVariable.js +72 -0
- package/lib/Dependency.js +89 -0
- package/lib/DllEntryPlugin.js +54 -0
- package/lib/DllModule.js +60 -0
- package/lib/DllModuleFactory.js +29 -0
- package/lib/DllPlugin.js +49 -0
- package/lib/DllReferencePlugin.js +156 -0
- package/lib/DynamicEntryPlugin.js +94 -0
- package/lib/EntryModuleNotFoundError.js +21 -0
- package/lib/EntryOptionPlugin.js +46 -0
- package/lib/Entrypoint.js +64 -0
- package/lib/EnvironmentPlugin.js +72 -0
- package/lib/ErrorHelpers.js +60 -0
- package/lib/EvalDevToolModulePlugin.js +27 -0
- package/lib/EvalDevToolModuleTemplatePlugin.js +61 -0
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +120 -0
- package/lib/EvalSourceMapDevToolPlugin.js +41 -0
- package/lib/ExportPropertyMainTemplatePlugin.js +53 -0
- package/lib/ExtendedAPIPlugin.js +88 -0
- package/lib/ExternalModule.js +179 -0
- package/lib/ExternalModuleFactoryPlugin.js +110 -0
- package/lib/ExternalsPlugin.js +23 -0
- package/lib/FlagAllModulesAsUsedPlugin.js +38 -0
- package/lib/FlagDependencyExportsPlugin.js +174 -0
- package/lib/FlagDependencyUsagePlugin.js +116 -0
- package/lib/FlagInitialModulesAsUsedPlugin.js +36 -0
- package/lib/FunctionModulePlugin.js +19 -0
- package/lib/FunctionModuleTemplatePlugin.js +102 -0
- package/lib/Generator.js +60 -0
- package/lib/GraphHelpers.js +65 -0
- package/lib/HarmonyLinkingError.js +17 -0
- package/lib/HashedModuleIdsPlugin.js +63 -0
- package/lib/HotModuleReplacement.runtime.js +721 -0
- package/lib/HotModuleReplacementPlugin.js +425 -0
- package/lib/HotUpdateChunk.js +17 -0
- package/lib/HotUpdateChunkTemplate.js +78 -0
- package/lib/IgnorePlugin.js +91 -0
- package/lib/JavascriptGenerator.js +229 -0
- package/lib/JavascriptModulesPlugin.js +185 -0
- package/lib/JsonGenerator.js +57 -0
- package/lib/JsonModulesPlugin.js +30 -0
- package/lib/JsonParser.js +27 -0
- package/lib/LibManifestPlugin.js +90 -0
- package/lib/LibraryTemplatePlugin.js +186 -0
- package/lib/LoaderOptionsPlugin.js +58 -0
- package/lib/LoaderTargetPlugin.js +24 -0
- package/lib/MainTemplate.js +568 -0
- package/lib/MemoryOutputFileSystem.js +5 -0
- package/lib/Module.js +435 -0
- package/lib/ModuleBuildError.js +52 -0
- package/lib/ModuleDependencyError.js +35 -0
- package/lib/ModuleDependencyWarning.js +25 -0
- package/lib/ModuleError.js +36 -0
- package/lib/ModuleFilenameHelpers.js +179 -0
- package/lib/ModuleNotFoundError.js +23 -0
- package/lib/ModuleParseError.js +67 -0
- package/lib/ModuleReason.js +48 -0
- package/lib/ModuleTemplate.js +93 -0
- package/lib/ModuleWarning.js +36 -0
- package/lib/MultiCompiler.js +290 -0
- package/lib/MultiEntryPlugin.js +80 -0
- package/lib/MultiModule.js +87 -0
- package/lib/MultiModuleFactory.js +23 -0
- package/lib/MultiStats.js +92 -0
- package/lib/MultiWatching.js +50 -0
- package/lib/NamedChunksPlugin.js +29 -0
- package/lib/NamedModulesPlugin.js +58 -0
- package/lib/NoEmitOnErrorsPlugin.js +20 -0
- package/lib/NoModeWarning.js +23 -0
- package/lib/NodeStuffPlugin.js +118 -0
- package/lib/NormalModule.js +582 -0
- package/lib/NormalModuleFactory.js +528 -0
- package/lib/NormalModuleReplacementPlugin.js +51 -0
- package/lib/NullFactory.js +12 -0
- package/lib/OptionsApply.js +10 -0
- package/lib/OptionsDefaulter.js +141 -0
- package/lib/Parser.js +2454 -0
- package/lib/ParserHelpers.js +103 -0
- package/lib/PrefetchPlugin.js +37 -0
- package/lib/ProgressPlugin.js +307 -0
- package/lib/ProvidePlugin.js +86 -0
- package/lib/RawModule.js +56 -0
- package/lib/RecordIdsPlugin.js +236 -0
- package/lib/RemovedPluginError.js +11 -0
- package/lib/RequestShortener.js +83 -0
- package/lib/RequireJsStuffPlugin.js +66 -0
- package/lib/ResolverFactory.js +74 -0
- package/lib/RuleSet.js +567 -0
- package/lib/RuntimeTemplate.js +336 -0
- package/lib/SetVarMainTemplatePlugin.js +69 -0
- package/lib/SingleEntryPlugin.js +63 -0
- package/lib/SizeFormatHelpers.js +24 -0
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +49 -0
- package/lib/SourceMapDevToolPlugin.js +418 -0
- package/lib/Stats.js +1685 -0
- package/lib/SystemMainTemplatePlugin.js +137 -0
- package/lib/Template.js +291 -0
- package/lib/TemplatedPathPlugin.js +188 -0
- package/lib/UmdMainTemplatePlugin.js +305 -0
- package/lib/UnsupportedFeatureWarning.js +30 -0
- package/lib/UseStrictPlugin.js +54 -0
- package/lib/WarnCaseSensitiveModulesPlugin.js +37 -0
- package/lib/WarnNoModeSetPlugin.js +17 -0
- package/lib/WatchIgnorePlugin.js +106 -0
- package/lib/Watching.js +211 -0
- package/lib/WebpackError.js +31 -0
- package/lib/WebpackOptionsApply.js +546 -0
- package/lib/WebpackOptionsDefaulter.js +391 -0
- package/lib/WebpackOptionsValidationError.js +390 -0
- package/lib/buildChunkGraph.js +712 -0
- package/lib/compareLocations.js +52 -0
- package/lib/debug/ProfilingPlugin.js +442 -0
- package/lib/dependencies/AMDDefineDependency.js +137 -0
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +336 -0
- package/lib/dependencies/AMDPlugin.js +249 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +49 -0
- package/lib/dependencies/AMDRequireContextDependency.js +20 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +47 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +274 -0
- package/lib/dependencies/AMDRequireDependency.js +135 -0
- package/lib/dependencies/AMDRequireItemDependency.js +22 -0
- package/lib/dependencies/CommonJsPlugin.js +158 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +23 -0
- package/lib/dependencies/CommonJsRequireDependency.js +22 -0
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +138 -0
- package/lib/dependencies/ConstDependency.js +33 -0
- package/lib/dependencies/ContextDependency.js +68 -0
- package/lib/dependencies/ContextDependencyHelpers.js +232 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +43 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +39 -0
- package/lib/dependencies/ContextElementDependency.js +21 -0
- package/lib/dependencies/CriticalDependencyWarning.js +20 -0
- package/lib/dependencies/DelegatedExportsDependency.js +33 -0
- package/lib/dependencies/DelegatedSourceDependency.js +18 -0
- package/lib/dependencies/DependencyReference.js +64 -0
- package/lib/dependencies/DllEntryDependency.js +20 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +48 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -0
- package/lib/dependencies/HarmonyCompatibilityDependency.js +31 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +96 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +154 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +58 -0
- package/lib/dependencies/HarmonyExportHeaderDependency.js +30 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +659 -0
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +54 -0
- package/lib/dependencies/HarmonyImportDependency.js +109 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +222 -0
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +31 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +163 -0
- package/lib/dependencies/HarmonyInitDependency.js +60 -0
- package/lib/dependencies/HarmonyModulesPlugin.js +143 -0
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +26 -0
- package/lib/dependencies/ImportContextDependency.js +23 -0
- package/lib/dependencies/ImportDependenciesBlock.js +18 -0
- package/lib/dependencies/ImportDependency.js +34 -0
- package/lib/dependencies/ImportEagerDependency.js +32 -0
- package/lib/dependencies/ImportParserPlugin.js +248 -0
- package/lib/dependencies/ImportPlugin.js +79 -0
- package/lib/dependencies/ImportWeakDependency.js +34 -0
- package/lib/dependencies/JsonExportsDependency.js +26 -0
- package/lib/dependencies/LoaderDependency.js +21 -0
- package/lib/dependencies/LoaderPlugin.js +115 -0
- package/lib/dependencies/LocalModule.js +23 -0
- package/lib/dependencies/LocalModuleDependency.js +28 -0
- package/lib/dependencies/LocalModulesHelpers.js +52 -0
- package/lib/dependencies/ModuleDependency.js +23 -0
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +17 -0
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +17 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +23 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +23 -0
- package/lib/dependencies/MultiEntryDependency.js +25 -0
- package/lib/dependencies/NullDependency.js +20 -0
- package/lib/dependencies/PrefetchDependency.js +18 -0
- package/lib/dependencies/RequireContextDependency.js +22 -0
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +56 -0
- package/lib/dependencies/RequireContextPlugin.js +143 -0
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +33 -0
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +116 -0
- package/lib/dependencies/RequireEnsureDependency.js +58 -0
- package/lib/dependencies/RequireEnsureItemDependency.js +21 -0
- package/lib/dependencies/RequireEnsurePlugin.js +74 -0
- package/lib/dependencies/RequireHeaderDependency.js +26 -0
- package/lib/dependencies/RequireIncludeDependency.js +39 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +23 -0
- package/lib/dependencies/RequireIncludePlugin.js +61 -0
- package/lib/dependencies/RequireResolveContextDependency.js +23 -0
- package/lib/dependencies/RequireResolveDependency.js +22 -0
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +86 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +26 -0
- package/lib/dependencies/SingleEntryDependency.js +21 -0
- package/lib/dependencies/SystemPlugin.js +122 -0
- package/lib/dependencies/UnsupportedDependency.js +27 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +31 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +54 -0
- package/lib/dependencies/WebpackMissingModule.js +20 -0
- package/lib/dependencies/getFunctionExpression.js +52 -0
- package/lib/formatLocation.js +75 -0
- package/lib/logging/Logger.js +128 -0
- package/lib/logging/createConsoleLogger.js +210 -0
- package/lib/logging/runtime.js +36 -0
- package/lib/logging/truncateArgs.js +76 -0
- package/lib/node/NodeChunkTemplatePlugin.js +31 -0
- package/lib/node/NodeEnvironmentPlugin.js +44 -0
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -0
- package/lib/node/NodeMainTemplate.runtime.js +32 -0
- package/lib/node/NodeMainTemplateAsync.runtime.js +50 -0
- package/lib/node/NodeMainTemplatePlugin.js +321 -0
- package/lib/node/NodeOutputFileSystem.js +22 -0
- package/lib/node/NodeSourcePlugin.js +141 -0
- package/lib/node/NodeTargetPlugin.js +19 -0
- package/lib/node/NodeTemplatePlugin.js +31 -0
- package/lib/node/NodeWatchFileSystem.js +109 -0
- package/lib/node/ReadFileCompileWasmTemplatePlugin.js +61 -0
- package/lib/node/nodeConsole.js +135 -0
- package/lib/optimize/AggressiveMergingPlugin.js +87 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +294 -0
- package/lib/optimize/ChunkModuleIdRangePlugin.js +66 -0
- package/lib/optimize/ConcatenatedModule.js +1477 -0
- package/lib/optimize/EnsureChunkConditionsPlugin.js +70 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +99 -0
- package/lib/optimize/LimitChunkCountPlugin.js +231 -0
- package/lib/optimize/MergeDuplicateChunksPlugin.js +78 -0
- package/lib/optimize/MinChunkSizePlugin.js +82 -0
- package/lib/optimize/MinMaxSizeWarning.js +29 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +485 -0
- package/lib/optimize/NaturalChunkOrderPlugin.js +41 -0
- package/lib/optimize/OccurrenceChunkOrderPlugin.js +66 -0
- package/lib/optimize/OccurrenceModuleOrderPlugin.js +112 -0
- package/lib/optimize/OccurrenceOrderPlugin.js +135 -0
- package/lib/optimize/RemoveEmptyChunksPlugin.js +42 -0
- package/lib/optimize/RemoveParentModulesPlugin.js +127 -0
- package/lib/optimize/RuntimeChunkPlugin.js +41 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +352 -0
- package/lib/optimize/SplitChunksPlugin.js +971 -0
- package/lib/performance/AssetsOverSizeLimitWarning.js +30 -0
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +30 -0
- package/lib/performance/NoAsyncChunksWarning.js +21 -0
- package/lib/performance/SizeLimitsPlugin.js +125 -0
- package/lib/util/LazyBucketSortedSet.js +235 -0
- package/lib/util/Queue.js +46 -0
- package/lib/util/Semaphore.js +53 -0
- package/lib/util/SetHelpers.js +48 -0
- package/lib/util/SortableSet.js +140 -0
- package/lib/util/StackedSetMap.js +142 -0
- package/lib/util/TrackingSet.js +35 -0
- package/lib/util/cachedMerge.js +35 -0
- package/lib/util/cleverMerge.js +77 -0
- package/lib/util/createHash.js +174 -0
- package/lib/util/deterministicGrouping.js +274 -0
- package/lib/util/hash/BatchedHash.js +71 -0
- package/lib/util/hash/md4.js +25 -0
- package/lib/util/hash/wasm-hash.js +174 -0
- package/lib/util/identifier.js +127 -0
- package/lib/util/objectToMap.js +16 -0
- package/lib/validateSchema.js +67 -0
- package/lib/wasm/UnsupportedWebAssemblyFeatureError.js +17 -0
- package/lib/wasm/WasmFinalizeExportsPlugin.js +69 -0
- package/lib/wasm/WasmMainTemplatePlugin.js +341 -0
- package/lib/wasm/WebAssemblyGenerator.js +458 -0
- package/lib/wasm/WebAssemblyInInitialChunkError.js +88 -0
- package/lib/wasm/WebAssemblyJavascriptGenerator.js +152 -0
- package/lib/wasm/WebAssemblyModulesPlugin.js +128 -0
- package/lib/wasm/WebAssemblyParser.js +175 -0
- package/lib/wasm/WebAssemblyUtils.js +59 -0
- package/lib/web/FetchCompileWasmTemplatePlugin.js +37 -0
- package/lib/web/JsonpChunkTemplatePlugin.js +71 -0
- package/lib/web/JsonpExportMainTemplatePlugin.js +50 -0
- package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -0
- package/lib/web/JsonpMainTemplate.runtime.js +71 -0
- package/lib/web/JsonpMainTemplatePlugin.js +615 -0
- package/lib/web/JsonpTemplatePlugin.js +23 -0
- package/lib/web/WebEnvironmentPlugin.js +18 -0
- package/lib/webpack.js +206 -0
- package/lib/webpack.web.js +31 -0
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -0
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -0
- package/lib/webworker/WebWorkerMainTemplate.runtime.js +73 -0
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +192 -0
- package/lib/webworker/WebWorkerTemplatePlugin.js +25 -0
- package/package.json +211 -0
- package/schemas/WebpackOptions.json +2285 -0
- package/schemas/ajv.absolutePath.js +57 -0
- package/schemas/plugins/BannerPlugin.json +101 -0
- package/schemas/plugins/DllPlugin.json +36 -0
- package/schemas/plugins/DllReferencePlugin.json +205 -0
- package/schemas/plugins/HashedModuleIdsPlugin.json +26 -0
- package/schemas/plugins/IgnorePlugin.json +37 -0
- package/schemas/plugins/LoaderOptionsPlugin.json +27 -0
- package/schemas/plugins/ProgressPlugin.json +52 -0
- package/schemas/plugins/SourceMapDevToolPlugin.json +185 -0
- package/schemas/plugins/WatchIgnorePlugin.json +18 -0
- package/schemas/plugins/debug/ProfilingPlugin.json +13 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +23 -0
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +16 -0
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +12 -0
- package/schemas/plugins/optimize/OccurrenceOrderChunkIdsPlugin.json +11 -0
- package/schemas/plugins/optimize/OccurrenceOrderModuleIdsPlugin.json +11 -0
- package/web_modules/node-libs-browser.js +0 -0
package/lib/DllPlugin.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const DllEntryPlugin = require("./DllEntryPlugin");
|
|
8
|
+
const FlagAllModulesAsUsedPlugin = require("./FlagAllModulesAsUsedPlugin");
|
|
9
|
+
const LibManifestPlugin = require("./LibManifestPlugin");
|
|
10
|
+
|
|
11
|
+
const validateOptions = require("schema-utils");
|
|
12
|
+
const schema = require("../schemas/plugins/DllPlugin.json");
|
|
13
|
+
|
|
14
|
+
/** @typedef {import("../declarations/plugins/DllPlugin").DllPluginOptions} DllPluginOptions */
|
|
15
|
+
|
|
16
|
+
class DllPlugin {
|
|
17
|
+
/**
|
|
18
|
+
* @param {DllPluginOptions} options options object
|
|
19
|
+
*/
|
|
20
|
+
constructor(options) {
|
|
21
|
+
validateOptions(schema, options, "Dll Plugin");
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
apply(compiler) {
|
|
26
|
+
compiler.hooks.entryOption.tap("DllPlugin", (context, entry) => {
|
|
27
|
+
const itemToPlugin = (item, name) => {
|
|
28
|
+
if (Array.isArray(item)) {
|
|
29
|
+
return new DllEntryPlugin(context, item, name);
|
|
30
|
+
}
|
|
31
|
+
throw new Error("DllPlugin: supply an Array as entry");
|
|
32
|
+
};
|
|
33
|
+
if (typeof entry === "object" && !Array.isArray(entry)) {
|
|
34
|
+
Object.keys(entry).forEach(name => {
|
|
35
|
+
itemToPlugin(entry[name], name).apply(compiler);
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
itemToPlugin(entry, "main").apply(compiler);
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
});
|
|
42
|
+
new LibManifestPlugin(this.options).apply(compiler);
|
|
43
|
+
if (!this.options.entryOnly) {
|
|
44
|
+
new FlagAllModulesAsUsedPlugin("DllPlugin").apply(compiler);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = DllPlugin;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const parseJson = require("json-parse-better-errors");
|
|
8
|
+
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
|
|
9
|
+
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
|
10
|
+
const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
|
|
11
|
+
const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
|
|
12
|
+
const NullFactory = require("./NullFactory");
|
|
13
|
+
const makePathsRelative = require("./util/identifier").makePathsRelative;
|
|
14
|
+
const WebpackError = require("./WebpackError");
|
|
15
|
+
|
|
16
|
+
const validateOptions = require("schema-utils");
|
|
17
|
+
const schema = require("../schemas/plugins/DllReferencePlugin.json");
|
|
18
|
+
|
|
19
|
+
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
|
20
|
+
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsManifest} DllReferencePluginOptionsManifest */
|
|
21
|
+
|
|
22
|
+
class DllReferencePlugin {
|
|
23
|
+
/**
|
|
24
|
+
* @param {DllReferencePluginOptions} options options object
|
|
25
|
+
*/
|
|
26
|
+
constructor(options) {
|
|
27
|
+
validateOptions(schema, options, "Dll Reference Plugin");
|
|
28
|
+
this.options = options;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
apply(compiler) {
|
|
32
|
+
compiler.hooks.compilation.tap(
|
|
33
|
+
"DllReferencePlugin",
|
|
34
|
+
(compilation, { normalModuleFactory }) => {
|
|
35
|
+
compilation.dependencyFactories.set(
|
|
36
|
+
DelegatedSourceDependency,
|
|
37
|
+
normalModuleFactory
|
|
38
|
+
);
|
|
39
|
+
compilation.dependencyFactories.set(
|
|
40
|
+
DelegatedExportsDependency,
|
|
41
|
+
new NullFactory()
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
compiler.hooks.beforeCompile.tapAsync(
|
|
47
|
+
"DllReferencePlugin",
|
|
48
|
+
(params, callback) => {
|
|
49
|
+
if ("manifest" in this.options) {
|
|
50
|
+
const manifest = this.options.manifest;
|
|
51
|
+
if (typeof manifest === "string") {
|
|
52
|
+
params.compilationDependencies.add(manifest);
|
|
53
|
+
compiler.inputFileSystem.readFile(manifest, (err, result) => {
|
|
54
|
+
if (err) return callback(err);
|
|
55
|
+
// Catch errors parsing the manifest so that blank
|
|
56
|
+
// or malformed manifest files don't kill the process.
|
|
57
|
+
try {
|
|
58
|
+
params["dll reference " + manifest] = parseJson(
|
|
59
|
+
result.toString("utf-8")
|
|
60
|
+
);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// Store the error in the params so that it can
|
|
63
|
+
// be added as a compilation error later on.
|
|
64
|
+
const manifestPath = makePathsRelative(
|
|
65
|
+
compiler.options.context,
|
|
66
|
+
manifest
|
|
67
|
+
);
|
|
68
|
+
params[
|
|
69
|
+
"dll reference parse error " + manifest
|
|
70
|
+
] = new DllManifestError(manifestPath, e.message);
|
|
71
|
+
}
|
|
72
|
+
return callback();
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return callback();
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
compiler.hooks.compile.tap("DllReferencePlugin", params => {
|
|
82
|
+
let name = this.options.name;
|
|
83
|
+
let sourceType = this.options.sourceType;
|
|
84
|
+
let content =
|
|
85
|
+
"content" in this.options ? this.options.content : undefined;
|
|
86
|
+
if ("manifest" in this.options) {
|
|
87
|
+
let manifestParameter = this.options.manifest;
|
|
88
|
+
let manifest;
|
|
89
|
+
if (typeof manifestParameter === "string") {
|
|
90
|
+
// If there was an error parsing the manifest
|
|
91
|
+
// file, exit now because the error will be added
|
|
92
|
+
// as a compilation error in the "compilation" hook.
|
|
93
|
+
if (params["dll reference parse error " + manifestParameter]) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
manifest =
|
|
97
|
+
/** @type {DllReferencePluginOptionsManifest} */ (params[
|
|
98
|
+
"dll reference " + manifestParameter
|
|
99
|
+
]);
|
|
100
|
+
} else {
|
|
101
|
+
manifest = manifestParameter;
|
|
102
|
+
}
|
|
103
|
+
if (manifest) {
|
|
104
|
+
if (!name) name = manifest.name;
|
|
105
|
+
if (!sourceType) sourceType = manifest.type;
|
|
106
|
+
if (!content) content = manifest.content;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const externals = {};
|
|
110
|
+
const source = "dll-reference " + name;
|
|
111
|
+
externals[source] = name;
|
|
112
|
+
const normalModuleFactory = params.normalModuleFactory;
|
|
113
|
+
new ExternalModuleFactoryPlugin(sourceType || "var", externals).apply(
|
|
114
|
+
normalModuleFactory
|
|
115
|
+
);
|
|
116
|
+
new DelegatedModuleFactoryPlugin({
|
|
117
|
+
source: source,
|
|
118
|
+
type: this.options.type,
|
|
119
|
+
scope: this.options.scope,
|
|
120
|
+
context: this.options.context || compiler.options.context,
|
|
121
|
+
content,
|
|
122
|
+
extensions: this.options.extensions
|
|
123
|
+
}).apply(normalModuleFactory);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
compiler.hooks.compilation.tap(
|
|
127
|
+
"DllReferencePlugin",
|
|
128
|
+
(compilation, params) => {
|
|
129
|
+
if ("manifest" in this.options) {
|
|
130
|
+
let manifest = this.options.manifest;
|
|
131
|
+
if (typeof manifest === "string") {
|
|
132
|
+
// If there was an error parsing the manifest file, add the
|
|
133
|
+
// error as a compilation error to make the compilation fail.
|
|
134
|
+
let e = params["dll reference parse error " + manifest];
|
|
135
|
+
if (e) {
|
|
136
|
+
compilation.errors.push(e);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
class DllManifestError extends WebpackError {
|
|
146
|
+
constructor(filename, message) {
|
|
147
|
+
super();
|
|
148
|
+
|
|
149
|
+
this.name = "DllManifestError";
|
|
150
|
+
this.message = `Dll manifest ${filename}\n${message}`;
|
|
151
|
+
|
|
152
|
+
Error.captureStackTrace(this, this.constructor);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = DllReferencePlugin;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Naoyuki Kanezawa @nkzawa
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const MultiEntryDependency = require("./dependencies/MultiEntryDependency");
|
|
8
|
+
const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
|
|
9
|
+
const MultiModuleFactory = require("./MultiModuleFactory");
|
|
10
|
+
const MultiEntryPlugin = require("./MultiEntryPlugin");
|
|
11
|
+
const SingleEntryPlugin = require("./SingleEntryPlugin");
|
|
12
|
+
|
|
13
|
+
/** @typedef {import("../declarations/WebpackOptions").EntryDynamic} EntryDynamic */
|
|
14
|
+
/** @typedef {import("../declarations/WebpackOptions").EntryStatic} EntryStatic */
|
|
15
|
+
/** @typedef {import("./Compiler")} Compiler */
|
|
16
|
+
|
|
17
|
+
class DynamicEntryPlugin {
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} context the context path
|
|
20
|
+
* @param {EntryDynamic} entry the entry value
|
|
21
|
+
*/
|
|
22
|
+
constructor(context, entry) {
|
|
23
|
+
this.context = context;
|
|
24
|
+
this.entry = entry;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {Compiler} compiler the compiler instance
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
apply(compiler) {
|
|
32
|
+
compiler.hooks.compilation.tap(
|
|
33
|
+
"DynamicEntryPlugin",
|
|
34
|
+
(compilation, { normalModuleFactory }) => {
|
|
35
|
+
const multiModuleFactory = new MultiModuleFactory();
|
|
36
|
+
|
|
37
|
+
compilation.dependencyFactories.set(
|
|
38
|
+
MultiEntryDependency,
|
|
39
|
+
multiModuleFactory
|
|
40
|
+
);
|
|
41
|
+
compilation.dependencyFactories.set(
|
|
42
|
+
SingleEntryDependency,
|
|
43
|
+
normalModuleFactory
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
compiler.hooks.make.tapAsync(
|
|
49
|
+
"DynamicEntryPlugin",
|
|
50
|
+
(compilation, callback) => {
|
|
51
|
+
/**
|
|
52
|
+
* @param {string|string[]} entry entry value or array of entry values
|
|
53
|
+
* @param {string} name name of entry
|
|
54
|
+
* @returns {Promise<EntryStatic>} returns the promise resolving the Compilation#addEntry function
|
|
55
|
+
*/
|
|
56
|
+
const addEntry = (entry, name) => {
|
|
57
|
+
const dep = DynamicEntryPlugin.createDependency(entry, name);
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
compilation.addEntry(this.context, dep, name, err => {
|
|
60
|
+
if (err) return reject(err);
|
|
61
|
+
resolve();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
Promise.resolve(this.entry()).then(entry => {
|
|
67
|
+
if (typeof entry === "string" || Array.isArray(entry)) {
|
|
68
|
+
addEntry(entry, "main").then(() => callback(), callback);
|
|
69
|
+
} else if (typeof entry === "object") {
|
|
70
|
+
Promise.all(
|
|
71
|
+
Object.keys(entry).map(name => {
|
|
72
|
+
return addEntry(entry[name], name);
|
|
73
|
+
})
|
|
74
|
+
).then(() => callback(), callback);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = DynamicEntryPlugin;
|
|
83
|
+
/**
|
|
84
|
+
* @param {string|string[]} entry entry value or array of entry paths
|
|
85
|
+
* @param {string} name name of entry
|
|
86
|
+
* @returns {SingleEntryDependency|MultiEntryDependency} returns dep
|
|
87
|
+
*/
|
|
88
|
+
DynamicEntryPlugin.createDependency = (entry, name) => {
|
|
89
|
+
if (Array.isArray(entry)) {
|
|
90
|
+
return MultiEntryPlugin.createDependency(entry, name);
|
|
91
|
+
} else {
|
|
92
|
+
return SingleEntryPlugin.createDependency(entry, name);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const WebpackError = require("./WebpackError");
|
|
8
|
+
|
|
9
|
+
class EntryModuleNotFoundError extends WebpackError {
|
|
10
|
+
constructor(err) {
|
|
11
|
+
super("Entry module not found: " + err);
|
|
12
|
+
|
|
13
|
+
this.name = "EntryModuleNotFoundError";
|
|
14
|
+
this.details = err.details;
|
|
15
|
+
this.error = err;
|
|
16
|
+
|
|
17
|
+
Error.captureStackTrace(this, this.constructor);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = EntryModuleNotFoundError;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const SingleEntryPlugin = require("./SingleEntryPlugin");
|
|
8
|
+
const MultiEntryPlugin = require("./MultiEntryPlugin");
|
|
9
|
+
const DynamicEntryPlugin = require("./DynamicEntryPlugin");
|
|
10
|
+
|
|
11
|
+
/** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */
|
|
12
|
+
/** @typedef {import("./Compiler")} Compiler */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} context context path
|
|
16
|
+
* @param {EntryItem} item entry array or single path
|
|
17
|
+
* @param {string} name entry key name
|
|
18
|
+
* @returns {SingleEntryPlugin | MultiEntryPlugin} returns either a single or multi entry plugin
|
|
19
|
+
*/
|
|
20
|
+
const itemToPlugin = (context, item, name) => {
|
|
21
|
+
if (Array.isArray(item)) {
|
|
22
|
+
return new MultiEntryPlugin(context, item, name);
|
|
23
|
+
}
|
|
24
|
+
return new SingleEntryPlugin(context, item, name);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = class EntryOptionPlugin {
|
|
28
|
+
/**
|
|
29
|
+
* @param {Compiler} compiler the compiler instance one is tapping into
|
|
30
|
+
* @returns {void}
|
|
31
|
+
*/
|
|
32
|
+
apply(compiler) {
|
|
33
|
+
compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
|
|
34
|
+
if (typeof entry === "string" || Array.isArray(entry)) {
|
|
35
|
+
itemToPlugin(context, entry, "main").apply(compiler);
|
|
36
|
+
} else if (typeof entry === "object") {
|
|
37
|
+
for (const name of Object.keys(entry)) {
|
|
38
|
+
itemToPlugin(context, entry[name], name).apply(compiler);
|
|
39
|
+
}
|
|
40
|
+
} else if (typeof entry === "function") {
|
|
41
|
+
new DynamicEntryPlugin(context, entry).apply(compiler);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const ChunkGroup = require("./ChunkGroup");
|
|
8
|
+
|
|
9
|
+
/** @typedef {import("./Chunk")} Chunk */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Entrypoint serves as an encapsulation primitive for chunks that are
|
|
13
|
+
* a part of a single ChunkGroup. They represent all bundles that need to be loaded for a
|
|
14
|
+
* single instance of a page. Multi-page application architectures will typically yield multiple Entrypoint objects
|
|
15
|
+
* inside of the compilation, whereas a Single Page App may only contain one with many lazy-loaded chunks.
|
|
16
|
+
*/
|
|
17
|
+
class Entrypoint extends ChunkGroup {
|
|
18
|
+
/**
|
|
19
|
+
* Creates an instance of Entrypoint.
|
|
20
|
+
* @param {string} name the name of the entrypoint
|
|
21
|
+
*/
|
|
22
|
+
constructor(name) {
|
|
23
|
+
super(name);
|
|
24
|
+
/** @type {Chunk=} */
|
|
25
|
+
this.runtimeChunk = undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* isInitial will always return true for Entrypoint ChunkGroup.
|
|
30
|
+
* @returns {true} returns true as all entrypoints are initial ChunkGroups
|
|
31
|
+
*/
|
|
32
|
+
isInitial() {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sets the runtimeChunk for an entrypoint.
|
|
38
|
+
* @param {Chunk} chunk the chunk being set as the runtime chunk.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
setRuntimeChunk(chunk) {
|
|
42
|
+
this.runtimeChunk = chunk;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Fetches the chunk reference containing the webpack bootstrap code
|
|
47
|
+
* @returns {Chunk} returns the runtime chunk or first chunk in `this.chunks`
|
|
48
|
+
*/
|
|
49
|
+
getRuntimeChunk() {
|
|
50
|
+
return this.runtimeChunk || this.chunks[0];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {Chunk} oldChunk chunk to be replaced
|
|
55
|
+
* @param {Chunk} newChunk New chunk that will be replaced with
|
|
56
|
+
* @returns {boolean} returns true if the replacement was successful
|
|
57
|
+
*/
|
|
58
|
+
replaceChunk(oldChunk, newChunk) {
|
|
59
|
+
if (this.runtimeChunk === oldChunk) this.runtimeChunk = newChunk;
|
|
60
|
+
return super.replaceChunk(oldChunk, newChunk);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = Entrypoint;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Authors Simen Brekken @simenbrekken, Einar Löve @einarlove
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
/** @typedef {import("./Compiler")} Compiler */
|
|
9
|
+
|
|
10
|
+
const WebpackError = require("./WebpackError");
|
|
11
|
+
const DefinePlugin = require("./DefinePlugin");
|
|
12
|
+
|
|
13
|
+
const needsEnvVarFix =
|
|
14
|
+
["8", "9"].indexOf(process.versions.node.split(".")[0]) >= 0 &&
|
|
15
|
+
process.platform === "win32";
|
|
16
|
+
|
|
17
|
+
class EnvironmentPlugin {
|
|
18
|
+
constructor(...keys) {
|
|
19
|
+
if (keys.length === 1 && Array.isArray(keys[0])) {
|
|
20
|
+
this.keys = keys[0];
|
|
21
|
+
this.defaultValues = {};
|
|
22
|
+
} else if (keys.length === 1 && keys[0] && typeof keys[0] === "object") {
|
|
23
|
+
this.keys = Object.keys(keys[0]);
|
|
24
|
+
this.defaultValues = keys[0];
|
|
25
|
+
} else {
|
|
26
|
+
this.keys = keys;
|
|
27
|
+
this.defaultValues = {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {Compiler} compiler webpack compiler instance
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
apply(compiler) {
|
|
36
|
+
const definitions = this.keys.reduce((defs, key) => {
|
|
37
|
+
// TODO remove once the fix has made its way into Node 8.
|
|
38
|
+
// Work around https://github.com/nodejs/node/pull/18463,
|
|
39
|
+
// affecting Node 8 & 9 by performing an OS-level
|
|
40
|
+
// operation that always succeeds before reading
|
|
41
|
+
// environment variables:
|
|
42
|
+
if (needsEnvVarFix) require("os").cpus();
|
|
43
|
+
|
|
44
|
+
const value =
|
|
45
|
+
process.env[key] !== undefined
|
|
46
|
+
? process.env[key]
|
|
47
|
+
: this.defaultValues[key];
|
|
48
|
+
|
|
49
|
+
if (value === undefined) {
|
|
50
|
+
compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => {
|
|
51
|
+
const error = new WebpackError(
|
|
52
|
+
`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
|
|
53
|
+
"You can pass an object with default values to suppress this warning.\n" +
|
|
54
|
+
"See https://webpack.js.org/plugins/environment-plugin for example."
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
error.name = "EnvVariableNotDefinedError";
|
|
58
|
+
compilation.warnings.push(error);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
defs[`process.env.${key}`] =
|
|
63
|
+
value === undefined ? "undefined" : JSON.stringify(value);
|
|
64
|
+
|
|
65
|
+
return defs;
|
|
66
|
+
}, {});
|
|
67
|
+
|
|
68
|
+
new DefinePlugin(definitions).apply(compiler);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = EnvironmentPlugin;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const loaderFlag = "LOADER_EXECUTION";
|
|
8
|
+
|
|
9
|
+
const webpackOptionsFlag = "WEBPACK_OPTIONS";
|
|
10
|
+
|
|
11
|
+
exports.cutOffByFlag = (stack, flag) => {
|
|
12
|
+
stack = stack.split("\n");
|
|
13
|
+
for (let i = 0; i < stack.length; i++) {
|
|
14
|
+
if (stack[i].includes(flag)) {
|
|
15
|
+
stack.length = i;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return stack.join("\n");
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.cutOffLoaderExecution = stack =>
|
|
22
|
+
exports.cutOffByFlag(stack, loaderFlag);
|
|
23
|
+
|
|
24
|
+
exports.cutOffWebpackOptions = stack =>
|
|
25
|
+
exports.cutOffByFlag(stack, webpackOptionsFlag);
|
|
26
|
+
|
|
27
|
+
exports.cutOffMultilineMessage = (stack, message) => {
|
|
28
|
+
stack = stack.split("\n");
|
|
29
|
+
message = message.split("\n");
|
|
30
|
+
|
|
31
|
+
return stack
|
|
32
|
+
.reduce(
|
|
33
|
+
(acc, line, idx) =>
|
|
34
|
+
line.includes(message[idx]) ? acc : acc.concat(line),
|
|
35
|
+
[]
|
|
36
|
+
)
|
|
37
|
+
.join("\n");
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.cutOffMessage = (stack, message) => {
|
|
41
|
+
const nextLine = stack.indexOf("\n");
|
|
42
|
+
if (nextLine === -1) {
|
|
43
|
+
return stack === message ? "" : stack;
|
|
44
|
+
} else {
|
|
45
|
+
const firstLine = stack.substr(0, nextLine);
|
|
46
|
+
return firstLine === message ? stack.substr(nextLine + 1) : stack;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.cleanUp = (stack, message) => {
|
|
51
|
+
stack = exports.cutOffLoaderExecution(stack);
|
|
52
|
+
stack = exports.cutOffMessage(stack, message);
|
|
53
|
+
return stack;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.cleanUpWebpackOptions = (stack, message) => {
|
|
57
|
+
stack = exports.cutOffWebpackOptions(stack);
|
|
58
|
+
stack = exports.cutOffMultilineMessage(stack, message);
|
|
59
|
+
return stack;
|
|
60
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const EvalDevToolModuleTemplatePlugin = require("./EvalDevToolModuleTemplatePlugin");
|
|
8
|
+
|
|
9
|
+
class EvalDevToolModulePlugin {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.sourceUrlComment = options.sourceUrlComment;
|
|
12
|
+
this.moduleFilenameTemplate = options.moduleFilenameTemplate;
|
|
13
|
+
this.namespace = options.namespace;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
apply(compiler) {
|
|
17
|
+
compiler.hooks.compilation.tap("EvalDevToolModulePlugin", compilation => {
|
|
18
|
+
new EvalDevToolModuleTemplatePlugin({
|
|
19
|
+
sourceUrlComment: this.sourceUrlComment,
|
|
20
|
+
moduleFilenameTemplate: this.moduleFilenameTemplate,
|
|
21
|
+
namespace: this.namespace
|
|
22
|
+
}).apply(compilation.moduleTemplates.javascript);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = EvalDevToolModulePlugin;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const { RawSource } = require("webpack-sources");
|
|
8
|
+
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
|
9
|
+
|
|
10
|
+
const cache = new WeakMap();
|
|
11
|
+
|
|
12
|
+
class EvalDevToolModuleTemplatePlugin {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.sourceUrlComment = options.sourceUrlComment || "\n//# sourceURL=[url]";
|
|
15
|
+
this.moduleFilenameTemplate =
|
|
16
|
+
options.moduleFilenameTemplate ||
|
|
17
|
+
"webpack://[namespace]/[resourcePath]?[loaders]";
|
|
18
|
+
this.namespace = options.namespace || "";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply(moduleTemplate) {
|
|
22
|
+
moduleTemplate.hooks.module.tap(
|
|
23
|
+
"EvalDevToolModuleTemplatePlugin",
|
|
24
|
+
(source, module) => {
|
|
25
|
+
const cacheEntry = cache.get(source);
|
|
26
|
+
if (cacheEntry !== undefined) return cacheEntry;
|
|
27
|
+
const content = source.source();
|
|
28
|
+
const str = ModuleFilenameHelpers.createFilename(
|
|
29
|
+
module,
|
|
30
|
+
{
|
|
31
|
+
moduleFilenameTemplate: this.moduleFilenameTemplate,
|
|
32
|
+
namespace: this.namespace
|
|
33
|
+
},
|
|
34
|
+
moduleTemplate.runtimeTemplate.requestShortener
|
|
35
|
+
);
|
|
36
|
+
const footer =
|
|
37
|
+
"\n" +
|
|
38
|
+
this.sourceUrlComment.replace(
|
|
39
|
+
/\[url\]/g,
|
|
40
|
+
encodeURI(str)
|
|
41
|
+
.replace(/%2F/g, "/")
|
|
42
|
+
.replace(/%20/g, "_")
|
|
43
|
+
.replace(/%5E/g, "^")
|
|
44
|
+
.replace(/%5C/g, "\\")
|
|
45
|
+
.replace(/^\//, "")
|
|
46
|
+
);
|
|
47
|
+
const result = new RawSource(
|
|
48
|
+
`eval(${JSON.stringify(content + footer)});`
|
|
49
|
+
);
|
|
50
|
+
cache.set(source, result);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
moduleTemplate.hooks.hash.tap("EvalDevToolModuleTemplatePlugin", hash => {
|
|
55
|
+
hash.update("EvalDevToolModuleTemplatePlugin");
|
|
56
|
+
hash.update("2");
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = EvalDevToolModuleTemplatePlugin;
|