diff --git a/.gitignore b/.gitignore index 2ed9b1619..40dea4da6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /node_modules /test/js /test/browsertest/js -/test/fixtures/temp-cache-fixture* +/test/fixtures/temp-* /benchmark/js /benchmark/fixtures /examples/**/dist diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 8941d31b5..0a2a47996 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -1302,7 +1302,12 @@ export interface OutputOptions { /** * The `publicPath` specifies the public URL address of the output files when referenced in a browser. */ - publicPath?: string | Function; + publicPath?: + | string + | (( + pathData: import("../lib/Compilation").PathData, + assetInfo?: import("../lib/Compilation").AssetInfo + ) => string); /** * The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory. */ diff --git a/lib/ChunkTemplate.js b/lib/ChunkTemplate.js index 988f11527..e472c8e2e 100644 --- a/lib/ChunkTemplate.js +++ b/lib/ChunkTemplate.js @@ -5,78 +5,119 @@ "use strict"; -const { SyncWaterfallHook, SyncHook } = require("tapable"); +const util = require("util"); +const memorize = require("./util/memorize"); -/** @typedef {import("./ModuleTemplate")} ModuleTemplate */ -/** @typedef {import("./Chunk")} Chunk */ -/** @typedef {import("./Module")} Module} */ -/** @typedef {import("./util/Hash")} Hash} */ -/** @typedef {import("webpack-sources").Source} Source} */ -/** @typedef {import("./ModuleTemplate").RenderContext} RenderContext} */ -/** @typedef {import("./MainTemplate").UpdateHashForChunkContext} UpdateHashForChunkContext} */ -/** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions} */ -/** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry} */ +/** @typedef {import("./Compilation")} Compilation */ -module.exports = class ChunkTemplate { - constructor(outputOptions) { - this.outputOptions = outputOptions || {}; +const getJavascriptModulesPlugin = memorize(() => + require("./JavascriptModulesPlugin") +); + +// TODO webpack 6 remove this class +class ChunkTemplate { + /** + * @param {TODO} outputOptions TODO + * @param {Compilation} compilation the compilation + */ + constructor(outputOptions, compilation) { + this._outputOptions = outputOptions || {}; + const moduleTemplate = null; // TODO add deprecated ModuleTemplate this.hooks = Object.freeze({ - /** @type {SyncWaterfallHook<[RenderManifestEntry[], RenderManifestOptions]>} */ - renderManifest: new SyncWaterfallHook(["result", "options"]), - /** @type {SyncWaterfallHook<[Source, ModuleTemplate, RenderContext]>} */ - modules: new SyncWaterfallHook([ - "source", - "moduleTemplate", - "renderContext" - ]), - /** @type {SyncWaterfallHook<[Source, ModuleTemplate, RenderContext]>} */ - render: new SyncWaterfallHook([ - "source", - "moduleTemplate", - "renderContext" - ]), - /** @type {SyncWaterfallHook<[Source, Chunk]>} */ - renderWithEntry: new SyncWaterfallHook(["source", "chunk"]), - /** @type {SyncHook<[Hash]>} */ - hash: new SyncHook(["hash"]), - /** @type {SyncHook<[Hash, Chunk]>} */ - hashForChunk: new SyncHook(["hash", "chunk"]) + renderManifest: { + tap: util.deprecate( + (options, fn) => { + compilation.hooks.renderManifest.tap( + options, + (entries, options) => { + if (options.chunk.hasRuntime()) return entries; + return fn(entries, options); + } + ); + }, + "ChunkTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead)", + "DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_MANIFEST" + ) + }, + modules: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderChunk.tap(options, (source, renderContext) => + fn(source, moduleTemplate, renderContext) + ); + }, + "ChunkTemplate.hooks.modules is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderChunk instead)", + "DEP_WEBPACK_CHUNK_TEMPLATE_MODULES" + ) + }, + render: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderChunk.tap(options, (source, renderContext) => + fn(source, moduleTemplate, renderContext) + ); + }, + "ChunkTemplate.hooks.render is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderChunk instead)", + "DEP_WEBPACK_CHUNK_TEMPLATE_RENDER" + ) + }, + renderWithEntry: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderWithEntry.tap(options, (source, renderContext) => { + if (renderContext.chunk.hasRuntime()) return source; + return fn(source, renderContext.chunk); + }); + }, + "ChunkTemplate.hooks.renderWithEntry is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderWithEntry instead)", + "DEP_WEBPACK_CHUNK_TEMPLATE_RENDER_WITH_ENTRY" + ) + }, + hash: { + tap: util.deprecate( + (options, fn) => { + compilation.hooks.fullHash.tap(options, fn); + }, + "ChunkTemplate.hooks.hash is deprecated (use Compilation.hooks.fullHash instead)", + "DEP_WEBPACK_CHUNK_TEMPLATE_HASH" + ) + }, + hashForChunk: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .chunkHash.tap(options, (chunk, hash, context) => { + if (chunk.hasRuntime()) return; + fn(hash, chunk, context); + }); + }, + "ChunkTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead)", + "DEP_WEBPACK_CHUNK_TEMPLATE_HASH_FOR_CHUNK" + ) + } }); } +} - /** - * - * @param {RenderManifestOptions} options render manifest options - * @returns {RenderManifestEntry[]} returns render manifest - */ - getRenderManifest(options) { - const result = []; +Object.defineProperty(ChunkTemplate.prototype, "outputOptions", { + get: util.deprecate( + /** + * @this {ChunkTemplate} + * @returns {TODO} output options + */ + function() { + return this._outputOptions; + }, + "ChunkTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)", + "DEP_WEBPACK_CHUNK_TEMPLATE_OUTPUT_OPTIONS" + ) +}); - this.hooks.renderManifest.call(result, options); - - return result; - } - - /** - * Updates hash with information from this template - * @param {Hash} hash the hash to update - * @returns {void} - */ - updateHash(hash) { - hash.update("ChunkTemplate"); - hash.update("3"); - this.hooks.hash.call(hash); - } - - /** - * Updates hash with chunk-specific information from this template - * @param {Hash} hash the hash to update - * @param {Chunk} chunk the chunk - * @param {UpdateHashForChunkContext} context options object - * @returns {void} - */ - updateHashForChunk(hash, chunk, context) { - this.updateHash(hash); - this.hooks.hashForChunk.call(hash, chunk); - } -}; +module.exports = ChunkTemplate; diff --git a/lib/Compilation.js b/lib/Compilation.js index 970b1fdc5..de68a6db4 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -68,6 +68,7 @@ const { arrayToSetDeprecation } = require("./util/deprecation"); /** @typedef {import("./ModuleFactory")} ModuleFactory */ /** @typedef {import("./RuntimeModule")} RuntimeModule */ /** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry */ +/** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions */ /** @typedef {import("./WebpackError")} WebpackError */ /** @typedef {import("./dependencies/DependencyReference")} DependencyReference */ /** @typedef {import("./dependencies/DllEntryDependency")} DllEntryDependency */ @@ -127,6 +128,13 @@ const { arrayToSetDeprecation } = require("./util/deprecation"); * @property {(Record string>)=} contentHashWithLength */ +/** + * @typedef {Object} ChunkHashContext + * @property {RuntimeTemplate} runtimeTemplate the runtime template + * @property {ModuleGraph} moduleGraph the module graph + * @property {ChunkGraph} chunkGraph the chunk graph + */ + /** * @typedef {Object} LogEntry * @property {string} type @@ -407,15 +415,21 @@ class Compilation { /** @type {AsyncSeriesHook<[]>} */ afterSeal: new AsyncSeriesHook([]), - /** @type {SyncHook<[Chunk, Hash]>} */ - chunkHash: new SyncHook(["chunk", "chunkHash"]), + /** @type {SyncWaterfallHook<[RenderManifestEntry[], RenderManifestOptions]>} */ + renderManifest: new SyncWaterfallHook(["result", "options"]), + + /** @type {SyncHook<[Hash]>} */ + fullHash: new SyncHook(["hash"]), + /** @type {SyncHook<[Chunk, Hash, ChunkHashContext]>} */ + chunkHash: new SyncHook(["chunk", "chunkHash", "ChunkHashContext"]), + /** @type {SyncHook<[Module, string]>} */ moduleAsset: new SyncHook(["module", "filename"]), /** @type {SyncHook<[Chunk, string]>} */ chunkAsset: new SyncHook(["chunk", "filename"]), - /** @type {SyncWaterfallHook<[string, TODO]>} */ - assetPath: new SyncWaterfallHook(["filename", "data"]), // TODO MainTemplate + /** @type {SyncWaterfallHook<[string, object, AssetInfo]>} */ + assetPath: new SyncWaterfallHook(["path", "options", "assetInfo"]), /** @type {SyncBailHook<[], boolean>} */ needAdditionalPass: new SyncBailHook([]), @@ -471,18 +485,36 @@ class Compilation { /** @type {boolean} */ this.profile = (options && options.profile) || false; - this.mainTemplate = new MainTemplate(this.outputOptions); - this.chunkTemplate = new ChunkTemplate(this.outputOptions); + this.mainTemplate = new MainTemplate(this.outputOptions, this); + this.chunkTemplate = new ChunkTemplate(this.outputOptions, this); this.runtimeTemplate = new RuntimeTemplate( this.outputOptions, this.requestShortener ); - /** @type {{asset: ModuleTemplate, javascript: ModuleTemplate, webassembly: ModuleTemplate}} */ + /** @type {{javascript: ModuleTemplate}} */ this.moduleTemplates = { - asset: new ModuleTemplate(this.runtimeTemplate, "asset"), - javascript: new ModuleTemplate(this.runtimeTemplate, "javascript"), - webassembly: new ModuleTemplate(this.runtimeTemplate, "webassembly") + javascript: new ModuleTemplate(this.runtimeTemplate, this) }; + Object.defineProperties(this.moduleTemplates, { + asset: { + enumerable: false, + configurable: false, + get() { + throw new WebpackError( + "Compilation.moduleTemplates.asset has been removed" + ); + } + }, + webassembly: { + enumerable: false, + configurable: false, + get() { + throw new WebpackError( + "Compilation.moduleTemplates.webassembly has been removed" + ); + } + } + }); this.moduleGraph = new ModuleGraph(); this.chunkGraph = undefined; @@ -1941,11 +1973,7 @@ class Compilation { if (outputOptions.hashSalt) { hash.update(outputOptions.hashSalt); } - this.mainTemplate.updateHash(hash); - this.chunkTemplate.updateHash(hash); - for (const key of Object.keys(this.moduleTemplates).sort()) { - this.moduleTemplates[key].updateHash(hash); - } + this.hooks.fullHash.call(hash); for (const child of this.children) { hash.update(child.hash); } @@ -1993,15 +2021,11 @@ class Compilation { chunkHash.update(outputOptions.hashSalt); } chunk.updateHash(chunkHash, chunkGraph); - const template = chunk.hasRuntime() - ? this.mainTemplate - : this.chunkTemplate; - template.updateHashForChunk(chunkHash, chunk, { + this.hooks.chunkHash.call(chunk, chunkHash, { chunkGraph, moduleGraph: this.moduleGraph, runtimeTemplate: this.runtimeTemplate }); - this.hooks.chunkHash.call(chunk, chunkHash); chunk.hash = /** @type {string} */ (chunkHash.digest(hashDigest)); hash.update(chunk.hash); chunk.renderedHash = chunk.hash.substr(0, hashDigestLength); @@ -2150,6 +2174,14 @@ class Compilation { } } + /** + * @param {RenderManifestOptions} options options object + * @returns {RenderManifestEntry[]} manifest entries + */ + getRenderManifest(options) { + return this.hooks.renderManifest.call([], options); + } + /** * @param {Callback} callback signals when the call finishes * @returns {void} @@ -2166,10 +2198,7 @@ class Compilation { /** @type {RenderManifestEntry[]} */ let manifest; try { - const template = chunk.hasRuntime() - ? this.mainTemplate - : this.chunkTemplate; - manifest = template.getRenderManifest({ + manifest = this.getRenderManifest({ chunk, hash: this.hash, fullHash: this.fullHash, @@ -2179,7 +2208,7 @@ class Compilation { chunkGraph: this.chunkGraph, moduleGraph: this.moduleGraph, runtimeTemplate: this.runtimeTemplate - }); // [{ render(), filenameTemplate, pathOptions, identifier, hash }] + }); } catch (err) { this.errors.push(new ChunkRenderError(chunk, "", err)); return callback(); @@ -2294,14 +2323,14 @@ class Compilation { * @param {PathData} data context data * @returns {string} interpolated path */ - getPath(filename, data) { + getPath(filename, data = {}) { if (!data.hash) { data = { hash: this.hash, ...data }; } - return this.mainTemplate.getAssetPath(filename, data); + return this.getAssetPath(filename, data); } /** @@ -2309,10 +2338,43 @@ class Compilation { * @param {PathData} data context data * @returns {{ path: string, info: AssetInfo }} interpolated path and asset info */ - getPathWithInfo(filename, data) { - data = data || {}; - data.hash = data.hash || this.hash; - return this.mainTemplate.getAssetPathWithInfo(filename, data); + getPathWithInfo(filename, data = {}) { + if (!data.hash) { + data = { + hash: this.hash, + ...data + }; + } + return this.getAssetPathWithInfo(filename, data); + } + + /** + * @param {string | function(PathData, AssetInfo=): string} filename used to get asset path with hash + * @param {PathData} data context data + * @returns {string} interpolated path + */ + getAssetPath(filename, data) { + return this.hooks.assetPath.call( + typeof filename === "function" ? filename(data) : filename, + data, + undefined + ); + } + + /** + * @param {string | function(PathData, AssetInfo=): string} filename used to get asset path with hash + * @param {PathData} data context data + * @returns {{ path: string, info: AssetInfo }} interpolated path and asset info + */ + getAssetPathWithInfo(filename, data) { + const assetInfo = {}; + // TODO webpack 5: refactor assetPath hook to receive { path, info } object + const newPath = this.hooks.assetPath.call( + typeof filename === "function" ? filename(data, assetInfo) : filename, + data, + assetInfo + ); + return { path: newPath, info: assetInfo }; } /** diff --git a/lib/FunctionModulePlugin.js b/lib/FunctionModulePlugin.js deleted file mode 100644 index 94c48de8a..000000000 --- a/lib/FunctionModulePlugin.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const FunctionModuleTemplatePlugin = require("./FunctionModuleTemplatePlugin"); - -/** @typedef {import("./Compiler")} Compiler */ - -class FunctionModulePlugin { - /** - * Apply the plugin - * @param {Compiler} compiler the compiler instance - * @returns {void} - */ - apply(compiler) { - compiler.hooks.compilation.tap("FunctionModulePlugin", compilation => { - new FunctionModuleTemplatePlugin({ - compilation - }).apply(compilation.moduleTemplates.javascript); - }); - } -} - -module.exports = FunctionModulePlugin; diff --git a/lib/HookWebpackError.js b/lib/HookWebpackError.js index 30c701345..0dce256f9 100644 --- a/lib/HookWebpackError.js +++ b/lib/HookWebpackError.js @@ -69,4 +69,26 @@ const makeWebpackErrorCallback = (callback, hook) => { callback(null, result); }; }; + module.exports.makeWebpackErrorCallback = makeWebpackErrorCallback; + +/** + * @template T + * @param {function(): T} fn function which will be wrapping in try catch + * @param {string} hook name of hook + * @returns {T} the result + */ +const tryRunOrWebpackError = (fn, hook) => { + let r; + try { + r = fn(); + } catch (err) { + if (err instanceof WebpackError) { + throw err; + } + throw new HookWebpackError(err, hook); + } + return r; +}; + +module.exports.tryRunOrWebpackError = tryRunOrWebpackError; diff --git a/lib/HotModuleReplacementPlugin.js b/lib/HotModuleReplacementPlugin.js index bb326e3c5..c63ba72e0 100644 --- a/lib/HotModuleReplacementPlugin.js +++ b/lib/HotModuleReplacementPlugin.js @@ -342,7 +342,7 @@ class HotModuleReplacementPlugin { newRuntimeModules ); hotUpdateChunk.removedModules = removedModules; - const renderManifest = chunkTemplate.getRenderManifest({ + const renderManifest = compilation.getRenderManifest({ chunk: hotUpdateChunk, hash: records.hash, fullHash: records.hash, diff --git a/lib/JavascriptModulesPlugin.js b/lib/JavascriptModulesPlugin.js index 025f0da88..e08e54cb4 100644 --- a/lib/JavascriptModulesPlugin.js +++ b/lib/JavascriptModulesPlugin.js @@ -5,10 +5,18 @@ "use strict"; -const { ConcatSource } = require("webpack-sources"); +const { SyncWaterfallHook, SyncHook } = require("tapable"); +const { + ConcatSource, + OriginalSource, + PrefixSource +} = require("webpack-sources"); +const Compilation = require("./Compilation"); +const { tryRunOrWebpackError } = require("./HookWebpackError"); const HotUpdateChunk = require("./HotUpdateChunk"); const JavascriptGenerator = require("./JavascriptGenerator"); const JavascriptParser = require("./JavascriptParser"); +const RuntimeGlobals = require("./RuntimeGlobals"); const Template = require("./Template"); const { compareModulesByIdOrIdentifier } = require("./util/comparators"); const createHash = require("./util/createHash"); @@ -17,12 +25,13 @@ const createHash = require("./util/createHash"); /** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./ChunkGraph")} ChunkGraph */ /** @typedef {import("./ChunkTemplate")} ChunkTemplate */ -/** @typedef {import("./Compilation")} Compilation */ +/** @typedef {import("./Compilation").ChunkHashContext} ChunkHashContext */ /** @typedef {import("./Compiler")} Compiler */ +/** @typedef {import("./DependencyTemplates")} DependencyTemplates */ /** @typedef {import("./Module")} Module */ -/** @typedef {import("./ModuleTemplate")} ModuleTemplate */ -/** @typedef {import("./ModuleTemplate").RenderContext} RenderContext */ +/** @typedef {import("./ModuleGraph")} ModuleGraph */ /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ +/** @typedef {import("./util/Hash")} Hash */ /** * @param {Chunk} chunk a chunk @@ -40,7 +49,89 @@ const chunkHasJs = (chunk, chunkGraph) => { return false; }; +/** + * @typedef {Object} RenderContext + * @property {Chunk} chunk the chunk + * @property {DependencyTemplates} dependencyTemplates the dependency templates + * @property {RuntimeTemplate} runtimeTemplate the runtime template + * @property {ModuleGraph} moduleGraph the module graph + * @property {ChunkGraph} chunkGraph the chunk graph + */ + +/** + * @typedef {Object} MainRenderContext + * @property {Chunk} chunk the chunk + * @property {DependencyTemplates} dependencyTemplates the dependency templates + * @property {RuntimeTemplate} runtimeTemplate the runtime template + * @property {ModuleGraph} moduleGraph the module graph + * @property {ChunkGraph} chunkGraph the chunk graph + * @property {string} hash hash to be used for render call + */ + +/** + * @typedef {Object} RenderBootstrapContext + * @property {Chunk} chunk the chunk + * @property {RuntimeTemplate} runtimeTemplate the runtime template + * @property {ModuleGraph} moduleGraph the module graph + * @property {ChunkGraph} chunkGraph the chunk graph + * @property {string} hash hash to be used for render call + */ + +/** + * @typedef {Object} CompilationHooks + * @property {SyncWaterfallHook<[Source, Module, RenderContext]>} renderModuleContent + * @property {SyncWaterfallHook<[Source, Module, RenderContext]>} renderModuleContainer + * @property {SyncWaterfallHook<[Source, Module, RenderContext]>} renderModulePackage + * @property {SyncWaterfallHook<[Source, RenderContext]>} renderChunk + * @property {SyncWaterfallHook<[Source, RenderContext]>} renderMain + * @property {SyncWaterfallHook<[Source, RenderContext]>} renderWithEntry + * @property {SyncWaterfallHook<[string, RenderBootstrapContext]>} renderRequire + * @property {SyncHook<[Chunk, Hash, ChunkHashContext]>} chunkHash + */ + +/** @type {WeakMap} */ +const compilationHooksMap = new WeakMap(); + class JavascriptModulesPlugin { + /** + * @param {Compilation} compilation the compilation + * @returns {CompilationHooks} the attached hooks + */ + static getCompilationHooks(compilation) { + if (!(compilation instanceof Compilation)) { + throw new TypeError( + "The 'compilation' argument must be an instance of JavascriptParser" + ); + } + let hooks = compilationHooksMap.get(compilation); + if (hooks === undefined) { + hooks = { + renderModuleContent: new SyncWaterfallHook([ + "source", + "module", + "renderContext" + ]), + renderModuleContainer: new SyncWaterfallHook([ + "source", + "module", + "renderContext" + ]), + renderModulePackage: new SyncWaterfallHook([ + "source", + "module", + "renderContext" + ]), + renderWithEntry: new SyncWaterfallHook(["source", "renderContext"]), + renderChunk: new SyncWaterfallHook(["source", "renderContext"]), + renderMain: new SyncWaterfallHook(["source", "renderContext"]), + renderRequire: new SyncWaterfallHook(["code", "renderContext"]), + chunkHash: new SyncHook(["chunk", "hash", "context"]) + }; + compilationHooksMap.set(compilation, hooks); + } + return hooks; + } + /** * @param {Compiler} compiler webpack compiler * @returns {void} @@ -49,6 +140,7 @@ class JavascriptModulesPlugin { compiler.hooks.compilation.tap( "JavascriptModulesPlugin", (compilation, { normalModuleFactory }) => { + const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation); const moduleGraph = compilation.moduleGraph; normalModuleFactory.hooks.createParser .for("javascript/auto") @@ -86,7 +178,6 @@ class JavascriptModulesPlugin { const chunk = options.chunk; const hash = options.hash; const outputOptions = options.outputOptions; - const moduleTemplates = options.moduleTemplates; const dependencyTemplates = options.dependencyTemplates; const filenameTemplate = @@ -94,14 +185,17 @@ class JavascriptModulesPlugin { result.push({ render: () => - compilation.mainTemplate.render(moduleTemplates.javascript, { - hash, - chunk, - dependencyTemplates, - runtimeTemplate: options.runtimeTemplate, - moduleGraph: options.moduleGraph, - chunkGraph: options.chunkGraph - }), + this.renderMain( + { + hash, + chunk, + dependencyTemplates, + runtimeTemplate: options.runtimeTemplate, + moduleGraph: options.moduleGraph, + chunkGraph: options.chunkGraph + }, + hooks + ), filenameTemplate, pathOptions: { chunk, @@ -121,7 +215,6 @@ class JavascriptModulesPlugin { const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null; const outputOptions = options.outputOptions; - const moduleTemplates = options.moduleTemplates; const dependencyTemplates = options.dependencyTemplates; if (!hotUpdateChunk && !chunkHasJs(chunk, chunkGraph)) { @@ -141,17 +234,17 @@ class JavascriptModulesPlugin { result.push({ render: () => - this.renderJavascript( + this.renderChunk( compilation, compilation.chunkTemplate, - moduleTemplates.javascript, { chunk, dependencyTemplates, runtimeTemplate: compilation.runtimeTemplate, moduleGraph, chunkGraph: compilation.chunkGraph - } + }, + hooks ), filenameTemplate, pathOptions: { @@ -166,6 +259,30 @@ class JavascriptModulesPlugin { return result; } ); + compilation.hooks.chunkHash.tap( + "JavascriptModulesPlugin", + (chunk, hash, context) => { + hooks.chunkHash.call(chunk, hash, context); + if (chunk.hasRuntime()) { + const bootstrap = this.renderBootstrap( + { + hash: "0000", + chunk, + chunkGraph: context.chunkGraph, + moduleGraph: context.moduleGraph, + runtimeTemplate: context.runtimeTemplate + }, + hooks + ); + for (const key of Object.keys(bootstrap)) { + hash.update(key); + for (const line of bootstrap[key]) { + hash.update(line); + } + } + } + } + ); compilation.hooks.contentHash.tap("JavascriptModulesPlugin", chunk => { const { chunkGraph, @@ -181,12 +298,9 @@ class JavascriptModulesPlugin { const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null; const hash = createHash(hashFunction); if (hashSalt) hash.update(hashSalt); - const template = chunk.hasRuntime() - ? compilation.mainTemplate - : compilation.chunkTemplate; hash.update(`${chunk.id} `); hash.update(chunk.ids ? chunk.ids.join(",") : ""); - template.updateHashForChunk(hash, chunk, { + hooks.chunkHash.call(chunk, hash, { chunkGraph, moduleGraph, runtimeTemplate @@ -209,36 +323,411 @@ class JavascriptModulesPlugin { ); } + /** + * @param {Module} module the rendered module + * @param {RenderContext} renderContext options object + * @param {CompilationHooks} hooks hooks + * @returns {Source} the newly generated source from rendering + */ + renderModule(module, renderContext, hooks) { + const { + chunkGraph, + moduleGraph, + runtimeTemplate, + dependencyTemplates + } = renderContext; + try { + const moduleSource = module.source({ + dependencyTemplates, + runtimeTemplate, + moduleGraph, + chunkGraph, + type: "javascript" + }); + const moduleSourcePostContent = tryRunOrWebpackError( + () => + hooks.renderModuleContent.call(moduleSource, module, renderContext), + "JavascriptModulesPlugin.getCompilationHooks().renderModuleContent" + ); + const source = new ConcatSource(); + const args = []; + const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements( + module + ); + const needModule = runtimeRequirements.has(RuntimeGlobals.module); + const needExports = runtimeRequirements.has(RuntimeGlobals.exports); + const needRequire = + runtimeRequirements.has(RuntimeGlobals.require) || + runtimeRequirements.has(RuntimeGlobals.requireScope); + const needThisAsExports = runtimeRequirements.has( + RuntimeGlobals.thisAsExports + ); + if (needExports || needRequire || needModule) + args.push( + needModule + ? module.moduleArgument + : "__unused_webpack_" + module.moduleArgument + ); + if (needExports || needRequire) + args.push( + needExports + ? module.exportsArgument + : "__unused_webpack_" + module.exportsArgument + ); + if (needRequire) args.push("__webpack_require__"); + if (!needThisAsExports && runtimeTemplate.supportsArrowFunction()) { + source.add("/***/ ((" + args.join(", ") + ") => {\n\n"); + } else { + source.add("/***/ (function(" + args.join(", ") + ") {\n\n"); + } + if (module.buildInfo.strict) source.add('"use strict";\n'); + source.add(moduleSourcePostContent); + source.add("\n\n/***/ })"); + const moduleSourcePostContainer = tryRunOrWebpackError( + () => hooks.renderModuleContainer.call(source, module, renderContext), + "JavascriptModulesPlugin.getCompilationHooks().renderModuleContainer" + ); + return tryRunOrWebpackError( + () => + hooks.renderModulePackage.call( + moduleSourcePostContainer, + module, + renderContext + ), + "JavascriptModulesPlugin.getCompilationHooks().renderModulePackage" + ); + } catch (e) { + e.module = module; + throw e; + } + } + /** * @param {Compilation} compilation the compilation * @param {ChunkTemplate} chunkTemplate the chunk template - * @param {ModuleTemplate} moduleTemplate the module template * @param {RenderContext} renderContext the render context + * @param {CompilationHooks} hooks hooks * @returns {Source} the rendered source */ - renderJavascript(compilation, chunkTemplate, moduleTemplate, renderContext) { + renderChunk(compilation, chunkTemplate, renderContext, hooks) { const chunk = renderContext.chunk; const moduleSources = Template.renderChunkModules( renderContext, m => m.getSourceTypes().has("javascript"), - moduleTemplate + module => this.renderModule(module, renderContext, hooks) ); - const core = chunkTemplate.hooks.modules.call( - moduleSources, - moduleTemplate, - renderContext - ); - let source = chunkTemplate.hooks.render.call( - core, - moduleTemplate, - renderContext + let source = tryRunOrWebpackError( + () => hooks.renderChunk.call(moduleSources, renderContext), + "JavascriptModulesPlugin.getCompilationHooks().renderChunk" ); if (renderContext.chunkGraph.getNumberOfEntryModules(chunk) > 0) { - source = chunkTemplate.hooks.renderWithEntry.call(source, chunk); + source = tryRunOrWebpackError( + () => hooks.renderWithEntry.call(source, renderContext), + "JavascriptModulesPlugin.getCompilationHooks().renderWithEntry" + ); } chunk.rendered = true; return new ConcatSource(source, ";"); } + + /** + * @param {MainRenderContext} renderContext options object + * @param {CompilationHooks} hooks hooks + * @returns {Source} the newly generated source from rendering + */ + renderMain(renderContext, hooks) { + const { chunk, chunkGraph, runtimeTemplate } = renderContext; + + let source = new ConcatSource(); + if (runtimeTemplate.supportsConst()) { + source.add("/******/ (() => { // webpackBootstrap\n"); + } else { + source.add("/******/ (function() { // webpackBootstrap\n"); + } + + source.add("/******/ \tvar __webpack_modules__ = ("); + source.add( + Template.renderChunkModules( + renderContext, + m => m.getSourceTypes().has("javascript"), + module => this.renderModule(module, renderContext, hooks), + "/******/ \t" + ) + ); + source.add(");\n"); + + const bootstrap = this.renderBootstrap(renderContext, hooks); + + source.add( + "/************************************************************************/\n" + ); + source.add( + new PrefixSource( + "/******/", + new OriginalSource( + Template.prefix(bootstrap.header, " \t") + "\n", + "webpack/bootstrap" + ) + ) + ); + + const runtimeModules = renderContext.chunkGraph.getChunkRuntimeModulesInOrder( + chunk + ); + + if (runtimeModules.length > 0) { + source.add( + "/************************************************************************/\n" + ); + source.add( + Template.renderMainRuntimeModules(runtimeModules, renderContext) + ); + } + source.add( + "/************************************************************************/\n" + ); + source.add( + new PrefixSource( + "/******/", + new OriginalSource( + Template.prefix(bootstrap.startup, " \t") + "\n", + "webpack/startup" + ) + ) + ); + source.add("/******/ })()\n"); + + /** @type {Source} */ + let finalSource = tryRunOrWebpackError( + () => hooks.renderMain.call(source, renderContext), + "JavascriptModulesPlugin.getCompilationHooks().renderMain" + ); + if (chunkGraph.getNumberOfEntryModules(chunk) > 0) { + finalSource = tryRunOrWebpackError( + () => hooks.renderWithEntry.call(finalSource, renderContext), + "JavascriptModulesPlugin.getCompilationHooks().renderWithEntry" + ); + } + if (!finalSource) { + throw new Error( + "Compiler error: MainTemplate plugin 'render' should return something" + ); + } + chunk.rendered = true; + return new ConcatSource(finalSource, ";"); + } + + /** + * @param {RenderBootstrapContext} renderContext options object + * @param {CompilationHooks} hooks hooks + * @returns {{ header: string[], startup: string[] }} the generated source of the bootstrap code + */ + renderBootstrap(renderContext, hooks) { + const { chunkGraph, chunk, runtimeTemplate } = renderContext; + + const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk); + + const requireFunction = runtimeRequirements.has(RuntimeGlobals.require); + const moduleCache = runtimeRequirements.has(RuntimeGlobals.moduleCache); + const moduleUsed = runtimeRequirements.has(RuntimeGlobals.module); + const exportsUsed = runtimeRequirements.has(RuntimeGlobals.exports); + const requireScopeUsed = runtimeRequirements.has( + RuntimeGlobals.requireScope + ); + const interceptModuleExecution = runtimeRequirements.has( + RuntimeGlobals.interceptModuleExecution + ); + const returnExportsFromRuntime = runtimeRequirements.has( + RuntimeGlobals.returnExportsFromRuntime + ); + + const useRequire = + requireFunction || + interceptModuleExecution || + returnExportsFromRuntime || + moduleUsed || + exportsUsed; + + const result = { + header: [], + startup: [] + }; + + let buf = result.header; + let startup = result.startup; + + if (useRequire || moduleCache) { + buf.push("// The module cache"); + buf.push("var __webpack_module_cache__ = {};"); + buf.push(""); + } + + if (useRequire) { + buf.push("// The require function"); + buf.push(`function __webpack_require__(moduleId) {`); + buf.push(Template.indent('"use strict";')); + buf.push(Template.indent(this.renderRequire(renderContext, hooks))); + buf.push("}"); + buf.push(""); + } else if (runtimeRequirements.has(RuntimeGlobals.requireScope)) { + buf.push("// The require scope"); + buf.push("var __webpack_require__ = {};"); + } + + if (runtimeRequirements.has(RuntimeGlobals.moduleFactories)) { + buf.push(""); + buf.push("// expose the modules object (__webpack_modules__)"); + buf.push(`${RuntimeGlobals.moduleFactories} = __webpack_modules__;`); + } + + if (moduleCache) { + buf.push(""); + buf.push("// expose the module cache"); + buf.push(`${RuntimeGlobals.moduleCache} = __webpack_module_cache__;`); + } + + if (interceptModuleExecution) { + buf.push(""); + buf.push("// expose the module execution interceptor"); + buf.push(`${RuntimeGlobals.interceptModuleExecution} = [];`); + } + + buf.push(""); + if (!runtimeRequirements.has(RuntimeGlobals.startupNoDefault)) { + if (chunkGraph.getNumberOfEntryModules(chunk) > 0) { + /** @type {string[]} */ + const buf2 = []; + const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements( + chunk + ); + buf2.push( + returnExportsFromRuntime + ? "// Load entry module and return exports" + : "// Load entry module" + ); + let i = chunkGraph.getNumberOfEntryModules(chunk); + for (const entryModule of chunkGraph.getChunkEntryModulesIterable( + chunk + )) { + const mayReturn = + --i === 0 && returnExportsFromRuntime ? "return " : ""; + const moduleId = chunkGraph.getModuleId(entryModule); + let moduleIdExpr = JSON.stringify(moduleId); + if (runtimeRequirements.has(RuntimeGlobals.entryModuleId)) { + moduleIdExpr = `${RuntimeGlobals.entryModuleId} = ${moduleIdExpr}`; + } + if (useRequire) { + buf2.push(`${mayReturn}__webpack_require__(${moduleIdExpr});`); + } else if (requireScopeUsed) { + buf2.push( + `__webpack_modules__[${moduleIdExpr}](0, 0, __webpack_require__);` + ); + } else { + buf2.push(`__webpack_modules__[${moduleIdExpr}]();`); + } + } + if (runtimeRequirements.has(RuntimeGlobals.startup)) { + buf.push( + Template.asString([ + "// the startup function", + `${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction( + "", + buf2 + )};` + ]) + ); + startup.push("// run startup"); + startup.push(`return ${RuntimeGlobals.startup}();`); + } else { + startup.push( + Template.asString(["// startup", Template.asString(buf2)]) + ); + } + } else if (runtimeRequirements.has(RuntimeGlobals.startup)) { + buf.push( + Template.asString([ + "// the startup function", + "// It's empty as no entry modules are in this chunk", + `${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction( + "", + "" + )}` + ]) + ); + } + } else if (runtimeRequirements.has(RuntimeGlobals.startup)) { + startup.push("// run startup"); + startup.push(`return ${RuntimeGlobals.startup}();`); + } + return result; + } + + /** + * @param {RenderBootstrapContext} renderContext options object + * @param {CompilationHooks} hooks hooks + * @returns {string} the generated source of the require function + */ + renderRequire(renderContext, hooks) { + const { + chunk, + chunkGraph, + runtimeTemplate: { outputOptions } + } = renderContext; + const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk); + const moduleExecution = runtimeRequirements.has( + RuntimeGlobals.interceptModuleExecution + ) + ? Template.asString([ + "var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: __webpack_require__ };", + `${RuntimeGlobals.interceptModuleExecution}.forEach(function(handler) { handler(execOptions); });`, + "module = execOptions.module;", + "execOptions.factory.call(module.exports, module, module.exports, execOptions.require);" + ]) + : runtimeRequirements.has(RuntimeGlobals.thisAsExports) + ? Template.asString([ + "__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);" + ]) + : Template.asString([ + "__webpack_modules__[moduleId](module, module.exports, __webpack_require__);" + ]); + const content = Template.asString([ + "// Check if module is in cache", + "if(__webpack_module_cache__[moduleId]) {", + Template.indent("return __webpack_module_cache__[moduleId].exports;"), + "}", + "// Create a new module (and put it into the cache)", + "var module = __webpack_module_cache__[moduleId] = {", + Template.indent(["i: moduleId,", "l: false,", "exports: {}"]), + "};", + "", + outputOptions.strictModuleExceptionHandling + ? Template.asString([ + "// Execute the module function", + "var threw = true;", + "try {", + Template.indent([moduleExecution, "threw = false;"]), + "} finally {", + Template.indent([ + "if(threw) delete __webpack_module_cache__[moduleId];" + ]), + "}" + ]) + : Template.asString([ + "// Execute the module function", + moduleExecution + ]), + "", + "// Flag the module as loaded", + "module.l = true;", + "", + "// Return the exports of the module", + "return module.exports;" + ]); + return tryRunOrWebpackError( + () => hooks.renderRequire.call(content, renderContext), + "JavascriptModulesPlugin.getCompilationHooks().renderRequire" + ); + } } module.exports = JavascriptModulesPlugin; diff --git a/lib/MainTemplate.js b/lib/MainTemplate.js index d80396e1f..8f8f9fe50 100644 --- a/lib/MainTemplate.js +++ b/lib/MainTemplate.js @@ -5,19 +5,16 @@ "use strict"; -const { SyncWaterfallHook, SyncHook } = require("tapable"); -const { - ConcatSource, - OriginalSource, - PrefixSource -} = require("webpack-sources"); +const { SyncWaterfallHook } = require("tapable"); +const util = require("util"); const RuntimeGlobals = require("./RuntimeGlobals"); -const Template = require("./Template"); +const memorize = require("./util/memorize"); /** @typedef {import("webpack-sources").ConcatSource} ConcatSource */ /** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("./ModuleTemplate")} ModuleTemplate */ /** @typedef {import("./Chunk")} Chunk */ +/** @typedef {import("./Compilation")} Compilation */ /** @typedef {import("./Compilation").AssetInfo} AssetInfo */ /** @typedef {import("./Module")} Module} */ /** @typedef {import("./util/Hash")} Hash} */ @@ -29,53 +26,93 @@ const Template = require("./Template"); /** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions} */ /** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry} */ -/** - * @typedef {Object} MainRenderContext - * @property {Chunk} chunk the chunk - * @property {DependencyTemplates} dependencyTemplates the dependency templates - * @property {RuntimeTemplate} runtimeTemplate the runtime template - * @property {ModuleGraph} moduleGraph the module graph - * @property {ChunkGraph} chunkGraph the chunk graph - * @property {string} hash hash to be used for render call - */ +const getJavascriptModulesPlugin = memorize(() => + require("./JavascriptModulesPlugin") +); -/** - * @typedef {Object} RenderBootstrapContext - * @property {Chunk} chunk the chunk - * @property {RuntimeTemplate} runtimeTemplate the runtime template - * @property {ModuleGraph} moduleGraph the module graph - * @property {ChunkGraph} chunkGraph the chunk graph - * @property {string} hash hash to be used for render call - */ - -/** - * @typedef {Object} UpdateHashForChunkContext - * @property {RuntimeTemplate} runtimeTemplate the runtime template - * @property {ModuleGraph} moduleGraph the module graph - * @property {ChunkGraph} chunkGraph the chunk graph - */ - -module.exports = class MainTemplate { +// TODO webpack 6 remove this class +class MainTemplate { /** * * @param {TODO=} outputOptions output options for the MainTemplate + * @param {Compilation} compilation the compilation */ - constructor(outputOptions) { + constructor(outputOptions, compilation) { /** @type {TODO?} */ - this.outputOptions = outputOptions || {}; + this._outputOptions = outputOptions || {}; this.hooks = Object.freeze({ - /** @type {SyncWaterfallHook<[RenderManifestEntry[], RenderManifestOptions]>} */ - renderManifest: new SyncWaterfallHook(["result", "options"]), - /** @type {SyncWaterfallHook<[string, RenderBootstrapContext]>} */ - require: new SyncWaterfallHook(["source", "renderContext"]), - /** @type {SyncWaterfallHook<[Source, Chunk, string]>} */ - renderWithEntry: new SyncWaterfallHook(["source", "chunk", "hash"]), - /** @type {SyncWaterfallHook<[string, object, AssetInfo]>} */ - assetPath: new SyncWaterfallHook(["path", "options", "assetInfo"]), - /** @type {SyncHook<[Hash]>} */ - hash: new SyncHook(["hash"]), - /** @type {SyncHook<[Hash, Chunk]>} */ - hashForChunk: new SyncHook(["hash", "chunk"]), + renderManifest: { + tap: util.deprecate( + (options, fn) => { + compilation.hooks.renderManifest.tap( + options, + (entries, options) => { + if (!options.chunk.hasRuntime()) return entries; + return fn(entries, options); + } + ); + }, + "MainTemplate.hooks.renderManifest is deprecated (use Compilation.hooks.renderManifest instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_RENDER_MANIFEST" + ) + }, + require: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderRequire.tap(options, fn); + }, + "MainTemplate.hooks.require is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderRequire instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE" + ) + }, + renderWithEntry: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderWithEntry.tap(options, (source, renderContext) => { + if (!renderContext.chunk.hasRuntime()) return source; + return fn(source, renderContext.chunk, compilation.hash); + }); + }, + "MainTemplate.hooks.renderWithEntry is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderWithEntry instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_RENDER_WITH_ENTRY" + ) + }, + assetPath: { + tap: util.deprecate( + (options, fn) => { + compilation.hooks.assetPath.tap(options, fn); + }, + "MainTemplate.hooks.assetPath is deprecated (use Compilation.hooks.assetPath instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_ASSET_PATH" + ) + }, + hash: { + tap: util.deprecate( + (options, fn) => { + compilation.hooks.fullHash.tap(options, fn); + }, + "MainTemplate.hooks.hash is deprecated (use Compilation.hooks.fullHash instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_HASH" + ) + }, + hashForChunk: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .chunkHash.tap(options, (chunk, hash) => { + if (!chunk.hasRuntime()) return; + return fn(hash, chunk); + }); + }, + "MainTemplate.hooks.hashForChunk is deprecated (use JavascriptModulesPlugin.getCompilationHooks().chunkHash instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK" + ) + }, // for compatibility: /** @type {SyncWaterfallHook<[string, Chunk, string, ModuleTemplate, DependencyTemplates]>} */ @@ -98,379 +135,78 @@ module.exports = class MainTemplate { "chunkIdExpression" ]) }); - this.hooks.require.tap("MainTemplate", (source, renderContext) => { - const { chunk, chunkGraph } = renderContext; - const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk); - const moduleExecution = runtimeRequirements.has( - RuntimeGlobals.interceptModuleExecution - ) - ? Template.asString([ - "var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: __webpack_require__ };", - `${RuntimeGlobals.interceptModuleExecution}.forEach(function(handler) { handler(execOptions); });`, - "module = execOptions.module;", - "execOptions.factory.call(module.exports, module, module.exports, execOptions.require);" - ]) - : runtimeRequirements.has(RuntimeGlobals.thisAsExports) - ? Template.asString([ - "__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);" - ]) - : Template.asString([ - "__webpack_modules__[moduleId](module, module.exports, __webpack_require__);" - ]); - return Template.asString([ - source, - "// Check if module is in cache", - "if(__webpack_module_cache__[moduleId]) {", - Template.indent("return __webpack_module_cache__[moduleId].exports;"), - "}", - "// Create a new module (and put it into the cache)", - "var module = __webpack_module_cache__[moduleId] = {", - Template.indent(["i: moduleId,", "l: false,", "exports: {}"]), - "};", - "", - outputOptions.strictModuleExceptionHandling - ? Template.asString([ - "// Execute the module function", - "var threw = true;", - "try {", - Template.indent([moduleExecution, "threw = false;"]), - "} finally {", - Template.indent([ - "if(threw) delete __webpack_module_cache__[moduleId];" - ]), - "}" - ]) - : Template.asString([ - "// Execute the module function", - moduleExecution - ]), - "", - "// Flag the module as loaded", - "module.l = true;", - "", - "// Return the exports of the module", - "return module.exports;" - ]); - }); - } - // TODO webpack 6 remove - // BACKWARD COMPAT START - get requireFn() { - return "__webpack_require__"; - } - - /** - * @deprecated - * @param {string} hash the hash - * @param {number=} length length of the hash - * @returns {string} generated code - */ - renderCurrentHashCode(hash, length) { - if (length) { - return `${RuntimeGlobals.getFullHash} ? ${ - RuntimeGlobals.getFullHash - }().slice(0, ${length}) : ${hash.slice(0, length)}`; - } - return `${RuntimeGlobals.getFullHash} ? ${RuntimeGlobals.getFullHash}() : ${hash}`; - } - // BACKWARD COMPAT END - - /** - * - * @param {RenderManifestOptions} options render manifest options - * @returns {RenderManifestEntry[]} returns render manifest - */ - getRenderManifest(options) { - const result = []; - - this.hooks.renderManifest.call(result, options); - - return result; - } - - /** - * @param {RenderBootstrapContext} renderContext options object - * @returns {{ header: string[], startup: string[] }} the generated source of the bootstrap code - */ - renderBootstrap(renderContext) { - const { chunkGraph, chunk, runtimeTemplate } = renderContext; - - const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk); - - const requireFunction = runtimeRequirements.has(RuntimeGlobals.require); - const moduleCache = runtimeRequirements.has(RuntimeGlobals.moduleCache); - const moduleUsed = runtimeRequirements.has(RuntimeGlobals.module); - const exportsUsed = runtimeRequirements.has(RuntimeGlobals.exports); - const requireScopeUsed = runtimeRequirements.has( - RuntimeGlobals.requireScope - ); - const interceptModuleExecution = runtimeRequirements.has( - RuntimeGlobals.interceptModuleExecution - ); - const returnExportsFromRuntime = runtimeRequirements.has( - RuntimeGlobals.returnExportsFromRuntime - ); - - const useRequire = - requireFunction || - interceptModuleExecution || - returnExportsFromRuntime || - moduleUsed || - exportsUsed; - - const result = { - header: [], - startup: [] - }; - - let buf = result.header; - let startup = result.startup; - - if (useRequire || moduleCache) { - buf.push("// The module cache"); - buf.push("var __webpack_module_cache__ = {};"); - buf.push(""); - } - - if (useRequire) { - buf.push("// The require function"); - buf.push(`function __webpack_require__(moduleId) {`); - buf.push(Template.indent('"use strict";')); - buf.push(Template.indent(this.hooks.require.call("", renderContext))); - buf.push("}"); - buf.push(""); - } else if (runtimeRequirements.has(RuntimeGlobals.requireScope)) { - buf.push("// The require scope"); - buf.push("var __webpack_require__ = {};"); - } - - if (runtimeRequirements.has(RuntimeGlobals.moduleFactories)) { - buf.push(""); - buf.push("// expose the modules object (__webpack_modules__)"); - buf.push(`${RuntimeGlobals.moduleFactories} = __webpack_modules__;`); - } - - if (moduleCache) { - buf.push(""); - buf.push("// expose the module cache"); - buf.push(`${RuntimeGlobals.moduleCache} = __webpack_module_cache__;`); - } - - if (interceptModuleExecution) { - buf.push(""); - buf.push("// expose the module execution interceptor"); - buf.push(`${RuntimeGlobals.interceptModuleExecution} = [];`); - } - - buf.push(""); - if (!runtimeRequirements.has(RuntimeGlobals.startupNoDefault)) { - if (chunkGraph.getNumberOfEntryModules(chunk) > 0) { - /** @type {string[]} */ - const buf2 = []; - const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements( - chunk - ); - buf2.push( - returnExportsFromRuntime - ? "// Load entry module and return exports" - : "// Load entry module" - ); - let i = chunkGraph.getNumberOfEntryModules(chunk); - for (const entryModule of chunkGraph.getChunkEntryModulesIterable( - chunk - )) { - const mayReturn = - --i === 0 && returnExportsFromRuntime ? "return " : ""; - const moduleId = chunkGraph.getModuleId(entryModule); - let moduleIdExpr = JSON.stringify(moduleId); - if (runtimeRequirements.has(RuntimeGlobals.entryModuleId)) { - moduleIdExpr = `${RuntimeGlobals.entryModuleId} = ${moduleIdExpr}`; - } - if (useRequire) { - buf2.push(`${mayReturn}__webpack_require__(${moduleIdExpr});`); - } else if (requireScopeUsed) { - buf2.push( - `__webpack_modules__[${moduleIdExpr}](0, 0, __webpack_require__);` - ); - } else { - buf2.push(`__webpack_modules__[${moduleIdExpr}]();`); - } + this.renderCurrentHashCode = util.deprecate( + /** + * @deprecated + * @param {string} hash the hash + * @param {number=} length length of the hash + * @returns {string} generated code + */ (hash, length) => { + if (length) { + return `${RuntimeGlobals.getFullHash} ? ${ + RuntimeGlobals.getFullHash + }().slice(0, ${length}) : ${hash.slice(0, length)}`; } - if (runtimeRequirements.has(RuntimeGlobals.startup)) { - buf.push( - Template.asString([ - "// the startup function", - `${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction( - "", - buf2 - )};` - ]) - ); - startup.push("// run startup"); - startup.push(`return ${RuntimeGlobals.startup}();`); - } else { - startup.push( - Template.asString(["// startup", Template.asString(buf2)]) - ); - } - } else if (runtimeRequirements.has(RuntimeGlobals.startup)) { - buf.push( - Template.asString([ - "// the startup function", - "// It's empty as no entry modules are in this chunk", - `${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction( - "", - "" - )}` - ]) + return `${RuntimeGlobals.getFullHash} ? ${RuntimeGlobals.getFullHash}() : ${hash}`; + }, + "MainTemplate.renderCurrentHashCode is deprecated (use RuntimeGlobals.getFullHash runtime function instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_RENDER_CURRENT_HASH_CODE" + ); + + this.getPublicPath = util.deprecate( + /** + * + * @param {object} options get public path options + * @returns {string} hook call + */ options => { + return compilation.getAssetPath( + compilation.outputOptions.publicPath, + options ); - } - } else if (runtimeRequirements.has(RuntimeGlobals.startup)) { - startup.push("// run startup"); - startup.push(`return ${RuntimeGlobals.startup}();`); - } - return result; - } - - /** - * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render - * @param {MainRenderContext} renderContext options object - * @returns {Source} the newly generated source from rendering - */ - render(moduleTemplate, renderContext) { - const { hash, chunk, chunkGraph, runtimeTemplate } = renderContext; - - let source = new ConcatSource(); - if (runtimeTemplate.supportsConst()) { - source.add("/******/ (() => { // webpackBootstrap\n"); - } else { - source.add("/******/ (function() { // webpackBootstrap\n"); - } - - source.add("/******/ \tvar __webpack_modules__ = ("); - source.add( - Template.renderChunkModules( - renderContext, - m => m.getSourceTypes().has("javascript"), - moduleTemplate, - "/******/ \t" - ) - ); - source.add(");\n"); - - const bootstrap = this.renderBootstrap(renderContext); - - source.add( - "/************************************************************************/\n" - ); - source.add( - new PrefixSource( - "/******/", - new OriginalSource( - Template.prefix(bootstrap.header, " \t") + "\n", - "webpack/bootstrap" - ) - ) + }, + "MainTemplate.getPublicPath is depreacted (use Compilation.getAssetPath(compilation.outputOptions.publicPath, options) instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_GET_PUBLIC_PATH" ); - const runtimeModules = renderContext.chunkGraph.getChunkRuntimeModulesInOrder( - chunk + this.getAssetPath = util.deprecate( + (path, options) => { + return compilation.getAssetPath(path, options); + }, + "MainTemplate.getAssetPath is deprecated (use Compilation.getAssetPath instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_GET_ASSET_PATH" ); - if (runtimeModules.length > 0) { - source.add( - "/************************************************************************/\n" - ); - source.add( - Template.renderMainRuntimeModules(runtimeModules, renderContext) - ); - } - source.add( - "/************************************************************************/\n" - ); - source.add( - new PrefixSource( - "/******/", - new OriginalSource( - Template.prefix(bootstrap.startup, " \t") + "\n", - "webpack/startup" - ) - ) - ); - source.add("/******/ })()\n"); - - /** @type {Source} */ - let finalSource = source; - if (chunkGraph.getNumberOfEntryModules(chunk) > 0) { - finalSource = this.hooks.renderWithEntry.call(finalSource, chunk, hash); - } - if (!finalSource) { - throw new Error( - "Compiler error: MainTemplate plugin 'render' should return something" - ); - } - chunk.rendered = true; - return new ConcatSource(finalSource, ";"); - } - - /** - * - * @param {object} options get public path options - * @returns {string} hook call - */ - getPublicPath(options) { - return this.hooks.assetPath.call( - this.outputOptions.publicPath || "", - options, - undefined + this.getAssetPathWithInfo = util.deprecate( + (path, options) => { + return compilation.getAssetPathWithInfo(path, options); + }, + "MainTemplate.getAssetPathWithInfo is deprecated (use Compilation.getAssetPath instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_GET_ASSET_PATH_WITH_INFO" ); } +} - getAssetPath(path, options) { - return this.hooks.assetPath.call(path, options, undefined); - } +Object.defineProperty(MainTemplate.prototype, "requireFn", { + get: util.deprecate( + () => "__webpack_require__", + 'MainTemplate.requireFn is deprecated (use "__webpack_require__")', + "DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE_FN" + ) +}); - getAssetPathWithInfo(path, options) { - const assetInfo = {}; - // TODO webpack 5: refactor assetPath hook to receive { path, info } object - const newPath = this.hooks.assetPath.call(path, options, assetInfo); - return { path: newPath, info: assetInfo }; - } +Object.defineProperty(MainTemplate.prototype, "outputOptions", { + get: util.deprecate( + /** + * @this {MainTemplate} + * @returns {TODO} output options + */ + function() { + return this._outputOptions; + }, + "MainTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)", + "DEP_WEBPACK_MAIN_TEMPLATE_OUTPUT_OPTIONS" + ) +}); - /** - * Updates hash with information from this template - * @param {Hash} hash the hash to update - * @returns {void} - */ - updateHash(hash) { - hash.update("maintemplate"); - hash.update("3"); - this.hooks.hash.call(hash); - } - - /** - * Updates hash with chunk-specific information from this template - * @param {Hash} hash the hash to update - * @param {Chunk} chunk the chunk - * @param {UpdateHashForChunkContext} context options object - * @returns {void} - */ - updateHashForChunk(hash, chunk, context) { - this.updateHash(hash); - this.hooks.hashForChunk.call(hash, chunk); - const bootstrap = this.renderBootstrap({ - hash: "0000", - chunk, - chunkGraph: context.chunkGraph, - moduleGraph: context.moduleGraph, - runtimeTemplate: context.runtimeTemplate - }); - for (const key of Object.keys(bootstrap)) { - hash.update(key); - for (const line of bootstrap[key]) { - hash.update(line); - } - } - } -}; +module.exports = MainTemplate; diff --git a/lib/FunctionModuleTemplatePlugin.js b/lib/ModuleInfoHeaderPlugin.js similarity index 52% rename from lib/FunctionModuleTemplatePlugin.js rename to lib/ModuleInfoHeaderPlugin.js index 7cbd11da3..1bdecaf17 100644 --- a/lib/FunctionModuleTemplatePlugin.js +++ b/lib/ModuleInfoHeaderPlugin.js @@ -6,9 +6,10 @@ "use strict"; const { ConcatSource } = require("webpack-sources"); -const RuntimeGlobals = require("./RuntimeGlobals"); +const JavascriptModulesPlugin = require("./JavascriptModulesPlugin"); const Template = require("./Template"); +/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./ModuleTemplate")} ModuleTemplate */ const joinIterableWithComma = iterable => { @@ -53,66 +54,24 @@ const printExportsInfoToSource = (source, indent, exportsInfo) => { } }; -class FunctionModuleTemplatePlugin { - constructor({ compilation }) { - this.compilation = compilation; - } - +class ModuleInfoHeaderPlugin { /** - * @param {ModuleTemplate} moduleTemplate a module template + * @param {Compiler} compiler the compiler * @returns {void} */ - apply(moduleTemplate) { - const arrow = this.compilation.runtimeTemplate.supportsArrowFunction(); - moduleTemplate.hooks.render.tap( - "FunctionModuleTemplatePlugin", - (moduleSource, module) => { - const { chunkGraph } = this.compilation; - const source = new ConcatSource(); - const args = []; - const runtimeRequirements = chunkGraph.getModuleRuntimeRequirements( - module - ); - const needModule = runtimeRequirements.has(RuntimeGlobals.module); - const needExports = runtimeRequirements.has(RuntimeGlobals.exports); - const needRequire = - runtimeRequirements.has(RuntimeGlobals.require) || - runtimeRequirements.has(RuntimeGlobals.requireScope); - const needThisAsExports = runtimeRequirements.has( - RuntimeGlobals.thisAsExports - ); - if (needExports || needRequire || needModule) - args.push( - needModule - ? module.moduleArgument - : "__unused" + module.moduleArgument - ); - if (needExports || needRequire) - args.push( - needExports - ? module.exportsArgument - : "__unused" + module.exportsArgument - ); - if (needRequire) args.push("__webpack_require__"); - if (arrow && !needThisAsExports) { - source.add("/***/ ((" + args.join(", ") + ") => {\n\n"); - } else { - source.add("/***/ (function(" + args.join(", ") + ") {\n\n"); - } - if (module.buildInfo.strict) source.add('"use strict";\n'); - source.add(moduleSource); - source.add("\n\n/***/ })"); - return source; - } - ); - - moduleTemplate.hooks.package.tap( - "FunctionModuleTemplatePlugin", - (moduleSource, module, { moduleGraph, chunkGraph }) => { - if (moduleTemplate.runtimeTemplate.outputOptions.pathinfo) { + apply(compiler) { + compiler.hooks.compilation.tap("ModuleInfoHeaderPlugin", compilation => { + const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation); + hooks.renderModulePackage.tap( + "ModuleInfoHeaderPlugin", + ( + moduleSource, + module, + { chunkGraph, moduleGraph, runtimeTemplate } + ) => { const source = new ConcatSource(); const req = module.readableIdentifier( - moduleTemplate.runtimeTemplate.requestShortener + runtimeTemplate.requestShortener ); const reqStr = req.replace(/\*\//g, "*_/"); const reqStrStar = "*".repeat(reqStr.length); @@ -135,7 +94,7 @@ class FunctionModuleTemplatePlugin { for (const text of optimizationBailout) { let code; if (typeof text === "function") { - code = text(moduleTemplate.runtimeTemplate.requestShortener); + code = text(runtimeTemplate.requestShortener); } else { code = text; } @@ -145,14 +104,12 @@ class FunctionModuleTemplatePlugin { source.add(moduleSource); return source; } - return moduleSource; - } - ); - - moduleTemplate.hooks.hash.tap("FunctionModuleTemplatePlugin", hash => { - hash.update("FunctionModuleTemplatePlugin"); - hash.update("2"); + ); + hooks.chunkHash.tap("ModuleInfoHeaderPlugin", (chunk, hash) => { + hash.update("ModuleInfoHeaderPlugin"); + hash.update("1"); + }); }); } } -module.exports = FunctionModuleTemplatePlugin; +module.exports = ModuleInfoHeaderPlugin; diff --git a/lib/ModuleTemplate.js b/lib/ModuleTemplate.js index 2fcda5daf..7da4f1369 100644 --- a/lib/ModuleTemplate.js +++ b/lib/ModuleTemplate.js @@ -5,17 +5,23 @@ "use strict"; -const { SyncWaterfallHook, SyncHook } = require("tapable"); +const util = require("util"); +const memorize = require("./util/memorize"); /** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./ChunkGraph")} ChunkGraph */ +/** @typedef {import("./Compilation")} Compilation */ /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ /** @typedef {import("./Module")} Module */ /** @typedef {import("./ModuleGraph")} ModuleGraph */ /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ /** @typedef {import("./util/Hash")} Hash */ +const getJavascriptModulesPlugin = memorize(() => + require("./JavascriptModulesPlugin") +); + /** * @typedef {Object} RenderContext * @property {Chunk} chunk the chunk @@ -25,77 +31,69 @@ const { SyncWaterfallHook, SyncHook } = require("tapable"); * @property {ChunkGraph} chunkGraph the chunk graph */ +// TODO webpack 6: remove this class module.exports = class ModuleTemplate { /** * @param {RuntimeTemplate} runtimeTemplate the runtime template - * @param {string} type the module template type + * @param {Compilation} compilation the compilation */ - constructor(runtimeTemplate, type) { + constructor(runtimeTemplate, compilation) { this.runtimeTemplate = runtimeTemplate; - this.type = type; + this.type = "javascript"; this.hooks = Object.freeze({ - /** @type {SyncWaterfallHook<[Source, Module, RenderContext]>} */ - content: new SyncWaterfallHook(["source", "module", "context"]), - /** @type {SyncWaterfallHook<[Source, Module, RenderContext]>} */ - module: new SyncWaterfallHook(["source", "module", "context"]), - /** @type {SyncWaterfallHook<[Source, Module, RenderContext]>} */ - render: new SyncWaterfallHook(["source", "module", "context"]), - /** @type {SyncWaterfallHook<[Source, Module, RenderContext]>} */ - package: new SyncWaterfallHook(["source", "module", "context"]), - /** @type {SyncHook<[Hash]>} */ - hash: new SyncHook(["hash"]) + content: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderModuleContent.tap(options, fn); + }, + "ModuleTemplate.hooks.content is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)", + "DEP_MODULE_TEMPLATE_CONTENT" + ) + }, + module: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderModuleContent.tap(options, fn); + }, + "ModuleTemplate.hooks.module is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContent instead)", + "DEP_MODULE_TEMPLATE_MODULE" + ) + }, + render: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderModuleContainer.tap(options, fn); + }, + "ModuleTemplate.hooks.render is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModuleContainer instead)", + "DEP_MODULE_TEMPLATE_RENDER" + ) + }, + package: { + tap: util.deprecate( + (options, fn) => { + getJavascriptModulesPlugin() + .getCompilationHooks(compilation) + .renderModulePackage.tap(options, fn); + }, + "ModuleTemplate.hooks.package is deprecated (use JavascriptModulesPlugin.getCompilationHooks().renderModulePackage instead)", + "DEP_MODULE_TEMPLATE_PACKAGE" + ) + }, + hash: { + tap: util.deprecate( + (options, fn) => { + compilation.hooks.fullHash.tap(options, fn); + }, + "ModuleTemplate.hooks.package is deprecated (use Compilation.hooks.fullHash instead)", + "DEP_MODULE_TEMPLATE_HASH" + ) + } }); } - - /** - * @param {Module} module the module - * @param {RenderContext} ctx render ctx - * @returns {Source} the source - */ - render(module, ctx) { - try { - const { - runtimeTemplate, - dependencyTemplates, - moduleGraph, - chunkGraph - } = ctx; - const moduleSource = module.source({ - dependencyTemplates, - runtimeTemplate, - moduleGraph, - chunkGraph, - type: this.type - }); - const moduleSourcePostContent = this.hooks.content.call( - moduleSource, - module, - ctx - ); - const moduleSourcePostModule = this.hooks.module.call( - moduleSourcePostContent, - module, - ctx - ); - const moduleSourcePostRender = this.hooks.render.call( - moduleSourcePostModule, - module, - ctx - ); - return this.hooks.package.call(moduleSourcePostRender, module, ctx); - } catch (e) { - e.message = `${module.identifier()}\n${e.message}`; - throw e; - } - } - - /** - * Updates hash with information from this template - * @param {Hash} hash the hash to update - * @returns {void} - */ - updateHash(hash) { - hash.update("1"); - this.hooks.hash.call(hash); - } }; diff --git a/lib/Template.js b/lib/Template.js index dded2fca2..0eb51e9cb 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -44,7 +44,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g; * @property {string} hash * @property {string} fullHash * @property {TODO} outputOptions - * @property {{asset: ModuleTemplate, javascript: ModuleTemplate, webassembly: ModuleTemplate}} moduleTemplates + * @property {{javascript: ModuleTemplate}} moduleTemplates * @property {DependencyTemplates} dependencyTemplates * @property {RuntimeTemplate} runtimeTemplate * @property {ModuleGraph} moduleGraph @@ -226,14 +226,14 @@ class Template { /** * @param {RenderContext} renderContext render context * @param {ModuleFilterPredicate} filterFn function used to filter modules from chunk to render - * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance used to render modules + * @param {function(Module): Source} renderModule function to render a module * @param {string=} prefix applying prefix strings * @returns {Source} rendered chunk modules in a Source object */ static renderChunkModules( renderContext, filterFn, - moduleTemplate, + renderModule, prefix = "" ) { const { chunk, chunkGraph } = renderContext; @@ -256,7 +256,7 @@ class Template { const allModules = modules.map(module => { return { id: chunkGraph.getModuleId(module), - source: moduleTemplate.render(module, renderContext) + source: renderModule(module) }; }); if (removedModules && removedModules.length > 0) { diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index db1d01038..384ba4f36 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -12,8 +12,8 @@ const JsonModulesPlugin = require("./JsonModulesPlugin"); const EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin"); const EvalSourceMapDevToolPlugin = require("./EvalSourceMapDevToolPlugin"); -const FunctionModulePlugin = require("./FunctionModulePlugin"); const LoaderTargetPlugin = require("./LoaderTargetPlugin"); +const ModuleInfoHeaderPlugin = require("./ModuleInfoHeaderPlugin"); const SourceMapDevToolPlugin = require("./SourceMapDevToolPlugin"); const EntryOptionPlugin = require("./EntryOptionPlugin"); @@ -81,7 +81,6 @@ class WebpackOptionsApply extends OptionsApply { mangleImports: options.optimization.mangleWasmImports }).apply(compiler); new FetchCompileAsyncWasmPlugin().apply(compiler); - new FunctionModulePlugin().apply(compiler); new NodeSourcePlugin(options.node).apply(compiler); new LoaderTargetPlugin(options.target).apply(compiler); break; @@ -97,7 +96,6 @@ class WebpackOptionsApply extends OptionsApply { mangleImports: options.optimization.mangleWasmImports }).apply(compiler); new FetchCompileAsyncWasmPlugin().apply(compiler); - new FunctionModulePlugin().apply(compiler); new NodeSourcePlugin(options.node).apply(compiler); new LoaderTargetPlugin(options.target).apply(compiler); new StartupChunkDependenciesPlugin({ @@ -119,7 +117,6 @@ class WebpackOptionsApply extends OptionsApply { mangleImports: options.optimization.mangleWasmImports }).apply(compiler); new ReadFileCompileAsyncWasmPlugin().apply(compiler); - new FunctionModulePlugin().apply(compiler); new NodeTargetPlugin().apply(compiler); new LoaderTargetPlugin("node").apply(compiler); new StartupChunkDependenciesPlugin({ @@ -133,7 +130,6 @@ class WebpackOptionsApply extends OptionsApply { const ExternalsPlugin = require("./ExternalsPlugin"); const StartupChunkDependenciesPlugin = require("./runtime/StartupChunkDependenciesPlugin"); new JsonpTemplatePlugin().apply(compiler); - new FunctionModulePlugin().apply(compiler); new NodeTargetPlugin().apply(compiler); new ExternalsPlugin("commonjs", "nw.gui").apply(compiler); new LoaderTargetPlugin(options.target).apply(compiler); @@ -150,7 +146,6 @@ class WebpackOptionsApply extends OptionsApply { new NodeTemplatePlugin({ asyncChunkLoading: true }).apply(compiler); - new FunctionModulePlugin().apply(compiler); new NodeTargetPlugin().apply(compiler); new ExternalsPlugin("commonjs", [ "app", @@ -202,7 +197,6 @@ class WebpackOptionsApply extends OptionsApply { mangleImports: options.optimization.mangleWasmImports }).apply(compiler); new FetchCompileAsyncWasmPlugin().apply(compiler); - new FunctionModulePlugin().apply(compiler); new NodeTargetPlugin().apply(compiler); new ExternalsPlugin("commonjs", [ "clipboard", @@ -250,6 +244,10 @@ class WebpackOptionsApply extends OptionsApply { ).apply(compiler); } + if (options.output.pathinfo) { + new ModuleInfoHeaderPlugin().apply(compiler); + } + if ( options.devtool && (options.devtool.includes("sourcemap") || diff --git a/lib/asset/AssetModulesPlugin.js b/lib/asset/AssetModulesPlugin.js index 9d797cdd2..2fad61085 100644 --- a/lib/asset/AssetModulesPlugin.js +++ b/lib/asset/AssetModulesPlugin.js @@ -17,8 +17,6 @@ const AssetParser = require("./AssetParser"); /** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../MainTemplate")} MainTemplate */ /** @typedef {import("../Module")} Module */ -/** @typedef {import("../ModuleTemplate")} ModuleTemplate */ -/** @typedef {import("../ModuleTemplate").RenderContext} RenderContext */ const type = "asset"; const plugin = "AssetModulesPlugin"; @@ -47,12 +45,7 @@ class AssetModulesPlugin { plugin, (result, options) => { const { chunkGraph, moduleGraph } = compilation; - const { - chunk, - moduleTemplates, - dependencyTemplates, - runtimeTemplate - } = options; + const { chunk, dependencyTemplates, runtimeTemplate } = options; const { outputOptions } = runtimeTemplate; @@ -66,12 +59,12 @@ class AssetModulesPlugin { result.push({ render: () => - this.renderAsset(module, moduleTemplates.asset, { - chunk, - chunkGraph, - moduleGraph, + module.source({ dependencyTemplates, - runtimeTemplate + runtimeTemplate, + moduleGraph, + chunkGraph, + type }), filenameTemplate, pathOptions: { @@ -92,17 +85,6 @@ class AssetModulesPlugin { } ); } - - /** - * @param {Module} module the module to render - * @param {ModuleTemplate} moduleTemplate the module template - * @param {RenderContext} renderContext the render context - * @returns {Source} the rendered source - */ - /* eslint-enable */ - renderAsset(module, moduleTemplate, renderContext) { - return moduleTemplate.render(module, renderContext); - } } module.exports = AssetModulesPlugin; diff --git a/lib/debug/ProfilingPlugin.js b/lib/debug/ProfilingPlugin.js index 61037b6bb..5618b5189 100644 --- a/lib/debug/ProfilingPlugin.js +++ b/lib/debug/ProfilingPlugin.js @@ -206,7 +206,7 @@ class ProfilingPlugin { "Context Module Factory" ); interceptAllParserHooks(normalModuleFactory, tracer); - interceptTemplateInstancesFrom(compilation, tracer); + interceptAllJavascriptModulesPluginHooks(compilation, tracer); } ); @@ -276,37 +276,6 @@ class ProfilingPlugin { } } -const interceptTemplateInstancesFrom = (compilation, tracer) => { - const { mainTemplate, chunkTemplate, moduleTemplates } = compilation; - - const { javascript, webassembly } = moduleTemplates; - - [ - { - instance: mainTemplate, - name: "MainTemplate" - }, - { - instance: chunkTemplate, - name: "ChunkTemplate" - }, - { - instance: javascript, - name: "JavaScriptModuleTemplate" - }, - { - instance: webassembly, - name: "WebAssemblyModuleTemplate" - } - ].forEach(templateObject => { - Object.keys(templateObject.instance.hooks).forEach(hookName => { - templateObject.instance.hooks[hookName].intercept( - makeInterceptorFor(templateObject.name, tracer)(hookName) - ); - }); - }); -}; - const interceptAllHooksFor = (instance, tracer, logLabel) => { if (Reflect.has(instance, "hooks")) { Object.keys(instance.hooks).forEach(hookName => { @@ -336,6 +305,18 @@ const interceptAllParserHooks = (moduleFactory, tracer) => { }); }; +const interceptAllJavascriptModulesPluginHooks = (compilation, tracer) => { + interceptAllHooksFor( + { + hooks: require("../JavascriptModulesPlugin").getCompilationHooks( + compilation + ) + }, + tracer, + "JavascriptModulesPlugin" + ); +}; + const makeInterceptorFor = (instance, tracer) => hookName => ({ register: ({ name, type, context, fn }) => { const newFn = makeNewProfiledTapFn(hookName, tracer, { diff --git a/lib/util/memorize.js b/lib/util/memorize.js index becb4da87..eff2c27bf 100644 --- a/lib/util/memorize.js +++ b/lib/util/memorize.js @@ -4,8 +4,16 @@ "use strict"; +/** @template T @typedef {function(): T} FunctionReturning */ + +/** + * @template T + * @param {FunctionReturning} fn memorized function + * @returns {FunctionReturning} new function + */ const memorize = fn => { let memorized = false; + /** @type {T} */ let result = undefined; return () => { if (memorized) { diff --git a/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js b/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js index 0b629ee61..8e5271dcc 100644 --- a/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +++ b/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js @@ -5,18 +5,65 @@ "use strict"; +const { SyncWaterfallHook } = require("tapable"); +const Compilation = require("../Compilation"); const Generator = require("../Generator"); +const { tryRunOrWebpackError } = require("../HookWebpackError"); const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency"); const { compareModulesById } = require("../util/comparators"); const AsyncWebAssemblyGenerator = require("./AsyncWebAssemblyGenerator"); const AsyncWebAssemblyJavascriptGenerator = require("./AsyncWebAssemblyJavascriptGenerator"); const AsyncWebAssemblyParser = require("./AsyncWebAssemblyParser"); +/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("../Compiler")} Compiler */ +/** @typedef {import("../Module")} Module */ +/** @typedef {import("../Compilation")} Compilation */ /** @typedef {import("../Template").RenderManifestOptions} RenderManifestOptions} */ /** @typedef {import("../Template").RenderManifestEntry} RenderManifestEntry} */ +/** + * @typedef {Object} RenderContext + * @property {Chunk} chunk the chunk + * @property {DependencyTemplates} dependencyTemplates the dependency templates + * @property {RuntimeTemplate} runtimeTemplate the runtime template + * @property {ModuleGraph} moduleGraph the module graph + * @property {ChunkGraph} chunkGraph the chunk graph + */ + +/** + * @typedef {Object} CompilationHooks + * @property {SyncWaterfallHook<[Source, Module, RenderContext]>} renderModuleContent + */ + +/** @type {WeakMap} */ +const compilationHooksMap = new WeakMap(); + class AsyncWebAssemblyModulesPlugin { + /** + * @param {Compilation} compilation the compilation + * @returns {CompilationHooks} the attached hooks + */ + static getCompilationHooks(compilation) { + if (!(compilation instanceof Compilation)) { + throw new TypeError( + "The 'compilation' argument must be an instance of JavascriptParser" + ); + } + let hooks = compilationHooksMap.get(compilation); + if (hooks === undefined) { + hooks = { + renderModuleContent: new SyncWaterfallHook([ + "source", + "module", + "renderContext" + ]) + }; + compilationHooksMap.set(compilation, hooks); + } + return hooks; + } + constructor(options) { this.options = options; } @@ -29,6 +76,9 @@ class AsyncWebAssemblyModulesPlugin { compiler.hooks.compilation.tap( "AsyncWebAssemblyModulesPlugin", (compilation, { normalModuleFactory }) => { + const hooks = AsyncWebAssemblyModulesPlugin.getCompilationHooks( + compilation + ); compilation.dependencyFactories.set( WebAssemblyImportDependency, normalModuleFactory @@ -50,62 +100,81 @@ class AsyncWebAssemblyModulesPlugin { }); }); - /** - * - * @param {RenderManifestEntry[]} result render entries - * @param {RenderManifestOptions} options context options - * @returns {RenderManifestEntry[]} render entries - */ - const handler = (result, options) => { - const { moduleGraph, chunkGraph, runtimeTemplate } = compilation; - const chunk = options.chunk; - const outputOptions = options.outputOptions; - const moduleTemplates = options.moduleTemplates; - const dependencyTemplates = options.dependencyTemplates; + compilation.hooks.renderManifest.tap( + "WebAssemblyModulesPlugin", + (result, options) => { + const { moduleGraph, chunkGraph, runtimeTemplate } = compilation; + const chunk = options.chunk; + const outputOptions = options.outputOptions; + const dependencyTemplates = options.dependencyTemplates; - for (const module of chunkGraph.getOrderedChunkModulesIterable( - chunk, - compareModulesById(chunkGraph) - )) { - if (module.type === "webassembly/async") { - const filenameTemplate = outputOptions.webassemblyModuleFilename; + for (const module of chunkGraph.getOrderedChunkModulesIterable( + chunk, + compareModulesById(chunkGraph) + )) { + if (module.type === "webassembly/async") { + const filenameTemplate = + outputOptions.webassemblyModuleFilename; - result.push({ - render: () => - moduleTemplates.webassembly.render(module, { - chunk, - dependencyTemplates, - runtimeTemplate, - moduleGraph, + result.push({ + render: () => + this.renderModule( + module, + { + chunk, + dependencyTemplates, + runtimeTemplate, + moduleGraph, + chunkGraph + }, + hooks + ), + filenameTemplate, + pathOptions: { + module, chunkGraph - }), - filenameTemplate, - pathOptions: { - module, - chunkGraph - }, - auxiliary: true, - identifier: `webassemblyAsyncModule${chunkGraph.getModuleId( - module - )}`, - hash: chunkGraph.getModuleHash(module) - }); + }, + auxiliary: true, + identifier: `webassemblyAsyncModule${chunkGraph.getModuleId( + module + )}`, + hash: chunkGraph.getModuleHash(module) + }); + } } - } - return result; - }; - compilation.chunkTemplate.hooks.renderManifest.tap( - "WebAssemblyModulesPlugin", - handler - ); - compilation.mainTemplate.hooks.renderManifest.tap( - "WebAssemblyModulesPlugin", - handler + return result; + } ); } ); } + + renderModule(module, renderContext, hooks) { + const { + chunkGraph, + moduleGraph, + runtimeTemplate, + dependencyTemplates + } = renderContext; + try { + const moduleSource = module.source({ + dependencyTemplates, + runtimeTemplate, + moduleGraph, + chunkGraph, + type: "webassembly" + }); + return tryRunOrWebpackError( + () => + hooks.renderModuleContent.call(moduleSource, module, renderContext), + "AsyncWebAssemblyModulesPlugin.getCompilationHooks().renderModuleContent" + ); + } catch (e) { + e.module = module; + throw e; + } + } } module.exports = AsyncWebAssemblyModulesPlugin; diff --git a/lib/wasm/WebAssemblyModulesPlugin.js b/lib/wasm/WebAssemblyModulesPlugin.js index 7de0683dd..db312be0f 100644 --- a/lib/wasm/WebAssemblyModulesPlugin.js +++ b/lib/wasm/WebAssemblyModulesPlugin.js @@ -64,7 +64,6 @@ class WebAssemblyModulesPlugin { const { moduleGraph, chunkGraph, runtimeTemplate } = compilation; const chunk = options.chunk; const outputOptions = options.outputOptions; - const moduleTemplates = options.moduleTemplates; const dependencyTemplates = options.dependencyTemplates; for (const module of chunkGraph.getOrderedChunkModulesIterable( @@ -77,17 +76,12 @@ class WebAssemblyModulesPlugin { result.push({ render: () => - this.renderWebAssembly( - module, - moduleTemplates.webassembly, - { - chunk, - dependencyTemplates, - runtimeTemplate, - moduleGraph, - chunkGraph - } - ), + module.source({ + dependencyTemplates, + runtimeTemplate, + moduleGraph, + chunkGraph + }), filenameTemplate, pathOptions: { module, @@ -132,17 +126,6 @@ class WebAssemblyModulesPlugin { } ); } - - /** - * - * @param {Module} module the wasm module - * @param {ModuleTemplate} moduleTemplate the module tempalte - * @param {RenderContext} renderContext render context - * @returns {Source} rendered source - */ - renderWebAssembly(module, moduleTemplate, renderContext) { - return moduleTemplate.render(module, renderContext); - } } module.exports = WebAssemblyModulesPlugin; diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 40afb9748..933aea251 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -1294,7 +1294,7 @@ }, { "instanceof": "Function", - "tsType": "Function" + "tsType": "((pathData: import(\"../lib/Compilation\").PathData, assetInfo?: import(\"../lib/Compilation\").AssetInfo) => string)" } ] }, diff --git a/test/StatsTestCases.test.js b/test/StatsTestCases.test.js index f732b8c44..3a72ed583 100644 --- a/test/StatsTestCases.test.js +++ b/test/StatsTestCases.test.js @@ -160,7 +160,10 @@ describe("StatsTestCases", () => { const testPath = path.join(base, testName); actual = actual .replace(/\r\n?/g, "\n") - .replace(/\(.+\) DeprecationWarning.+(\n\s+at .*)*\n?/g, "") + .replace( + /\([^)]+\) (\[[^\]]+\]\s*)?DeprecationWarning.+(\n\s+at .*)*\n?/g, + "" + ) .replace(/[\t ]*Version:.+\n/g, "") .replace(new RegExp(quotemeta(testPath), "g"), "Xdir/" + testName) .replace(/(\w)\\(\w)/g, "$1/$2") diff --git a/test/__snapshots__/StatsTestCases.test.js.snap b/test/__snapshots__/StatsTestCases.test.js.snap index b3b2fea5d..ae5ba6c5b 100644 --- a/test/__snapshots__/StatsTestCases.test.js.snap +++ b/test/__snapshots__/StatsTestCases.test.js.snap @@ -1,143 +1,143 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`StatsTestCases should print correct stats for aggressive-splitting-entry 1`] = ` -"Hash: 83f83194ca81e29ad93083f83194ca81e29ad930 +"Hash: b4524ca479888c8ceb73b4524ca479888c8ceb73 Child fitting: - Hash: 83f83194ca81e29ad930 + Hash: b4524ca479888c8ceb73 Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names - 501a16e2f184bd3b8ea5.js 1.07 KiB {785} [emitted] [immutable] - b655127fd4eca55a90aa.js 1.91 KiB {394} [emitted] [immutable] - bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] [immutable] - ecb9144d6f2b6e082333.js 12.8 KiB {10} [emitted] [immutable] - Entrypoint main = b655127fd4eca55a90aa.js bac8938bfd9c34df221b.js ecb9144d6f2b6e082333.js - chunk {10} ecb9144d6f2b6e082333.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered] + 4393bf4227899af05251.js 1.91 KiB {394} [emitted] [immutable] + 6dc81979aedbea58e281.js 12.8 KiB {10} [emitted] [immutable] + 8d1687584089811a81ad.js 1.91 KiB {102} [emitted] [immutable] + 98439f7e3080522c6b08.js 1.08 KiB {785} [emitted] [immutable] + Entrypoint main = 4393bf4227899af05251.js 8d1687584089811a81ad.js 6dc81979aedbea58e281.js + chunk {10} 6dc81979aedbea58e281.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered] > ./index main [10] ./index.js 111 bytes {10} [built] [390] ./e.js 899 bytes {10} [built] [568] ./f.js 900 bytes {10} [built] + 7 hidden chunk modules - chunk {102} bac8938bfd9c34df221b.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted + chunk {102} 8d1687584089811a81ad.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted > ./index main [460] ./c.js 899 bytes {102} [built] [767] ./d.js 899 bytes {102} [built] - chunk {394} b655127fd4eca55a90aa.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted + chunk {394} 4393bf4227899af05251.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted > ./index main [847] ./a.js 899 bytes {394} [built] [996] ./b.js 899 bytes {394} [built] - chunk {785} 501a16e2f184bd3b8ea5.js 916 bytes [rendered] + chunk {785} 98439f7e3080522c6b08.js 916 bytes [rendered] > ./g [10] ./index.js 7:0-13 [785] ./g.js 916 bytes {785} [built] Child content-change: - Hash: 83f83194ca81e29ad930 + Hash: b4524ca479888c8ceb73 Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names - 501a16e2f184bd3b8ea5.js 1.07 KiB {785} [emitted] [immutable] - b655127fd4eca55a90aa.js 1.91 KiB {394} [emitted] [immutable] - bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] [immutable] - ecb9144d6f2b6e082333.js 12.8 KiB {10} [emitted] [immutable] - Entrypoint main = b655127fd4eca55a90aa.js bac8938bfd9c34df221b.js ecb9144d6f2b6e082333.js - chunk {10} ecb9144d6f2b6e082333.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered] + 4393bf4227899af05251.js 1.91 KiB {394} [emitted] [immutable] + 6dc81979aedbea58e281.js 12.8 KiB {10} [emitted] [immutable] + 8d1687584089811a81ad.js 1.91 KiB {102} [emitted] [immutable] + 98439f7e3080522c6b08.js 1.08 KiB {785} [emitted] [immutable] + Entrypoint main = 4393bf4227899af05251.js 8d1687584089811a81ad.js 6dc81979aedbea58e281.js + chunk {10} 6dc81979aedbea58e281.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered] > ./index main [10] ./index.js 111 bytes {10} [built] [390] ./e.js 899 bytes {10} [built] [568] ./f.js 900 bytes {10} [built] + 7 hidden chunk modules - chunk {102} bac8938bfd9c34df221b.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted + chunk {102} 8d1687584089811a81ad.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted > ./index main [460] ./c.js 899 bytes {102} [built] [767] ./d.js 899 bytes {102} [built] - chunk {394} b655127fd4eca55a90aa.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted + chunk {394} 4393bf4227899af05251.js 1.76 KiB [initial] [rendered] [recorded] aggressive splitted > ./index main [847] ./a.js 899 bytes {394} [built] [996] ./b.js 899 bytes {394} [built] - chunk {785} 501a16e2f184bd3b8ea5.js 916 bytes [rendered] + chunk {785} 98439f7e3080522c6b08.js 916 bytes [rendered] > ./g [10] ./index.js 7:0-13 [785] ./g.js 916 bytes {785} [built]" `; exports[`StatsTestCases should print correct stats for aggressive-splitting-on-demand 1`] = ` -"Hash: a0835567cd5ac79ef1c9 +"Hash: 3b34ba02f86c5d2b468a Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names -035ce1d102419ee4897b.js 1010 bytes {701} [emitted] [immutable] -1ffcc984ad7d7c92ab0b.js 1.91 KiB {594} [emitted] [immutable] -2d925701a76fac28b8cc.js 1.91 KiB {817} [emitted] [immutable] -4717957e3d668ff4f9e8.js 1.91 KiB {591} [emitted] [immutable] -49dd7266942f0ed4ae64.js 1010 bytes {847} [emitted] [immutable] -61fe00576946c9f2606d.js 1.91 KiB {454} [emitted] [immutable] -a5d468e53d230541a8cb.js 9.31 KiB {179} [emitted] [immutable] main -b18de3d2b973b820ea21.js 1.91 KiB {294}, {701} [emitted] [immutable] -bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] [immutable] -c0e562c433da5d2d3cb7.js 1.91 KiB {390}, {523} [emitted] [immutable] -f2593c9acd7da73fffbe.js 1010 bytes {390} [emitted] [immutable] -f50587036d9d0e61836c.js 1.91 KiB {613} [emitted] [immutable] -Entrypoint main = a5d468e53d230541a8cb.js -chunk {102} bac8938bfd9c34df221b.js 1.76 KiB [rendered] [recorded] aggressive splitted +07da00f0ae83da63d782.js 1010 bytes {847} [emitted] [immutable] +2604db3ab2e79792c96c.js 1.91 KiB {591} [emitted] [immutable] +56afd62529625582668f.js 9.32 KiB {179} [emitted] [immutable] main +60b17101a071250ce9a0.js 1.91 KiB {454} [emitted] [immutable] +64a2cf8d2c3ddf1c3e46.js 1.91 KiB {613} [emitted] [immutable] +6bafe7dc70c6faffaa36.js 1.91 KiB {594} [emitted] [immutable] +886af1f8f436bb7b50c4.js 1010 bytes {390} [emitted] [immutable] +8d1687584089811a81ad.js 1.91 KiB {102} [emitted] [immutable] +a7a564e29811c704ecfe.js 1.91 KiB {390}, {523} [emitted] [immutable] +d56725c242278ec75fcd.js 1.91 KiB {817} [emitted] [immutable] +d5a902d3b3f0abea6457.js 1.91 KiB {294}, {701} [emitted] [immutable] +daba47db1ba13dba0372.js 1010 bytes {701} [emitted] [immutable] +Entrypoint main = 56afd62529625582668f.js +chunk {102} 8d1687584089811a81ad.js 1.76 KiB [rendered] [recorded] aggressive splitted > ./c ./d ./e [942] ./index.js 3:0-30 [460] ./c.js 899 bytes {102} {591} [built] [767] ./d.js 899 bytes {102} {817} [built] -chunk {179} a5d468e53d230541a8cb.js (main) 248 bytes (javascript) 4.44 KiB (runtime) [entry] [rendered] +chunk {179} 56afd62529625582668f.js (main) 248 bytes (javascript) 4.44 KiB (runtime) [entry] [rendered] > ./index main [942] ./index.js 248 bytes {179} [built] + 4 hidden chunk modules -chunk {294} b18de3d2b973b820ea21.js 1.76 KiB [rendered] +chunk {294} d5a902d3b3f0abea6457.js 1.76 KiB [rendered] > ./f ./g ./h ./i ./j ./k [942] ./index.js 4:0-51 [138] ./j.js 901 bytes {294} {454} [built] [701] ./k.js 899 bytes {294} {701} [built] -chunk {390} f2593c9acd7da73fffbe.js 899 bytes [rendered] +chunk {390} 886af1f8f436bb7b50c4.js 899 bytes [rendered] > ./c ./d ./e [942] ./index.js 3:0-30 > ./b ./d ./e ./f ./g [942] ./index.js 5:0-44 [390] ./e.js 899 bytes {390} {523} [built] -chunk {454} 61fe00576946c9f2606d.js 1.76 KiB [rendered] [recorded] aggressive splitted +chunk {454} 60b17101a071250ce9a0.js 1.76 KiB [rendered] [recorded] aggressive splitted > ./b ./d ./e ./f ./g ./h ./i ./j ./k [942] ./index.js 6:0-72 [101] ./i.js 899 bytes {454} {594} [built] [138] ./j.js 901 bytes {294} {454} [built] -chunk {523} c0e562c433da5d2d3cb7.js 1.76 KiB [rendered] [recorded] aggressive splitted +chunk {523} a7a564e29811c704ecfe.js 1.76 KiB [rendered] [recorded] aggressive splitted > ./b ./d ./e ./f ./g ./h ./i ./j ./k [942] ./index.js 6:0-72 [307] ./h.js 899 bytes {523} {594} [built] [390] ./e.js 899 bytes {390} {523} [built] -chunk {591} 4717957e3d668ff4f9e8.js 1.76 KiB [rendered] +chunk {591} 2604db3ab2e79792c96c.js 1.76 KiB [rendered] > ./b ./c [942] ./index.js 2:0-23 [460] ./c.js 899 bytes {102} {591} [built] [996] ./b.js 899 bytes {591} {817} [built] -chunk {594} 1ffcc984ad7d7c92ab0b.js 1.76 KiB [rendered] [recorded] aggressive splitted +chunk {594} 6bafe7dc70c6faffaa36.js 1.76 KiB [rendered] [recorded] aggressive splitted > ./f ./g ./h ./i ./j ./k [942] ./index.js 4:0-51 [101] ./i.js 899 bytes {454} {594} [built] [307] ./h.js 899 bytes {523} {594} [built] -chunk {613} f50587036d9d0e61836c.js 1.76 KiB [rendered] [recorded] aggressive splitted +chunk {613} 64a2cf8d2c3ddf1c3e46.js 1.76 KiB [rendered] [recorded] aggressive splitted > ./f ./g ./h ./i ./j ./k [942] ./index.js 4:0-51 > ./b ./d ./e ./f ./g [942] ./index.js 5:0-44 > ./b ./d ./e ./f ./g ./h ./i ./j ./k [942] ./index.js 6:0-72 [568] ./f.js 899 bytes {613} [built] [785] ./g.js 901 bytes {613} [built] -chunk {701} 035ce1d102419ee4897b.js 899 bytes [rendered] +chunk {701} daba47db1ba13dba0372.js 899 bytes [rendered] > ./b ./d ./e ./f ./g ./h ./i ./j ./k [942] ./index.js 6:0-72 [701] ./k.js 899 bytes {294} {701} [built] -chunk {817} 2d925701a76fac28b8cc.js 1.76 KiB [rendered] [recorded] aggressive splitted +chunk {817} d56725c242278ec75fcd.js 1.76 KiB [rendered] [recorded] aggressive splitted > ./b ./d ./e ./f ./g [942] ./index.js 5:0-44 > ./b ./d ./e ./f ./g ./h ./i ./j ./k [942] ./index.js 6:0-72 [767] ./d.js 899 bytes {102} {817} [built] [996] ./b.js 899 bytes {591} {817} [built] -chunk {847} 49dd7266942f0ed4ae64.js 899 bytes [rendered] +chunk {847} 07da00f0ae83da63d782.js 899 bytes [rendered] > ./a [942] ./index.js 1:0-16 [847] ./a.js 899 bytes {847} [built]" `; exports[`StatsTestCases should print correct stats for asset 1`] = ` -"Hash: 9be0f1e0623c01091019 +"Hash: 0e9f6ca6b21997c1583a Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names 44af8fe384aadccba06e.svg 656 bytes ({179}) [emitted] [immutable] (main) 62787d6ac9d673cc8926.png 14.6 KiB ({179}) [emitted] [immutable] (main) - bundle.js 4.27 KiB {179} [emitted] main + bundle.js 4.3 KiB {179} [emitted] main c2a9ba2e6ec92fd70245.jpg 5.89 KiB ({179}) [emitted] [immutable] (main) Entrypoint main = bundle.js (44af8fe384aadccba06e.svg 62787d6ac9d673cc8926.png c2a9ba2e6ec92fd70245.jpg) [10] ./index.js 111 bytes {179} [built] @@ -447,13 +447,13 @@ Child all: `; exports[`StatsTestCases should print correct stats for chunk-module-id-range 1`] = ` -"Hash: 1e086a89bae53380ecd2 +"Hash: b5735b789ea9f6271194 Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names -main1.js 4.26 KiB {1} [emitted] main1 -main2.js 4.25 KiB {0} [emitted] main2 +main1.js 4.29 KiB {1} [emitted] main1 +main2.js 4.29 KiB {0} [emitted] main2 Entrypoint main1 = main1.js Entrypoint main2 = main2.js chunk {0} main2.js (main2) 136 bytes (javascript) 632 bytes (runtime) [entry] [rendered] @@ -475,15 +475,15 @@ chunk {1} main1.js (main1) 136 bytes (javascript) 632 bytes (runtime) [entry] [r `; exports[`StatsTestCases should print correct stats for chunks 1`] = ` -"Hash: 4da70a103c7c9329f3ac +"Hash: 808468ffb50d3cab9bbf Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names -460.bundle.js 306 bytes {460} [emitted] +460.bundle.js 324 bytes {460} [emitted] 524.bundle.js 210 bytes {524} [emitted] 996.bundle.js 142 bytes {996} [emitted] - bundle.js 7.8 KiB {179} [emitted] main + bundle.js 7.81 KiB {179} [emitted] main Entrypoint main = bundle.js chunk {179} bundle.js (main) 73 bytes (javascript) 4.13 KiB (runtime) >{460}< >{996}< [entry] [rendered] > ./index main @@ -515,15 +515,15 @@ chunk {996} 996.bundle.js 22 bytes <{179}> [rendered] `; exports[`StatsTestCases should print correct stats for chunks-development 1`] = ` -"Hash: 37e46b7b140f40b87e4f +"Hash: 4ddebd7e67b657a24523 Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names b_js.bundle.js 359 bytes {b_js} [emitted] - bundle.js 8.4 KiB {main} [emitted] main - c_js.bundle.js 570 bytes {c_js} [emitted] -d_js-e_js.bundle.js 750 bytes {d_js-e_js} [emitted] + bundle.js 8.41 KiB {main} [emitted] main + c_js.bundle.js 588 bytes {c_js} [emitted] +d_js-e_js.bundle.js 759 bytes {d_js-e_js} [emitted] Entrypoint main = bundle.js chunk {b_js} b_js.bundle.js 22 bytes <{main}> [rendered] > ./b [./index.js] ./index.js 2:0-16 @@ -569,7 +569,7 @@ chunk {786} 786.bundle.js (a) 49 bytes <{179}> <{459}> >{459}< [rendered] `; exports[`StatsTestCases should print correct stats for color-disabled 1`] = ` -"Hash: ab39ead63d47ea78804b +"Hash: 192807ce932ddf7801c7 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -579,7 +579,7 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for color-enabled 1`] = ` -"Hash: ab39ead63d47ea78804b +"Hash: 192807ce932ddf7801c7 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -589,7 +589,7 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for color-enabled-custom 1`] = ` -"Hash: ab39ead63d47ea78804b +"Hash: 192807ce932ddf7801c7 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -599,12 +599,12 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for commons-chunk-min-size-0 1`] = ` -"Hash: 386362a70942728c6784 +"Hash: d6c80d242715736e2fb7 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names 429.js 278 bytes {429} [emitted] -entry-1.js 5.21 KiB {472} [emitted] entry-1 +entry-1.js 5.22 KiB {472} [emitted] entry-1 Entrypoint entry-1 = 429.js entry-1.js [115] ./modules/c.js 22 bytes {429} [built] [544] ./modules/f.js 22 bytes {472} [built] @@ -617,11 +617,11 @@ Entrypoint entry-1 = 429.js entry-1.js `; exports[`StatsTestCases should print correct stats for commons-chunk-min-size-Infinity 1`] = ` -"Hash: 9c0c7df965d32c5af0d7 +"Hash: cd44d45f7ae9bef16123 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - entry-1.js 5.21 KiB {472} [emitted] entry-1 + entry-1.js 5.22 KiB {472} [emitted] entry-1 vendor-1.js 278 bytes {844} [emitted] vendor-1 Entrypoint entry-1 = vendor-1.js entry-1.js [115] ./modules/c.js 22 bytes {844} [built] @@ -635,26 +635,26 @@ Entrypoint entry-1 = vendor-1.js entry-1.js `; exports[`StatsTestCases should print correct stats for commons-plugin-issue-4980 1`] = ` -"Hash: b5e5b4b55e7b2d7662c723bb67ab2183d45e0a07 +"Hash: 6f07316d6ddd6396f17f00fd6078629461e3d229 Child - Hash: b5e5b4b55e7b2d7662c7 + Hash: 6f07316d6ddd6396f17f Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - app.8f85861f8fbd1c6860b5.js 6.73 KiB {143} [emitted] [immutable] app - vendor.3ca106870164d059e3b7.js 606 bytes {736} [emitted] [immutable] vendor - Entrypoint app = vendor.3ca106870164d059e3b7.js app.8f85861f8fbd1c6860b5.js + app.878864b2a48f6be36f58.js 6.73 KiB {143} [emitted] [immutable] app + vendor.da0e56634afc22a486e6.js 615 bytes {736} [emitted] [immutable] vendor + Entrypoint app = vendor.da0e56634afc22a486e6.js app.878864b2a48f6be36f58.js [117] ./entry-1.js + 2 modules 190 bytes {143} [built] [381] ./constants.js 87 bytes {736} [built] + 4 hidden modules Child - Hash: 23bb67ab2183d45e0a07 + Hash: 00fd6078629461e3d229 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - app.5e7c0987f5feb9f4522a.js 6.75 KiB {143} [emitted] [immutable] app - vendor.3ca106870164d059e3b7.js 606 bytes {736} [emitted] [immutable] vendor - Entrypoint app = vendor.3ca106870164d059e3b7.js app.5e7c0987f5feb9f4522a.js + app.e9b3c5cb3db397ea7e0c.js 6.75 KiB {143} [emitted] [immutable] app + vendor.da0e56634afc22a486e6.js 615 bytes {736} [emitted] [immutable] vendor + Entrypoint app = vendor.da0e56634afc22a486e6.js app.e9b3c5cb3db397ea7e0c.js [381] ./constants.js 87 bytes {736} [built] [655] ./entry-2.js + 2 modules 197 bytes {143} [built] + 4 hidden modules" @@ -679,35 +679,35 @@ exports[`StatsTestCases should print correct stats for concat-and-sideeffects 1` `; exports[`StatsTestCases should print correct stats for define-plugin 1`] = ` -"Hash: fda28c2a019271c6765c0073b4f9edcac2b2dd3d4f56029b41d3f8602887 +"Hash: aa5b115a0288f2c2e9ee54a3aa4e0ca2fb43d363c5b18c53850578be3fcd Child - Hash: fda28c2a019271c6765c + Hash: aa5b115a0288f2c2e9ee Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - main.js 1.28 KiB {179} [emitted] main + main.js 1.27 KiB {179} [emitted] main Entrypoint main = main.js [10] ./index.js 24 bytes {179} [built] Child - Hash: 0073b4f9edcac2b2dd3d + Hash: 54a3aa4e0ca2fb43d363 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - main.js 1.28 KiB {179} [emitted] main + main.js 1.27 KiB {179} [emitted] main Entrypoint main = main.js [10] ./index.js 24 bytes {179} [built] Child - Hash: 4f56029b41d3f8602887 + Hash: c5b18c53850578be3fcd Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - main.js 1.28 KiB {179} [emitted] main + main.js 1.27 KiB {179} [emitted] main Entrypoint main = main.js [10] ./index.js 24 bytes {179} [built]" `; exports[`StatsTestCases should print correct stats for dll-reference-plugin-issue-7624 1`] = ` -"Hash: 87dbd4f2d15f56d76257 +"Hash: 75b20b1aa3e431fb8a95 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -717,7 +717,7 @@ Entrypoint main = bundle.js `; exports[`StatsTestCases should print correct stats for dll-reference-plugin-issue-7624-error 1`] = ` -"Hash: 74d364b1dc63cccf3462 +"Hash: 169e58ad4e677ac662a8 Time: Xms Built at: 1970-04-20 12:42:42 1 asset @@ -730,11 +730,11 @@ Unexpected end of JSON input while parsing near '' `; exports[`StatsTestCases should print correct stats for exclude-with-loader 1`] = ` -"Hash: f9d96205378cf2d78ae3 +"Hash: 66932e2a273e3e402fd0 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names -bundle.js 3.53 KiB {179} [emitted] main +bundle.js 3.56 KiB {179} [emitted] main + 1 hidden asset Entrypoint main = bundle.js (5bcd36918d225eeda398ea3f372b7f16.json) [10] ./index.js 77 bytes {179} [built] @@ -743,7 +743,7 @@ Entrypoint main = bundle.js (5bcd36918d225eeda398ea3f372b7f16.json) `; exports[`StatsTestCases should print correct stats for external 1`] = ` -"Hash: 5b5b62b332898f49f8c8 +"Hash: 63db29e5c710b76e32fe Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -754,13 +754,13 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for filter-warnings 1`] = ` -"Hash: 573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9573a4b066b341577dee9 +"Hash: e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389e907826420a06c687389 Child undefined: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0] @@ -786,53 +786,53 @@ Child undefined: WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child Terser: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js Child /Terser/: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js Child warnings => true: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js Child [Terser]: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js Child [/Terser/]: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js Child [warnings => true]: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js Child should not filter: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0] @@ -858,11 +858,11 @@ Child should not filter: WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child /should not filter/: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0] @@ -888,11 +888,11 @@ Child /should not filter/: WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child warnings => false: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0] @@ -918,11 +918,11 @@ Child warnings => false: WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child [should not filter]: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0] @@ -948,11 +948,11 @@ Child [should not filter]: WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child [/should not filter/]: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0] @@ -978,11 +978,11 @@ Child [/should not filter/]: WARNING in Terser Plugin: Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child [warnings => false]: - Hash: 573a4b066b341577dee9 + Hash: e907826420a06c687389 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 1.12 KiB {179} [emitted] main + bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js WARNING in Terser Plugin: Dropping side-effect-free statement [./index.js:6,0] @@ -1104,19 +1104,19 @@ chunk {trees} trees.js (trees) 71 bytes [rendered] exports[`StatsTestCases should print correct stats for immutable 1`] = ` " Asset Size Chunks Chunk Names -5a00a5aaadb77d195a77.js 346 bytes {chunk_js} [emitted] [immutable] -cc4f840c240486451e92.js 9.93 KiB {main} [emitted] [immutable] main" +e962f33a28fe7c3eba46.js 346 bytes {chunk_js} [emitted] [immutable] +ff3f5f3afd7fc39dee35.js 9.94 KiB {main} [emitted] [immutable] main" `; exports[`StatsTestCases should print correct stats for import-context-filter 1`] = ` -"Hash: 557ec55c23f1ec577bc1 +"Hash: 3e41c56e2bb16aa37a20 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 398.js 475 bytes {398} [emitted] - 544.js 475 bytes {544} [emitted] - 718.js 475 bytes {718} [emitted] -entry.js 9.62 KiB {497} [emitted] entry + 398.js 484 bytes {398} [emitted] + 544.js 484 bytes {544} [emitted] + 718.js 484 bytes {718} [emitted] +entry.js 9.64 KiB {497} [emitted] entry Entrypoint entry = entry.js [389] ./templates lazy ^\\\\.\\\\/.*$ include: \\\\.js$ exclude: \\\\.noimport\\\\.js$ namespace object 160 bytes {497} [optional] [built] [398] ./templates/bar.js 38 bytes {398} [optional] [built] @@ -1127,7 +1127,7 @@ Entrypoint entry = entry.js `; exports[`StatsTestCases should print correct stats for import-weak 1`] = ` -"Hash: a79f737411e8ac5edc02 +"Hash: 5d3f315f2e18efcf9820 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1164,42 +1164,42 @@ Compilation error while processing magic comment(-s): /* webpackPrefetch: nope * `; exports[`StatsTestCases should print correct stats for issue-7577 1`] = ` -"Hash: 8007e5481ab0996b24229ab93e52c79cde06fdf3f9d8d6561e9b61fb9d05 +"Hash: 380267806f8a546a09e6febad2e5f9ae162599c1b988de17a1a0c2dae024 Child - Hash: 8007e5481ab0996b2422 + Hash: 380267806f8a546a09e6 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - a-all-a_js-5ed868390c43e7086a86.js 144 bytes {all-a_js} [emitted] [immutable] - a-main-5b1dc11fec11f25eaf1b.js 115 bytes {main} [emitted] [immutable] main - a-runtime~main-2ddfebad083f190c54f0.js 4.76 KiB {runtime~main} [emitted] [immutable] runtime~main - Entrypoint main = a-runtime~main-2ddfebad083f190c54f0.js a-all-a_js-5ed868390c43e7086a86.js a-main-5b1dc11fec11f25eaf1b.js + a-all-a_js-7daa793cbf0b34cfc26d.js 144 bytes {all-a_js} [emitted] [immutable] + a-main-fc86a2cf757da86beae8.js 115 bytes {main} [emitted] [immutable] main + a-runtime~main-a7f0d0a7a6024e5229d1.js 4.75 KiB {runtime~main} [emitted] [immutable] runtime~main + Entrypoint main = a-runtime~main-a7f0d0a7a6024e5229d1.js a-all-a_js-7daa793cbf0b34cfc26d.js a-main-fc86a2cf757da86beae8.js [./a.js] 18 bytes {all-a_js} [built] + 1 hidden module Child - Hash: 9ab93e52c79cde06fdf3 + Hash: febad2e5f9ae162599c1 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - b-all-b_js-89c3127ba563ffa436dc.js 497 bytes {all-b_js} [emitted] [immutable] - b-main-f043bf83e8ebac493a99.js 148 bytes {main} [emitted] [immutable] main - b-runtime~main-419a0a24d9d86bf0f8fd.js 6.21 KiB {runtime~main} [emitted] [immutable] runtime~main - b-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js 189 bytes {vendors-node_modules_vendor_js} [emitted] [immutable] - Entrypoint main = b-runtime~main-419a0a24d9d86bf0f8fd.js b-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js b-all-b_js-89c3127ba563ffa436dc.js b-main-f043bf83e8ebac493a99.js + b-all-b_js-5b048fc0e62af6a259e9.js 506 bytes {all-b_js} [emitted] [immutable] + b-main-3de463a8a3e085edeb6b.js 148 bytes {main} [emitted] [immutable] main + b-runtime~main-7409f9b56a254efb03a8.js 6.2 KiB {runtime~main} [emitted] [immutable] runtime~main + b-vendors-node_modules_vendor_js-77f6ec0fbc8556ed87af.js 189 bytes {vendors-node_modules_vendor_js} [emitted] [immutable] + Entrypoint main = b-runtime~main-7409f9b56a254efb03a8.js b-vendors-node_modules_vendor_js-77f6ec0fbc8556ed87af.js b-all-b_js-5b048fc0e62af6a259e9.js b-main-3de463a8a3e085edeb6b.js [./b.js] 17 bytes {all-b_js} [built] [./node_modules/vendor.js] 23 bytes {vendors-node_modules_vendor_js} [built] + 4 hidden modules Child - Hash: f9d8d6561e9b61fb9d05 + Hash: b988de17a1a0c2dae024 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - c-all-b_js-89c3127ba563ffa436dc.js 497 bytes {all-b_js} [emitted] [immutable] - c-all-c_js-936472833753792cc303.js 364 bytes {all-c_js} [emitted] [immutable] - c-main-74481bfa6b28e9e83c8f.js 164 bytes {main} [emitted] [immutable] main - c-runtime~main-a40bb511645587263b1e.js 11.2 KiB {runtime~main} [emitted] [immutable] runtime~main - c-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js 189 bytes {vendors-node_modules_vendor_js} [emitted] [immutable] - Entrypoint main = c-runtime~main-a40bb511645587263b1e.js c-all-c_js-936472833753792cc303.js c-main-74481bfa6b28e9e83c8f.js (prefetch: c-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js c-all-b_js-89c3127ba563ffa436dc.js) + c-all-b_js-5b048fc0e62af6a259e9.js 506 bytes {all-b_js} [emitted] [immutable] + c-all-c_js-dba8425221a1c8392a18.js 382 bytes {all-c_js} [emitted] [immutable] + c-main-143d5a3c252ba98b89ae.js 164 bytes {main} [emitted] [immutable] main + c-runtime~main-e0b388d300c86ec70716.js 11.2 KiB {runtime~main} [emitted] [immutable] runtime~main + c-vendors-node_modules_vendor_js-77f6ec0fbc8556ed87af.js 189 bytes {vendors-node_modules_vendor_js} [emitted] [immutable] + Entrypoint main = c-runtime~main-e0b388d300c86ec70716.js c-all-c_js-dba8425221a1c8392a18.js c-main-143d5a3c252ba98b89ae.js (prefetch: c-vendors-node_modules_vendor_js-77f6ec0fbc8556ed87af.js c-all-b_js-5b048fc0e62af6a259e9.js) [./b.js] 17 bytes {all-b_js} [built] [./c.js] 61 bytes {all-c_js} [built] [./node_modules/vendor.js] 23 bytes {vendors-node_modules_vendor_js} [built] @@ -1207,13 +1207,13 @@ Child `; exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 1`] = ` -"Hash: b89f59691cd5820b75668a4406e71413f56fa4008464c8e8dc0e38aae73271a37603ba9eac59b24f +"Hash: 7bc11b8228ee5c6b9219ddfd4ec0cd4c351bafc5bc05efb0a248cb4c6f038d75b4cea6ef92a6f9fb Child 1 chunks: - Hash: b89f59691cd5820b7566 + Hash: 7bc11b8228ee5c6b9219 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - bundle.js 4.25 KiB {179} [emitted] main + bundle.js 4.28 KiB {179} [emitted] main Entrypoint main = bundle.js chunk {179} bundle.js (main) 219 bytes (javascript) 1.32 KiB (runtime) <{179}> >{179}< [entry] [rendered] [10] ./index.js 101 bytes {179} [built] @@ -1224,12 +1224,12 @@ Child 1 chunks: [996] ./b.js 22 bytes {179} [built] + 3 hidden chunk modules Child 2 chunks: - Hash: 8a4406e71413f56fa400 + Hash: ddfd4ec0cd4c351bafc5 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 459.bundle.js 648 bytes {459} [emitted] c - bundle.js 9.84 KiB {179} [emitted] main + 459.bundle.js 666 bytes {459} [emitted] c + bundle.js 9.85 KiB {179} [emitted] main Entrypoint main = bundle.js chunk {179} bundle.js (main) 101 bytes (javascript) 5.45 KiB (runtime) >{459}< [entry] [rendered] [10] ./index.js 101 bytes {179} [built] @@ -1241,13 +1241,13 @@ Child 2 chunks: [847] ./a.js 22 bytes {459} [built] [996] ./b.js 22 bytes {459} [built] Child 3 chunks: - Hash: 8464c8e8dc0e38aae732 + Hash: bc05efb0a248cb4c6f03 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 459.bundle.js 512 bytes {459} [emitted] c + 459.bundle.js 530 bytes {459} [emitted] c 524.bundle.js 210 bytes {524} [emitted] - bundle.js 9.84 KiB {179} [emitted] main + bundle.js 9.85 KiB {179} [emitted] main Entrypoint main = bundle.js chunk {179} bundle.js (main) 101 bytes (javascript) 5.45 KiB (runtime) >{459}< [entry] [rendered] [10] ./index.js 101 bytes {179} [built] @@ -1260,14 +1260,14 @@ Child 3 chunks: [390] ./e.js 22 bytes {524} [built] [767] ./d.js 22 bytes {524} [built] Child 4 chunks: - Hash: 71a37603ba9eac59b24f + Hash: 8d75b4cea6ef92a6f9fb Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names 394.bundle.js 210 bytes {394} [emitted] - 459.bundle.js 376 bytes {459} [emitted] c + 459.bundle.js 394 bytes {459} [emitted] c 524.bundle.js 210 bytes {524} [emitted] - bundle.js 9.84 KiB {179} [emitted] main + bundle.js 9.85 KiB {179} [emitted] main Entrypoint main = bundle.js chunk {179} bundle.js (main) 101 bytes (javascript) 5.45 KiB (runtime) >{394}< >{459}< [entry] [rendered] [10] ./index.js 101 bytes {179} [built] @@ -1284,7 +1284,7 @@ Child 4 chunks: exports[`StatsTestCases should print correct stats for logging 1`] = ` " [LogTestPlugin] Info -Hash: c6cf43db31de13663a98 +Hash: 9d0606e39f3f1b8c6983 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1325,11 +1325,11 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for max-modules 1`] = ` -"Hash: bc825797597fba258915 +"Hash: 9bece5f748f5bd0d5710 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names -main.js 4.99 KiB {179} [emitted] main +main.js 5.52 KiB {179} [emitted] main Entrypoint main = main.js [10] ./index.js 181 bytes {179} [built] [92] ./c.js?1 33 bytes {179} [built] @@ -1355,11 +1355,11 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for max-modules-default 1`] = ` -"Hash: bc825797597fba258915 +"Hash: 9bece5f748f5bd0d5710 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names -main.js 4.99 KiB {179} [emitted] main +main.js 5.52 KiB {179} [emitted] main Entrypoint main = main.js [10] ./index.js 181 bytes {179} [built] [92] ./c.js?1 33 bytes {179} [built] @@ -1380,15 +1380,15 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for module-assets 1`] = ` -"Hash: 42b43e10f8b8eb885ec1 +"Hash: f07f12dc2ed78d25c272 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names 1.png 21 KiB ({786}) [emitted] (a) 2.png 21 KiB ({128}, {786}) [emitted] (a, b) - a.js 961 bytes {786} [emitted] a - b.js 598 bytes {128} [emitted] b -main.js 9.11 KiB {179} [emitted] main + a.js 988 bytes {786} [emitted] a + b.js 616 bytes {128} [emitted] b +main.js 9.12 KiB {179} [emitted] main Entrypoint main = main.js Chunk Group a = a.js (1.png 2.png) Chunk Group b = b.js (2.png) @@ -1412,12 +1412,12 @@ chunk {786} a.js (a) 138 bytes [rendered] exports[`StatsTestCases should print correct stats for module-deduplication 1`] = ` " Asset Size Chunks Chunk Names -114.js 672 bytes {114} [emitted] -172.js 672 bytes {172} [emitted] -326.js 725 bytes {326}, {593} [emitted] -593.js 672 bytes {593} [emitted] -716.js 725 bytes {172}, {716} [emitted] -923.js 725 bytes {114}, {923} [emitted] +114.js 681 bytes {114} [emitted] +172.js 681 bytes {172} [emitted] +326.js 734 bytes {326}, {593} [emitted] +593.js 681 bytes {593} [emitted] +716.js 734 bytes {172}, {716} [emitted] +923.js 734 bytes {114}, {923} [emitted] e1.js 10.3 KiB {257} [emitted] e1 e2.js 10.3 KiB {621} [emitted] e2 e3.js 10.3 KiB {144} [emitted] e3 @@ -1464,9 +1464,9 @@ chunk {923} 923.js 37 bytes [rendered] exports[`StatsTestCases should print correct stats for module-deduplication-named 1`] = ` " Asset Size Chunks Chunk Names -async1.js 815 bytes {515} [emitted] async1 -async2.js 815 bytes {989} [emitted] async2 -async3.js 815 bytes {611} [emitted] async3 +async1.js 824 bytes {515} [emitted] async1 +async2.js 824 bytes {989} [emitted] async2 +async3.js 824 bytes {611} [emitted] async3 e1.js 10.2 KiB {257} [emitted] e1 e2.js 10.2 KiB {621} [emitted] e2 e3.js 10.2 KiB {144} [emitted] e3 @@ -1531,7 +1531,7 @@ If you don't want to include a polyfill, you can use an empty module like this: `; exports[`StatsTestCases should print correct stats for module-reasons 1`] = ` -"Hash: 1ca2ed371827dd8ca751 +"Hash: 50e640ed6293df4b34de Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1653,11 +1653,11 @@ Child `; exports[`StatsTestCases should print correct stats for named-chunks-plugin 1`] = ` -"Hash: 2104c049d0b8a07d9263 +"Hash: ee353a089d6d044a7df1 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - entry.js 5.08 KiB {entry} [emitted] entry + entry.js 5.09 KiB {entry} [emitted] entry vendor.js 241 bytes {vendor} [emitted] vendor Entrypoint entry = vendor.js entry.js [./entry.js] 72 bytes {entry} [built] @@ -1668,12 +1668,12 @@ Entrypoint entry = vendor.js entry.js `; exports[`StatsTestCases should print correct stats for named-chunks-plugin-async 1`] = ` -"Hash: 0556fc2ca6e831d439f7 +"Hash: 309d60ac34e4ee896b21 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - entry.js 9.71 KiB {entry} [emitted] entry -modules_a_js.js 307 bytes {modules_a_js} [emitted] + entry.js 9.72 KiB {entry} [emitted] entry +modules_a_js.js 316 bytes {modules_a_js} [emitted] modules_b_js.js 153 bytes {modules_b_js} [emitted] Entrypoint entry = entry.js [594] ./entry.js 47 bytes {entry} [built] @@ -1683,7 +1683,7 @@ Entrypoint entry = entry.js `; exports[`StatsTestCases should print correct stats for no-emit-on-errors-plugin-with-child-error 1`] = ` -"Hash: 65a90de8264b8fe4d528 +"Hash: 897dd93656fe4b0ef999 Time: Xms Built at: 1970-04-20 12:42:42 2 assets @@ -1706,7 +1706,7 @@ Child child: `; exports[`StatsTestCases should print correct stats for optimize-chunks 1`] = ` -"Hash: 291b732d9430210b524e +"Hash: 3fc0fee0be06c53d99d7 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1714,10 +1714,10 @@ Built at: 1970-04-20 12:42:42 abd.js 197 bytes {90}, {374} [emitted] abd ac in ab.js 114 bytes {753} [emitted] ac in ab chunk.js 158 bytes {284}, {753} [emitted] chunk - cir1.js 316 bytes {592} [emitted] cir1 -cir2 from cir1.js 360 bytes {288}, {289} [emitted] cir2 from cir1 - cir2.js 316 bytes {289} [emitted] cir2 - main.js 8.61 KiB {179} [emitted] main + cir1.js 334 bytes {592} [emitted] cir1 +cir2 from cir1.js 378 bytes {288}, {289} [emitted] cir2 from cir1 + cir2.js 334 bytes {289} [emitted] cir2 + main.js 8.62 KiB {179} [emitted] main Entrypoint main = main.js chunk {90} ab.js (ab) 2 bytes <{179}> >{753}< [rendered] > [10] ./index.js 1:0-6:8 @@ -1775,9 +1775,9 @@ You may need an appropriate loader to handle this file type, currently no loader `; exports[`StatsTestCases should print correct stats for performance-different-mode-and-target 1`] = ` -"Hash: e2b5a1bca95548546ae59d3cb806ed9e7152e2112ea6396cd288404e972aaa46ee8dfdb95338a233da85945fdce476f56d22aa46ee8dfdb95338a2332ea6396cd288404e972a +"Hash: 7fcab1d9bdfa20807d16088f3fb744e50e71c0e3d95b388602aed487a11073a319f47bad7e37438426eb54f6bebed2df3a3673a319f47bad7e374384d95b388602aed487a110 Child - Hash: e2b5a1bca95548546ae5 + Hash: 7fcab1d9bdfa20807d16 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1800,7 +1800,7 @@ Child For more info visit https://webpack.js.org/guides/code-splitting/ Child - Hash: 9d3cb806ed9e7152e211 + Hash: 088f3fb744e50e71c0e3 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1823,7 +1823,7 @@ Child For more info visit https://webpack.js.org/guides/code-splitting/ Child - Hash: 2ea6396cd288404e972a + Hash: d95b388602aed487a110 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1831,7 +1831,7 @@ Child Entrypoint main = no-warning.pro-node.js [10] ./index.js 293 KiB {179} [built] Child - Hash: aa46ee8dfdb95338a233 + Hash: 73a319f47bad7e374384 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1839,7 +1839,7 @@ Child Entrypoint main = no-warning.dev-web.js [./index.js] 293 KiB {main} [built] Child - Hash: da85945fdce476f56d22 + Hash: 26eb54f6bebed2df3a36 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1847,7 +1847,7 @@ Child Entrypoint main = no-warning.dev-node.js [./index.js] 293 KiB {main} [built] Child - Hash: aa46ee8dfdb95338a233 + Hash: 73a319f47bad7e374384 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1855,7 +1855,7 @@ Child Entrypoint main [big] = no-warning.dev-web-with-limit-set.js [./index.js] 293 KiB {main} [built] Child - Hash: 2ea6396cd288404e972a + Hash: d95b388602aed487a110 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -1883,7 +1883,7 @@ exports[`StatsTestCases should print correct stats for performance-disabled 1`] "Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 460.js 306 bytes {460} [emitted] + 460.js 324 bytes {460} [emitted] 524.js 210 bytes {524} [emitted] 996.js 142 bytes {996} [emitted] main.js 301 KiB {179} [emitted] main @@ -1901,7 +1901,7 @@ exports[`StatsTestCases should print correct stats for performance-error 1`] = ` "Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 460.js 306 bytes {460} [emitted] + 460.js 324 bytes {460} [emitted] 524.js 210 bytes {524} [emitted] 996.js 142 bytes {996} [emitted] main.js 301 KiB {179} [emitted] [big] main @@ -1932,7 +1932,7 @@ exports[`StatsTestCases should print correct stats for performance-no-async-chun Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names main.js 294 KiB {179} [emitted] [big] main - sec.js 1.58 KiB {295} [emitted] sec + sec.js 1.59 KiB {295} [emitted] sec Entrypoint main [big] = main.js Entrypoint sec = sec.js [10] ./index.js 32 bytes {179} [built] @@ -1963,7 +1963,7 @@ exports[`StatsTestCases should print correct stats for performance-no-hints 1`] "Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 460.js 306 bytes {460} [emitted] + 460.js 324 bytes {460} [emitted] 524.js 210 bytes {524} [emitted] 996.js 142 bytes {996} [emitted] main.js 301 KiB {179} [emitted] [big] main @@ -2015,7 +2015,7 @@ exports[`StatsTestCases should print correct stats for prefetch 1`] = ` inner2.js 154 bytes {641} [emitted] inner2 main.js 12.2 KiB {179} [emitted] main normal.js 113 bytes {30} [emitted] normal - prefetched.js 554 bytes {505} [emitted] prefetched + prefetched.js 572 bytes {505} [emitted] prefetched prefetched2.js 114 bytes {379} [emitted] prefetched2 prefetched3.js 114 bytes {220} [emitted] prefetched3 Entrypoint main = main.js (prefetch: prefetched2.js prefetched.js prefetched3.js) @@ -2046,9 +2046,9 @@ exports[`StatsTestCases should print correct stats for preload 1`] = ` " Asset Size Chunks Chunk Names inner.js 114 bytes {746} [emitted] inner inner2.js 154 bytes {641} [emitted] inner2 - main.js 11.9 KiB {179} [emitted] main + main.js 12 KiB {179} [emitted] main normal.js 113 bytes {30} [emitted] normal - preloaded.js 539 bytes {851} [emitted] preloaded + preloaded.js 557 bytes {851} [emitted] preloaded preloaded2.js 113 bytes {363} [emitted] preloaded2 preloaded3.js 112 bytes {355} [emitted] preloaded3 Entrypoint main = main.js (preload: preloaded2.js preloaded.js preloaded3.js) @@ -2070,15 +2070,15 @@ exports[`StatsTestCases should print correct stats for preset-detailed 1`] = ` <+> [LogTestPlugin] Collaped group [LogTestPlugin] Log [LogTestPlugin] End -Hash: ddc399920af7b70e3ea0 +Hash: 0ac6b9f93a7e7dd5cbef Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names - 460.js 306 bytes {460} [emitted] + 460.js 324 bytes {460} [emitted] 524.js 210 bytes {524} [emitted] 996.js 142 bytes {996} [emitted] -main.js 7.8 KiB {179} [emitted] main +main.js 7.81 KiB {179} [emitted] main Entrypoint main = main.js chunk {179} main.js (main) 73 bytes (javascript) 4.12 KiB (runtime) >{460}< >{996}< [entry] [rendered] > ./index main @@ -2186,14 +2186,14 @@ exports[`StatsTestCases should print correct stats for preset-normal 1`] = ` " [LogTestPlugin] Error [LogTestPlugin] Warning [LogTestPlugin] Info -Hash: ddc399920af7b70e3ea0 +Hash: 0ac6b9f93a7e7dd5cbef Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 460.js 306 bytes {460} [emitted] + 460.js 324 bytes {460} [emitted] 524.js 210 bytes {524} [emitted] 996.js 142 bytes {996} [emitted] -main.js 7.8 KiB {179} [emitted] main +main.js 7.81 KiB {179} [emitted] main Entrypoint main = main.js [10] ./index.js 51 bytes {179} [built] [390] ./e.js 22 bytes {524} [built] @@ -2215,7 +2215,7 @@ exports[`StatsTestCases should print correct stats for preset-normal-performance "Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 460.js 306 bytes {460} [emitted] + 460.js 324 bytes {460} [emitted] 524.js 210 bytes {524} [emitted] 996.js 142 bytes {996} [emitted] main.js 301 KiB {179} [emitted] [big] main @@ -2245,7 +2245,7 @@ exports[`StatsTestCases should print correct stats for preset-normal-performance "Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 460.js 338 bytes {460} [emitted] + 460.js 356 bytes {460} [emitted] 460.js.map 212 bytes ({460}) [emitted] [dev] 524.js 242 bytes {524} [emitted] 524.js.map 218 bytes ({524}) [emitted] [dev] @@ -2287,15 +2287,15 @@ exports[`StatsTestCases should print correct stats for preset-verbose 1`] = ` [LogTestPlugin] Inner inner message [LogTestPlugin] Log [LogTestPlugin] End -Hash: ddc399920af7b70e3ea0 +Hash: 0ac6b9f93a7e7dd5cbef Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) Asset Size Chunks Chunk Names - 460.js 306 bytes {460} [emitted] + 460.js 324 bytes {460} [emitted] 524.js 210 bytes {524} [emitted] 996.js 142 bytes {996} [emitted] -main.js 7.8 KiB {179} [emitted] main +main.js 7.81 KiB {179} [emitted] main Entrypoint main = main.js chunk {179} main.js (main) 73 bytes (javascript) 4.12 KiB (runtime) >{460}< >{996}< [entry] [rendered] > ./index main @@ -2387,11 +2387,11 @@ LOG from webpack.SplitChunksPlugin `; exports[`StatsTestCases should print correct stats for resolve-plugin-context 1`] = ` -"Hash: 1172ede5fd3c8c636237 +"Hash: 814e882a3081dbd47b6d Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names -bundle.js 1.69 KiB {179} [emitted] main +bundle.js 1.73 KiB {179} [emitted] main Entrypoint main = bundle.js [10] ./index.js 48 bytes {179} [built] [258] ./node_modules/def/index.js 16 bytes {179} [built] @@ -2401,11 +2401,11 @@ Entrypoint main = bundle.js `; exports[`StatsTestCases should print correct stats for reverse-sort-modules 1`] = ` -"Hash: bc825797597fba258915 +"Hash: 9bece5f748f5bd0d5710 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names -main.js 4.99 KiB {179} [emitted] main +main.js 5.52 KiB {179} [emitted] main Entrypoint main = main.js [969] ./a.js?3 33 bytes {179} [built] [931] ./c.js?6 33 bytes {179} [built] @@ -2438,9 +2438,9 @@ Entrypoint e2 = runtime~e2.js e2.js" exports[`StatsTestCases should print correct stats for runtime-chunk-integration 1`] = ` "Child base: Asset Size Chunks Chunk Names - 505.js 1.19 KiB {505} [emitted] - main1.js 723 bytes {909} [emitted] main1 - runtime.js 9.6 KiB {666} [emitted] runtime + 505.js 1.22 KiB {505} [emitted] + main1.js 732 bytes {909} [emitted] main1 + runtime.js 9.59 KiB {666} [emitted] runtime Entrypoint main1 = runtime.js main1.js [68] ./main1.js 66 bytes {909} [built] [460] ./c.js 20 bytes {505} [built] @@ -2449,8 +2449,8 @@ exports[`StatsTestCases should print correct stats for runtime-chunk-integration + 6 hidden modules Child manifest is named entry: Asset Size Chunks Chunk Names - 505.js 1.19 KiB {505} [emitted] - main1.js 723 bytes {909} [emitted] main1 + 505.js 1.22 KiB {505} [emitted] + main1.js 732 bytes {909} [emitted] main1 manifest.js 9.99 KiB {700} [emitted] manifest Entrypoint main1 = manifest.js main1.js Entrypoint manifest = manifest.js @@ -2473,7 +2473,7 @@ Entrypoint e2 = runtime.js e2.js" `; exports[`StatsTestCases should print correct stats for scope-hoisting-bailouts 1`] = ` -"Hash: bd588df93f01102150e9 +"Hash: 6488f8f2fdd28869b0a3 Time: Xms Built at: 1970-04-20 12:42:42 Entrypoint index = index.js @@ -2503,9 +2503,9 @@ Entrypoint entry = entry.js `; exports[`StatsTestCases should print correct stats for scope-hoisting-multi 1`] = ` -"Hash: d7a6647c10750bba833a1bc5715209fdf2572cee +"Hash: 58881658f9ef0ba4d46176bc49ce2d7948157fd6 Child - Hash: d7a6647c10750bba833a + Hash: 58881658f9ef0ba4d461 Time: Xms Built at: 1970-04-20 12:42:42 Entrypoint first = vendor.js first.js @@ -2523,7 +2523,7 @@ Child [965] ./vendor.js 25 bytes {736} [built] + 10 hidden modules Child - Hash: 1bc5715209fdf2572cee + Hash: 76bc49ce2d7948157fd6 Time: Xms Built at: 1970-04-20 12:42:42 Entrypoint first = vendor.js first.js @@ -2550,11 +2550,11 @@ Child `; exports[`StatsTestCases should print correct stats for side-effects-issue-7428 1`] = ` -"Hash: 8a2d2fe73b751db10c6d +"Hash: dbfabfa357b93d619912 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names - 1.js 633 bytes {1} [emitted] + 1.js 642 bytes {1} [emitted] main.js 10.4 KiB {0} [emitted] main Entrypoint main = main.js [0] ./main.js + 1 modules 231 bytes {0} [built] @@ -2599,7 +2599,7 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for side-effects-simple-unused 1`] = ` -"Hash: 68c2283824715bc339e3 +"Hash: a2547ccb2ca2f0e8c3ea Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -2631,7 +2631,7 @@ Entrypoint main = main.js `; exports[`StatsTestCases should print correct stats for simple 1`] = ` -"Hash: 40c62f46dc252dea3432 +"Hash: f9716925585c0d9a772b Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -2641,7 +2641,7 @@ Entrypoint main = bundle.js `; exports[`StatsTestCases should print correct stats for simple-more-info 1`] = ` -"Hash: ab39ead63d47ea78804b +"Hash: 192807ce932ddf7801c7 Time: Xms Built at: 1970-04-20 12:42:42 PublicPath: (none) @@ -3631,11 +3631,11 @@ chunk {794} default/async-a.js (async-a) 134 bytes <{179}> [rendered] `; exports[`StatsTestCases should print correct stats for tree-shaking 1`] = ` -"Hash: 3f54b6ba72ef0d38f5cc +"Hash: e0ab7e769967b4622ab4 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names -bundle.js 7.72 KiB {179} [emitted] main +bundle.js 7.79 KiB {179} [emitted] main Entrypoint main = bundle.js [10] ./index.js 315 bytes {179} [built] [no exports] @@ -3669,11 +3669,11 @@ Entrypoint main = bundle.js `; exports[`StatsTestCases should print correct stats for warnings-terser 1`] = ` -"Hash: 44912a0fc5c471e3a94b +"Hash: 0e0dbb0c6e288b3a94e0 Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names -bundle.js 1.12 KiB {179} [emitted] main +bundle.js 1.14 KiB {179} [emitted] main Entrypoint main = bundle.js [10] ./index.js 299 bytes {179} [built] [847] ./a.js 249 bytes {179} [built] @@ -3692,7 +3692,7 @@ WARNING in Terser Plugin: Dropping unused function someUnRemoteUsedFunction5 [./ `; exports[`StatsTestCases should print correct stats for wasm-explorer-examples-sync 1`] = ` -"Hash: 1abff85a74578f91c2f0 +"Hash: 3d7acccee475e7718e4f Time: Xms Built at: 1970-04-20 12:42:42 Asset Size Chunks Chunk Names @@ -3701,7 +3701,7 @@ Built at: 1970-04-20 12:42:42 230.bundle.js 207 bytes {230} [emitted] 256e72dd8b9a83a6e45b.module.wasm 120 bytes ({325}) [emitted] [immutable] 325.bundle.js 3.71 KiB {325} [emitted] - 526.bundle.js 359 bytes {526} [emitted] + 526.bundle.js 368 bytes {526} [emitted] 780.bundle.js 495 bytes {780} [emitted] 99.bundle.js 205 bytes {99} [emitted] a0e9dd97d7ced35a5b2c.module.wasm 154 bytes ({780}) [emitted] [immutable] diff --git a/test/configCases/code-generation/use-strict/index.js b/test/configCases/code-generation/use-strict/index.js index f3bb5021c..150523009 100644 --- a/test/configCases/code-generation/use-strict/index.js +++ b/test/configCases/code-generation/use-strict/index.js @@ -19,7 +19,7 @@ it("should include only one use strict per module", function() { expect(matches).toEqual([ '/* unused harmony default export */ var _unused_webpack_default_export = ("a");', - "/******/", + "/******/ // Check if module is in cache", "__webpack_require__.r(__webpack_exports__);", "__webpack_require__.r(__webpack_exports__);", "__webpack_require__.r(__webpack_exports__);", diff --git a/test/configCases/wasm/identical/webpack.config.js b/test/configCases/wasm/identical/webpack.config.js index 9c944d02a..2fd7be168 100644 --- a/test/configCases/wasm/identical/webpack.config.js +++ b/test/configCases/wasm/identical/webpack.config.js @@ -1,6 +1,7 @@ const { CachedSource } = require("webpack-sources"); +const AsyncWebAssemblyModulesPlugin = require("../../../../lib/wasm-async/AsyncWebAssemblyModulesPlugin"); -/** @typedef {import("../../../lib/Compilation")} Compilation */ +/** @typedef {import("../../../../lib/Compilation")} Compilation */ module.exports = { module: { @@ -25,13 +26,12 @@ module.exports = { * @returns {void} */ compilation => { - compilation.moduleTemplates.webassembly.hooks.package.tap( - "Test", - source => { - // this is important to make each returned value a new instance - return new CachedSource(source); - } - ); + AsyncWebAssemblyModulesPlugin.getCompilationHooks( + compilation + ).renderModuleContent.tap("Test", source => { + // this is important to make each returned value a new instance + return new CachedSource(source); + }); } ); } diff --git a/test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js b/test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js index c89fe3c81..89fa2b530 100644 --- a/test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js +++ b/test/hotCases/child-compiler/issue-9706/report-child-assets-loader.js @@ -1,5 +1,4 @@ const NodeTemplatePlugin = require("../../../../lib/node/NodeTemplatePlugin"); -const FunctionModulePlugin = require("../../../../lib/FunctionModulePlugin"); const SingleEntryPlugin = require("../../../../lib/SingleEntryPlugin"); const compilerCache = new WeakMap(); @@ -14,7 +13,6 @@ module.exports = function(source) { }, [ new NodeTemplatePlugin(), - new FunctionModulePlugin(), new SingleEntryPlugin(this.context, this.resource) ] );