Merge tag 'v4.40.0' into next

4.40.0
This commit is contained in:
Tobias Koppers 2019-09-13 11:12:26 +02:00
commit 7bde43f47a
28 changed files with 928 additions and 785 deletions

2
declarations.d.ts vendored
View File

@ -257,6 +257,8 @@ declare module "webpack-sources" {
updateHash(hash: import("./lib/util/Hash")): void; updateHash(hash: import("./lib/util/Hash")): void;
source(): string | Buffer; source(): string | Buffer;
buffer(): Buffer;
} }
export class RawSource extends Source { export class RawSource extends Source {

View File

@ -1016,7 +1016,10 @@ export interface OptimizationSplitChunksOptions {
*/ */
filename?: filename?:
| string | string
| ((pathData: import("../lib/Compilation").PathData) => string); | ((
pathData: import("../lib/Compilation").PathData,
assetInfo?: import("../lib/Compilation").AssetInfo
) => string);
/** /**
* Prevents exposing path info when creating names for parts splitted by maxSize * Prevents exposing path info when creating names for parts splitted by maxSize
*/ */
@ -1082,7 +1085,10 @@ export interface OptimizationSplitChunksCacheGroup {
*/ */
filename?: filename?:
| string | string
| ((pathData: import("../lib/Compilation").PathData) => string); | ((
pathData: import("../lib/Compilation").PathData,
assetInfo?: import("../lib/Compilation").AssetInfo
) => string);
/** /**
* Sets the hint for chunk id * Sets the hint for chunk id
*/ */
@ -1150,7 +1156,10 @@ export interface OutputOptions {
*/ */
assetModuleFilename?: assetModuleFilename?:
| string | string
| ((pathData: import("../lib/Compilation").PathData) => string); | ((
pathData: import("../lib/Compilation").PathData,
assetInfo?: import("../lib/Compilation").AssetInfo
) => string);
/** /**
* Add a comment in the UMD wrapper. * Add a comment in the UMD wrapper.
*/ */
@ -1211,7 +1220,10 @@ export interface OutputOptions {
*/ */
filename?: filename?:
| string | string
| ((pathData: import("../lib/Compilation").PathData) => string); | ((
pathData: import("../lib/Compilation").PathData,
assetInfo?: import("../lib/Compilation").AssetInfo
) => string);
/** /**
* An expression which is used to address the global object/scope in runtime code * An expression which is used to address the global object/scope in runtime code
*/ */

View File

@ -91,10 +91,9 @@ class BannerPlugin {
const comment = compilation.getPath(banner, data); const comment = compilation.getPath(banner, data);
compilation.assets[file] = new ConcatSource( compilation.updateAsset(
comment, file,
"\n", old => new ConcatSource(comment, "\n", old)
compilation.assets[file]
); );
} }
} }

View File

@ -19,6 +19,7 @@ const { createArrayToSetDeprecationSet } = require("./util/deprecation");
/** @typedef {import("./ChunkGraph").ModuleFilterPredicate} ModuleFilterPredicate */ /** @typedef {import("./ChunkGraph").ModuleFilterPredicate} ModuleFilterPredicate */
/** @typedef {import("./ChunkGroup")} ChunkGroup */ /** @typedef {import("./ChunkGroup")} ChunkGroup */
/** @typedef {import("./Compilation")} Compilation */ /** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").PathData} PathData */ /** @typedef {import("./Compilation").PathData} PathData */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
/** @typedef {import("./ModuleGraph")} ModuleGraph */ /** @typedef {import("./ModuleGraph")} ModuleGraph */
@ -73,7 +74,7 @@ class Chunk {
this.idNameHints = new SortableSet(); this.idNameHints = new SortableSet();
/** @type {boolean} */ /** @type {boolean} */
this.preventIntegration = false; this.preventIntegration = false;
/** @type {(string | function(PathData): string)?} */ /** @type {(string | function(PathData, AssetInfo=): string)?} */
this.filenameTemplate = undefined; this.filenameTemplate = undefined;
/** @private @type {SortableSet<ChunkGroup>} */ /** @private @type {SortableSet<ChunkGroup>} */
this._groups = new SortableSet(undefined, sortChunkGroupById); this._groups = new SortableSet(undefined, sortChunkGroupById);

View File

@ -134,6 +134,21 @@ const { arrayToSetDeprecation } = require("./util/deprecation");
* @property {string[]=} trace * @property {string[]=} trace
*/ */
/**
* @typedef {Object} AssetInfo
* @property {boolean=} immutable true, if the asset can be long term cached forever (contains a hash)
* @property {number=} size size in bytes, only set after asset has been emitted
* @property {boolean=} development true, when asset is only used for development and doesn't count towards user-facing assets
* @property {boolean=} hotModuleReplacement true, when asset ships data for updating an existing application (HMR)
*/
/**
* @typedef {Object} Asset
* @property {string} name the filename of the asset
* @property {Source} source source of the asset
* @property {AssetInfo} info info about the asset
*/
/** /**
* @typedef {Object} ModulePathData * @typedef {Object} ModulePathData
* @property {string|number} id * @property {string|number} id
@ -507,6 +522,8 @@ class Compilation {
this.additionalChunkAssets = []; this.additionalChunkAssets = [];
/** @type {CompilationAssets} */ /** @type {CompilationAssets} */
this.assets = {}; this.assets = {};
/** @type {Map<string, AssetInfo>} */
this.assetsInfo = new Map();
/** @type {WebpackError[]} */ /** @type {WebpackError[]} */
this.errors = []; this.errors = [];
/** @type {WebpackError[]} */ /** @type {WebpackError[]} */
@ -1275,6 +1292,7 @@ class Compilation {
this.entrypoints.clear(); this.entrypoints.clear();
this.additionalChunkAssets.length = 0; this.additionalChunkAssets.length = 0;
this.assets = {}; this.assets = {};
this.assetsInfo.clear();
this.moduleGraph.removeAllModuleAttributes(); this.moduleGraph.removeAllModuleAttributes();
} }
@ -1985,6 +2003,89 @@ class Compilation {
this.hash = this.fullHash.substr(0, hashDigestLength); this.hash = this.fullHash.substr(0, hashDigestLength);
} }
/**
* @param {string} file file name
* @param {Source} source asset source
* @param {AssetInfo} assetInfo extra asset information
* @returns {void}
*/
emitAsset(file, source, assetInfo = {}) {
if (this.assets[file]) {
if (this.assets[file] !== source) {
throw new Error(
`Conflict: Multiple assets emit to the same filename ${file}`
);
}
const oldInfo = this.assetsInfo.get(file);
this.assetsInfo.set(file, Object.assign({}, oldInfo, assetInfo));
return;
}
this.assets[file] = source;
this.assetsInfo.set(file, assetInfo);
}
/**
* @param {string} file file name
* @param {Source | function(Source): Source} newSourceOrFunction new asset source or function converting old to new
* @param {AssetInfo | function(AssetInfo | undefined): AssetInfo} assetInfoUpdateOrFunction new asset info or function converting old to new
*/
updateAsset(
file,
newSourceOrFunction,
assetInfoUpdateOrFunction = undefined
) {
if (!this.assets[file]) {
throw new Error(
`Called Compilation.updateAsset for not existing filename ${file}`
);
}
if (typeof newSourceOrFunction === "function") {
this.assets[file] = newSourceOrFunction(this.assets[file]);
} else {
this.assets[file] = newSourceOrFunction;
}
if (assetInfoUpdateOrFunction !== undefined) {
const oldInfo = this.assetsInfo.get(file);
if (typeof assetInfoUpdateOrFunction === "function") {
this.assetsInfo.set(file, assetInfoUpdateOrFunction(oldInfo || {}));
} else {
this.assetsInfo.set(
file,
Object.assign({}, oldInfo, assetInfoUpdateOrFunction)
);
}
}
}
getAssets() {
/** @type {Asset[]} */
const array = [];
for (const assetName of Object.keys(this.assets)) {
if (Object.prototype.hasOwnProperty.call(this.assets, assetName)) {
array.push({
name: assetName,
source: this.assets[assetName],
info: this.assetsInfo.get(assetName) || {}
});
}
}
return array;
}
/**
* @param {string} name the name of the asset
* @returns {Asset | undefined} the asset or undefined when not found
*/
getAsset(name) {
if (!Object.prototype.hasOwnProperty.call(this.assets, name))
return undefined;
return {
name,
source: this.assets[name],
info: this.assetsInfo.get(name) || {}
};
}
clearAssets() { clearAssets() {
for (const chunk of this.chunks) { for (const chunk of this.chunks) {
chunk.files.clear(); chunk.files.clear();
@ -1996,6 +2097,7 @@ class Compilation {
const { chunkGraph } = this; const { chunkGraph } = this;
for (const module of this.modules) { for (const module of this.modules) {
if (module.buildInfo.assets) { if (module.buildInfo.assets) {
const assetsInfo = module.buildInfo.assetsInfo;
for (const assetName of Object.keys(module.buildInfo.assets)) { for (const assetName of Object.keys(module.buildInfo.assets)) {
const fileName = this.getPath(assetName, { const fileName = this.getPath(assetName, {
chunkGraph: this.chunkGraph, chunkGraph: this.chunkGraph,
@ -2004,7 +2106,11 @@ class Compilation {
for (const chunk of chunkGraph.getModuleChunksIterable(module)) { for (const chunk of chunkGraph.getModuleChunksIterable(module)) {
chunk.auxiliaryFiles.add(fileName); chunk.auxiliaryFiles.add(fileName);
} }
this.assets[fileName] = module.buildInfo.assets[assetName]; this.emitAsset(
fileName,
module.buildInfo.assets[assetName],
assetsInfo ? assetsInfo.get(assetName) : undefined
);
this.hooks.moduleAsset.call(module, fileName); this.hooks.moduleAsset.call(module, fileName);
} }
} }
@ -2053,7 +2159,7 @@ class Compilation {
const usedHash = fileManifest.hash; const usedHash = fileManifest.hash;
this.cache.get(cacheName, usedHash, (err, sourceFromCache) => { this.cache.get(cacheName, usedHash, (err, sourceFromCache) => {
/** @type {string | function(PathData): string} */ /** @type {string | function(PathData, AssetInfo=): string} */
let filenameTemplate; let filenameTemplate;
/** @type {string} */ /** @type {string} */
let file; let file;
@ -2073,7 +2179,12 @@ class Compilation {
try { try {
filenameTemplate = fileManifest.filenameTemplate; filenameTemplate = fileManifest.filenameTemplate;
file = this.getPath(filenameTemplate, fileManifest.pathOptions); const pathAndInfo = this.getPathWithInfo(
filenameTemplate,
fileManifest.pathOptions
);
file = pathAndInfo.path;
const assetInfo = pathAndInfo.info;
if (err) { if (err) {
return errorAndCallback(err); return errorAndCallback(err);
@ -2111,18 +2222,7 @@ class Compilation {
} }
} }
} }
if (this.assets[file] && this.assets[file] !== source) { this.emitAsset(file, source, assetInfo);
inTry = false;
return callback(
new WebpackError(
`Conflict: Rendering chunk ${chunk.id} ` +
`emits to the filename ${file} ` +
"which was already written to by something else " +
"(but not another chunk)"
)
);
}
this.assets[file] = source;
if (fileManifest.auxiliary) { if (fileManifest.auxiliary) {
chunk.auxiliaryFiles.add(file); chunk.auxiliaryFiles.add(file);
} else { } else {
@ -2157,7 +2257,7 @@ class Compilation {
} }
/** /**
* @param {string | function(PathData): string} filename used to get asset path with hash * @param {string | function(PathData, AssetInfo=): string} filename used to get asset path with hash
* @param {PathData} data context data * @param {PathData} data context data
* @returns {string} interpolated path * @returns {string} interpolated path
*/ */
@ -2171,6 +2271,17 @@ class Compilation {
return this.mainTemplate.getAssetPath(filename, data); return this.mainTemplate.getAssetPath(filename, data);
} }
/**
* @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
*/
getPathWithInfo(filename, data) {
data = data || {};
data.hash = data.hash || this.hash;
return this.mainTemplate.getAssetPathWithInfo(filename, data);
}
/** /**
* This function allows you to run another instance of webpack inside of webpack however as * This function allows you to run another instance of webpack inside of webpack however as
* a child with different settings and configurations (if desired) applied. It copies all hooks, plugins * a child with different settings and configurations (if desired) applied. It copies all hooks, plugins

View File

@ -378,8 +378,8 @@ class Compiler {
if (err) return callback(err); if (err) return callback(err);
this.parentCompilation.children.push(compilation); this.parentCompilation.children.push(compilation);
for (const name of Object.keys(compilation.assets)) { for (const { name, source, info } of compilation.getAssets()) {
this.parentCompilation.assets[name] = compilation.assets[name]; this.parentCompilation.emitAsset(name, source, info);
} }
const entries = Array.from( const entries = Array.from(
@ -411,9 +411,9 @@ class Compiler {
if (err) return callback(err); if (err) return callback(err);
asyncLib.forEachLimit( asyncLib.forEachLimit(
compilation.assets, compilation.getAssets(),
15, 15,
(source, file, callback) => { ({ name: file, source }, callback) => {
let targetFile = file; let targetFile = file;
const queryStringIdx = targetFile.indexOf("?"); const queryStringIdx = targetFile.indexOf("?");
if (queryStringIdx >= 0) { if (queryStringIdx >= 0) {
@ -451,10 +451,18 @@ class Compiler {
// if yes, we skip writing the file // if yes, we skip writing the file
// as it's already there // as it's already there
// (we assume one doesn't remove files while the Compiler is running) // (we assume one doesn't remove files while the Compiler is running)
compilation.updateAsset(file, cacheEntry.sizeOnlySource, {
size: cacheEntry.sizeOnlySource.size()
});
return callback(); return callback();
} }
} }
// TODO webpack 5: if info.immutable check if file already exists in output
// skip emitting if it's already there
// get the binary (Buffer) content from the Source // get the binary (Buffer) content from the Source
/** @type {Buffer} */ /** @type {Buffer} */
let content; let content;
@ -473,7 +481,9 @@ class Compiler {
// This allows to GC all memory allocated by the Source // This allows to GC all memory allocated by the Source
// (expect when the Source is stored in any other cache) // (expect when the Source is stored in any other cache)
cacheEntry.sizeOnlySource = new SizeOnlySource(content.length); cacheEntry.sizeOnlySource = new SizeOnlySource(content.length);
compilation.assets[file] = cacheEntry.sizeOnlySource; compilation.updateAsset(file, cacheEntry.sizeOnlySource, {
size: content.length
});
// Write the file to output file system // Write the file to output file system
this.outputFileSystem.writeFile(targetPath, content, err => { this.outputFileSystem.writeFile(targetPath, content, err => {

View File

@ -350,13 +350,19 @@ class HotModuleReplacementPlugin {
chunkGraph chunkGraph
}); });
for (const entry of renderManifest) { for (const entry of renderManifest) {
const filename = compilation.getPath( const {
path: filename,
info: assetInfo
} = compilation.getPathWithInfo(
entry.filenameTemplate, entry.filenameTemplate,
entry.pathOptions entry.pathOptions
); );
const source = entry.render(); const source = entry.render();
compilation.additionalChunkAssets.push(filename); compilation.additionalChunkAssets.push(filename);
compilation.assets[filename] = source; compilation.emitAsset(filename, source, {
hotModuleReplacement: true,
...assetInfo
});
currentChunk.files.add(filename); currentChunk.files.add(filename);
compilation.hooks.chunkAsset.call(currentChunk, filename); compilation.hooks.chunkAsset.call(currentChunk, filename);
} }
@ -370,10 +376,16 @@ class HotModuleReplacementPlugin {
} }
hotUpdateMainContent.m = Array.from(allRemovedModules); hotUpdateMainContent.m = Array.from(allRemovedModules);
const source = new RawSource(JSON.stringify(hotUpdateMainContent)); const source = new RawSource(JSON.stringify(hotUpdateMainContent));
const filename = compilation.getPath(hotUpdateMainFilename, { const {
path: filename,
info: assetInfo
} = compilation.getPathWithInfo(hotUpdateMainFilename, {
hash: records.hash hash: records.hash
}); });
compilation.assets[filename] = source; compilation.emitAsset(filename, source, {
hotModuleReplacement: true,
...assetInfo
});
} }
); );

View File

@ -56,7 +56,7 @@ const defaultParserOptions = {
onComment: null onComment: null
}; };
// regexp to match at lease one "magic comment" // regexp to match at least one "magic comment"
const webpackCommentRegExp = new RegExp(/(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/); const webpackCommentRegExp = new RegExp(/(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/);
const EMPTY_COMMENT_OPTIONS = { const EMPTY_COMMENT_OPTIONS = {

View File

@ -19,6 +19,7 @@ const Template = require("./Template");
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("./ModuleTemplate")} ModuleTemplate */ /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
/** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Module")} Module} */ /** @typedef {import("./Module")} Module} */
/** @typedef {import("./util/Hash")} Hash} */ /** @typedef {import("./util/Hash")} Hash} */
/** @typedef {import("./DependencyTemplates")} DependencyTemplates} */ /** @typedef {import("./DependencyTemplates")} DependencyTemplates} */
@ -107,8 +108,8 @@ module.exports = class MainTemplate {
"hash", "hash",
"moduleIdExpression" "moduleIdExpression"
]), ]),
/** @type {SyncWaterfallHook<[string, object]>} */ /** @type {SyncWaterfallHook<[string, object, AssetInfo]>} */
assetPath: new SyncWaterfallHook(["path", "options"]), assetPath: new SyncWaterfallHook(["path", "options", "assetInfo"]),
/** @type {SyncHook<[Hash]>} */ /** @type {SyncHook<[Hash]>} */
hash: new SyncHook(["hash"]), hash: new SyncHook(["hash"]),
/** @type {SyncHook<[Hash, Chunk]>} */ /** @type {SyncHook<[Hash, Chunk]>} */
@ -404,12 +405,20 @@ module.exports = class MainTemplate {
getPublicPath(options) { getPublicPath(options) {
return this.hooks.assetPath.call( return this.hooks.assetPath.call(
this.outputOptions.publicPath || "", this.outputOptions.publicPath || "",
options options,
undefined
); );
} }
getAssetPath(path, options) { getAssetPath(path, options) {
return this.hooks.assetPath.call(path, options); return this.hooks.assetPath.call(path, options, undefined);
}
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 };
} }
/** /**

View File

@ -301,15 +301,17 @@ class NormalModule extends Module {
} }
}; };
}, },
emitFile: (name, content, sourceMap) => { emitFile: (name, content, sourceMap, assetInfo) => {
if (!this.buildInfo.assets) { if (!this.buildInfo.assets) {
this.buildInfo.assets = Object.create(null); this.buildInfo.assets = Object.create(null);
this.buildInfo.assetsInfo = new Map();
} }
this.buildInfo.assets[name] = this.createSourceForAsset( this.buildInfo.assets[name] = this.createSourceForAsset(
name, name,
content, content,
sourceMap sourceMap
); );
this.buildInfo.assetsInfo.set(name, assetInfo);
}, },
rootContext: options.context, rootContext: options.context,
webpack: true, webpack: true,
@ -564,7 +566,8 @@ class NormalModule extends Module {
contextDependencies: undefined, contextDependencies: undefined,
missingDependencies: undefined, missingDependencies: undefined,
hash: undefined, hash: undefined,
assets: undefined assets: undefined,
assetsInfo: undefined
}; };
return this.doBuild(options, compilation, resolver, fs, err => { return this.doBuild(options, compilation, resolver, fs, err => {

View File

@ -164,14 +164,20 @@ class SourceMapDevToolPlugin {
/** @type {SourceMapTask[]} */ /** @type {SourceMapTask[]} */
const tasks = []; const tasks = [];
files.forEach((file, idx) => { files.forEach((file, idx) => {
const asset = compilation.assets[file]; const asset = compilation.getAsset(file).source;
const cache = assetsCache.get(asset); const cache = assetsCache.get(asset);
/** /**
* If presented in cache, reassigns assets. Cache assets already have source maps. * If presented in cache, reassigns assets. Cache assets already have source maps.
*/ */
if (cache && cache.file === file) { if (cache && cache.file === file) {
for (const cachedFile in cache.assets) { for (const cachedFile in cache.assets) {
compilation.assets[cachedFile] = cache.assets[cachedFile]; if (cachedFile === file) {
compilation.updateAsset(cachedFile, cache.assets[cachedFile]);
} else {
compilation.emitAsset(cachedFile, cache.assets[cachedFile], {
development: true
});
}
/** /**
* Add file to chunk, if not presented there * Add file to chunk, if not presented there
*/ */
@ -338,20 +344,24 @@ class SourceMapDevToolPlugin {
* Add source map url to compilation asset, if {@link currentSourceMappingURLComment} presented * Add source map url to compilation asset, if {@link currentSourceMappingURLComment} presented
*/ */
if (currentSourceMappingURLComment !== false) { if (currentSourceMappingURLComment !== false) {
assets[file] = compilation.assets[file] = new ConcatSource( const asset = new ConcatSource(
new RawSource(source), new RawSource(source),
compilation.getPath( compilation.getPath(
currentSourceMappingURLComment, currentSourceMappingURLComment,
Object.assign({ url: sourceMapUrl }, pathParams) Object.assign({ url: sourceMapUrl }, pathParams)
) )
); );
assets[file] = asset;
compilation.updateAsset(file, asset);
} }
/** /**
* Add source map file to compilation assets and chunk files * Add source map file to compilation assets and chunk files
*/ */
assets[sourceMapFile] = compilation.assets[ const asset = new RawSource(sourceMapString);
sourceMapFile assets[sourceMapFile] = asset;
] = new RawSource(sourceMapString); compilation.emitAsset(sourceMapFile, asset, {
development: true
});
if (chunk !== undefined) chunk.auxiliaryFiles.add(sourceMapFile); if (chunk !== undefined) chunk.auxiliaryFiles.add(sourceMapFile);
} else { } else {
if (currentSourceMappingURLComment === false) { if (currentSourceMappingURLComment === false) {
@ -362,7 +372,7 @@ class SourceMapDevToolPlugin {
/** /**
* Add source map as data url to asset * Add source map as data url to asset
*/ */
assets[file] = compilation.assets[file] = new ConcatSource( const asset = new ConcatSource(
new RawSource(source), new RawSource(source),
currentSourceMappingURLComment currentSourceMappingURLComment
.replace(/\[map\]/g, () => sourceMapString) .replace(/\[map\]/g, () => sourceMapString)
@ -375,6 +385,8 @@ class SourceMapDevToolPlugin {
).toString("base64")}` ).toString("base64")}`
) )
); );
assets[file] = asset;
compilation.updateAsset(file, asset);
} }
}); });
reportProgress(1.0); reportProgress(1.0);

View File

@ -16,6 +16,7 @@ const {
/** @typedef {import("webpack-sources").Source} Source */ /** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("./Chunk")} Chunk */ /** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./ChunkGraph")} ChunkGraph */ /** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").PathData} PathData */ /** @typedef {import("./Compilation").PathData} PathData */
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */ /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./Module")} Module */ /** @typedef {import("./Module")} Module */
@ -53,7 +54,7 @@ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
/** /**
* @typedef {Object} RenderManifestEntry * @typedef {Object} RenderManifestEntry
* @property {function(): Source} render * @property {function(): Source} render
* @property {string | function(PathData): string} filenameTemplate * @property {string | function(PathData, AssetInfo=): string} filenameTemplate
* @property {PathData=} pathOptions * @property {PathData=} pathOptions
* @property {string} identifier * @property {string} identifier
* @property {string=} hash * @property {string=} hash

View File

@ -9,6 +9,7 @@ const { basename, extname } = require("path");
const util = require("util"); const util = require("util");
const Module = require("./Module"); const Module = require("./Module");
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").PathData} PathData */ /** @typedef {import("./Compilation").PathData} PathData */
/** @typedef {import("./Compiler")} Compiler */ /** @typedef {import("./Compiler")} Compiler */
@ -28,8 +29,9 @@ const prepareId = id => {
return id.replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_"); return id.replace(/(^[.-]|[^a-zA-Z0-9_-])+/g, "_");
}; };
const hashLength = (replacer, handler) => { const hashLength = (replacer, handler, assetInfo) => {
const fn = (match, arg, input) => { const fn = (match, arg, input) => {
if (assetInfo) assetInfo.immutable = true;
const length = arg && parseInt(arg, 10); const length = arg && parseInt(arg, 10);
if (length && handler) { if (length && handler) {
@ -77,11 +79,12 @@ const deprecated = (fn, message) => {
}; };
/** /**
* @param {string | function(PathData): string} path the raw path * @param {string | function(PathData, AssetInfo=): string} path the raw path
* @param {PathData} data context data * @param {PathData} data context data
* @param {AssetInfo} assetInfo extra info about the asset (will be written to)
* @returns {string} the interpolated path * @returns {string} the interpolated path
*/ */
const replacePathVariables = (path, data) => { const replacePathVariables = (path, data, assetInfo) => {
const chunkGraph = data.chunkGraph; const chunkGraph = data.chunkGraph;
/** @type {Map<string, Function>} */ /** @type {Map<string, Function>} */
@ -141,7 +144,11 @@ const replacePathVariables = (path, data) => {
// //
// [hash] - data.hash (3a4b5c6e7f) // [hash] - data.hash (3a4b5c6e7f)
if (data.hash) { if (data.hash) {
const hashReplacer = hashLength(replacer(data.hash), data.hashWithLength); const hashReplacer = hashLength(
replacer(data.hash),
data.hashWithLength,
assetInfo
);
replacements.set("fullhash", hashReplacer); replacements.set("fullhash", hashReplacer);
@ -172,7 +179,8 @@ const replacePathVariables = (path, data) => {
const nameReplacer = replacer(chunk.name || chunk.id); const nameReplacer = replacer(chunk.name || chunk.id);
const chunkhashReplacer = hashLength( const chunkhashReplacer = hashLength(
replacer(chunk.renderedHash || chunk.hash), replacer(chunk.renderedHash || chunk.hash),
"hashWithLength" in chunk ? chunk.hashWithLength : undefined "hashWithLength" in chunk ? chunk.hashWithLength : undefined,
assetInfo
); );
const contenthashReplacer = hashLength( const contenthashReplacer = hashLength(
replacer( replacer(
@ -184,7 +192,8 @@ const replacePathVariables = (path, data) => {
data.contentHashWithLength || data.contentHashWithLength ||
("contentHashWithLength" in chunk && chunk.contentHashWithLength ("contentHashWithLength" in chunk && chunk.contentHashWithLength
? chunk.contentHashWithLength[contentHashType] ? chunk.contentHashWithLength[contentHashType]
: undefined) : undefined),
assetInfo
); );
replacements.set("id", idReplacer); replacements.set("id", idReplacer);
@ -218,7 +227,8 @@ const replacePathVariables = (path, data) => {
? chunkGraph.getRenderedModuleHash(module) ? chunkGraph.getRenderedModuleHash(module)
: module.renderedHash || module.hash : module.renderedHash || module.hash
), ),
"hashWithLength" in module ? module.hashWithLength : undefined "hashWithLength" in module ? module.hashWithLength : undefined,
assetInfo
); );
replacements.set("id", idReplacer); replacements.set("id", idReplacer);
@ -240,7 +250,7 @@ const replacePathVariables = (path, data) => {
} }
if (typeof path === "function") { if (typeof path === "function") {
path = path(data); path = path(data, assetInfo);
} }
path = path.replace(REGEXP, (match, content) => { path = path.replace(REGEXP, (match, content) => {

View File

@ -32,14 +32,14 @@ const LogType = Object.freeze({
exports.LogType = LogType; exports.LogType = LogType;
/** @typedef {LogType} LogTypeEnum */ /** @typedef {keyof LogType} LogTypeEnum */
const LOG_SYMBOL = Symbol("webpack logger raw log method"); const LOG_SYMBOL = Symbol("webpack logger raw log method");
const TIMERS_SYMBOL = Symbol("webpack logger times"); const TIMERS_SYMBOL = Symbol("webpack logger times");
class WebpackLogger { class WebpackLogger {
/** /**
* @param {function(LogType, any[]=): void} log log function * @param {function(LogTypeEnum, any[]=): void} log log function
*/ */
constructor(log) { constructor(log) {
this[LOG_SYMBOL] = log; this[LOG_SYMBOL] = log;

View File

@ -47,7 +47,8 @@ const filterToFunction = item => {
}; };
/** /**
* @enum {number} */ * @enum {number}
*/
const LogLevel = { const LogLevel = {
none: 6, none: 6,
false: 6, false: 6,

View File

@ -602,6 +602,14 @@ class ConcatenatedModule extends Module {
} }
Object.assign(this.buildInfo.assets, m.buildInfo.assets); Object.assign(this.buildInfo.assets, m.buildInfo.assets);
} }
if (m.buildInfo.assetsInfo) {
if (this.buildInfo.assetsInfo === undefined) {
this.buildInfo.assetsInfo = new Map();
}
for (const [key, value] of m.buildInfo.assetsInfo) {
this.buildInfo.assetsInfo.set(key, value);
}
}
} }
} }
this._identifier = this._createIdentifier(compilation.compiler.root); this._identifier = this._createIdentifier(compilation.compiler.root);

View File

@ -25,6 +25,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */ /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
/** @typedef {import("../Chunk")} Chunk */ /** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../ChunkGraph")} ChunkGraph */ /** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
/** @typedef {import("../Compilation").PathData} PathData */ /** @typedef {import("../Compilation").PathData} PathData */
/** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Module")} Module */ /** @typedef {import("../Module")} Module */
@ -61,7 +62,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
* @property {number=} minChunks * @property {number=} minChunks
* @property {number=} maxAsyncRequests * @property {number=} maxAsyncRequests
* @property {number=} maxInitialRequests * @property {number=} maxInitialRequests
* @property {(string | function(PathData): string)=} filename * @property {(string | function(PathData, AssetInfo=): string)=} filename
* @property {string=} idHint * @property {string=} idHint
* @property {string} automaticNameDelimiter * @property {string} automaticNameDelimiter
* @property {boolean=} reuseExistingChunk * @property {boolean=} reuseExistingChunk
@ -82,7 +83,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
* @property {number=} minChunks * @property {number=} minChunks
* @property {number=} maxAsyncRequests * @property {number=} maxAsyncRequests
* @property {number=} maxInitialRequests * @property {number=} maxInitialRequests
* @property {(string | function(PathData): string)=} filename * @property {(string | function(PathData, AssetInfo=): string)=} filename
* @property {string=} idHint * @property {string=} idHint
* @property {string} automaticNameDelimiter * @property {string} automaticNameDelimiter
* @property {boolean=} reuseExistingChunk * @property {boolean=} reuseExistingChunk
@ -128,7 +129,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
* @property {number} maxAsyncRequests * @property {number} maxAsyncRequests
* @property {number} maxInitialRequests * @property {number} maxInitialRequests
* @property {boolean} hidePathInfo * @property {boolean} hidePathInfo
* @property {string | function(PathData): string} filename * @property {string | function(PathData, AssetInfo=): string} filename
* @property {string} automaticNameDelimiter * @property {string} automaticNameDelimiter
* @property {GetCacheGroups} getCacheGroups * @property {GetCacheGroups} getCacheGroups
* @property {GetName} getName * @property {GetName} getName

View File

@ -14,6 +14,7 @@ const NoAsyncChunksWarning = require("./NoAsyncChunksWarning");
/** @typedef {import("../../declarations/WebpackOptions").PerformanceOptions} PerformanceOptions */ /** @typedef {import("../../declarations/WebpackOptions").PerformanceOptions} PerformanceOptions */
/** @typedef {import("../ChunkGroup")} ChunkGroup */ /** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Entrypoint")} Entrypoint */
/** @typedef {import("../WebpackError")} WebpackError */ /** @typedef {import("../WebpackError")} WebpackError */
/** /**
@ -31,7 +32,7 @@ const NoAsyncChunksWarning = require("./NoAsyncChunksWarning");
const isOverSizeLimitSet = new WeakSet(); const isOverSizeLimitSet = new WeakSet();
const excludeSourceMap = asset => !asset.endsWith(".map"); const excludeSourceMap = (name, source, info) => !info.development;
module.exports = class SizeLimitsPlugin { module.exports = class SizeLimitsPlugin {
/** /**
@ -67,13 +68,17 @@ module.exports = class SizeLimitsPlugin {
const warnings = []; const warnings = [];
/** /**
* @param {ChunkGroup} entrypoint the entrypoint * @param {Entrypoint} entrypoint an entrypoint
* @returns {number} its calculated size * @returns {number} the size of the entrypoint
*/ */
const getEntrypointSize = entrypoint => const getEntrypointSize = entrypoint =>
entrypoint.getFiles().reduce((currentSize, file) => { entrypoint.getFiles().reduce((currentSize, file) => {
if (assetFilter(file) && compilation.assets[file]) { const asset = compilation.getAsset(file);
return currentSize + compilation.assets[file].size(); if (
assetFilter(asset.name, asset.source, asset.info) &&
asset.source
) {
return currentSize + (asset.info.size || asset.source.size());
} }
return currentSize; return currentSize;
@ -81,34 +86,36 @@ module.exports = class SizeLimitsPlugin {
/** @type {AssetDetails[]} */ /** @type {AssetDetails[]} */
const assetsOverSizeLimit = []; const assetsOverSizeLimit = [];
for (const assetName of Object.keys(compilation.assets)) { for (const { name, source, info } of compilation.getAssets()) {
if (!assetFilter(assetName)) { if (!assetFilter(name, source, info) || !source) {
continue; continue;
} }
const asset = compilation.assets[assetName]; const size = info.size || source.size();
const size = asset.size();
if (size > assetSizeLimit) { if (size > assetSizeLimit) {
assetsOverSizeLimit.push({ assetsOverSizeLimit.push({
name: assetName, name,
size: size size
}); });
isOverSizeLimitSet.add(asset); isOverSizeLimitSet.add(source);
} }
} }
const fileFilter = name => {
const asset = compilation.getAsset(name);
return assetFilter(asset.name, asset.source, asset.info);
};
/** @type {EntrypointDetails[]} */ /** @type {EntrypointDetails[]} */
const entrypointsOverLimit = []; const entrypointsOverLimit = [];
for (const pair of compilation.entrypoints) { for (const [name, entry] of compilation.entrypoints) {
const name = pair[0];
const entry = pair[1];
const size = getEntrypointSize(entry); const size = getEntrypointSize(entry);
if (size > entrypointSizeLimit) { if (size > entrypointSizeLimit) {
entrypointsOverLimit.push({ entrypointsOverLimit.push({
name: name, name: name,
size: size, size: size,
files: entry.getFiles().filter(assetFilter) files: entry.getFiles().filter(fileFilter)
}); });
isOverSizeLimitSet.add(entry); isOverSizeLimitSet.add(entry);
} }

View File

@ -10,9 +10,10 @@ const Template = require("../Template");
/** @typedef {import("../Chunk")} Chunk */ /** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Compilation")} Compilation */ /** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
/** @typedef {import("../Compilation").PathData} PathData */ /** @typedef {import("../Compilation").PathData} PathData */
/** @typedef {function(PathData): string} FilenameFunction */ /** @typedef {function(PathData, AssetInfo=): string} FilenameFunction */
class GetChunkFilenameRuntimeModule extends RuntimeModule { class GetChunkFilenameRuntimeModule extends RuntimeModule {
/** /**

View File

@ -27,6 +27,7 @@ const identifierUtils = require("../util/identifier");
/** @typedef {import("../ChunkGroup")} ChunkGroup */ /** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../ChunkGroup").OriginRecord} OriginRecord */ /** @typedef {import("../ChunkGroup").OriginRecord} OriginRecord */
/** @typedef {import("../Compilation")} Compilation */ /** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compilation").Asset} Asset */
/** @typedef {import("../Compiler")} Compiler */ /** @typedef {import("../Compiler")} Compiler */
/** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
@ -42,8 +43,8 @@ const identifierUtils = require("../util/identifier");
* @typedef {Object} UsualContext * @typedef {Object} UsualContext
* @property {string} type * @property {string} type
* @property {Compilation} compilation * @property {Compilation} compilation
* @property {Map<string|Chunk[]>} compilationFileToChunks * @property {Map<string,Chunk[]>} compilationFileToChunks
* @property {Map<string|Chunk[]>} compilationAuxiliaryFileToChunks * @property {Map<string,Chunk[]>} compilationAuxiliaryFileToChunks
* @property {number} startTime * @property {number} startTime
* @property {number} endTime * @property {number} endTime
*/ */
@ -70,7 +71,7 @@ const identifierUtils = require("../util/identifier");
/** /**
* @typedef {Object} SimpleExtractors * @typedef {Object} SimpleExtractors
* @property {ExtractorsByOption<Compilation>} compilation * @property {ExtractorsByOption<Compilation>} compilation
* @property {ExtractorsByOption<{ name: string, source: Source }>} asset * @property {ExtractorsByOption<Asset>} asset
* @property {ExtractorsByOption<{ name: string, chunkGroup: ChunkGroup }>} chunkGroup * @property {ExtractorsByOption<{ name: string, chunkGroup: ChunkGroup }>} chunkGroup
* @property {ExtractorsByOption<Module>} module * @property {ExtractorsByOption<Module>} module
* @property {ExtractorsByOption<Module>} moduleIssuer * @property {ExtractorsByOption<Module>} moduleIssuer
@ -213,14 +214,10 @@ const SIMPLE_EXTRACTORS = {
}, },
assets: (object, compilation, context, options, factory) => { assets: (object, compilation, context, options, factory) => {
const { type } = context; const { type } = context;
const array = Object.keys(compilation.assets).map(name => { const array = compilation.getAssets();
const source = compilation.assets[name]; /** @type {Map<string, Chunk[]>} */
return {
name,
source
};
});
const compilationFileToChunks = new Map(); const compilationFileToChunks = new Map();
/** @type {Map<string, Chunk[]>} */
const compilationAuxiliaryFileToChunks = new Map(); const compilationAuxiliaryFileToChunks = new Map();
for (const chunk of compilation.chunks) { for (const chunk of compilation.chunks) {
for (const file of chunk.files) { for (const file of chunk.files) {
@ -478,6 +475,7 @@ const SIMPLE_EXTRACTORS = {
compareIds compareIds
); );
object.emitted = compilation.emittedAssets.has(asset.name); object.emitted = compilation.emittedAssets.has(asset.name);
object.info = asset.info;
}, },
performance: (object, asset) => { performance: (object, asset) => {
object.isOverSizeLimit = SizeLimitsPlugin.isOverSizeLimit(asset.source); object.isOverSizeLimit = SizeLimitsPlugin.isOverSizeLimit(asset.source);

View File

@ -158,6 +158,15 @@ const SIMPLE_PRINTERS = {
"asset.isOverSizeLimit": (isOverSizeLimit, { yellow, formatFlag }) => "asset.isOverSizeLimit": (isOverSizeLimit, { yellow, formatFlag }) =>
isOverSizeLimit ? yellow(formatFlag("big")) : undefined, isOverSizeLimit ? yellow(formatFlag("big")) : undefined,
"asset.info.immutable": (immutable, { green, formatFlag }) =>
immutable ? green(formatFlag("immutable")) : undefined,
"asset.info.development": (development, { green, formatFlag }) =>
development ? green(formatFlag("dev")) : undefined,
"asset.info.hotModuleReplacement": (
hotModuleReplacement,
{ green, formatFlag }
) => ((hotModuleReplacement ? green(formatFlag("hmr")) : undefined)),
assetChunk: (id, { formatChunkId }) => formatChunkId(id), assetChunk: (id, { formatChunkId }) => formatChunkId(id),
assetChunkName: name => name, assetChunkName: name => name,
@ -535,10 +544,12 @@ const PREFERED_ORDERS = {
"chunks", "chunks",
"auxiliaryChunks", "auxiliaryChunks",
"emitted", "emitted",
"info",
"isOverSizeLimit", "isOverSizeLimit",
"chunkNames", "chunkNames",
"auxiliaryChunkNames" "auxiliaryChunkNames"
], ],
"asset.info": ["immutable", "development", "hotModuleReplacement"],
chunkGroup: [ chunkGroup: [
"kind!", "kind!",
"name", "name",
@ -1086,7 +1097,9 @@ class DefaultStatsPrinterPlugin {
[elementsMap.chunks, elementsMap.auxiliaryChunks] [elementsMap.chunks, elementsMap.auxiliaryChunks]
.filter(Boolean) .filter(Boolean)
.join(" "), .join(" "),
elementsMap.emitted || "", [elementsMap.emitted, elementsMap.info]
.filter(Boolean)
.join(" "),
elementsMap.isOverSizeLimit || "", elementsMap.isOverSizeLimit || "",
[elementsMap.chunkNames, elementsMap.auxiliaryChunkNames] [elementsMap.chunkNames, elementsMap.auxiliaryChunkNames]
.filter(Boolean) .filter(Boolean)

View File

@ -48,8 +48,8 @@
"glob": "^7.1.3", "glob": "^7.1.3",
"husky": "^3.0.2", "husky": "^3.0.2",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"jest": "24.1.0", "jest": "^24.9.0",
"jest-junit": "^7.0.0", "jest-junit": "^8.0.0",
"json-loader": "^0.5.7", "json-loader": "^0.5.7",
"json-schema-to-typescript": "^7.0.0", "json-schema-to-typescript": "^7.0.0",
"less": "^3.9.0", "less": "^3.9.0",

View File

@ -708,7 +708,7 @@
}, },
{ {
"instanceof": "Function", "instanceof": "Function",
"tsType": "((pathData: import(\"../lib/Compilation\").PathData) => string)" "tsType": "((pathData: import(\"../lib/Compilation\").PathData, assetInfo?: import(\"../lib/Compilation\").AssetInfo) => string)"
} }
] ]
}, },
@ -933,7 +933,7 @@
}, },
{ {
"instanceof": "Function", "instanceof": "Function",
"tsType": "((pathData: import(\"../lib/Compilation\").PathData) => string)" "tsType": "((pathData: import(\"../lib/Compilation\").PathData, assetInfo?: import(\"../lib/Compilation\").AssetInfo) => string)"
} }
] ]
}, },
@ -1043,7 +1043,7 @@
}, },
{ {
"instanceof": "Function", "instanceof": "Function",
"tsType": "((pathData: import(\"../lib/Compilation\").PathData) => string)" "tsType": "((pathData: import(\"../lib/Compilation\").PathData, assetInfo?: import(\"../lib/Compilation\").AssetInfo) => string)"
} }
] ]
}, },
@ -1146,7 +1146,7 @@
}, },
{ {
"instanceof": "Function", "instanceof": "Function",
"tsType": "((pathData: import(\"../lib/Compilation\").PathData) => string)" "tsType": "((pathData: import(\"../lib/Compilation\").PathData, assetInfo?: import(\"../lib/Compilation\").AssetInfo) => string)"
} }
] ]
}, },

View File

@ -7,11 +7,11 @@ Child fitting:
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
PublicPath: (none) PublicPath: (none)
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
3c19ea16aff43940b7fd.js 12.8 KiB {10} [emitted] 3c19ea16aff43940b7fd.js 12.8 KiB {10} [emitted] [immutable]
501a16e2f184bd3b8ea5.js 1.07 KiB {785} [emitted] 501a16e2f184bd3b8ea5.js 1.07 KiB {785} [emitted] [immutable]
b655127fd4eca55a90aa.js 1.91 KiB {394} [emitted] b655127fd4eca55a90aa.js 1.91 KiB {394} [emitted] [immutable]
bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] [immutable]
Entrypoint main = b655127fd4eca55a90aa.js bac8938bfd9c34df221b.js 3c19ea16aff43940b7fd.js Entrypoint main = b655127fd4eca55a90aa.js bac8938bfd9c34df221b.js 3c19ea16aff43940b7fd.js
chunk {10} 3c19ea16aff43940b7fd.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered] chunk {10} 3c19ea16aff43940b7fd.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered]
> ./index main > ./index main
@ -35,11 +35,11 @@ Child content-change:
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
PublicPath: (none) PublicPath: (none)
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
3c19ea16aff43940b7fd.js 12.8 KiB {10} [emitted] 3c19ea16aff43940b7fd.js 12.8 KiB {10} [emitted] [immutable]
501a16e2f184bd3b8ea5.js 1.07 KiB {785} [emitted] 501a16e2f184bd3b8ea5.js 1.07 KiB {785} [emitted] [immutable]
b655127fd4eca55a90aa.js 1.91 KiB {394} [emitted] b655127fd4eca55a90aa.js 1.91 KiB {394} [emitted] [immutable]
bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] [immutable]
Entrypoint main = b655127fd4eca55a90aa.js bac8938bfd9c34df221b.js 3c19ea16aff43940b7fd.js Entrypoint main = b655127fd4eca55a90aa.js bac8938bfd9c34df221b.js 3c19ea16aff43940b7fd.js
chunk {10} 3c19ea16aff43940b7fd.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered] chunk {10} 3c19ea16aff43940b7fd.js 1.87 KiB (javascript) 6.41 KiB (runtime) [entry] [rendered]
> ./index main > ./index main
@ -65,19 +65,19 @@ exports[`StatsTestCases should print correct stats for aggressive-splitting-on-d
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
PublicPath: (none) PublicPath: (none)
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
035ce1d102419ee4897b.js 1010 bytes {701} [emitted] 035ce1d102419ee4897b.js 1010 bytes {701} [emitted] [immutable]
1ffcc984ad7d7c92ab0b.js 1.91 KiB {594} [emitted] 1ffcc984ad7d7c92ab0b.js 1.91 KiB {594} [emitted] [immutable]
2d925701a76fac28b8cc.js 1.91 KiB {817} [emitted] 2d925701a76fac28b8cc.js 1.91 KiB {817} [emitted] [immutable]
4717957e3d668ff4f9e8.js 1.91 KiB {591} [emitted] 4717957e3d668ff4f9e8.js 1.91 KiB {591} [emitted] [immutable]
49dd7266942f0ed4ae64.js 1010 bytes {847} [emitted] 49dd7266942f0ed4ae64.js 1010 bytes {847} [emitted] [immutable]
61fe00576946c9f2606d.js 1.91 KiB {454} [emitted] 61fe00576946c9f2606d.js 1.91 KiB {454} [emitted] [immutable]
b18de3d2b973b820ea21.js 1.91 KiB {294}, {701} [emitted] b18de3d2b973b820ea21.js 1.91 KiB {294}, {701} [emitted] [immutable]
bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] bac8938bfd9c34df221b.js 1.91 KiB {102} [emitted] [immutable]
c0e562c433da5d2d3cb7.js 1.91 KiB {390}, {523} [emitted] c0e562c433da5d2d3cb7.js 1.91 KiB {390}, {523} [emitted] [immutable]
d1200bb114eb31d95075.js 9.43 KiB {179} [emitted] main d1200bb114eb31d95075.js 9.43 KiB {179} [emitted] [immutable] main
f2593c9acd7da73fffbe.js 1010 bytes {390} [emitted] f2593c9acd7da73fffbe.js 1010 bytes {390} [emitted] [immutable]
f50587036d9d0e61836c.js 1.91 KiB {613} [emitted] f50587036d9d0e61836c.js 1.91 KiB {613} [emitted] [immutable]
Entrypoint main = d1200bb114eb31d95075.js Entrypoint main = d1200bb114eb31d95075.js
chunk {102} bac8938bfd9c34df221b.js 1.76 KiB [rendered] [recorded] aggressive splitted chunk {102} bac8938bfd9c34df221b.js 1.76 KiB [rendered] [recorded] aggressive splitted
> ./c ./d ./e [942] ./index.js 3:0-30 > ./c ./d ./e [942] ./index.js 3:0-30
@ -134,11 +134,11 @@ exports[`StatsTestCases should print correct stats for asset 1`] = `
"Hash: 69bf1248ab820a0f4d8d "Hash: 69bf1248ab820a0f4d8d
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
44af8fe384aadccba06e.svg 656 bytes ({179}) [emitted] (main) 44af8fe384aadccba06e.svg 656 bytes ({179}) [emitted] [immutable] (main)
62787d6ac9d673cc8926.png 14.6 KiB ({179}) [emitted] (main) 62787d6ac9d673cc8926.png 14.6 KiB ({179}) [emitted] [immutable] (main)
bundle.js 4.42 KiB {179} [emitted] main bundle.js 4.42 KiB {179} [emitted] main
c2a9ba2e6ec92fd70245.jpg 5.89 KiB ({179}) [emitted] (main) c2a9ba2e6ec92fd70245.jpg 5.89 KiB ({179}) [emitted] [immutable] (main)
Entrypoint main = bundle.js (44af8fe384aadccba06e.svg 62787d6ac9d673cc8926.png c2a9ba2e6ec92fd70245.jpg) Entrypoint main = bundle.js (44af8fe384aadccba06e.svg 62787d6ac9d673cc8926.png c2a9ba2e6ec92fd70245.jpg)
[10] ./index.js 111 bytes {179} [built] [10] ./index.js 111 bytes {179} [built]
[359] ./images/file.jpg 5.89 KiB (asset) 42 bytes (javascript) {179} [built] [359] ./images/file.jpg 5.89 KiB (asset) 42 bytes (javascript) {179} [built]
@ -640,9 +640,9 @@ Child
Hash: e8a1307ea3c860453151 Hash: e8a1307ea3c860453151
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
app.20e7d920f7a5dd7ba86a.js 6.72 KiB {143} [emitted] app app.20e7d920f7a5dd7ba86a.js 6.72 KiB {143} [emitted] [immutable] app
vendor.3ca106870164d059e3b7.js 606 bytes {736} [emitted] vendor vendor.3ca106870164d059e3b7.js 606 bytes {736} [emitted] [immutable] vendor
Entrypoint app = vendor.3ca106870164d059e3b7.js app.20e7d920f7a5dd7ba86a.js Entrypoint app = vendor.3ca106870164d059e3b7.js app.20e7d920f7a5dd7ba86a.js
[117] ./entry-1.js + 2 modules 190 bytes {143} [built] [117] ./entry-1.js + 2 modules 190 bytes {143} [built]
[381] ./constants.js 87 bytes {736} [built] [381] ./constants.js 87 bytes {736} [built]
@ -651,9 +651,9 @@ Child
Hash: 9325cea6a11512fc55f7 Hash: 9325cea6a11512fc55f7
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
app.9ff34c93a677586ea3e1.js 6.74 KiB {143} [emitted] app app.9ff34c93a677586ea3e1.js 6.74 KiB {143} [emitted] [immutable] app
vendor.3ca106870164d059e3b7.js 606 bytes {736} [emitted] vendor vendor.3ca106870164d059e3b7.js 606 bytes {736} [emitted] [immutable] vendor
Entrypoint app = vendor.3ca106870164d059e3b7.js app.9ff34c93a677586ea3e1.js Entrypoint app = vendor.3ca106870164d059e3b7.js app.9ff34c93a677586ea3e1.js
[381] ./constants.js 87 bytes {736} [built] [381] ./constants.js 87 bytes {736} [built]
[655] ./entry-2.js + 2 modules 197 bytes {143} [built] [655] ./entry-2.js + 2 modules 197 bytes {143} [built]
@ -1102,6 +1102,12 @@ chunk {trees} trees.js (trees) 71 bytes [rendered]
+ 3 hidden dependent modules" + 3 hidden dependent modules"
`; `;
exports[`StatsTestCases should print correct stats for immutable 1`] = `
" Asset Size Chunks Chunk Names
5a00a5aaadb77d195a77.js 346 bytes {chunk_js} [emitted] [immutable]
6f3582e5d1757d08c675.js 10.1 KiB {main} [emitted] [immutable] main"
`;
exports[`StatsTestCases should print correct stats for import-context-filter 1`] = ` exports[`StatsTestCases should print correct stats for import-context-filter 1`] = `
"Hash: 10cc1554ce1aa0fa0104 "Hash: 10cc1554ce1aa0fa0104
Time: Xms Time: Xms
@ -1163,10 +1169,10 @@ Child
Hash: 99ffcd8f42141d9c28b7 Hash: 99ffcd8f42141d9c28b7
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
a-all-a_js-5ed868390c43e7086a86.js 144 bytes {all-a_js} [emitted] a-all-a_js-5ed868390c43e7086a86.js 144 bytes {all-a_js} [emitted] [immutable]
a-main-5b1dc11fec11f25eaf1b.js 115 bytes {main} [emitted] main a-main-5b1dc11fec11f25eaf1b.js 115 bytes {main} [emitted] [immutable] main
a-runtime~main-d1e9699b86adac706ec9.js 4.75 KiB {runtime~main} [emitted] runtime~main a-runtime~main-d1e9699b86adac706ec9.js 4.75 KiB {runtime~main} [emitted] [immutable] runtime~main
Entrypoint main = a-runtime~main-d1e9699b86adac706ec9.js a-all-a_js-5ed868390c43e7086a86.js a-main-5b1dc11fec11f25eaf1b.js Entrypoint main = a-runtime~main-d1e9699b86adac706ec9.js a-all-a_js-5ed868390c43e7086a86.js a-main-5b1dc11fec11f25eaf1b.js
[./a.js] 18 bytes {all-a_js} [built] [./a.js] 18 bytes {all-a_js} [built]
+ 1 hidden module + 1 hidden module
@ -1174,11 +1180,11 @@ Child
Hash: 6d345881901567a13eae Hash: 6d345881901567a13eae
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
b-all-b_js-89c3127ba563ffa436dc.js 497 bytes {all-b_js} [emitted] b-all-b_js-89c3127ba563ffa436dc.js 497 bytes {all-b_js} [emitted] [immutable]
b-main-f043bf83e8ebac493a99.js 148 bytes {main} [emitted] main b-main-f043bf83e8ebac493a99.js 148 bytes {main} [emitted] [immutable] main
b-runtime~main-4dcb3ddd3a8a25ba0a97.js 6.2 KiB {runtime~main} [emitted] runtime~main b-runtime~main-4dcb3ddd3a8a25ba0a97.js 6.2 KiB {runtime~main} [emitted] [immutable] runtime~main
b-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js 189 bytes {vendors-node_modules_vendor_js} [emitted] b-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js 189 bytes {vendors-node_modules_vendor_js} [emitted] [immutable]
Entrypoint main = b-runtime~main-4dcb3ddd3a8a25ba0a97.js b-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js b-all-b_js-89c3127ba563ffa436dc.js b-main-f043bf83e8ebac493a99.js Entrypoint main = b-runtime~main-4dcb3ddd3a8a25ba0a97.js b-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js b-all-b_js-89c3127ba563ffa436dc.js b-main-f043bf83e8ebac493a99.js
[./b.js] 17 bytes {all-b_js} [built] [./b.js] 17 bytes {all-b_js} [built]
[./node_modules/vendor.js] 23 bytes {vendors-node_modules_vendor_js} [built] [./node_modules/vendor.js] 23 bytes {vendors-node_modules_vendor_js} [built]
@ -1187,12 +1193,12 @@ Child
Hash: ecf48c9ff644f453240d Hash: ecf48c9ff644f453240d
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
c-all-b_js-89c3127ba563ffa436dc.js 497 bytes {all-b_js} [emitted] 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] c-all-c_js-936472833753792cc303.js 364 bytes {all-c_js} [emitted] [immutable]
c-main-74481bfa6b28e9e83c8f.js 164 bytes {main} [emitted] main c-main-74481bfa6b28e9e83c8f.js 164 bytes {main} [emitted] [immutable] main
c-runtime~main-07662f2ca56a15eb8680.js 11.2 KiB {runtime~main} [emitted] runtime~main c-runtime~main-07662f2ca56a15eb8680.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] c-vendors-node_modules_vendor_js-a7aa3079a16cbae3f591.js 189 bytes {vendors-node_modules_vendor_js} [emitted] [immutable]
Entrypoint main = c-runtime~main-07662f2ca56a15eb8680.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) Entrypoint main = c-runtime~main-07662f2ca56a15eb8680.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)
[./b.js] 17 bytes {all-b_js} [built] [./b.js] 17 bytes {all-b_js} [built]
[./c.js] 61 bytes {all-c_js} [built] [./c.js] 61 bytes {all-c_js} [built]
@ -2238,15 +2244,15 @@ Entrypoints:
exports[`StatsTestCases should print correct stats for preset-normal-performance-ensure-filter-sourcemaps 1`] = ` exports[`StatsTestCases should print correct stats for preset-normal-performance-ensure-filter-sourcemaps 1`] = `
"Time: <CLR=BOLD>X</CLR>ms "Time: <CLR=BOLD>X</CLR>ms
Built at: 1970-04-20 <CLR=BOLD>12:42:42</CLR> Built at: 1970-04-20 <CLR=BOLD>12:42:42</CLR>
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=BOLD>Chunk Names</CLR> <CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=BOLD>Chunk Names</CLR>
<CLR=32,BOLD>460.js</CLR> 338 bytes {<CLR=33,BOLD>460</CLR>} <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>460.js</CLR> 338 bytes {<CLR=33,BOLD>460</CLR>} <CLR=32,BOLD>[emitted]</CLR>
<CLR=32,BOLD>460.js.map</CLR> 212 bytes ({<CLR=33,BOLD>460</CLR>}) <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>460.js.map</CLR> 212 bytes ({<CLR=33,BOLD>460</CLR>}) <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>[dev]</CLR>
<CLR=32,BOLD>524.js</CLR> 242 bytes {<CLR=33,BOLD>524</CLR>} <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>524.js</CLR> 242 bytes {<CLR=33,BOLD>524</CLR>} <CLR=32,BOLD>[emitted]</CLR>
<CLR=32,BOLD>524.js.map</CLR> 228 bytes ({<CLR=33,BOLD>524</CLR>}) <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>524.js.map</CLR> 228 bytes ({<CLR=33,BOLD>524</CLR>}) <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>[dev]</CLR>
<CLR=32,BOLD>996.js</CLR> 174 bytes {<CLR=33,BOLD>996</CLR>} <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>996.js</CLR> 174 bytes {<CLR=33,BOLD>996</CLR>} <CLR=32,BOLD>[emitted]</CLR>
<CLR=32,BOLD>996.js.map</CLR> 163 bytes ({<CLR=33,BOLD>996</CLR>}) <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>996.js.map</CLR> 163 bytes ({<CLR=33,BOLD>996</CLR>}) <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>[dev]</CLR>
<CLR=33,BOLD>main.js</CLR> <CLR=33,BOLD>301 KiB</CLR> {<CLR=33,BOLD>179</CLR>} <CLR=32,BOLD>[emitted]</CLR> <CLR=33,BOLD>[big]</CLR> main <CLR=33,BOLD>main.js</CLR> <CLR=33,BOLD>301 KiB</CLR> {<CLR=33,BOLD>179</CLR>} <CLR=32,BOLD>[emitted]</CLR> <CLR=33,BOLD>[big]</CLR> main
<CLR=32,BOLD>main.js.map</CLR> 1.72 MiB ({<CLR=33,BOLD>179</CLR>}) <CLR=32,BOLD>[emitted]</CLR> (main) <CLR=32,BOLD>main.js.map</CLR> 1.72 MiB ({<CLR=33,BOLD>179</CLR>}) <CLR=32,BOLD>[emitted]</CLR> <CLR=32,BOLD>[dev]</CLR> (main)
Entrypoint <CLR=BOLD>main</CLR> <CLR=33,BOLD>[big]</CLR> = <CLR=32,BOLD>main.js</CLR> (<CLR=32,BOLD>main.js.map</CLR>) Entrypoint <CLR=BOLD>main</CLR> <CLR=33,BOLD>[big]</CLR> = <CLR=32,BOLD>main.js</CLR> (<CLR=32,BOLD>main.js.map</CLR>)
[10] <CLR=BOLD>./index.js</CLR> 52 bytes {<CLR=33,BOLD>179</CLR>} <CLR=32,BOLD>[built]</CLR> [10] <CLR=BOLD>./index.js</CLR> 52 bytes {<CLR=33,BOLD>179</CLR>} <CLR=32,BOLD>[built]</CLR>
[390] <CLR=BOLD>./e.js</CLR> 22 bytes {<CLR=33,BOLD>524</CLR>} <CLR=32,BOLD>[built]</CLR> [390] <CLR=BOLD>./e.js</CLR> 22 bytes {<CLR=33,BOLD>524</CLR>} <CLR=32,BOLD>[built]</CLR>
@ -3689,19 +3695,19 @@ exports[`StatsTestCases should print correct stats for wasm-explorer-examples-sy
"Hash: 95cded38c001e943cb13 "Hash: 95cded38c001e943cb13
Time: Xms Time: Xms
Built at: 1970-04-20 12:42:42 Built at: 1970-04-20 12:42:42
Asset Size Chunks Chunk Names Asset Size Chunks Chunk Names
1d55f77c08cd19684f13.module.wasm 154 bytes ({325}) [emitted] 1d55f77c08cd19684f13.module.wasm 154 bytes ({325}) [emitted] [immutable]
200c03abdc3f4ae1e15c.module.wasm 290 bytes ({780}) [emitted] 200c03abdc3f4ae1e15c.module.wasm 290 bytes ({780}) [emitted] [immutable]
230.bundle.js 207 bytes {230} [emitted] 230.bundle.js 207 bytes {230} [emitted]
256e72dd8b9a83a6e45b.module.wasm 120 bytes ({325}) [emitted] 256e72dd8b9a83a6e45b.module.wasm 120 bytes ({325}) [emitted] [immutable]
325.bundle.js 3.71 KiB {325} [emitted] 325.bundle.js 3.71 KiB {325} [emitted]
526.bundle.js 359 bytes {526} [emitted] 526.bundle.js 359 bytes {526} [emitted]
780.bundle.js 495 bytes {780} [emitted] 780.bundle.js 495 bytes {780} [emitted]
99.bundle.js 205 bytes {99} [emitted] 99.bundle.js 205 bytes {99} [emitted]
a0e9dd97d7ced35a5b2c.module.wasm 154 bytes ({780}) [emitted] a0e9dd97d7ced35a5b2c.module.wasm 154 bytes ({780}) [emitted] [immutable]
bundle.js 11.2 KiB {520} [emitted] main-1df31ce3 bundle.js 11.2 KiB {520} [emitted] main-1df31ce3
d37b3336426771c2a6e2.module.wasm 531 bytes ({99}) [emitted] d37b3336426771c2a6e2.module.wasm 531 bytes ({99}) [emitted] [immutable]
ebd3f263522776d85971.module.wasm 156 bytes ({230}) [emitted] ebd3f263522776d85971.module.wasm 156 bytes ({230}) [emitted] [immutable]
Entrypoint main = bundle.js Entrypoint main = bundle.js
chunk {99} 99.bundle.js 50 bytes (javascript) 531 bytes (webassembly) [rendered] chunk {99} 99.bundle.js 50 bytes (javascript) 531 bytes (webassembly) [rendered]
[99] ./duff.wasm 50 bytes (javascript) 531 bytes (webassembly) {99} [built] [99] ./duff.wasm 50 bytes (javascript) 531 bytes (webassembly) {99} [built]

View File

View File

@ -0,0 +1 @@
import("./chunk");

View File

@ -0,0 +1,11 @@
module.exports = {
mode: "development",
entry: "./index.js",
output: {
filename: "[contenthash].js"
},
stats: {
all: false,
assets: true
}
};

1164
yarn.lock

File diff suppressed because it is too large Load Diff