Merge tag 'v5.0.0-beta.15' into dev-1

5.0.0-beta.15
This commit is contained in:
Tobias Koppers 2020-04-22 06:40:18 +02:00
commit 5887c20ab0
482 changed files with 10175 additions and 2337 deletions

View File

@ -1,3 +1,5 @@
package.json
# Ignore test fixtures
test/*.*
!test/*.js

View File

@ -8,8 +8,15 @@ module.exports = {
{
files: "*.json",
options: {
parser: "json",
useTabs: false
}
},
{
files: "*.ts",
options: {
parser: "typescript"
}
}
]
};

View File

@ -85,9 +85,11 @@ jobs:
set -e
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn -s run code-lint --format junit > junit.xml
yarn jest-lint
yarn type-lint
yarn special-lint
yarn type-lint
yarn typings-lint
yarn pretty-lint
yarn spellcheck
displayName: "Run linting"
- task: PublishTestResults@2
inputs:

5
declarations.d.ts vendored
View File

@ -385,3 +385,8 @@ declare module "enhanced-resolve" {
}
type TODO = any;
type RecursiveArrayOrRecord<T> =
| { [index: string]: RecursiveArrayOrRecord<T> }
| Array<RecursiveArrayOrRecord<T>>
| T;

18
declarations.test.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
declare module "*.json";
declare namespace jest {
interface Matchers<R> {
toBeTypeOf: (
expected:
| "string"
| "number"
| "bigint"
| "boolean"
| "symbol"
| "undefined"
| "object"
| "function"
) => void;
toEndWith: (expected: string) => void;
}
}

View File

@ -19,11 +19,14 @@ export type Bail = boolean;
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*/
export type Cache = true | CacheNormalized;
export type CacheOptions = true | CacheOptionsNormalized;
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*/
export type CacheNormalized = false | MemoryCacheOptions | FileCacheOptions;
export type CacheOptionsNormalized =
| false
| MemoryCacheOptions
| FileCacheOptions;
/**
* The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*/
@ -239,7 +242,13 @@ export type RuleSetLoaderOptions =
*/
export type RuleSetUse =
| RuleSetUseItem[]
| ((data: object) => RuleSetUseItem[])
| ((data: {
resource: string;
realResource: string;
resourceQuery: string;
issuer: string;
compiler: string;
}) => RuleSetUseItem[])
| RuleSetUseItem;
/**
* A description of an applied loader.
@ -292,15 +301,6 @@ export type OptimizationRuntimeChunk =
*/
name?: string | Function;
};
/**
* A function returning cache groups.
*/
export type OptimizationSplitChunksGetCacheGroups = (
module: import("../lib/Module")
) =>
| OptimizationSplitChunksCacheGroup
| OptimizationSplitChunksCacheGroup[]
| void;
/**
* Size description for limits.
*/
@ -489,7 +489,7 @@ export type ResolveLoader = ResolveOptions;
/**
* Stats options object or preset name.
*/
export type Stats =
export type StatsValue =
| (
| "none"
| "errors-only"
@ -539,6 +539,15 @@ export type OptimizationRuntimeChunkNormalized =
*/
name?: Function;
};
/**
* A function returning cache groups.
*/
export type OptimizationSplitChunksGetCacheGroups = (
module: import("../lib/Module")
) =>
| OptimizationSplitChunksCacheGroup
| OptimizationSplitChunksCacheGroup[]
| void;
/**
* Options object as provided by the user.
@ -555,7 +564,7 @@ export interface WebpackOptions {
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*/
cache?: Cache;
cache?: CacheOptions;
/**
* The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*/
@ -603,7 +612,7 @@ export interface WebpackOptions {
/**
* Options affecting the normal modules (`NormalModuleFactory`).
*/
module?: Module;
module?: ModuleOptions;
/**
* Name of the configuration. Used when loading multiple configurations.
*/
@ -659,7 +668,7 @@ export interface WebpackOptions {
/**
* Stats options object or preset name.
*/
stats?: Stats;
stats?: StatsValue;
/**
* Environment to build for.
*/
@ -906,7 +915,7 @@ export interface Loader {
/**
* Options affecting the normal modules (`NormalModuleFactory`).
*/
export interface Module {
export interface ModuleOptions {
/**
* An array of rules applied by default for modules.
*/
@ -1323,7 +1332,9 @@ export interface OptimizationSplitChunksOptions {
/**
* Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML).
*/
chunks?: ("initial" | "async" | "all") | Function;
chunks?:
| ("initial" | "async" | "all")
| ((chunk: import("../lib/Chunk")) => boolean);
/**
* Options for modules not selected by any other cache group.
*/
@ -1412,7 +1423,7 @@ export interface OptimizationSplitChunksCacheGroup {
*/
chunks?:
| ("initial" | "async" | "all")
| OptimizationSplitChunksGetCacheGroups;
| ((chunk: import("../lib/Chunk")) => boolean);
/**
* Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group.
*/
@ -2096,7 +2107,7 @@ export interface WebpackOptionsNormalized {
/**
* Cache generated modules and chunks to improve performance for multiple incremental builds.
*/
cache: CacheNormalized;
cache: CacheOptionsNormalized;
/**
* The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*/
@ -2144,7 +2155,7 @@ export interface WebpackOptionsNormalized {
/**
* Options affecting the normal modules (`NormalModuleFactory`).
*/
module: Module;
module: ModuleOptions;
/**
* Name of the configuration. Used when loading multiple configurations.
*/
@ -2196,7 +2207,7 @@ export interface WebpackOptionsNormalized {
/**
* Stats options object or preset name.
*/
stats: Stats;
stats: StatsValue;
/**
* Environment to build for.
*/

7
generate-types-config.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
nameMapping: {
FsStats: /^Stats Import fs/,
Configuration: /^WebpackOptions /
},
exclude: [/^devServer in WebpackOptions /]
};

View File

@ -135,6 +135,7 @@ class ChunkGroup {
this.options.name = value;
}
/* istanbul ignore next */
/**
* get a uniqueId for ChunkGroup, made up of its member Chunk debugId's
* @returns {string} a unique concatenation of chunk debugId's
@ -529,6 +530,7 @@ class ChunkGroup {
return this._modulePostOrderIndices.get(module);
}
/* istanbul ignore next */
checkConstraints() {
const chunk = this;
for (const child of chunk._children) {

View File

@ -16,8 +16,8 @@ const {
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {null|undefined|RegExp|Function|string|number} CodeValuePrimitive */
/** @typedef {CodeValuePrimitive|Record<string, CodeValuePrimitive>|RuntimeValue} CodeValue */
/** @typedef {null|undefined|RegExp|Function|string|number|boolean|bigint|undefined} CodeValuePrimitive */
/** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive|RuntimeValue>} CodeValue */
class RuntimeValue {
constructor(fn, fileDependencies) {

View File

@ -5,8 +5,6 @@
"use strict";
const AbstractMethodError = require("./AbstractMethodError");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./Dependency")} Dependency */
@ -28,6 +26,7 @@ const AbstractMethodError = require("./AbstractMethodError");
*/
class DependencyTemplate {
/* istanbul ignore next */
/**
* @abstract
* @param {Dependency} dependency the dependency for which the template should be applied
@ -36,6 +35,7 @@ class DependencyTemplate {
* @returns {void}
*/
apply(dependency, source, templateContext) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
}

View File

@ -5,8 +5,6 @@
"use strict";
const AbstractMethodError = require("./AbstractMethodError");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./Compilation")} Compilation */
@ -41,15 +39,18 @@ class Generator {
return new ByTypeGenerator(map);
}
/* istanbul ignore next */
/**
* @abstract
* @param {NormalModule} module fresh module
* @returns {Set<string>} available types (do not mutate)
*/
getTypes(module) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
/* istanbul ignore next */
/**
* @abstract
* @param {NormalModule} module the module
@ -57,9 +58,11 @@ class Generator {
* @returns {number} estimate size of the module
*/
getSize(module, type) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
/* istanbul ignore next */
/**
* @abstract
* @param {NormalModule} module module for which the code should be generated
@ -70,6 +73,7 @@ class Generator {
module,
{ dependencyTemplates, runtimeTemplate, moduleGraph, type }
) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}

View File

@ -6,7 +6,6 @@
"use strict";
const util = require("util");
const AbstractMethodError = require("./AbstractMethodError");
const ChunkGraph = require("./ChunkGraph");
const DependenciesBlock = require("./DependenciesBlock");
const ModuleGraph = require("./ModuleGraph");
@ -647,23 +646,28 @@ class Module extends DependenciesBlock {
// should be overridden to support this feature
}
/* istanbul ignore next */
/**
* @abstract
* @returns {string} a unique identifier of the module
*/
identifier() {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
/* istanbul ignore next */
/**
* @abstract
* @param {RequestShortener} requestShortener the request shortener
* @returns {string} a user readable identifier of the module
*/
readableIdentifier(requestShortener) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
/* istanbul ignore next */
/**
* @abstract
* @param {WebpackOptions} options webpack options
@ -674,6 +678,7 @@ class Module extends DependenciesBlock {
* @returns {void}
*/
build(options, compilation, resolver, fs, callback) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
@ -698,6 +703,7 @@ class Module extends DependenciesBlock {
*/
source(sourceContext) {
if (this.codeGeneration === Module.prototype.codeGeneration) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
const sources = this.codeGeneration(sourceContext).sources;
@ -706,12 +712,14 @@ class Module extends DependenciesBlock {
: sources.get(this.getSourceTypes().values().next().value);
}
/* istanbul ignore next */
/**
* @abstract
* @param {string=} type the source type for which the size should be estimated
* @returns {number} the estimated size of the module (must be non-zero)
*/
size(type) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}

View File

@ -5,8 +5,6 @@
"use strict";
const AbstractMethodError = require("./AbstractMethodError");
/** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./Module")} Module */
@ -33,12 +31,15 @@ const AbstractMethodError = require("./AbstractMethodError");
*/
class ModuleFactory {
/* istanbul ignore next */
/**
* @abstract
* @param {ModuleFactoryCreateData} data data object
* @param {function(Error=, ModuleFactoryResult=): void} callback callback
* @returns {void}
*/
create(data, callback) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
}

View File

@ -5,8 +5,6 @@
"use strict";
const AbstractMethodError = require("./AbstractMethodError");
/** @typedef {import("./Compilation")} Compilation */
/** @typedef {import("./NormalModule")} NormalModule */
@ -23,12 +21,15 @@ const AbstractMethodError = require("./AbstractMethodError");
/** @typedef {Record<string, any> & ParserStateBase} ParserState */
class Parser {
/* istanbul ignore next */
/**
* @abstract
* @param {string | Buffer | PreparsedAst} source the source to parse
* @param {ParserState} state the parser state
* @returns {ParserState} the parser state
*/
parse(source, state) {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}
}

View File

@ -47,6 +47,23 @@ class RecordIdsPlugin {
*/
apply(compiler) {
const portableIds = this.options.portableIds;
const makePathsRelative = identifierUtils.makePathsRelative.bindContextCache(
compiler.context,
compiler.root
);
/**
* @param {Module} module the module
* @returns {string} the (portable) identifier
*/
const getModuleIdentifier = module => {
if (portableIds) {
return makePathsRelative(module.identifier());
}
return module.identifier();
};
compiler.hooks.compilation.tap("RecordIdsPlugin", compilation => {
compilation.hooks.recordModules.tap(
"RecordIdsPlugin",
@ -64,13 +81,7 @@ class RecordIdsPlugin {
for (const module of modules) {
const moduleId = chunkGraph.getModuleId(module);
if (typeof moduleId !== "number") continue;
const identifier = portableIds
? identifierUtils.makePathsRelative(
compiler.context,
module.identifier(),
compiler.root
)
: module.identifier();
const identifier = getModuleIdentifier(module);
records.modules.byIdentifier[identifier] = moduleId;
usedIds.add(moduleId);
}
@ -93,13 +104,7 @@ class RecordIdsPlugin {
for (const module of modules) {
const moduleId = chunkGraph.getModuleId(module);
if (moduleId !== null) continue;
const identifier = portableIds
? identifierUtils.makePathsRelative(
compiler.context,
module.identifier(),
compiler.root
)
: module.identifier();
const identifier = getModuleIdentifier(module);
const id = records.modules.byIdentifier[identifier];
if (id === undefined) continue;
if (usedIds.has(id)) continue;
@ -113,21 +118,6 @@ class RecordIdsPlugin {
}
);
/**
* @param {Module} module the module
* @returns {string} the (portable) identifier
*/
const getModuleIdentifier = module => {
if (portableIds) {
return identifierUtils.makePathsRelative(
compiler.context,
module.identifier(),
compiler.root
);
}
return module.identifier();
};
/**
* @param {Chunk} chunk the chunk
* @returns {string[]} sources of the chunk

View File

@ -220,6 +220,11 @@ exports.hmrDownloadUpdateHandlers = "__webpack_require__.hmrC";
*/
exports.hmrModuleData = "__webpack_require__.hmrD";
/**
* array with handler functions when a module should be invalidated
*/
exports.hmrInvalidateModuleHandlers = "__webpack_require__.hmrI";
/**
* the AMD define function
*/

View File

@ -6,7 +6,6 @@
"use strict";
const OriginalSource = require("webpack-sources").OriginalSource;
const AbstractMethodError = require("./AbstractMethodError");
const Module = require("./Module");
/** @typedef {import("webpack-sources").Source} Source */
@ -145,11 +144,13 @@ class RuntimeModule extends Module {
return 0;
}
/* istanbul ignore next */
/**
* @abstract
* @returns {string} runtime code
*/
generate() {
const AbstractMethodError = require("./AbstractMethodError");
throw new AbstractMethodError();
}

View File

@ -74,9 +74,10 @@ const getTaskForFile = (
if (!sourceMap || typeof source !== "string") return;
const context = compilation.options.context;
const root = compilation.compiler.root;
const cachedAbsolutify = absolutify.bindContextCache(context, root);
const modules = sourceMap.sources.map(source => {
if (!source.startsWith("webpack://")) return source;
source = absolutify(context, source.slice(10), root);
source = cachedAbsolutify(source.slice(10));
const module = compilation.findModule(source);
return module || source;
});

View File

@ -15,9 +15,11 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
* @property {string} path the path in the config
*/
/** @typedef {"unknown-argument" | "unexpected-non-array-in-path" | "unexpected-non-object-in-path" | "multiple-values-unexpected" | "invalid-value"} ProblemType */
/**
* @typedef {Object} Problem
* @property {string} type
* @property {ProblemType} type
* @property {string} path
* @property {string} argument
* @property {any=} value
@ -27,7 +29,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
/**
* @typedef {Object} LocalProblem
* @property {string} type
* @property {ProblemType} type
* @property {string} path
* @property {string=} expected
*/
@ -563,7 +565,7 @@ const parseValueForArgumentConfig = (argConfig, value) => {
/**
* @param {Record<string, Argument>} args object of arguments
* @param {any} config configuration
* @param {Record<string, string | number | boolean | RegExp>} values object with values
* @param {Record<string, string | number | boolean | RegExp | (string | number | boolean | RegExp)[]>} values object with values
* @returns {Problem[] | null} problems or null for success
*/
const processArguments = (args, config, values) => {

View File

@ -8,13 +8,13 @@
const path = require("path");
const Template = require("../Template");
/** @typedef {import("../../declarations/WebpackOptions").CacheNormalized} WebpackCache */
/** @typedef {import("../../declarations/WebpackOptions").CacheOptionsNormalized} CacheOptions */
/** @typedef {import("../../declarations/WebpackOptions").Experiments} Experiments */
/** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
/** @typedef {import("../../declarations/WebpackOptions").Library} Library */
/** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */
/** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
/** @typedef {import("../../declarations/WebpackOptions").Module} WebpackModule */
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptions} ModuleOptions */
/** @typedef {import("../../declarations/WebpackOptions").Node} WebpackNode */
/** @typedef {import("../../declarations/WebpackOptions").Optimization} Optimization */
/** @typedef {import("../../declarations/WebpackOptions").Output} Output */
@ -178,7 +178,7 @@ const applyExperimentsDefaults = experiments => {
};
/**
* @param {WebpackCache} cache options
* @param {CacheOptions} cache options
* @param {Object} options options
* @param {string} options.name name
* @param {string} options.mode mode
@ -256,7 +256,7 @@ const applyCacheDefaults = (cache, { name, mode }) => {
};
/**
* @param {WebpackModule} module options
* @param {ModuleOptions} module options
* @param {Object} options options
* @param {boolean} options.cache is caching enabled
* @param {boolean} options.mjs is mjs enabled

View File

@ -28,7 +28,7 @@ const ConstDependency = require("./ConstDependency");
const LocalModuleDependency = require("./LocalModuleDependency");
const UnsupportedDependency = require("./UnsupportedDependency");
/** @typedef {import("../../declarations/WebpackOptions").Module} ModuleOptions */
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptions} ModuleOptions */
/** @typedef {import("../Compiler")} Compiler */
class AMDPlugin {

View File

@ -12,6 +12,7 @@ var $moduleCache$ = undefined;
var $hmrModuleData$ = undefined;
var $hmrDownloadManifest$ = undefined;
var $hmrDownloadUpdateHandlers$ = undefined;
var $hmrInvalidateModuleHandlers$ = undefined;
var __webpack_require__ = undefined;
module.exports = function () {
@ -33,6 +34,7 @@ module.exports = function () {
// The update info
var currentUpdateApplyHandlers;
var currentUpdateNewHash;
var queuedInvalidatedModules;
$hmrModuleData$ = currentModuleData;
@ -51,6 +53,7 @@ module.exports = function () {
});
$hmrDownloadUpdateHandlers$ = {};
$hmrInvalidateModuleHandlers$ = {};
function createRequire(require, moduleId) {
var me = installedModules[moduleId];
@ -110,6 +113,7 @@ module.exports = function () {
_declinedDependencies: {},
_selfAccepted: false,
_selfDeclined: false,
_selfInvalidated: false,
_disposeHandlers: [],
_main: currentChildModule !== moduleId,
_requireSelf: function () {
@ -145,6 +149,40 @@ module.exports = function () {
var idx = hot._disposeHandlers.indexOf(callback);
if (idx >= 0) hot._disposeHandlers.splice(idx, 1);
},
invalidate: function () {
this._selfInvalidated = true;
switch (currentStatus) {
case "idle":
currentUpdateApplyHandlers = [];
Object.keys($hmrInvalidateModuleHandlers$).forEach(function (key) {
$hmrInvalidateModuleHandlers$[key](
moduleId,
currentUpdateApplyHandlers
);
});
setStatus("ready");
break;
case "ready":
Object.keys($hmrInvalidateModuleHandlers$).forEach(function (key) {
$hmrInvalidateModuleHandlers$[key](
moduleId,
currentUpdateApplyHandlers
);
});
break;
case "prepare":
case "check":
case "dispose":
case "apply":
(queuedInvalidatedModules = queuedInvalidatedModules || []).push(
moduleId
);
break;
default:
// ignore requests in error states
break;
}
},
// Management API
check: hotCheck,
@ -207,7 +245,7 @@ module.exports = function () {
setStatus("check");
return $hmrDownloadManifest$().then(function (update) {
if (!update) {
setStatus("idle");
setStatus(applyInvalidatedModules() ? "ready" : "idle");
return null;
}
@ -260,9 +298,12 @@ module.exports = function () {
function internalApply(options) {
options = options || {};
applyInvalidatedModules();
var results = currentUpdateApplyHandlers.map(function (handler) {
return handler(options);
});
currentUpdateApplyHandlers = undefined;
var errors = results
.map(function (r) {
@ -287,7 +328,10 @@ module.exports = function () {
// Now in "apply" phase
setStatus("apply");
currentHash = currentUpdateNewHash;
if (currentUpdateNewHash !== undefined) {
currentHash = currentUpdateNewHash;
currentUpdateNewHash = undefined;
}
var error;
var reportError = function (err) {
@ -314,7 +358,32 @@ module.exports = function () {
});
}
if (queuedInvalidatedModules) {
return internalApply(options).then(function (list) {
outdatedModules.forEach(function (moduleId) {
if (list.indexOf(moduleId) < 0) list.push(moduleId);
});
return list;
});
}
setStatus("idle");
return Promise.resolve(outdatedModules);
}
function applyInvalidatedModules() {
if (queuedInvalidatedModules) {
if (!currentUpdateApplyHandlers) currentUpdateApplyHandlers = [];
Object.keys($hmrInvalidateModuleHandlers$).forEach(function (key) {
queuedInvalidatedModules.forEach(function (moduleId) {
$hmrInvalidateModuleHandlers$[key](
moduleId,
currentUpdateApplyHandlers
);
});
});
queuedInvalidatedModules = undefined;
return true;
}
}
};

View File

@ -28,6 +28,10 @@ class HotModuleReplacementRuntimeModule extends RuntimeModule {
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(/\$hmrDownloadManifest\$/g, RuntimeGlobals.hmrDownloadManifest)
.replace(
/\$hmrInvalidateModuleHandlers\$/g,
RuntimeGlobals.hmrInvalidateModuleHandlers
)
.replace(
/\$hmrDownloadUpdateHandlers\$/g,
RuntimeGlobals.hmrDownloadUpdateHandlers

View File

@ -5,369 +5,426 @@
"use strict";
var $options$ = undefined;
var $updateModuleFactories$ = undefined;
var $updateRuntimeModules$ = undefined;
var $installedChunks$ = undefined;
var $loadUpdateChunk$ = undefined;
var $moduleCache$ = undefined;
var $moduleFactories$ = undefined;
var $ensureChunkHandlers$ = undefined;
var $hasOwnProperty$ = undefined;
var $hmrModuleData$ = undefined;
var $hmrDownloadUpdateHandlers$ = undefined;
var $hmrInvalidateModuleHandlers$ = undefined;
var __webpack_require__ = undefined;
module.exports = function () {
function getAffectedModuleEffects(updateModuleId) {
var outdatedModules = [updateModuleId];
var outdatedDependencies = {};
var currentUpdateChunks;
var currentUpdate;
var currentUpdateRemovedChunks;
var currentUpdateRuntime;
function applyHandler(options) {
if ($ensureChunkHandlers$) delete $ensureChunkHandlers$.$key$Hmr;
currentUpdateChunks = undefined;
function getAffectedModuleEffects(updateModuleId) {
var outdatedModules = [updateModuleId];
var outdatedDependencies = {};
var queue = outdatedModules.map(function (id) {
return {
chain: [id],
id: id
};
});
while (queue.length > 0) {
var queueItem = queue.pop();
var moduleId = queueItem.id;
var chain = queueItem.chain;
var module = $moduleCache$[moduleId];
if (!module || module.hot._selfAccepted) continue;
if (module.hot._selfDeclined) {
var queue = outdatedModules.map(function (id) {
return {
type: "self-declined",
chain: chain,
moduleId: moduleId
chain: [id],
id: id
};
}
if (module.hot._main) {
return {
type: "unaccepted",
chain: chain,
moduleId: moduleId
};
}
for (var i = 0; i < module.parents.length; i++) {
var parentId = module.parents[i];
var parent = $moduleCache$[parentId];
if (!parent) continue;
if (parent.hot._declinedDependencies[moduleId]) {
});
while (queue.length > 0) {
var queueItem = queue.pop();
var moduleId = queueItem.id;
var chain = queueItem.chain;
var module = $moduleCache$[moduleId];
if (
!module ||
(module.hot._selfAccepted && !module.hot._selfInvalidated)
)
continue;
if (module.hot._selfDeclined) {
return {
type: "declined",
chain: chain.concat([parentId]),
moduleId: moduleId,
parentId: parentId
type: "self-declined",
chain: chain,
moduleId: moduleId
};
}
if (outdatedModules.indexOf(parentId) !== -1) continue;
if (parent.hot._acceptedDependencies[moduleId]) {
if (!outdatedDependencies[parentId])
outdatedDependencies[parentId] = [];
addAllToSet(outdatedDependencies[parentId], [moduleId]);
continue;
if (module.hot._main) {
return {
type: "unaccepted",
chain: chain,
moduleId: moduleId
};
}
delete outdatedDependencies[parentId];
outdatedModules.push(parentId);
queue.push({
chain: chain.concat([parentId]),
id: parentId
for (var i = 0; i < module.parents.length; i++) {
var parentId = module.parents[i];
var parent = $moduleCache$[parentId];
if (!parent) continue;
if (parent.hot._declinedDependencies[moduleId]) {
return {
type: "declined",
chain: chain.concat([parentId]),
moduleId: moduleId,
parentId: parentId
};
}
if (outdatedModules.indexOf(parentId) !== -1) continue;
if (parent.hot._acceptedDependencies[moduleId]) {
if (!outdatedDependencies[parentId])
outdatedDependencies[parentId] = [];
addAllToSet(outdatedDependencies[parentId], [moduleId]);
continue;
}
delete outdatedDependencies[parentId];
outdatedModules.push(parentId);
queue.push({
chain: chain.concat([parentId]),
id: parentId
});
}
}
return {
type: "accepted",
moduleId: updateModuleId,
outdatedModules: outdatedModules,
outdatedDependencies: outdatedDependencies
};
}
function addAllToSet(a, b) {
for (var i = 0; i < b.length; i++) {
var item = b[i];
if (a.indexOf(item) === -1) a.push(item);
}
}
// at begin all updates modules are outdated
// the "outdated" status can propagate to parents if they don't accept the children
var outdatedDependencies = {};
var outdatedModules = [];
var appliedUpdate = {};
var warnUnexpectedRequire = function warnUnexpectedRequire() {
console.warn(
"[HMR] unexpected require(" + result.moduleId + ") to disposed module"
);
};
for (var moduleId in currentUpdate) {
if ($hasOwnProperty$(currentUpdate, moduleId)) {
var newModuleFactory = currentUpdate[moduleId];
/** @type {TODO} */
var result;
if (newModuleFactory) {
result = getAffectedModuleEffects(moduleId);
} else {
result = {
type: "disposed",
moduleId: moduleId
};
}
/** @type {Error|false} */
var abortError = false;
var doApply = false;
var doDispose = false;
var chainInfo = "";
if (result.chain) {
chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
}
switch (result.type) {
case "self-declined":
if (options.onDeclined) options.onDeclined(result);
if (!options.ignoreDeclined)
abortError = new Error(
"Aborted because of self decline: " +
result.moduleId +
chainInfo
);
break;
case "declined":
if (options.onDeclined) options.onDeclined(result);
if (!options.ignoreDeclined)
abortError = new Error(
"Aborted because of declined dependency: " +
result.moduleId +
" in " +
result.parentId +
chainInfo
);
break;
case "unaccepted":
if (options.onUnaccepted) options.onUnaccepted(result);
if (!options.ignoreUnaccepted)
abortError = new Error(
"Aborted because " + moduleId + " is not accepted" + chainInfo
);
break;
case "accepted":
if (options.onAccepted) options.onAccepted(result);
doApply = true;
break;
case "disposed":
if (options.onDisposed) options.onDisposed(result);
doDispose = true;
break;
default:
throw new Error("Unexception type " + result.type);
}
if (abortError) {
return {
error: abortError
};
}
if (doApply) {
appliedUpdate[moduleId] = newModuleFactory;
addAllToSet(outdatedModules, result.outdatedModules);
for (moduleId in result.outdatedDependencies) {
if ($hasOwnProperty$(result.outdatedDependencies, moduleId)) {
if (!outdatedDependencies[moduleId])
outdatedDependencies[moduleId] = [];
addAllToSet(
outdatedDependencies[moduleId],
result.outdatedDependencies[moduleId]
);
}
}
}
if (doDispose) {
addAllToSet(outdatedModules, [result.moduleId]);
appliedUpdate[moduleId] = warnUnexpectedRequire;
}
}
}
currentUpdate = undefined;
// Store self accepted outdated modules to require them later by the module system
var outdatedSelfAcceptedModules = [];
for (var j = 0; j < outdatedModules.length; j++) {
var outdatedModuleId = outdatedModules[j];
if (
$moduleCache$[outdatedModuleId] &&
$moduleCache$[outdatedModuleId].hot._selfAccepted &&
// removed self-accepted modules should not be required
appliedUpdate[outdatedModuleId] !== warnUnexpectedRequire &&
// when called invalidate self-accepting is not possible
!$moduleCache$[moduleId].hot._selfInvalidated
) {
outdatedSelfAcceptedModules.push({
module: outdatedModuleId,
require: $moduleCache$[outdatedModuleId].hot._requireSelf,
errorHandler: $moduleCache$[outdatedModuleId].hot._selfAccepted
});
}
}
var moduleOutdatedDependencies;
return {
type: "accepted",
moduleId: updateModuleId,
outdatedModules: outdatedModules,
outdatedDependencies: outdatedDependencies
};
}
dispose: function () {
currentUpdateRemovedChunks.forEach(function (chunkId) {
delete $installedChunks$[chunkId];
});
currentUpdateRemovedChunks = undefined;
function addAllToSet(a, b) {
for (var i = 0; i < b.length; i++) {
var item = b[i];
if (a.indexOf(item) === -1) a.push(item);
}
}
var idx;
var queue = outdatedModules.slice();
while (queue.length > 0) {
var moduleId = queue.pop();
var module = $moduleCache$[moduleId];
if (!module) continue;
// at begin all updates modules are outdated
// the "outdated" status can propagate to parents if they don't accept the children
var outdatedDependencies = {};
var outdatedModules = [];
var appliedUpdate = {};
var data = {};
var warnUnexpectedRequire = function warnUnexpectedRequire() {
console.warn(
"[HMR] unexpected require(" + result.moduleId + ") to disposed module"
);
};
for (var moduleId in $updateModuleFactories$) {
if (
Object.prototype.hasOwnProperty.call($updateModuleFactories$, moduleId)
) {
var newModuleFactory = $updateModuleFactories$[moduleId];
/** @type {TODO} */
var result;
if (newModuleFactory) {
result = getAffectedModuleEffects(moduleId);
} else {
result = {
type: "disposed",
moduleId: moduleId
};
}
/** @type {Error|false} */
var abortError = false;
var doApply = false;
var doDispose = false;
var chainInfo = "";
if (result.chain) {
chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
}
switch (result.type) {
case "self-declined":
if ($options$.onDeclined) $options$.onDeclined(result);
if (!$options$.ignoreDeclined)
abortError = new Error(
"Aborted because of self decline: " + result.moduleId + chainInfo
);
break;
case "declined":
if ($options$.onDeclined) $options$.onDeclined(result);
if (!$options$.ignoreDeclined)
abortError = new Error(
"Aborted because of declined dependency: " +
result.moduleId +
" in " +
result.parentId +
chainInfo
);
break;
case "unaccepted":
if ($options$.onUnaccepted) $options$.onUnaccepted(result);
if (!$options$.ignoreUnaccepted)
abortError = new Error(
"Aborted because " + moduleId + " is not accepted" + chainInfo
);
break;
case "accepted":
if ($options$.onAccepted) $options$.onAccepted(result);
doApply = true;
break;
case "disposed":
if ($options$.onDisposed) $options$.onDisposed(result);
doDispose = true;
break;
default:
throw new Error("Unexception type " + result.type);
}
if (abortError) {
return {
error: abortError
};
}
if (doApply) {
appliedUpdate[moduleId] = newModuleFactory;
addAllToSet(outdatedModules, result.outdatedModules);
for (moduleId in result.outdatedDependencies) {
if (
Object.prototype.hasOwnProperty.call(
result.outdatedDependencies,
moduleId
)
) {
if (!outdatedDependencies[moduleId])
outdatedDependencies[moduleId] = [];
addAllToSet(
outdatedDependencies[moduleId],
result.outdatedDependencies[moduleId]
);
// Call dispose handlers
var disposeHandlers = module.hot._disposeHandlers;
for (j = 0; j < disposeHandlers.length; j++) {
disposeHandlers[j].call(null, data);
}
}
}
if (doDispose) {
addAllToSet(outdatedModules, [result.moduleId]);
appliedUpdate[moduleId] = warnUnexpectedRequire;
}
}
}
$hmrModuleData$[moduleId] = data;
// Store self accepted outdated modules to require them later by the module system
var outdatedSelfAcceptedModules = [];
for (var j = 0; j < outdatedModules.length; j++) {
var outdatedModuleId = outdatedModules[j];
if (
$moduleCache$[outdatedModuleId] &&
$moduleCache$[outdatedModuleId].hot._selfAccepted &&
// removed self-accepted modules should not be required
appliedUpdate[outdatedModuleId] !== warnUnexpectedRequire
) {
outdatedSelfAcceptedModules.push({
module: outdatedModuleId,
require: $moduleCache$[outdatedModuleId].hot._requireSelf,
errorHandler: $moduleCache$[outdatedModuleId].hot._selfAccepted
});
}
}
// disable module (this disables requires from this module)
module.hot.active = false;
var moduleOutdatedDependencies;
// remove module from cache
delete $moduleCache$[moduleId];
return {
dispose: function () {
// $dispose$
// when disposing there is no need to call dispose handler
delete outdatedDependencies[moduleId];
var idx;
var queue = outdatedModules.slice();
while (queue.length > 0) {
var moduleId = queue.pop();
var module = $moduleCache$[moduleId];
if (!module) continue;
var data = {};
// Call dispose handlers
var disposeHandlers = module.hot._disposeHandlers;
for (j = 0; j < disposeHandlers.length; j++) {
disposeHandlers[j].call(null, data);
}
$hmrModuleData$[moduleId] = data;
// disable module (this disables requires from this module)
module.hot.active = false;
// remove module from cache
delete $moduleCache$[moduleId];
// when disposing there is no need to call dispose handler
delete outdatedDependencies[moduleId];
// remove "parents" references from all children
for (j = 0; j < module.children.length; j++) {
var child = $moduleCache$[module.children[j]];
if (!child) continue;
idx = child.parents.indexOf(moduleId);
if (idx >= 0) {
child.parents.splice(idx, 1);
}
}
}
// remove outdated dependency from module children
var dependency;
for (var outdatedModuleId in outdatedDependencies) {
if (
Object.prototype.hasOwnProperty.call(
outdatedDependencies,
outdatedModuleId
)
) {
module = $moduleCache$[outdatedModuleId];
if (module) {
moduleOutdatedDependencies = outdatedDependencies[outdatedModuleId];
for (j = 0; j < moduleOutdatedDependencies.length; j++) {
dependency = moduleOutdatedDependencies[j];
idx = module.children.indexOf(dependency);
if (idx >= 0) module.children.splice(idx, 1);
// remove "parents" references from all children
for (j = 0; j < module.children.length; j++) {
var child = $moduleCache$[module.children[j]];
if (!child) continue;
idx = child.parents.indexOf(moduleId);
if (idx >= 0) {
child.parents.splice(idx, 1);
}
}
}
}
},
apply: function (reportError) {
// insert new code
for (var updateModuleId in appliedUpdate) {
if (
Object.prototype.hasOwnProperty.call(appliedUpdate, updateModuleId)
) {
$moduleFactories$[updateModuleId] = appliedUpdate[updateModuleId];
}
}
// run new runtime modules
for (var i = 0; i < $updateRuntimeModules$.length; i++) {
$updateRuntimeModules$[i](__webpack_require__);
}
// call accept handlers
var error = null;
for (var outdatedModuleId in outdatedDependencies) {
if (
Object.prototype.hasOwnProperty.call(
outdatedDependencies,
outdatedModuleId
)
) {
var module = $moduleCache$[outdatedModuleId];
if (module) {
moduleOutdatedDependencies = outdatedDependencies[outdatedModuleId];
var callbacks = [];
for (var j = 0; j < moduleOutdatedDependencies.length; j++) {
var dependency = moduleOutdatedDependencies[j];
var acceptCallback = module.hot._acceptedDependencies[dependency];
if (acceptCallback) {
if (callbacks.indexOf(acceptCallback) !== -1) continue;
callbacks.push(acceptCallback);
// remove outdated dependency from module children
var dependency;
for (var outdatedModuleId in outdatedDependencies) {
if ($hasOwnProperty$(outdatedDependencies, outdatedModuleId)) {
module = $moduleCache$[outdatedModuleId];
if (module) {
moduleOutdatedDependencies =
outdatedDependencies[outdatedModuleId];
for (j = 0; j < moduleOutdatedDependencies.length; j++) {
dependency = moduleOutdatedDependencies[j];
idx = module.children.indexOf(dependency);
if (idx >= 0) module.children.splice(idx, 1);
}
}
for (var k = 0; k < callbacks.length; k++) {
}
}
},
apply: function (reportError) {
// insert new code
for (var updateModuleId in appliedUpdate) {
if ($hasOwnProperty$(appliedUpdate, updateModuleId)) {
$moduleFactories$[updateModuleId] = appliedUpdate[updateModuleId];
}
}
// run new runtime modules
for (var i = 0; i < currentUpdateRuntime.length; i++) {
currentUpdateRuntime[i](__webpack_require__);
}
// call accept handlers
var error = null;
for (var outdatedModuleId in outdatedDependencies) {
if ($hasOwnProperty$(outdatedDependencies, outdatedModuleId)) {
var module = $moduleCache$[outdatedModuleId];
if (module) {
moduleOutdatedDependencies =
outdatedDependencies[outdatedModuleId];
var callbacks = [];
for (var j = 0; j < moduleOutdatedDependencies.length; j++) {
var dependency = moduleOutdatedDependencies[j];
var acceptCallback =
module.hot._acceptedDependencies[dependency];
if (acceptCallback) {
if (callbacks.indexOf(acceptCallback) !== -1) continue;
callbacks.push(acceptCallback);
}
}
for (var k = 0; k < callbacks.length; k++) {
try {
callbacks[k].call(null, moduleOutdatedDependencies);
} catch (err) {
if (options.onErrored) {
options.onErrored({
type: "accept-errored",
moduleId: outdatedModuleId,
dependencyId: moduleOutdatedDependencies[i],
error: err
});
}
if (!options.ignoreErrored) {
if (!error) error = err;
}
}
}
}
}
}
// Load self accepted modules
for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) {
var item = outdatedSelfAcceptedModules[o];
var moduleId = item.module;
try {
item.require(moduleId);
} catch (err) {
if (typeof item.errorHandler === "function") {
try {
callbacks[k].call(null, moduleOutdatedDependencies);
} catch (err) {
if ($options$.onErrored) {
$options$.onErrored({
type: "accept-errored",
moduleId: outdatedModuleId,
dependencyId: moduleOutdatedDependencies[i],
error: err
item.errorHandler(err);
} catch (err2) {
if (options.onErrored) {
options.onErrored({
type: "self-accept-error-handler-errored",
moduleId: moduleId,
error: err2,
originalError: err
});
}
if (!$options$.ignoreErrored) {
if (!error) error = err;
if (!options.ignoreErrored) {
reportError(err2);
}
reportError(err);
}
}
}
}
}
// Load self accepted modules
for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) {
var item = outdatedSelfAcceptedModules[o];
var moduleId = item.module;
try {
item.require(moduleId);
} catch (err) {
if (typeof item.errorHandler === "function") {
try {
item.errorHandler(err);
} catch (err2) {
if ($options$.onErrored) {
$options$.onErrored({
type: "self-accept-error-handler-errored",
} else {
if (options.onErrored) {
options.onErrored({
type: "self-accept-errored",
moduleId: moduleId,
error: err2,
originalError: err
error: err
});
}
if (!$options$.ignoreErrored) {
reportError(err2);
if (!options.ignoreErrored) {
reportError(err);
}
reportError(err);
}
} else {
if ($options$.onErrored) {
$options$.onErrored({
type: "self-accept-errored",
moduleId: moduleId,
error: err
});
}
if (!$options$.ignoreErrored) {
reportError(err);
}
}
}
}
return outdatedModules;
return outdatedModules;
}
};
}
$hmrInvalidateModuleHandlers$.$key$ = function (moduleId, applyHandlers) {
if (!currentUpdate) {
currentUpdate = {};
currentUpdateRuntime = [];
currentUpdateRemovedChunks = [];
applyHandlers.push(applyHandler);
}
if (!$hasOwnProperty$(currentUpdate, moduleId)) {
currentUpdate[moduleId] = $moduleFactories$[moduleId];
}
};
$hmrDownloadUpdateHandlers$.$key$ = function (
chunkIds,
removedChunks,
removedModules,
promises,
applyHandlers,
updatedModulesList
) {
applyHandlers.push(applyHandler);
currentUpdateChunks = {};
currentUpdateRemovedChunks = removedChunks;
currentUpdate = removedModules.reduce(function (obj, key) {
obj[key] = false;
return obj;
}, {});
currentUpdateRuntime = [];
chunkIds.forEach(function (chunkId) {
if (
$hasOwnProperty$($installedChunks$, chunkId) &&
$installedChunks$[chunkId] !== undefined
) {
promises.push($loadUpdateChunk$(chunkId, updatedModulesList));
currentUpdateChunks[chunkId] = true;
}
});
if ($ensureChunkHandlers$) {
$ensureChunkHandlers$.$key$Hmr = function (chunkId, promises) {
if (
currentUpdateChunks &&
!$hasOwnProperty$(currentUpdateChunks, chunkId) &&
$hasOwnProperty$($installedChunks$, chunkId) &&
$installedChunks$[chunkId] !== undefined
) {
promises.push($loadUpdateChunk$(chunkId));
currentUpdateChunks[chunkId] = true;
}
};
}
};
};

View File

@ -5,172 +5,389 @@
"use strict";
const validate = require("schema-utils");
const util = require("util");
const { version } = require("../package.json");
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
const WebpackOptionsApply = require("./WebpackOptionsApply");
const memorize = require("./util/memorize");
const validateSchema = require("./validateSchema");
const webpack = require("./webpack");
module.exports = webpack;
module.exports.WebpackOptionsApply = WebpackOptionsApply;
module.exports.validate = validateSchema.bind(null, webpackOptionsSchema);
module.exports.validateSchema = validateSchema;
module.exports.version = version;
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} Configuration */
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
/** @typedef {import("./Parser").ParserState} ParserState */
const exportPlugins = (obj, mappings) => {
for (const name of Object.keys(mappings)) {
Object.defineProperty(obj, name, {
configurable: false,
enumerable: true,
get: memorize(mappings[name])
});
}
/**
* @template {Function} T
* @param {function(): T} factory factory function
* @returns {T} function
*/
const lazyFunction = factory => {
const fac = memorize(factory);
const f = /** @type {any} */ ((...args) => {
return fac()(...args);
});
return /** @type {T} */ (f);
};
exportPlugins(module.exports, {
cli: () => require("./cli"),
AutomaticPrefetchPlugin: () => require("./AutomaticPrefetchPlugin"),
BannerPlugin: () => require("./BannerPlugin"),
Cache: () => require("./Cache"),
Compilation: () => require("./Compilation"),
Compiler: () => require("./Compiler"),
ContextExclusionPlugin: () => require("./ContextExclusionPlugin"),
ContextReplacementPlugin: () => require("./ContextReplacementPlugin"),
DefinePlugin: () => require("./DefinePlugin"),
DelegatedPlugin: () => require("./DelegatedPlugin"),
Dependency: () => require("./Dependency"),
DllPlugin: () => require("./DllPlugin"),
DllReferencePlugin: () => require("./DllReferencePlugin"),
EntryPlugin: () => require("./EntryPlugin"),
EnvironmentPlugin: () => require("./EnvironmentPlugin"),
EvalDevToolModulePlugin: () => require("./EvalDevToolModulePlugin"),
EvalSourceMapDevToolPlugin: () => require("./EvalSourceMapDevToolPlugin"),
ExternalsPlugin: () => require("./ExternalsPlugin"),
Generator: () => require("./Generator"),
HotModuleReplacementPlugin: () => require("./HotModuleReplacementPlugin"),
IgnorePlugin: () => require("./IgnorePlugin"),
JavascriptModulesPlugin: util.deprecate(
() => require("./javascript/JavascriptModulesPlugin"),
"webpack.JavascriptModulesPlugin has moved to webpack.javascript.JavascriptModulesPlugin",
"DEP_WEBPACK_JAVASCRIPT_MODULES_PLUGIN"
),
LibManifestPlugin: () => require("./LibManifestPlugin"),
LibraryTemplatePlugin: util.deprecate(
() => require("./LibraryTemplatePlugin"),
"webpack.LibraryTemplatePlugin is deprecated and has been replaced by compilation.outputOptions.library or compilation.addEntry + passing a library option",
"DEP_WEBPACK_LIBRARY_TEMPLATE_PLUGIN"
),
LoaderOptionsPlugin: () => require("./LoaderOptionsPlugin"),
LoaderTargetPlugin: () => require("./LoaderTargetPlugin"),
Module: () => require("./Module"),
ModuleFilenameHelpers: () => require("./ModuleFilenameHelpers"),
NoEmitOnErrorsPlugin: () => require("./NoEmitOnErrorsPlugin"),
NormalModule: () => require("./NormalModule"),
NormalModuleReplacementPlugin: () =>
require("./NormalModuleReplacementPlugin"),
MultiCompiler: () => require("./MultiCompiler"),
Parser: () => require("./Parser"),
PrefetchPlugin: () => require("./PrefetchPlugin"),
ProgressPlugin: () => require("./ProgressPlugin"),
ProvidePlugin: () => require("./ProvidePlugin"),
RuntimeGlobals: () => require("./RuntimeGlobals"),
RuntimeModule: () => require("./RuntimeModule"),
SingleEntryPlugin: util.deprecate(
() => require("./EntryPlugin"),
"SingleEntryPlugin was renamed to EntryPlugin",
"DEP_WEBPACK_SINGLE_ENTRY_PLUGIN"
),
SourceMapDevToolPlugin: () => require("./SourceMapDevToolPlugin"),
Stats: () => require("./Stats"),
Template: () => require("./Template"),
WatchIgnorePlugin: () => require("./WatchIgnorePlugin"),
WebpackOptionsDefaulter: util.deprecate(
() => require("./WebpackOptionsDefaulter"),
"webpack.WebpackOptionsDefaulter is deprecated and has been replaced by webpack.config.getNormalizedWebpackOptions and webpack.config.applyWebpackOptionsDefaults",
"DEP_WEBPACK_OPTIONS_DEFAULTER"
),
/**
* @template A
* @template B
* @param {A} obj input a
* @param {B} exports input b
* @returns {A & B} merged
*/
const mergeExports = (obj, exports) => {
const descriptors = Object.getOwnPropertyDescriptors(exports);
for (const name of Object.keys(descriptors)) {
const descriptor = descriptors[name];
if (descriptor.get) {
const fn = descriptor.get;
Object.defineProperty(obj, name, {
configurable: false,
enumerable: true,
get: memorize(fn)
});
} else if (typeof descriptor.value === "object") {
Object.defineProperty(obj, name, {
configurable: false,
enumerable: true,
writable: false,
value: mergeExports({}, descriptor.value)
});
} else {
throw new Error(
"Exposed values must be either a getter or an nested object"
);
}
}
return /** @type {A & B} */ (Object.freeze(obj));
};
const fn = lazyFunction(() => require("./webpack"));
module.exports = mergeExports(fn, {
get webpack() {
return require("./webpack");
},
get validate() {
const validateSchema = require("./validateSchema");
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
return options => validateSchema(webpackOptionsSchema, options);
},
get validateSchema() {
const validateSchema = require("./validateSchema");
return validateSchema;
},
get version() {
return /** @type {string} */ (require("../package.json").version);
},
get cli() {
return require("./cli");
},
get AutomaticPrefetchPlugin() {
return require("./AutomaticPrefetchPlugin");
},
get BannerPlugin() {
return require("./BannerPlugin");
},
get Cache() {
return require("./Cache");
},
get Chunk() {
return require("./Chunk");
},
get ChunkGraph() {
return require("./ChunkGraph");
},
get Compilation() {
return require("./Compilation");
},
get Compiler() {
return require("./Compiler");
},
get ContextExclusionPlugin() {
return require("./ContextExclusionPlugin");
},
get ContextReplacementPlugin() {
return require("./ContextReplacementPlugin");
},
get DefinePlugin() {
return require("./DefinePlugin");
},
get DelegatedPlugin() {
return require("./DelegatedPlugin");
},
get Dependency() {
return require("./Dependency");
},
get DllPlugin() {
return require("./DllPlugin");
},
get DllReferencePlugin() {
return require("./DllReferencePlugin");
},
get EntryPlugin() {
return require("./EntryPlugin");
},
get EnvironmentPlugin() {
return require("./EnvironmentPlugin");
},
get EvalDevToolModulePlugin() {
return require("./EvalDevToolModulePlugin");
},
get EvalSourceMapDevToolPlugin() {
return require("./EvalSourceMapDevToolPlugin");
},
get ExternalModule() {
return require("./ExternalModule");
},
get ExternalsPlugin() {
return require("./ExternalsPlugin");
},
get Generator() {
return require("./Generator");
},
get HotModuleReplacementPlugin() {
return require("./HotModuleReplacementPlugin");
},
get IgnorePlugin() {
return require("./IgnorePlugin");
},
get JavascriptModulesPlugin() {
return util.deprecate(
() => require("./javascript/JavascriptModulesPlugin"),
"webpack.JavascriptModulesPlugin has moved to webpack.javascript.JavascriptModulesPlugin",
"DEP_WEBPACK_JAVASCRIPT_MODULES_PLUGIN"
)();
},
get LibManifestPlugin() {
return require("./LibManifestPlugin");
},
get LibraryTemplatePlugin() {
return util.deprecate(
() => require("./LibraryTemplatePlugin"),
"webpack.LibraryTemplatePlugin is deprecated and has been replaced by compilation.outputOptions.library or compilation.addEntry + passing a library option",
"DEP_WEBPACK_LIBRARY_TEMPLATE_PLUGIN"
)();
},
get LoaderOptionsPlugin() {
return require("./LoaderOptionsPlugin");
},
get LoaderTargetPlugin() {
return require("./LoaderTargetPlugin");
},
get Module() {
return require("./Module");
},
get ModuleFilenameHelpers() {
return require("./ModuleFilenameHelpers");
},
get ModuleGraph() {
return require("./ModuleGraph");
},
get NoEmitOnErrorsPlugin() {
return require("./NoEmitOnErrorsPlugin");
},
get NormalModule() {
return require("./NormalModule");
},
get NormalModuleReplacementPlugin() {
return require("./NormalModuleReplacementPlugin");
},
get MultiCompiler() {
return require("./MultiCompiler");
},
get Parser() {
return require("./Parser");
},
get PrefetchPlugin() {
return require("./PrefetchPlugin");
},
get ProgressPlugin() {
return require("./ProgressPlugin");
},
get ProvidePlugin() {
return require("./ProvidePlugin");
},
get RuntimeGlobals() {
return require("./RuntimeGlobals");
},
get RuntimeModule() {
return require("./RuntimeModule");
},
get SingleEntryPlugin() {
return util.deprecate(
() => require("./EntryPlugin"),
"SingleEntryPlugin was renamed to EntryPlugin",
"DEP_WEBPACK_SINGLE_ENTRY_PLUGIN"
)();
},
get SourceMapDevToolPlugin() {
return require("./SourceMapDevToolPlugin");
},
get Stats() {
return require("./Stats");
},
get Template() {
return require("./Template");
},
get WatchIgnorePlugin() {
return require("./WatchIgnorePlugin");
},
get WebpackOptionsApply() {
return require("./WebpackOptionsApply");
},
get WebpackOptionsDefaulter() {
return util.deprecate(
() => require("./WebpackOptionsDefaulter"),
"webpack.WebpackOptionsDefaulter is deprecated and has been replaced by webpack.config.getNormalizedWebpackOptions and webpack.config.applyWebpackOptionsDefaults",
"DEP_WEBPACK_OPTIONS_DEFAULTER"
)();
},
// TODO webpack 6 deprecate
WebpackOptionsValidationError: () => validate.ValidationError,
ValidationError: () => validate.ValidationError
});
get WebpackOptionsValidationError() {
return require("schema-utils").ValidationError;
},
get ValidationError() {
return require("schema-utils").ValidationError;
},
exportPlugins((module.exports.cache = {}), {
MemoryCachePlugin: () => require("./cache/MemoryCachePlugin")
});
cache: {
get MemoryCachePlugin() {
return require("./cache/MemoryCachePlugin");
}
},
exportPlugins((module.exports.config = {}), {
getNormalizedWebpackOptions: () =>
require("./config/normalization").getNormalizedWebpackOptions,
applyWebpackOptionsDefaults: () =>
require("./config/defaults").applyWebpackOptionsDefaults
});
config: {
get getNormalizedWebpackOptions() {
return require("./config/normalization").getNormalizedWebpackOptions;
},
get applyWebpackOptionsDefaults() {
return require("./config/defaults").applyWebpackOptionsDefaults;
}
},
exportPlugins((module.exports.ids = {}), {
ChunkModuleIdRangePlugin: () => require("./ids/ChunkModuleIdRangePlugin"),
NaturalModuleIdsPlugin: () => require("./ids/NaturalModuleIdsPlugin"),
OccurrenceModuleIdsPlugin: () => require("./ids/OccurrenceModuleIdsPlugin"),
NamedModuleIdsPlugin: () => require("./ids/NamedModuleIdsPlugin"),
DeterministicModuleIdsPlugin: () =>
require("./ids/DeterministicModuleIdsPlugin"),
NamedChunkIdsPlugin: () => require("./ids/NamedChunkIdsPlugin"),
OccurrenceChunkIdsPlugin: () => require("./ids/OccurrenceChunkIdsPlugin"),
HashedModuleIdsPlugin: () => require("./ids/HashedModuleIdsPlugin")
});
ids: {
get ChunkModuleIdRangePlugin() {
return require("./ids/ChunkModuleIdRangePlugin");
},
get NaturalModuleIdsPlugin() {
return require("./ids/NaturalModuleIdsPlugin");
},
get OccurrenceModuleIdsPlugin() {
return require("./ids/OccurrenceModuleIdsPlugin");
},
get NamedModuleIdsPlugin() {
return require("./ids/NamedModuleIdsPlugin");
},
get DeterministicChunkIdsPlugin() {
return require("./ids/DeterministicChunkIdsPlugin");
},
get DeterministicModuleIdsPlugin() {
return require("./ids/DeterministicModuleIdsPlugin");
},
get NamedChunkIdsPlugin() {
return require("./ids/NamedChunkIdsPlugin");
},
get OccurrenceChunkIdsPlugin() {
return require("./ids/OccurrenceChunkIdsPlugin");
},
get HashedModuleIdsPlugin() {
return require("./ids/HashedModuleIdsPlugin");
}
},
exportPlugins((module.exports.javascript = {}), {
JavascriptModulesPlugin: () => require("./javascript/JavascriptModulesPlugin")
});
javascript: {
get JavascriptModulesPlugin() {
return require("./javascript/JavascriptModulesPlugin");
}
},
exportPlugins((module.exports.optimize = {}), {
AggressiveMergingPlugin: () => require("./optimize/AggressiveMergingPlugin"),
AggressiveSplittingPlugin: util.deprecate(
() => require("./optimize/AggressiveSplittingPlugin"),
"AggressiveSplittingPlugin is deprecated in favor of SplitChunksPlugin",
"DEP_WEBPACK_AGGRESSIVE_SPLITTING_PLUGIN"
),
LimitChunkCountPlugin: () => require("./optimize/LimitChunkCountPlugin"),
MinChunkSizePlugin: () => require("./optimize/MinChunkSizePlugin"),
ModuleConcatenationPlugin: () =>
require("./optimize/ModuleConcatenationPlugin"),
RuntimeChunkPlugin: () => require("./optimize/RuntimeChunkPlugin"),
SideEffectsFlagPlugin: () => require("./optimize/SideEffectsFlagPlugin"),
SplitChunksPlugin: () => require("./optimize/SplitChunksPlugin")
});
optimize: {
get AggressiveMergingPlugin() {
return require("./optimize/AggressiveMergingPlugin");
},
get AggressiveSplittingPlugin() {
return util.deprecate(
() => require("./optimize/AggressiveSplittingPlugin"),
"AggressiveSplittingPlugin is deprecated in favor of SplitChunksPlugin",
"DEP_WEBPACK_AGGRESSIVE_SPLITTING_PLUGIN"
)();
},
get LimitChunkCountPlugin() {
return require("./optimize/LimitChunkCountPlugin");
},
get MinChunkSizePlugin() {
return require("./optimize/MinChunkSizePlugin");
},
get ModuleConcatenationPlugin() {
return require("./optimize/ModuleConcatenationPlugin");
},
get RuntimeChunkPlugin() {
return require("./optimize/RuntimeChunkPlugin");
},
get SideEffectsFlagPlugin() {
return require("./optimize/SideEffectsFlagPlugin");
},
get SplitChunksPlugin() {
return require("./optimize/SplitChunksPlugin");
}
},
exportPlugins((module.exports.web = {}), {
FetchCompileWasmPlugin: () => require("./web/FetchCompileWasmPlugin"),
JsonpTemplatePlugin: () => require("./web/JsonpTemplatePlugin")
});
web: {
get FetchCompileWasmPlugin() {
return require("./web/FetchCompileWasmPlugin");
},
get JsonpTemplatePlugin() {
return require("./web/JsonpTemplatePlugin");
}
},
exportPlugins((module.exports.webworker = {}), {
WebWorkerTemplatePlugin: () => require("./webworker/WebWorkerTemplatePlugin")
});
webworker: {
get WebWorkerTemplatePlugin() {
return require("./webworker/WebWorkerTemplatePlugin");
}
},
exportPlugins((module.exports.node = {}), {
NodeEnvironmentPlugin: () => require("./node/NodeEnvironmentPlugin"),
NodeTemplatePlugin: () => require("./node/NodeTemplatePlugin"),
ReadFileCompileWasmPlugin: () => require("./node/ReadFileCompileWasmPlugin")
});
node: {
get NodeEnvironmentPlugin() {
return require("./node/NodeEnvironmentPlugin");
},
get NodeTemplatePlugin() {
return require("./node/NodeTemplatePlugin");
},
get ReadFileCompileWasmPlugin() {
return require("./node/ReadFileCompileWasmPlugin");
}
},
exportPlugins((module.exports.wasm = {}), {
AsyncWebAssemblyModulesPlugin: () =>
require("./wasm-async/AsyncWebAssemblyModulesPlugin")
});
wasm: {
get AsyncWebAssemblyModulesPlugin() {
return require("./wasm-async/AsyncWebAssemblyModulesPlugin");
}
},
exportPlugins((module.exports.library = {}), {
AbstractLibraryPlugin: () => require("./library/AbstractLibraryPlugin"),
EnableLibraryPlugin: () => require("./library/EnableLibraryPlugin")
});
library: {
get AbstractLibraryPlugin() {
return require("./library/AbstractLibraryPlugin");
},
get EnableLibraryPlugin() {
return require("./library/EnableLibraryPlugin");
}
},
exportPlugins((module.exports.debug = {}), {
ProfilingPlugin: () => require("./debug/ProfilingPlugin")
});
debug: {
get ProfilingPlugin() {
return require("./debug/ProfilingPlugin");
}
},
exportPlugins((module.exports.util = {}), {
createHash: () => require("./util/createHash"),
comparators: () => require("./util/comparators"),
serialization: () => require("./util/serialization")
util: {
get createHash() {
return require("./util/createHash");
},
get comparators() {
return require("./util/comparators");
},
get serialization() {
return require("./util/serialization");
}
}
});

View File

@ -118,6 +118,7 @@ class AbstractLibraryPlugin {
return result;
}
/* istanbul ignore next */
/**
* @abstract
* @param {LibraryOptions} library normalized library option

View File

@ -103,36 +103,19 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
"});",
"promises.push(installedChunkData[2] = promise);"
]),
"} else installedChunks[chunkId] = 0;",
"",
withHmr
? Template.asString([
"if(currentUpdateChunks && currentUpdateChunks[chunkId]) promises.push(loadUpdateChunk(chunkId));"
])
: "// no HMR"
"} else installedChunks[chunkId] = 0;"
]),
"}"
]),
"}"
])
: Template.indent([
"installedChunks[chunkId] = 0;",
"",
withHmr
? Template.asString([
"if(currentUpdateChunks && currentUpdateChunks[chunkId]) promises.push(loadUpdateChunk(chunkId));"
])
: "// no HMR"
]),
: Template.indent(["installedChunks[chunkId] = 0;"]),
"};"
])
: "// no chunk loading",
"",
withHmr
? Template.asString([
"var currentUpdateChunks;",
"var currentUpdate;",
"var currentUpdateRuntime;",
"function loadUpdateChunk(chunkId, updatedModulesList) {",
Template.indent([
"return new Promise(function(resolve, reject) {",
@ -165,46 +148,28 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
]),
"}",
"",
`${RuntimeGlobals.hmrDownloadUpdateHandlers}.readFileVm = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
Template.indent([
"applyHandlers.push(function(options) {",
Template.indent([
"currentUpdateChunks = undefined;",
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$options\$/g, "options")
.replace(/\$updateModuleFactories\$/g, "currentUpdate")
.replace(/\$updateRuntimeModules\$/g, "currentUpdateRuntime")
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$moduleFactories\$/g,
RuntimeGlobals.moduleFactories
)
.replace(
/\/\/ \$dispose\$/g,
Template.asString([
"removedChunks.forEach(function(chunkId) { delete installedChunks[chunkId]; });"
])
)
]),
"});",
"currentUpdateChunks = {};",
"currentUpdate = removedModules.reduce(function(obj, key) { obj[key] = false; return obj; }, {});",
"currentUpdateRuntime = [];",
"chunkIds.forEach(function(chunkId) {",
Template.indent([
"if(installedChunks[chunkId] !== undefined) {",
Template.indent([
"promises.push(loadUpdateChunk(chunkId, updatedModulesList));"
]),
"}",
"currentUpdateChunks[chunkId] = true;"
]),
"});"
]),
"};"
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$key\$/g, "readFileVm")
.replace(/\$installedChunks\$/g, "installedChunks")
.replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
.replace(
/\$ensureChunkHandlers\$/g,
RuntimeGlobals.ensureChunkHandlers
)
.replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$hmrDownloadUpdateHandlers\$/g,
RuntimeGlobals.hmrDownloadUpdateHandlers
)
.replace(
/\$hmrInvalidateModuleHandlers\$/g,
RuntimeGlobals.hmrInvalidateModuleHandlers
)
])
: "// no HMR",
"",

View File

@ -95,32 +95,17 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
Template.indent("installedChunks[chunkIds[i]] = 1;")
]),
"} else installedChunks[chunkId] = 1;",
"",
withHmr
? Template.asString([
"if(currentUpdateChunks && currentUpdateChunks[chunkId]) loadUpdateChunk(chunkId);"
])
: "// no HMR"
""
]),
"}"
])
: Template.asString([
"installedChunks[chunkId] = 1;",
withHmr
? Template.asString([
"if(currentUpdateChunks && currentUpdateChunks[chunkId]) loadUpdateChunk(chunkId);"
])
: "// no HMR"
]),
: "installedChunks[chunkId] = 1;",
"};"
])
: "// no chunk loading",
"",
withHmr
? Template.asString([
"var currentUpdateChunks;",
"var currentUpdate;",
"var currentUpdateRuntime;",
"function loadUpdateChunk(chunkId, updatedModulesList) {",
Template.indent([
`var update = require("./" + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
@ -140,46 +125,28 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
]),
"}",
"",
`${RuntimeGlobals.hmrDownloadUpdateHandlers}.require = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
Template.indent([
"applyHandlers.push(function(options) {",
Template.indent([
"currentUpdateChunks = undefined;",
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$options\$/g, "options")
.replace(/\$updateModuleFactories\$/g, "currentUpdate")
.replace(/\$updateRuntimeModules\$/g, "currentUpdateRuntime")
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$moduleFactories\$/g,
RuntimeGlobals.moduleFactories
)
.replace(
/\/\/ \$dispose\$/g,
Template.asString([
"removedChunks.forEach(function(chunkId) { delete installedChunks[chunkId]; });"
])
)
]),
"});",
"currentUpdateChunks = {};",
"currentUpdate = removedModules.reduce(function(obj, key) { obj[key] = false; return obj; }, {});",
"currentUpdateRuntime = [];",
"chunkIds.forEach(function(chunkId) {",
Template.indent([
"if(installedChunks[chunkId] !== undefined) {",
Template.indent([
"loadUpdateChunk(chunkId, updatedModulesList);"
]),
"}",
"currentUpdateChunks[chunkId] = true;"
]),
"});"
]),
"};"
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$key\$/g, "require")
.replace(/\$installedChunks\$/g, "installedChunks")
.replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
.replace(
/\$ensureChunkHandlers\$/g,
RuntimeGlobals.ensureChunkHandlers
)
.replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$hmrDownloadUpdateHandlers\$/g,
RuntimeGlobals.hmrDownloadUpdateHandlers
)
.replace(
/\$hmrInvalidateModuleHandlers\$/g,
RuntimeGlobals.hmrInvalidateModuleHandlers
)
])
: "// no HMR",
"",

View File

@ -102,12 +102,12 @@ class AggressiveSplittingPlugin {
// Precompute stuff
const nameToModuleMap = new Map();
const moduleToNameMap = new Map();
const makePathsRelative = identifierUtils.makePathsRelative.bindContextCache(
compiler.context,
compiler.root
);
for (const m of compilation.modules) {
const name = identifierUtils.makePathsRelative(
compiler.context,
m.identifier(),
compiler.root
);
const name = makePathsRelative(m.identifier());
nameToModuleMap.set(name, m);
moduleToNameMap.set(m, name);
}

View File

@ -342,7 +342,7 @@ const normalizeName = name => {
};
/**
* @param {"initial"|"async"|"all"|Function} chunks the chunk filter option
* @param {OptimizationSplitChunksCacheGroup["chunks"]} chunks the chunk filter option
* @returns {ChunkFilterFunction} the chunk filter function
*/
const normalizeChunksFilter = chunks => {
@ -356,7 +356,7 @@ const normalizeChunksFilter = chunks => {
return ALL_CHUNK_FILTER;
}
if (typeof chunks === "function") {
return /** @type {ChunkFilterFunction} */ (chunks);
return chunks;
}
};

View File

@ -14,26 +14,28 @@ const LAZY_SERIALIZED_VALUE = Symbol("lazy serialization data");
* @template SerializedType
*/
class SerializerMiddleware {
/* istanbul ignore next */
/**
* @abstract
* @param {DeserializedType} data data
* @param {Object} context context object
* @returns {SerializedType|Promise<SerializedType>} serialized data
*/
serialize(data, context) {
throw new Error(
"Serializer.serialize is abstract and need to be overwritten"
);
const AbstractMethodError = require("../AbstractMethodError");
throw new AbstractMethodError();
}
/* istanbul ignore next */
/**
* @abstract
* @param {SerializedType} data data
* @param {Object} context context object
* @returns {DeserializedType|Promise<DeserializedType>} deserialized data
*/
deserialize(data, context) {
throw new Error(
"Serializer.deserialize is abstract and need to be overwritten"
);
const AbstractMethodError = require("../AbstractMethodError");
throw new AbstractMethodError();
}
/**

View File

@ -404,6 +404,10 @@ const SIMPLE_EXTRACTORS = {
collapsedGroups = true;
break;
}
const makePathsRelative = identifierUtils.makePathsRelative.bindContextCache(
context,
compilation.compiler.root
);
let depthInCollapsedGroup = 0;
for (const [origin, logEntries] of compilation.logging) {
const debugMode = loggingDebug.some(fn => fn(origin));
@ -462,9 +466,7 @@ const SIMPLE_EXTRACTORS = {
}
}
}
let name = identifierUtils
.makePathsRelative(context, origin, compilation.cache)
.replace(/\|/g, " ");
let name = makePathsRelative(origin).replace(/\|/g, " ");
if (name in object.logging) {
let i = 1;
while (`${name}#${i}` in object.logging) {

View File

@ -6,7 +6,9 @@
"use strict";
class Hash {
/* istanbul ignore next */
/**
* @abstract
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @param {string|Buffer} data data
* @param {string=} inputEncoding data encoding
@ -17,7 +19,9 @@ class Hash {
throw new AbstractMethodError();
}
/* istanbul ignore next */
/**
* @abstract
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @param {string=} encoding encoding of the return value
* @returns {string|Buffer} digest

View File

@ -173,6 +173,7 @@ class LazySet {
return this._set[Symbol.iterator]();
}
/* istanbul ignore next */
get [Symbol.toStringTag]() {
return "LazySet";
}

View File

@ -85,9 +85,7 @@ class BulkUpdateDecorator extends Hash {
}
}
/**
* istanbul ignore next
*/
/* istanbul ignore next */
class DebugHash extends Hash {
constructor() {
super();

View File

@ -7,11 +7,13 @@
const path = require("path");
/** @typedef {import("fs").Stats} NodeFsStats */
/** @typedef {function(NodeJS.ErrnoException=): void} Callback */
/** @typedef {function(NodeJS.ErrnoException=, Buffer=): void} BufferCallback */
/** @typedef {function(NodeJS.ErrnoException=, string[]=): void} StringArrayCallback */
/** @typedef {function(NodeJS.ErrnoException=, string=): void} StringCallback */
/** @typedef {function(NodeJS.ErrnoException=, import("fs").Stats=): void} StatsCallback */
/** @typedef {function(NodeJS.ErrnoException=, NodeFsStats=): void} StatsCallback */
/**
* @typedef {Object} OutputFileSystem

View File

@ -115,23 +115,13 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
jsonpScript.call("", chunk),
"document.head.appendChild(script);"
]),
"} else installedChunks[chunkId] = 0;",
"",
withHmr
? "if(currentUpdateChunks && currentUpdateChunks[chunkId]) promises.push(loadUpdateChunk(chunkId));"
: "// no HMR"
"} else installedChunks[chunkId] = 0;"
]),
"}"
]),
"}"
])
: Template.indent([
"installedChunks[chunkId] = 0;",
"",
withHmr
? "if(currentUpdateChunks && currentUpdateChunks[chunkId]) promises.push(loadUpdateChunk(chunkId));"
: "// no HMR"
])
: Template.indent(["installedChunks[chunkId] = 0;"])
)};`
])
: "// no chunk on demand loading",
@ -174,9 +164,6 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
"",
withHmr
? Template.asString([
"var currentUpdateChunks;",
"var currentUpdate;",
"var currentUpdateRuntime;",
"var currentUpdatedModulesList;",
"var waitingUpdateResolves = {};",
"function loadUpdateChunk(chunkId) {",
@ -227,54 +214,28 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
]
)};`,
"",
`${
RuntimeGlobals.hmrDownloadUpdateHandlers
}.jsonp = ${runtimeTemplate.basicFunction(
"chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList",
[
`applyHandlers.push(${runtimeTemplate.basicFunction("options", [
"currentUpdateChunks = undefined;",
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$options\$/g, "options")
.replace(/\$updateModuleFactories\$/g, "currentUpdate")
.replace(
/\$updateRuntimeModules\$/g,
"currentUpdateRuntime"
)
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$moduleFactories\$/g,
RuntimeGlobals.moduleFactories
)
.replace(
/\/\/ \$dispose\$/g,
Template.asString([
runtimeTemplate.forEach(
"chunkId",
"removedChunks",
"delete installedChunks[chunkId];"
)
])
)
])});`,
"currentUpdateChunks = {};",
`currentUpdate = removedModules.reduce(${runtimeTemplate.basicFunction(
"obj, key",
["obj[key] = false;", "return obj;"]
)}, {});`,
"currentUpdateRuntime = [];",
"currentUpdatedModulesList = updatedModulesList;",
runtimeTemplate.forEach("chunkId", "chunkIds", [
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && installedChunks[chunkId] !== undefined) {`,
Template.indent(["promises.push(loadUpdateChunk(chunkId));"]),
"}",
"currentUpdateChunks[chunkId] = true;"
])
]
)};`
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$key\$/g, "jsonp")
.replace(/\$installedChunks\$/g, "installedChunks")
.replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
.replace(
/\$ensureChunkHandlers\$/g,
RuntimeGlobals.ensureChunkHandlers
)
.replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$hmrDownloadUpdateHandlers\$/g,
RuntimeGlobals.hmrDownloadUpdateHandlers
)
.replace(
/\$hmrInvalidateModuleHandlers\$/g,
RuntimeGlobals.hmrInvalidateModuleHandlers
)
])
: "// no HMR",
"",

View File

@ -80,11 +80,23 @@ const createCompiler = rawOptions => {
};
/**
* @param {WebpackOptions | WebpackOptions[]} options options object
* @param {Callback<Stats | MultiStats>=} callback callback
* @returns {Compiler | MultiCompiler} the compiler object
* @callback WebpackFunctionSingle
* @param {WebpackOptions} options options object
* @param {Callback<Stats>=} callback callback
* @returns {Compiler} the compiler object
*/
const webpack = (options, callback) => {
/**
* @callback WebpackFunctionMulti
* @param {WebpackOptions[]} options options objects
* @param {Callback<MultiStats>=} callback callback
* @returns {MultiCompiler} the multi compiler object
*/
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ ((
options,
callback
) => {
validateSchema(webpackOptionsSchema, options);
/** @type {MultiCompiler|Compiler} */
let compiler;
@ -114,6 +126,6 @@ const webpack = (options, callback) => {
}
}
return compiler;
};
});
module.exports = webpack;

View File

@ -69,11 +69,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
Template.indent("installedChunks[chunkIds.pop()] = 1;")
]),
"};",
`importScripts(${RuntimeGlobals.getChunkScriptFilename}(chunkId));`,
"",
withHmr
? "if(currentUpdateChunks && currentUpdateChunks[chunkId]) loadUpdateChunk(chunkId);"
: "// no HMR"
`importScripts(${RuntimeGlobals.getChunkScriptFilename}(chunkId));`
]),
"}"
]),
@ -83,9 +79,6 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
"",
withHmr
? Template.asString([
"var currentUpdateChunks;",
"var currentUpdate;",
"var currentUpdateRuntime;",
"function loadUpdateChunk(chunkId, updatedModulesList) {",
Template.indent([
"var success = false;",
@ -113,46 +106,28 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
]),
"}",
"",
`${RuntimeGlobals.hmrDownloadUpdateHandlers}.jsonp = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
Template.indent([
"applyHandlers.push(function(options) {",
Template.indent([
"currentUpdateChunks = undefined;",
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$options\$/g, "options")
.replace(/\$updateModuleFactories\$/g, "currentUpdate")
.replace(/\$updateRuntimeModules\$/g, "currentUpdateRuntime")
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$moduleFactories\$/g,
RuntimeGlobals.moduleFactories
)
.replace(
/\/\/ \$dispose\$/g,
Template.asString([
"removedChunks.forEach(function(chunkId) { delete installedChunks[chunkId]; });"
])
)
]),
"});",
"currentUpdateChunks = {};",
"currentUpdate = removedModules.reduce(function(obj, key) { obj[key] = false; return obj; }, {});",
"currentUpdateRuntime = [];",
"chunkIds.forEach(function(chunkId) {",
Template.indent([
"if(installedChunks[chunkId] !== undefined) {",
Template.indent([
"promises.push(loadUpdateChunk(chunkId, updatedModulesList));"
]),
"}",
"currentUpdateChunks[chunkId] = true;"
]),
"});"
]),
"}"
Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$key\$/g, "importScrips")
.replace(/\$installedChunks\$/g, "installedChunks")
.replace(/\$loadUpdateChunk\$/g, "loadUpdateChunk")
.replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
.replace(/\$moduleFactories\$/g, RuntimeGlobals.moduleFactories)
.replace(
/\$ensureChunkHandlers\$/g,
RuntimeGlobals.ensureChunkHandlers
)
.replace(/\$hasOwnProperty\$/g, RuntimeGlobals.hasOwnProperty)
.replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
.replace(
/\$hmrDownloadUpdateHandlers\$/g,
RuntimeGlobals.hmrDownloadUpdateHandlers
)
.replace(
/\$hmrInvalidateModuleHandlers\$/g,
RuntimeGlobals.hmrInvalidateModuleHandlers
)
])
: "// no HMR",
"",

View File

@ -1,6 +1,6 @@
{
"name": "webpack",
"version": "5.0.0-beta.14",
"version": "5.0.0-beta.15",
"author": "Tobias Koppers @sokra",
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
"license": "MIT",
@ -31,8 +31,8 @@
"devDependencies": {
"@babel/core": "^7.7.2",
"@types/estree": "0.0.42",
"@types/jest": "^25.1.5",
"@types/node": "^12.6.9",
"@yarnpkg/lockfile": "^1.1.0",
"babel-loader": "^8.0.6",
"benchmark": "^2.1.1",
"bundle-loader": "~0.5.0",
@ -50,14 +50,12 @@
"eslint-plugin-prettier": "^3.1.0",
"file-loader": "^4.1.0",
"fork-ts-checker-webpack-plugin": "^1.5.0",
"glob": "^7.1.3",
"husky": "^4.2.3",
"istanbul": "^0.4.5",
"jest": "^25.1.0",
"jest-diff": "^25.1.0",
"jest-junit": "^10.0.0",
"json-loader": "^0.5.7",
"json-schema-to-typescript": "^8.1.0",
"json5": "^2.1.1",
"less": "^3.9.0",
"less-loader": "^5.0.0",
@ -81,6 +79,7 @@
"strip-ansi": "^6.0.0",
"style-loader": "^1.0.0",
"toml": "^3.0.0",
"tooling": "webpack/tooling#v1.2.0",
"ts-loader": "^6.0.4",
"typescript": "^3.6.4",
"url-loader": "^2.1.0",
@ -104,13 +103,15 @@
"homepage": "https://github.com/webpack/webpack",
"main": "lib/index.js",
"bin": "./bin/webpack.js",
"types": "types.d.ts",
"files": [
"lib/",
"bin/",
"declarations/",
"hot/",
"schemas/",
"SECURITY.md"
"SECURITY.md",
"types.d.ts"
],
"scripts": {
"setup": "node ./setup/setup.js",
@ -130,25 +131,25 @@
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
"pretest": "yarn lint",
"prelint": "yarn setup",
"lint": "yarn code-lint && yarn jest-lint && yarn type-lint && yarn special-lint && yarn pretty-lint && yarn spellcheck",
"lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-lint && yarn pretty-lint && yarn spellcheck",
"code-lint": "eslint . --ext '.js' --cache",
"type-lint": "tsc --pretty",
"type-lint": "tsc",
"typings-lint": "tsc -p tsconfig.test.json",
"spellcheck": "cspell \"{.github,benchmark,bin,examples,hot,lib,schemas,setup,tooling}/**/*.{md,yml,yaml,js,json}\" \"*.md\"",
"special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/format-file-header && node tooling/compile-to-definitions",
"special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/format-file-header --write && node tooling/compile-to-definitions --write",
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/generate-types",
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/generate-types --write",
"fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
"pretty-lint-base": "prettier \"*.{ts,json,yml,yaml,md}\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.json\" \"examples/*.md\"",
"pretty-lint-base-all": "yarn pretty-lint-base \"*.js\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/helpers/*.js\" \"test/{configCases,watchCases,statsCases,hotCases,benchmarkCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
"pretty-lint-fix": "yarn pretty-lint-base-all --loglevel warn --write",
"pretty-lint": "yarn pretty-lint-base --check",
"jest-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
"cover": "yarn cover:all && yarn cover:report",
"cover:all": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --coverage",
"cover:basic": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/te{st/TestCasesNormal,st/StatsTestCases,st/ConfigTestCases}.test.js\" --coverage",
"cover:integration": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\" --coverage",
"cover:unit": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
"cover:types": "node tooling/type-coverage.js",
"cover:types": "node node_modules/tooling/type-coverage",
"cover:report": "istanbul report"
},
"husky": {

View File

@ -42,7 +42,7 @@
"description": "Report the first error as a hard error instead of tolerating it.",
"type": "boolean"
},
"Cache": {
"CacheOptions": {
"description": "Cache generated modules and chunks to improve performance for multiple incremental builds.",
"anyOf": [
{
@ -50,11 +50,11 @@
"enum": [true]
},
{
"$ref": "#/definitions/CacheNormalized"
"$ref": "#/definitions/CacheOptionsNormalized"
}
]
},
"CacheNormalized": {
"CacheOptionsNormalized": {
"description": "Cache generated modules and chunks to improve performance for multiple incremental builds.",
"anyOf": [
{
@ -878,7 +878,7 @@
"description": "Enable production optimizations or development hints.",
"enum": ["development", "production", "none"]
},
"Module": {
"ModuleOptions": {
"description": "Options affecting the normal modules (`NormalModuleFactory`).",
"type": "object",
"additionalProperties": false,
@ -1248,7 +1248,8 @@
"enum": ["initial", "async", "all"]
},
{
"$ref": "#/definitions/OptimizationSplitChunksGetCacheGroups"
"instanceof": "Function",
"tsType": "((chunk: import('../lib/Chunk')) => boolean)"
}
]
},
@ -1459,7 +1460,7 @@
},
{
"instanceof": "Function",
"tsType": "Function"
"tsType": "((chunk: import('../lib/Chunk')) => boolean)"
}
]
},
@ -2572,7 +2573,7 @@
},
{
"instanceof": "Function",
"tsType": "((data: object) => RuleSetUseItem[])"
"tsType": "((data: { resource: string, realResource: string, resourceQuery: string, issuer: string, compiler: string }) => RuleSetUseItem[])"
},
{
"$ref": "#/definitions/RuleSetUseItem"
@ -2626,28 +2627,6 @@
"description": "Prefixes every line of the source in the bundle with this string.",
"type": "string"
},
"Stats": {
"description": "Stats options object or preset name.",
"anyOf": [
{
"enum": [
"none",
"errors-only",
"minimal",
"normal",
"detailed",
"verbose",
"errors-warnings"
]
},
{
"type": "boolean"
},
{
"$ref": "#/definitions/StatsOptions"
}
]
},
"StatsOptions": {
"description": "Stats options object.",
"type": "object",
@ -2944,6 +2923,28 @@
}
}
},
"StatsValue": {
"description": "Stats options object or preset name.",
"anyOf": [
{
"enum": [
"none",
"errors-only",
"minimal",
"normal",
"detailed",
"verbose",
"errors-warnings"
]
},
{
"type": "boolean"
},
{
"$ref": "#/definitions/StatsOptions"
}
]
},
"StrictModuleExceptionHandling": {
"description": "Handles exceptions in module loading correctly at a performance cost.",
"type": "boolean"
@ -3045,7 +3046,7 @@
"$ref": "#/definitions/Bail"
},
"cache": {
"$ref": "#/definitions/CacheNormalized"
"$ref": "#/definitions/CacheOptionsNormalized"
},
"context": {
"$ref": "#/definitions/Context"
@ -3081,7 +3082,7 @@
"$ref": "#/definitions/Mode"
},
"module": {
"$ref": "#/definitions/Module"
"$ref": "#/definitions/ModuleOptions"
},
"name": {
"$ref": "#/definitions/Name"
@ -3120,7 +3121,7 @@
"$ref": "#/definitions/ResolveLoader"
},
"stats": {
"$ref": "#/definitions/Stats"
"$ref": "#/definitions/StatsValue"
},
"target": {
"$ref": "#/definitions/Target"
@ -3179,7 +3180,7 @@
"$ref": "#/definitions/Bail"
},
"cache": {
"$ref": "#/definitions/Cache"
"$ref": "#/definitions/CacheOptions"
},
"context": {
"$ref": "#/definitions/Context"
@ -3215,7 +3216,7 @@
"$ref": "#/definitions/Mode"
},
"module": {
"$ref": "#/definitions/Module"
"$ref": "#/definitions/ModuleOptions"
},
"name": {
"$ref": "#/definitions/Name"
@ -3257,7 +3258,7 @@
"$ref": "#/definitions/ResolveLoader"
},
"stats": {
"$ref": "#/definitions/Stats"
"$ref": "#/definitions/StatsValue"
},
"target": {
"$ref": "#/definitions/Target"

View File

@ -1,27 +0,0 @@
const fs = require("graceful-fs");
const path = require("path");
const lockfile = require("@yarnpkg/lockfile");
const file = fs.readFileSync(path.resolve(__dirname, "../yarn.lock"), "utf-8");
const result = lockfile.parse(file);
describe("Dependencies", () => {
it("should parse fine", () => {
expect(result.type).toBe("success");
});
if (result.type === "success") {
const content = result.object;
for (const dep of Object.keys(content)) {
describe(dep, () => {
const info = content[dep];
it("should resolve to an npm package", () => {
expect(info.resolved).toMatch(/^https:\/\/registry\.yarnpkg\.com\//);
});
it("should have an integrity hash", () => {
expect(info.integrity).toMatch(/^(sha1|sha512)-/);
});
});
}
}
});

View File

@ -38,7 +38,7 @@ describe("Persistent Caching", () => {
}
};
beforeAll(done => {
beforeEach(done => {
rimraf(tempPath, done);
});
@ -52,9 +52,9 @@ describe("Persistent Caching", () => {
}
};
const compile = async () => {
const compile = async (configAdditions = {}) => {
return new Promise((resolve, reject) => {
webpack(config, (err, stats) => {
webpack({ ...config, ...configAdditions }, (err, stats) => {
if (err) return reject(err);
resolve(stats);
});
@ -99,4 +99,28 @@ export default ${files.map((_, i) => `f${i}`).join(" + ")};
expect(cacheFiles.length).toBeLessThan(20);
expect(cacheFiles.length).toBeGreaterThan(10);
}, 60000);
it("should optimize unused content", async () => {
const data = {
"a.js": 'import "react-dom";',
"b.js": 'import "acorn";',
"c.js": 'import "core-js";',
"d.js": 'import "date-fns";',
"e.js": 'import "lodash";'
};
const createEntry = items => {
const entry = {};
for (const item of items.split("")) entry[item] = `./src/${item}.js`;
return entry;
};
await updateSrc(data);
await compile({ entry: createEntry("abcde") });
await compile({ entry: createEntry("abc") });
await compile({ entry: createEntry("cde") });
await compile({ entry: createEntry("acd") });
await compile({ entry: createEntry("bce") });
await compile({ entry: createEntry("abcde") });
const cacheFiles = await readdir(cachePath);
expect(cacheFiles.length).toBeGreaterThan(4);
}, 60000);
});

View File

@ -9,13 +9,16 @@ let webpack;
describe("ProgressPlugin", function () {
let stderr;
let stdout;
beforeEach(() => {
stderr = captureStdio(process.stderr, true);
stdout = captureStdio(process.stdout, true);
webpack = require("..");
});
afterEach(() => {
stderr && stderr.restore();
stdout && stdout.restore();
});
it("should not contain NaN as a percentage when it is applied to MultiCompiler", () => {
@ -27,6 +30,27 @@ describe("ProgressPlugin", function () {
});
});
it("should print profile information", () => {
const compiler = createSimpleCompiler({
profile: true
});
return RunCompilerAsync(compiler).then(() => {
const logs = getLogs(stderr.toString());
expect(logs).toContainEqual(
expect.stringMatching(
/^ {4}\[webpack\.Progress\] \d+ ms module ids DeterministicModuleIdsPlugin\n$/
)
);
expect(logs).toContainEqual(
expect.stringMatching(
/^ {4}\[webpack\.Progress\] \d+ ms(?: \(-\d+ ms\))? module ids\n$/
)
);
});
});
it("should not print lines longer than stderr.columns", () => {
const compiler = createSimpleCompiler();
process.stderr.columns = 36;
@ -114,7 +138,10 @@ const createMultiCompiler = () => {
const createSimpleCompiler = progressOptions => {
const compiler = webpack({
context: path.join(__dirname, "fixtures"),
entry: "./a.js"
entry: "./a.js",
infrastructureLogging: {
debug: /Progress/
}
});
compiler.outputFileSystem = createFsFromVolume(new Volume());

View File

@ -1,209 +0,0 @@
"use strict";
const fs = require("graceful-fs");
const path = require("path");
const glob = require("glob");
const rootDir = path.resolve(__dirname, "..");
describe("Schemas", () => {
const schemas = glob.sync("schemas/**/*.json", {
cwd: rootDir
});
schemas.forEach(filename => {
describe(filename, () => {
let content;
let fileContent;
let errorWhileParsing;
try {
fileContent = fs.readFileSync(path.resolve(rootDir, filename), "utf-8");
content = JSON.parse(fileContent);
} catch (e) {
errorWhileParsing = e;
}
it("should be parse-able", () => {
if (errorWhileParsing) throw errorWhileParsing;
});
if (content) {
const arrayProperties = ["oneOf", "anyOf", "allOf"];
const allowedProperties = [
"definitions",
"$ref",
"$id",
"title",
"cli",
"items",
"properties",
"additionalProperties",
"type",
"oneOf",
"anyOf",
"absolutePath",
"description",
"enum",
"minLength",
"pattern",
"minimum",
"maximum",
"required",
"uniqueItems",
"minItems",
"minProperties",
"instanceof",
"tsType",
"not"
];
const isReference = schema => {
return (
"$ref" in schema ||
("oneOf" in schema &&
schema.oneOf.length === 1 &&
"$ref" in schema.oneOf[0])
);
};
const validateProperty = property => {
if (isReference(property)) return;
it("should have description set", () => {
expect(typeof property.description).toBe("string");
expect(property.description.length).toBeGreaterThan(1);
expect(property.description).toMatch(/^[A-Z`]/);
expect(property.description).toEndWith(".");
expect(property.description).not.toEndWith("..");
});
};
const walker = item => {
it("should only use allowed schema properties", () => {
const otherProperties = Object.keys(item).filter(
p => allowedProperties.indexOf(p) < 0
);
if (otherProperties.length > 0) {
throw new Error(
`The properties ${otherProperties.join(
", "
)} are not allowed to use`
);
// When allowing more properties make sure to add nice error messages for them in WebpackOptionsValidationError
}
});
if ("$ref" in item) {
it("should not have other properties next to $ref", () => {
const otherProperties = Object.keys(item).filter(
p => p !== "$ref"
);
if (otherProperties.length > 0) {
throw new Error(
`When using $ref other properties are not possible (${otherProperties.join(
", "
)})`
);
}
});
}
if ("type" in item) {
it("should have a single type", () => {
expect(item.type).toBeTypeOf("string");
});
}
if ("instanceof" in item) {
it("should have tsType specified when using instanceof", () => {
if (!("tsType" in item)) {
throw new Error("When using instanceof, tsType is required");
}
});
}
if ("absolutePath" in item) {
it("should have type: 'string' specified when using absolutePath", () => {
if (item.type !== "string") {
throw new Error(
"When using absolutePath, type must be 'string'"
);
}
});
}
if ("properties" in item || "additionalProperties" in item) {
it("should have type: 'object' specified when using properties or additionalProperties", () => {
if (item.type !== "object") {
throw new Error(
"When using properties or additionalProperties, type must be 'object'"
);
}
});
}
arrayProperties.forEach(prop => {
if (prop in item) {
describe(prop, () => {
it("should not double nest array properties", () => {
for (const nestedProp of arrayProperties) {
for (const value of item[prop])
expect(value).not.toHaveProperty(nestedProp);
}
});
if (prop === "oneOf") {
it("should have only one item which is a $ref", () => {
expect(item[prop].length).toBe(1);
expect(Object.keys(item[prop][0])).toEqual(["$ref"]);
});
} else {
it("should have multiple items", () => {
expect(item[prop].length).toBeGreaterThan(1);
});
}
item[prop].forEach(walker);
});
}
});
if ("items" in item) {
describe("items", () => {
validateProperty(item.items);
walker(item.items);
});
}
if ("definitions" in item) {
Object.keys(item.definitions).forEach(name => {
describe(`#${name}`, () => {
const def = item.definitions[name];
it("should have description set", () => {
expect(typeof def.description).toBe("string");
expect(def.description.length).toBeGreaterThan(1);
});
walker(def);
});
});
}
if ("properties" in item) {
it("should have additionalProperties set to some value when describing properties", () => {
expect(item.additionalProperties).toBeDefined();
});
Object.keys(item.properties).forEach(name => {
describe(`> '${name}'`, () => {
const property = item.properties[name];
validateProperty(property);
walker(property);
});
});
}
if (typeof item.additionalProperties === "object") {
describe("properties", () => {
validateProperty(item.additionalProperties);
walker(item.additionalProperties);
});
}
};
walker(content);
}
});
});
});

View File

@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`StatsTestCases should print correct stats for aggressive-splitting-entry 1`] = `
"Hash: 04643923d1e5b3d9b4e64c2917d507e71f03c5bf
"Hash: 70451bfc89d3718807c8e248e9e5e0b2dd571a44
Child fitting:
Hash: 04643923d1e5b3d9b4e6
Hash: 70451bfc89d3718807c8
Time: X ms
Built at: 1970-04-20 12:42:42
PublicPath: (none)
Asset Size
fitting-0046e6aef2622051a0a3.js 13.2 KiB [emitted] [immutable]
fitting-1e85d2c6a3bb53369456.js 1.91 KiB [emitted] [immutable]
fitting-32fa512a201604f3e8b7.js 1.08 KiB [emitted] [immutable]
fitting-64ea4fa3fe9d8c4817d8.js 1.91 KiB [emitted] [immutable]
Entrypoint main = fitting-1e85d2c6a3bb53369456.js fitting-64ea4fa3fe9d8c4817d8.js fitting-0046e6aef2622051a0a3.js
chunk fitting-0046e6aef2622051a0a3.js 1.87 KiB (javascript) 6.63 KiB (runtime) [entry] [rendered]
fitting-8c5036027c59f3e9a4a5.js 13.1 KiB [emitted] [immutable]
Entrypoint main = fitting-1e85d2c6a3bb53369456.js fitting-64ea4fa3fe9d8c4817d8.js fitting-8c5036027c59f3e9a4a5.js
chunk fitting-8c5036027c59f3e9a4a5.js 1.87 KiB (javascript) 6.62 KiB (runtime) [entry] [rendered]
> ./index main
./e.js 899 bytes [built]
./f.js 900 bytes [built]
@ -31,7 +31,7 @@ Child fitting:
> ./g ./index.js 7:0-13
./g.js 916 bytes [built]
Child content-change:
Hash: 4c2917d507e71f03c5bf
Hash: e248e9e5e0b2dd571a44
Time: X ms
Built at: 1970-04-20 12:42:42
PublicPath: (none)
@ -39,9 +39,9 @@ Child content-change:
content-change-1e85d2c6a3bb53369456.js 1.91 KiB [emitted] [immutable]
content-change-32fa512a201604f3e8b7.js 1.08 KiB [emitted] [immutable]
content-change-64ea4fa3fe9d8c4817d8.js 1.91 KiB [emitted] [immutable]
content-change-e59e7c1b76d46146f969.js 13.2 KiB [emitted] [immutable]
Entrypoint main = content-change-1e85d2c6a3bb53369456.js content-change-64ea4fa3fe9d8c4817d8.js content-change-e59e7c1b76d46146f969.js
chunk content-change-e59e7c1b76d46146f969.js 1.87 KiB (javascript) 6.64 KiB (runtime) [entry] [rendered]
content-change-e66ad755b1c39cc2ae4a.js 13.2 KiB [emitted] [immutable]
Entrypoint main = content-change-1e85d2c6a3bb53369456.js content-change-64ea4fa3fe9d8c4817d8.js content-change-e66ad755b1c39cc2ae4a.js
chunk content-change-e66ad755b1c39cc2ae4a.js 1.87 KiB (javascript) 6.62 KiB (runtime) [entry] [rendered]
> ./index main
./e.js 899 bytes [built]
./f.js 900 bytes [built]
@ -61,13 +61,14 @@ Child content-change:
`;
exports[`StatsTestCases should print correct stats for aggressive-splitting-on-demand 1`] = `
"Hash: 92339c1f044fa965d380
"Hash: 21f9ed5ab7a127d97c1a
Time: X ms
Built at: 1970-04-20 12:42:42
PublicPath: (none)
Asset Size
1c8f0f5fb926b811c0e5.js 1010 bytes [emitted] [immutable]
21fd8e73389271e24957.js 1.91 KiB [emitted] [immutable]
45ae21726ca0cc660a47.js 9.19 KiB [emitted] [immutable] [name: main]
64ea4fa3fe9d8c4817d8.js 1.91 KiB [emitted] [immutable]
6a2a05a9feb43a535129.js 1.91 KiB [emitted] [immutable]
ae7ced4135ed4f2282f6.js 1.91 KiB [emitted] [immutable]
@ -75,15 +76,14 @@ b4a95c5544295741de67.js 1010 bytes [emitted] [immutable]
b63bab94d02c84e0f081.js 1.91 KiB [emitted] [immutable]
db9a189ff52c97050941.js 1.91 KiB [emitted] [immutable]
de61daf57f7861bbb2f6.js 1.91 KiB [emitted] [immutable]
ed463ade3b69f0f1da84.js 9.22 KiB [emitted] [immutable] [name: main]
f80243284f4ab491b78e.js 1.91 KiB [emitted] [immutable]
fb5a5560e641649a6ed8.js 1010 bytes [emitted] [immutable]
Entrypoint main = ed463ade3b69f0f1da84.js
Entrypoint main = 45ae21726ca0cc660a47.js
chunk 64ea4fa3fe9d8c4817d8.js 1.76 KiB [rendered] [recorded] aggressive splitted
> ./c ./d ./e ./index.js 3:0-30
./c.js 899 bytes [built]
./d.js 899 bytes [built]
chunk ed463ade3b69f0f1da84.js (main) 248 bytes (javascript) 4.51 KiB (runtime) [entry] [rendered]
chunk 45ae21726ca0cc660a47.js (main) 248 bytes (javascript) 4.49 KiB (runtime) [entry] [rendered]
> ./index main
./index.js 248 bytes [built]
+ 5 hidden chunk modules
@ -149,7 +149,7 @@ Entrypoint main = bundle.js (6eef074bdaf47143a239.png static/file.html)
exports[`StatsTestCases should print correct stats for async-commons-chunk 1`] = `
"Entrypoint main = main.js
chunk main.js (main) 515 bytes (javascript) 4.19 KiB (runtime) >{460}< >{847}< >{996}< [entry] [rendered]
chunk main.js (main) 515 bytes (javascript) 4.18 KiB (runtime) >{460}< >{847}< >{996}< [entry] [rendered]
> ./ main
./index.js 515 bytes [built]
+ 5 hidden root modules
@ -181,7 +181,7 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
+ 1 hidden dependent module
chunk disabled/main.js (main) 147 bytes (javascript) 4.84 KiB (runtime) [entry] [rendered]
chunk disabled/main.js (main) 147 bytes (javascript) 4.82 KiB (runtime) [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -198,7 +198,7 @@ exports[`StatsTestCases should print correct stats for async-commons-chunk-auto
./c.js + 1 modules 107 bytes [built]
+ 3 hidden root modules
+ 3 hidden dependent modules
chunk disabled/a.js (a) 216 bytes (javascript) 4.78 KiB (runtime) [entry] [rendered]
chunk disabled/a.js (a) 216 bytes (javascript) 4.77 KiB (runtime) [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -220,7 +220,7 @@ Child default:
chunk default/async-g.js (async-g) 34 bytes [rendered]
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
chunk default/main.js (main) 147 bytes (javascript) 4.85 KiB (runtime) [entry] [rendered]
chunk default/main.js (main) 147 bytes (javascript) 4.83 KiB (runtime) [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -253,7 +253,7 @@ Child default:
chunk default/769.js (id hint: vendors) 20 bytes [rendered] split chunk (cache group: defaultVendors)
> ./c ./index.js 3:0-47
./node_modules/z.js 20 bytes [built]
chunk default/a.js (a) 216 bytes (javascript) 4.84 KiB (runtime) [entry] [rendered]
chunk default/a.js (a) 216 bytes (javascript) 4.82 KiB (runtime) [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -279,7 +279,7 @@ Child vendors:
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
+ 1 hidden dependent module
chunk vendors/main.js (main) 147 bytes (javascript) 4.84 KiB (runtime) [entry] [rendered]
chunk vendors/main.js (main) 147 bytes (javascript) 4.82 KiB (runtime) [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -303,7 +303,7 @@ Child vendors:
./c.js 72 bytes [built]
+ 4 hidden root modules
+ 2 hidden dependent modules
chunk vendors/a.js (a) 176 bytes (javascript) 5.95 KiB (runtime) [entry] [rendered]
chunk vendors/a.js (a) 176 bytes (javascript) 5.94 KiB (runtime) [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -333,7 +333,7 @@ Child multiple-vendors:
chunk multiple-vendors/async-g.js (async-g) 34 bytes [rendered]
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
chunk multiple-vendors/main.js (main) 147 bytes (javascript) 4.87 KiB (runtime) [entry] [rendered]
chunk multiple-vendors/main.js (main) 147 bytes (javascript) 4.86 KiB (runtime) [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -365,7 +365,7 @@ Child multiple-vendors:
> ./c ./index.js 3:0-47
> ./c c
./node_modules/z.js 20 bytes [built]
chunk multiple-vendors/a.js (a) 156 bytes (javascript) 6 KiB (runtime) [entry] [rendered]
chunk multiple-vendors/a.js (a) 156 bytes (javascript) 5.99 KiB (runtime) [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -391,7 +391,7 @@ Child all:
chunk all/async-g.js (async-g) 34 bytes [rendered]
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
chunk all/main.js (main) 147 bytes (javascript) 4.84 KiB (runtime) [entry] [rendered]
chunk all/main.js (main) 147 bytes (javascript) 4.83 KiB (runtime) [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -431,7 +431,7 @@ Child all:
> ./c ./index.js 3:0-47
> ./c c
./node_modules/z.js 20 bytes [built]
chunk all/a.js (a) 156 bytes (javascript) 5.99 KiB (runtime) [entry] [rendered]
chunk all/a.js (a) 156 bytes (javascript) 5.98 KiB (runtime) [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -473,7 +473,7 @@ chunk main1.js (main1) 136 bytes [entry] [rendered]
`;
exports[`StatsTestCases should print correct stats for chunks 1`] = `
"Hash: ceb0547564135a0a6c0c
"Hash: 02575b74aab5a2ac7302
Time: X ms
Built at: 1970-04-20 12:42:42
PublicPath: (none)
@ -481,9 +481,9 @@ PublicPath: (none)
460.bundle.js 324 bytes [emitted]
524.bundle.js 210 bytes [emitted]
996.bundle.js 142 bytes [emitted]
bundle.js 7.74 KiB [emitted] [name: main]
bundle.js 7.71 KiB [emitted] [name: main]
Entrypoint main = bundle.js
chunk bundle.js (main) 73 bytes (javascript) 4.2 KiB (runtime) >{460}< >{996}< [entry] [rendered]
chunk bundle.js (main) 73 bytes (javascript) 4.19 KiB (runtime) >{460}< >{996}< [entry] [rendered]
> ./index main
./a.js 22 bytes [built]
cjs self exports reference ./a.js 1:0-14
@ -517,13 +517,13 @@ chunk 996.bundle.js 22 bytes <{179}> [rendered]
`;
exports[`StatsTestCases should print correct stats for chunks-development 1`] = `
"Hash: 9a94c2757a36b51de23c
"Hash: 84a61a5e2153e565ad2d
Time: X ms
Built at: 1970-04-20 12:42:42
PublicPath: (none)
Asset Size
b_js.bundle.js 982 bytes [emitted]
bundle.js 8.96 KiB [emitted] [name: main]
bundle.js 8.92 KiB [emitted] [name: main]
c_js.bundle.js 1.18 KiB [emitted]
d_js-e_js.bundle.js 1.4 KiB [emitted]
Entrypoint main = bundle.js
@ -548,7 +548,7 @@ chunk d_js-e_js.bundle.js 60 bytes <{c_js}> [rendered]
require.ensure item ./e ./c.js 1:0-52
cjs self exports reference ./e.js 2:0-14
X ms -> X ms -> X ms (resolving: X ms, restoring: X ms, integration: X ms, building: X ms, storing: X ms)
chunk bundle.js (main) 73 bytes (javascript) 4.2 KiB (runtime) >{b_js}< >{c_js}< [entry] [rendered]
chunk bundle.js (main) 73 bytes (javascript) 4.19 KiB (runtime) >{b_js}< >{c_js}< [entry] [rendered]
> ./index main
./a.js 22 bytes [built]
cjs self exports reference ./a.js 1:0-14
@ -565,7 +565,7 @@ exports[`StatsTestCases should print correct stats for circular-correctness 1`]
"Entrypoint main = bundle.js
chunk 128.bundle.js (b) 49 bytes <{179}> <{459}> >{459}< [rendered]
./module-b.js 49 bytes [built]
chunk bundle.js (main) 98 bytes (javascript) 5.43 KiB (runtime) >{128}< >{786}< [entry] [rendered]
chunk bundle.js (main) 98 bytes (javascript) 5.42 KiB (runtime) >{128}< >{786}< [entry] [rendered]
./index.js 98 bytes [built]
+ 8 hidden chunk modules
chunk 459.bundle.js (c) 98 bytes <{128}> <{786}> >{128}< >{786}< [rendered]
@ -684,52 +684,52 @@ exports[`StatsTestCases should print correct stats for concat-and-sideeffects 1`
`;
exports[`StatsTestCases should print correct stats for context-independence 1`] = `
"Hash: 3c59c3d45edbe20ee0af3c59c3d45edbe20ee0af39303b7d3ef1ce28f20139303b7d3ef1ce28f201
"Hash: cc1c058603d38f2497facc1c058603d38f2497fab87c6ae33adeba417c54b87c6ae33adeba417c54
Child
Hash: 3c59c3d45edbe20ee0af
Hash: cc1c058603d38f2497fa
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
703-35b05b4f9ece3e5b7253.js 457 bytes [emitted] [immutable]
703-35b05b4f9ece3e5b7253.js.map 344 bytes [emitted] [dev]
main-322147d992bb0a885b10.js 8.02 KiB [emitted] [immutable] [name: main]
main-322147d992bb0a885b10.js.map 7.14 KiB [emitted] [dev] [name: (main)]
Entrypoint main = main-322147d992bb0a885b10.js (main-322147d992bb0a885b10.js.map)
main-cfadecfa45a71360cb9e.js 7.98 KiB [emitted] [immutable] [name: main]
main-cfadecfa45a71360cb9e.js.map 7.11 KiB [emitted] [dev] [name: (main)]
Entrypoint main = main-cfadecfa45a71360cb9e.js (main-cfadecfa45a71360cb9e.js.map)
./a/index.js 40 bytes [built]
./a/chunk.js + 1 modules 66 bytes [built]
+ 6 hidden modules
Child
Hash: 3c59c3d45edbe20ee0af
Hash: cc1c058603d38f2497fa
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
703-35b05b4f9ece3e5b7253.js 457 bytes [emitted] [immutable]
703-35b05b4f9ece3e5b7253.js.map 344 bytes [emitted] [dev]
main-322147d992bb0a885b10.js 8.02 KiB [emitted] [immutable] [name: main]
main-322147d992bb0a885b10.js.map 7.14 KiB [emitted] [dev] [name: (main)]
Entrypoint main = main-322147d992bb0a885b10.js (main-322147d992bb0a885b10.js.map)
main-cfadecfa45a71360cb9e.js 7.98 KiB [emitted] [immutable] [name: main]
main-cfadecfa45a71360cb9e.js.map 7.11 KiB [emitted] [dev] [name: (main)]
Entrypoint main = main-cfadecfa45a71360cb9e.js (main-cfadecfa45a71360cb9e.js.map)
./b/index.js 40 bytes [built]
./b/chunk.js + 1 modules 66 bytes [built]
+ 6 hidden modules
Child
Hash: 39303b7d3ef1ce28f201
Hash: b87c6ae33adeba417c54
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
703-d460da0006247c80e6fd.js 1.51 KiB [emitted] [immutable]
main-d716298143ad43b551dc.js 8.91 KiB [emitted] [immutable] [name: main]
Entrypoint main = main-d716298143ad43b551dc.js
main-cac72fdf6d5096abb062.js 8.87 KiB [emitted] [immutable] [name: main]
Entrypoint main = main-cac72fdf6d5096abb062.js
./a/index.js 40 bytes [built]
./a/chunk.js + 1 modules 66 bytes [built]
+ 6 hidden modules
Child
Hash: 39303b7d3ef1ce28f201
Hash: b87c6ae33adeba417c54
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
703-d460da0006247c80e6fd.js 1.51 KiB [emitted] [immutable]
main-d716298143ad43b551dc.js 8.91 KiB [emitted] [immutable] [name: main]
Entrypoint main = main-d716298143ad43b551dc.js
main-cac72fdf6d5096abb062.js 8.87 KiB [emitted] [immutable] [name: main]
Entrypoint main = main-cac72fdf6d5096abb062.js
./b/index.js 40 bytes [built]
./b/chunk.js + 1 modules 66 bytes [built]
+ 6 hidden modules"
@ -1096,7 +1096,7 @@ Entrypoint e2 = e2.js
chunk b.js (b) 49 bytes <{786}> >{459}< [rendered]
./module-b.js 49 bytes [built]
import() ./module-b ./module-a.js 1:0-47
chunk e1.js (e1) 49 bytes (javascript) 5.46 KiB (runtime) >{786}< [entry] [rendered]
chunk e1.js (e1) 49 bytes (javascript) 5.45 KiB (runtime) >{786}< [entry] [rendered]
./e1.js 49 bytes [built]
entry ./e1 e1
+ 8 hidden chunk modules
@ -1104,7 +1104,7 @@ chunk c.js (c) 49 bytes <{128}> <{621}> >{786}< [rendered]
./module-c.js 49 bytes [built]
import() ./module-c ./e2.js 1:0-47
import() ./module-c ./module-b.js 1:0-47
chunk e2.js (e2) 49 bytes (javascript) 5.46 KiB (runtime) >{459}< [entry] [rendered]
chunk e2.js (e2) 49 bytes (javascript) 5.45 KiB (runtime) >{459}< [entry] [rendered]
./e2.js 49 bytes [built]
entry ./e2 e2
+ 8 hidden chunk modules
@ -1120,7 +1120,7 @@ Entrypoint e2 = e2.js
chunk b.js (b) 179 bytes <{786}> >{459}< [rendered]
./module-b.js 179 bytes [built]
import() ./module-b ./module-a.js 1:0-47
chunk e1.js (e1) 119 bytes (javascript) 5.73 KiB (runtime) >{786}< >{892}< [entry] [rendered]
chunk e1.js (e1) 119 bytes (javascript) 5.71 KiB (runtime) >{786}< >{892}< [entry] [rendered]
./e1.js 70 bytes [built]
entry ./e1 e1
./module-x.js 49 bytes [built]
@ -1132,7 +1132,7 @@ chunk c.js (c) 49 bytes <{128}> <{621}> >{786}< [rendered]
./module-c.js 49 bytes [built]
import() ./module-c ./e2.js 2:0-47
import() ./module-c ./module-b.js 1:0-47
chunk e2.js (e2) 119 bytes (javascript) 5.73 KiB (runtime) >{459}< >{892}< [entry] [rendered]
chunk e2.js (e2) 119 bytes (javascript) 5.71 KiB (runtime) >{459}< >{892}< [entry] [rendered]
./e2.js 70 bytes [built]
entry ./e2 e2
./module-x.js 49 bytes [built]
@ -1170,7 +1170,7 @@ chunk id-equals-name_js0.js 1 bytes [rendered]
./id-equals-name.js 1 bytes [built]
chunk id-equals-name_js_3.js 1 bytes [rendered]
./id-equals-name.js?3 1 bytes [built]
chunk main.js (main) 639 bytes (javascript) 5.69 KiB (runtime) [entry] [rendered]
chunk main.js (main) 639 bytes (javascript) 5.67 KiB (runtime) [entry] [rendered]
./index.js 639 bytes [built]
+ 9 hidden root modules
chunk tree.js (tree) 43 bytes [rendered]
@ -1185,19 +1185,19 @@ chunk trees.js (trees) 71 bytes [rendered]
exports[`StatsTestCases should print correct stats for immutable 1`] = `
" Asset Size
459e878fcc68e6bc31b5.js 969 bytes [emitted] [immutable]
8de1e5224fd97f952d35.js 10.3 KiB [emitted] [immutable] [name: main]"
2e5c8e7789add597f0a3.js 10.3 KiB [emitted] [immutable] [name: main]
459e878fcc68e6bc31b5.js 969 bytes [emitted] [immutable]"
`;
exports[`StatsTestCases should print correct stats for import-context-filter 1`] = `
"Hash: 781698f35c52fda3a34c
"Hash: f104ca8423b75b3910da
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
398.js 484 bytes [emitted]
544.js 484 bytes [emitted]
718.js 484 bytes [emitted]
entry.js 9.44 KiB [emitted] [name: entry]
entry.js 9.41 KiB [emitted] [name: entry]
Entrypoint entry = entry.js
./entry.js 450 bytes [built]
./templates lazy ^\\\\.\\\\/.*$ include: \\\\.js$ exclude: \\\\.noimport\\\\.js$ namespace object 160 bytes [optional] [built]
@ -1208,12 +1208,12 @@ Entrypoint entry = entry.js
`;
exports[`StatsTestCases should print correct stats for import-weak 1`] = `
"Hash: 6dbe8fe5e0ca1a6a79c1
"Hash: 9ca01d0b495f60b6f5d4
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
836.js 142 bytes [emitted]
entry.js 10.1 KiB [emitted] [name: entry]
entry.js 10 KiB [emitted] [name: entry]
Entrypoint entry = entry.js
./entry.js 120 bytes [built]
./modules/b.js 22 bytes [built]
@ -1245,7 +1245,7 @@ Compilation error while processing magic comment(-s): /* webpackPrefetch: nope *
`;
exports[`StatsTestCases should print correct stats for issue-7577 1`] = `
"Hash: 240afdff8e34e13bf7c474666e54b11156c90f600bcb051f063ea4854f5a
"Hash: 240afdff8e34e13bf7c474666e54b11156c90f60d38a80cc1def96682e31
Child
Hash: 240afdff8e34e13bf7c4
Time: X ms
@ -1271,16 +1271,16 @@ Child
./node_modules/vendor.js 23 bytes [built]
+ 4 hidden modules
Child
Hash: 0bcb051f063ea4854f5a
Hash: d38a80cc1def96682e31
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
c-all-b_js-50bf184dfe57dc2022a6.js 506 bytes [emitted] [immutable] [id hint: all]
c-all-c_js-6756694a5d280748f5a3.js 397 bytes [emitted] [immutable] [id hint: all]
c-main-cd09b1722e319798c3c4.js 607 bytes [emitted] [immutable] [name: main]
c-runtime~main-b1642de27efb3100d464.js 11.5 KiB [emitted] [immutable] [name: runtime~main]
c-runtime~main-22ab6f32a8e9bb9f113b.js 11.4 KiB [emitted] [immutable] [name: runtime~main]
c-vendors-node_modules_vendor_js-a51f8ed2c8dc9ce97afd.js 189 bytes [emitted] [immutable] [id hint: vendors]
Entrypoint main = c-runtime~main-b1642de27efb3100d464.js c-all-c_js-6756694a5d280748f5a3.js c-main-cd09b1722e319798c3c4.js (prefetch: c-vendors-node_modules_vendor_js-a51f8ed2c8dc9ce97afd.js c-all-b_js-50bf184dfe57dc2022a6.js)
Entrypoint main = c-runtime~main-22ab6f32a8e9bb9f113b.js c-all-c_js-6756694a5d280748f5a3.js c-main-cd09b1722e319798c3c4.js (prefetch: c-vendors-node_modules_vendor_js-a51f8ed2c8dc9ce97afd.js c-all-b_js-50bf184dfe57dc2022a6.js)
./c.js 61 bytes [built]
./b.js 17 bytes [built]
./node_modules/vendor.js 23 bytes [built]
@ -1288,7 +1288,7 @@ Child
`;
exports[`StatsTestCases should print correct stats for limit-chunk-count-plugin 1`] = `
"Hash: 15b4b06d5bdcf1dbb31716d26c25af9645add63bd15c4ce907e30280da1c7e365bb10ae0bcc4b7e4
"Hash: 15b4b06d5bdcf1dbb3178839e7746418e3b43d364f987317c5f9ca9c6b86c4c3c120d98e5075e490
Child 1 chunks:
Hash: 15b4b06d5bdcf1dbb317
Time: X ms
@ -1305,14 +1305,14 @@ Child 1 chunks:
./index.js 101 bytes [built]
+ 4 hidden chunk modules
Child 2 chunks:
Hash: 16d26c25af9645add63b
Hash: 8839e7746418e3b43d36
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
459.bundle2.js 666 bytes [emitted] [name: c]
bundle2.js 9.65 KiB [emitted] [name: main]
bundle2.js 9.61 KiB [emitted] [name: main]
Entrypoint main = bundle2.js
chunk bundle2.js (main) 101 bytes (javascript) 5.44 KiB (runtime) >{459}< [entry] [rendered]
chunk bundle2.js (main) 101 bytes (javascript) 5.42 KiB (runtime) >{459}< [entry] [rendered]
./index.js 101 bytes [built]
+ 8 hidden chunk modules
chunk 459.bundle2.js (c) 118 bytes <{179}> <{459}> >{459}< [rendered]
@ -1322,15 +1322,15 @@ Child 2 chunks:
./d.js 22 bytes [built]
./e.js 22 bytes [built]
Child 3 chunks:
Hash: d15c4ce907e30280da1c
Hash: 4f987317c5f9ca9c6b86
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
459.bundle3.js 530 bytes [emitted] [name: c]
524.bundle3.js 210 bytes [emitted]
bundle3.js 9.65 KiB [emitted] [name: main]
bundle3.js 9.61 KiB [emitted] [name: main]
Entrypoint main = bundle3.js
chunk bundle3.js (main) 101 bytes (javascript) 5.44 KiB (runtime) >{459}< [entry] [rendered]
chunk bundle3.js (main) 101 bytes (javascript) 5.42 KiB (runtime) >{459}< [entry] [rendered]
./index.js 101 bytes [built]
+ 8 hidden chunk modules
chunk 459.bundle3.js (c) 74 bytes <{179}> >{524}< [rendered]
@ -1341,16 +1341,16 @@ Child 3 chunks:
./d.js 22 bytes [built]
./e.js 22 bytes [built]
Child 4 chunks:
Hash: 7e365bb10ae0bcc4b7e4
Hash: c4c3c120d98e5075e490
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
394.bundle4.js 210 bytes [emitted]
459.bundle4.js 394 bytes [emitted] [name: c]
524.bundle4.js 210 bytes [emitted]
bundle4.js 9.65 KiB [emitted] [name: main]
bundle4.js 9.61 KiB [emitted] [name: main]
Entrypoint main = bundle4.js
chunk bundle4.js (main) 101 bytes (javascript) 5.44 KiB (runtime) >{394}< >{459}< [entry] [rendered]
chunk bundle4.js (main) 101 bytes (javascript) 5.42 KiB (runtime) >{394}< >{459}< [entry] [rendered]
./index.js 101 bytes [built]
+ 8 hidden chunk modules
chunk 394.bundle4.js 44 bytes <{179}> [rendered]
@ -1461,7 +1461,7 @@ Entrypoint main = main.js
`;
exports[`StatsTestCases should print correct stats for module-assets 1`] = `
"Hash: a0f836f8d11fa3366e14
"Hash: 09818c8e8ab4eb5fb372
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
@ -1469,14 +1469,14 @@ Built at: 1970-04-20 12:42:42
2.png 21 KiB [emitted] [name: (a, b)]
a.js 988 bytes [emitted] [name: a]
b.js 616 bytes [emitted] [name: b]
main.js 8.98 KiB [emitted] [name: main]
main.js 8.94 KiB [emitted] [name: main]
Entrypoint main = main.js
Chunk Group a = a.js (1.png 2.png)
Chunk Group b = b.js (2.png)
chunk b.js (b) 69 bytes [rendered]
./node_modules/a/2.png 51 bytes [built] [1 asset]
./node_modules/b/index.js 18 bytes [built]
chunk main.js (main) 82 bytes (javascript) 5.04 KiB (runtime) [entry] [rendered]
chunk main.js (main) 82 bytes (javascript) 5.03 KiB (runtime) [entry] [rendered]
./index.js 82 bytes [built]
+ 8 hidden chunk modules
chunk a.js (a) 138 bytes [rendered]
@ -1507,7 +1507,7 @@ Entrypoint e2 = e2.js
Entrypoint e3 = e3.js
chunk 114.js 28 bytes [rendered]
./async1.js 28 bytes [built]
chunk e3.js (e3) 152 bytes (javascript) 5.02 KiB (runtime) [entry] [rendered]
chunk e3.js (e3) 152 bytes (javascript) 5 KiB (runtime) [entry] [rendered]
./a.js 9 bytes [built]
./b.js 9 bytes [built]
./e3.js 116 bytes [built]
@ -1516,7 +1516,7 @@ chunk e3.js (e3) 152 bytes (javascript) 5.02 KiB (runtime) [entry] [rendered]
+ 8 hidden chunk modules
chunk 172.js 28 bytes [rendered]
./async2.js 28 bytes [built]
chunk e1.js (e1) 152 bytes (javascript) 5.02 KiB (runtime) [entry] [rendered]
chunk e1.js (e1) 152 bytes (javascript) 5 KiB (runtime) [entry] [rendered]
./a.js 9 bytes [built]
./b.js 9 bytes [built]
./c.js 9 bytes [built]
@ -1528,7 +1528,7 @@ chunk 326.js 37 bytes [rendered]
./h.js 9 bytes [built]
chunk 593.js 28 bytes [rendered]
./async3.js 28 bytes [built]
chunk e2.js (e2) 152 bytes (javascript) 5.02 KiB (runtime) [entry] [rendered]
chunk e2.js (e2) 152 bytes (javascript) 5 KiB (runtime) [entry] [rendered]
./a.js 9 bytes [built]
./b.js 9 bytes [built]
./e.js 9 bytes [built]
@ -1548,20 +1548,20 @@ exports[`StatsTestCases should print correct stats for module-deduplication-name
async1.js 839 bytes [emitted] [name: async1]
async2.js 839 bytes [emitted] [name: async2]
async3.js 839 bytes [emitted] [name: async3]
e1.js 10 KiB [emitted] [name: e1]
e2.js 10 KiB [emitted] [name: e2]
e3.js 10 KiB [emitted] [name: e3]
e1.js 9.97 KiB [emitted] [name: e1]
e2.js 9.97 KiB [emitted] [name: e2]
e3.js 9.97 KiB [emitted] [name: e3]
Entrypoint e1 = e1.js
Entrypoint e2 = e2.js
Entrypoint e3 = e3.js
chunk e3.js (e3) 144 bytes (javascript) 5.07 KiB (runtime) [entry] [rendered]
chunk e3.js (e3) 144 bytes (javascript) 5.05 KiB (runtime) [entry] [rendered]
./a.js 9 bytes [built]
./b.js 9 bytes [built]
./e3.js 108 bytes [built]
./g.js 9 bytes [built]
./h.js 9 bytes [built]
+ 8 hidden chunk modules
chunk e1.js (e1) 144 bytes (javascript) 5.07 KiB (runtime) [entry] [rendered]
chunk e1.js (e1) 144 bytes (javascript) 5.05 KiB (runtime) [entry] [rendered]
./a.js 9 bytes [built]
./b.js 9 bytes [built]
./c.js 9 bytes [built]
@ -1574,7 +1574,7 @@ chunk async1.js (async1) 89 bytes [rendered]
chunk async3.js (async3) 89 bytes [rendered]
./async3.js 80 bytes [built]
./h.js 9 bytes [built]
chunk e2.js (e2) 144 bytes (javascript) 5.07 KiB (runtime) [entry] [rendered]
chunk e2.js (e2) 144 bytes (javascript) 5.05 KiB (runtime) [entry] [rendered]
./a.js 9 bytes [built]
./b.js 9 bytes [built]
./e.js 9 bytes [built]
@ -1687,7 +1687,7 @@ exports[`StatsTestCases should print correct stats for named-chunk-groups 1`] =
> ./a ./index.js 1:0-47
> ./b ./index.js 2:0-47
./shared.js 133 bytes [built]
chunk a-main.js (main) 146 bytes (javascript) 5.1 KiB (runtime) [entry] [rendered]
chunk a-main.js (main) 146 bytes (javascript) 5.08 KiB (runtime) [entry] [rendered]
> ./ main
./index.js 146 bytes [built]
+ 8 hidden root modules
@ -1713,7 +1713,7 @@ Child
> ./a ./index.js 1:0-47
> ./b ./index.js 2:0-47
./shared.js 133 bytes [built]
chunk b-main.js (main) 146 bytes (javascript) 5.1 KiB (runtime) [entry] [rendered]
chunk b-main.js (main) 146 bytes (javascript) 5.08 KiB (runtime) [entry] [rendered]
> ./ main
./index.js 146 bytes [built]
+ 8 hidden root modules
@ -1748,11 +1748,11 @@ Entrypoint entry = vendor.js entry.js
`;
exports[`StatsTestCases should print correct stats for named-chunks-plugin-async 1`] = `
"Hash: 7abbbbb49488363d0624
"Hash: 13f3946adc937dfdcf61
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
entry.js 9.51 KiB [emitted] [name: entry]
entry.js 9.48 KiB [emitted] [name: entry]
modules_a_js.js 316 bytes [emitted]
modules_b_js.js 153 bytes [emitted]
Entrypoint entry = entry.js
@ -1777,7 +1777,7 @@ You can also set it to 'none' to disable any default behavior. Learn more: https
`;
exports[`StatsTestCases should print correct stats for optimize-chunks 1`] = `
"Hash: 7d84007dec272e753c2e
"Hash: fa01130d44bca49cd773
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size Chunks
@ -1788,13 +1788,13 @@ Built at: 1970-04-20 12:42:42
cir1.js 334 bytes {592} [emitted] [name: cir1]
cir2 from cir1.js 378 bytes {288}, {289} [emitted] [name: cir2 from cir1]
cir2.js 334 bytes {289} [emitted] [name: cir2]
main.js 8.54 KiB {179} [emitted] [name: main]
main.js 8.51 KiB {179} [emitted] [name: main]
Entrypoint main = main.js
chunk {90} ab.js (ab) 2 bytes <{179}> >{753}< [rendered]
> [10] ./index.js 1:0-6:8
[839] ./modules/a.js 1 bytes {90} {374} [built]
[836] ./modules/b.js 1 bytes {90} {374} [built]
chunk {179} main.js (main) 524 bytes (javascript) 4.3 KiB (runtime) >{90}< >{289}< >{374}< >{592}< [entry] [rendered]
chunk {179} main.js (main) 524 bytes (javascript) 4.28 KiB (runtime) >{90}< >{289}< >{374}< >{592}< [entry] [rendered]
> ./index main
[10] ./index.js 523 bytes {179} [built]
[544] ./modules/f.js 1 bytes {179} [built]
@ -2090,7 +2090,7 @@ prefetched2.js 114 bytes [emitted] [name: prefetched2]
prefetched3.js 114 bytes [emitted] [name: prefetched3]
Entrypoint main = main.js (prefetch: prefetched2.js prefetched.js prefetched3.js)
chunk normal.js (normal) 1 bytes <{179}> [rendered]
chunk main.js (main) 436 bytes (javascript) 6.85 KiB (runtime) >{30}< >{220}< >{379}< >{505}< (prefetch: {379} {505} {220}) [entry] [rendered]
chunk main.js (main) 436 bytes (javascript) 6.84 KiB (runtime) >{30}< >{220}< >{379}< >{505}< (prefetch: {379} {505} {220}) [entry] [rendered]
chunk prefetched3.js (prefetched3) 1 bytes <{179}> [rendered]
chunk prefetched2.js (prefetched2) 1 bytes <{179}> [rendered]
chunk prefetched.js (prefetched) 228 bytes <{179}> >{641}< >{746}< (prefetch: {641} {746}) [rendered]
@ -2105,7 +2105,7 @@ chunk c1.js (c1) 1 bytes <{459}> [rendered]
chunk b.js (b) 203 bytes <{179}> >{132}< >{751}< >{978}< (prefetch: {751} {132}) (preload: {978}) [rendered]
chunk b3.js (b3) 1 bytes <{128}> [rendered]
chunk a2.js (a2) 1 bytes <{786}> [rendered]
chunk main.js (main) 195 bytes (javascript) 7.52 KiB (runtime) >{128}< >{459}< >{786}< (prefetch: {786} {128} {459}) [entry] [rendered]
chunk main.js (main) 195 bytes (javascript) 7.51 KiB (runtime) >{128}< >{459}< >{786}< (prefetch: {786} {128} {459}) [entry] [rendered]
chunk c.js (c) 134 bytes <{179}> >{3}< >{76}< (preload: {76} {3}) [rendered]
chunk b1.js (b1) 1 bytes <{128}> [rendered]
chunk a.js (a) 136 bytes <{179}> >{74}< >{178}< (prefetch: {74} {178}) [rendered]
@ -2123,7 +2123,7 @@ preloaded2.js 113 bytes [emitted] [name: preloaded2]
preloaded3.js 112 bytes [emitted] [name: preloaded3]
Entrypoint main = main.js (preload: preloaded2.js preloaded.js preloaded3.js)
chunk normal.js (normal) 1 bytes [rendered]
chunk main.js (main) 424 bytes (javascript) 6.67 KiB (runtime) (preload: {363} {851} {355}) [entry] [rendered]
chunk main.js (main) 424 bytes (javascript) 6.65 KiB (runtime) (preload: {363} {851} {355}) [entry] [rendered]
chunk preloaded3.js (preloaded3) 1 bytes [rendered]
chunk preloaded2.js (preloaded2) 1 bytes [rendered]
chunk inner2.js (inner2) 2 bytes [rendered]
@ -2140,7 +2140,7 @@ exports[`StatsTestCases should print correct stats for preset-detailed 1`] = `
<+> [LogTestPlugin] Collaped group
[LogTestPlugin] Log
[LogTestPlugin] End
Hash: 024d57772fd9d4dc8f32
Hash: 925032eb3197675c4411
Time: X ms
Built at: 1970-04-20 12:42:42
PublicPath: (none)
@ -2148,9 +2148,9 @@ PublicPath: (none)
460.js 324 bytes {460} [emitted]
524.js 210 bytes {524} [emitted]
996.js 142 bytes {996} [emitted]
main.js 7.74 KiB {179} [emitted] [name: main]
main.js 7.7 KiB {179} [emitted] [name: main]
Entrypoint main = main.js
chunk {179} main.js (main) 73 bytes (javascript) 4.19 KiB (runtime) >{460}< >{996}< [entry] [rendered]
chunk {179} main.js (main) 73 bytes (javascript) 4.18 KiB (runtime) >{460}< >{996}< [entry] [rendered]
> ./index main
chunk {460} 460.js 54 bytes <{179}> >{524}< [rendered]
> ./c [10] ./index.js 3:0-16
@ -2180,7 +2180,7 @@ webpack/runtime/get javascript chunk filename 167 bytes {179} [runtime]
webpack/runtime/hasOwnProperty shorthand 86 bytes {179} [runtime]
[no exports]
[used exports unknown]
webpack/runtime/jsonp chunk loading 3.6 KiB {179} [runtime]
webpack/runtime/jsonp chunk loading 3.59 KiB {179} [runtime]
[no exports]
[used exports unknown]
webpack/runtime/publicPath 27 bytes {179} [runtime]
@ -2260,14 +2260,14 @@ exports[`StatsTestCases should print correct stats for preset-normal 1`] = `
"<e> [LogTestPlugin] Error
<w> [LogTestPlugin] Warning
<i> [LogTestPlugin] Info
Hash: 024d57772fd9d4dc8f32
Hash: 925032eb3197675c4411
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
460.js 324 bytes [emitted]
524.js 210 bytes [emitted]
996.js 142 bytes [emitted]
main.js 7.74 KiB [emitted] [name: main]
main.js 7.7 KiB [emitted] [name: main]
Entrypoint main = main.js
./index.js 51 bytes [built]
./a.js 22 bytes [built]
@ -2361,7 +2361,7 @@ exports[`StatsTestCases should print correct stats for preset-verbose 1`] = `
[LogTestPlugin] Inner inner message
[LogTestPlugin] Log
[LogTestPlugin] End
Hash: 024d57772fd9d4dc8f32
Hash: 925032eb3197675c4411
Time: X ms
Built at: 1970-04-20 12:42:42
PublicPath: (none)
@ -2369,9 +2369,9 @@ PublicPath: (none)
460.js 324 bytes {460} [emitted]
524.js 210 bytes {524} [emitted]
996.js 142 bytes {996} [emitted]
main.js 7.74 KiB {179} [emitted] [name: main]
main.js 7.7 KiB {179} [emitted] [name: main]
Entrypoint main = main.js
chunk {179} main.js (main) 73 bytes (javascript) 4.19 KiB (runtime) >{460}< >{996}< [entry] [rendered]
chunk {179} main.js (main) 73 bytes (javascript) 4.18 KiB (runtime) >{460}< >{996}< [entry] [rendered]
> ./index main
[847] ./a.js 22 bytes {179} [depth 1] [built]
ModuleConcatenation bailout: Module is not an ECMAScript module
@ -2392,7 +2392,7 @@ chunk {179} main.js (main) 73 bytes (javascript) 4.19 KiB (runtime) >{460}< >{99
webpack/runtime/hasOwnProperty shorthand 86 bytes {179} [runtime]
[no exports]
[used exports unknown]
webpack/runtime/jsonp chunk loading 3.6 KiB {179} [runtime]
webpack/runtime/jsonp chunk loading 3.59 KiB {179} [runtime]
[no exports]
[used exports unknown]
webpack/runtime/publicPath 27 bytes {179} [runtime]
@ -2572,7 +2572,7 @@ exports[`StatsTestCases should print correct stats for runtime-chunk-integration
Asset Size
without-505.js 1.22 KiB [emitted]
without-main1.js 601 bytes [emitted] [name: main1]
without-runtime.js 10 KiB [emitted] [name: runtime]
without-runtime.js 9.96 KiB [emitted] [name: runtime]
Entrypoint main1 = without-runtime.js without-main1.js
./main1.js 66 bytes [built]
./b.js 20 bytes [built]
@ -2605,7 +2605,7 @@ Entrypoint e2 = runtime.js e2.js"
`;
exports[`StatsTestCases should print correct stats for scope-hoisting-bailouts 1`] = `
"Hash: 7cfe1ff84c4ec618a2da
"Hash: c710798c836957d64814
Time: X ms
Built at: 1970-04-20 12:42:42
Entrypoint index = index.js
@ -2635,9 +2635,9 @@ external \\"external\\" 42 bytes [built]
`;
exports[`StatsTestCases should print correct stats for scope-hoisting-multi 1`] = `
"Hash: 7cb360b116ad92cf28c7eecef53ff6803bb3e2c1
"Hash: 0889473011d0255191769306a1593cdfa11fe6c7
Child
Hash: 7cb360b116ad92cf28c7
Hash: 0889473011d025519176
Time: X ms
Built at: 1970-04-20 12:42:42
Entrypoint first = a-vendor.js a-first.js
@ -2655,7 +2655,7 @@ Child
./common_lazy_shared.js 25 bytes [built]
+ 12 hidden modules
Child
Hash: eecef53ff6803bb3e2c1
Hash: 9306a1593cdfa11fe6c7
Time: X ms
Built at: 1970-04-20 12:42:42
Entrypoint first = b-vendor.js b-first.js
@ -2682,12 +2682,12 @@ Child
`;
exports[`StatsTestCases should print correct stats for side-effects-issue-7428 1`] = `
"Hash: 63afda29824f1a48fef1
"Hash: 62cf5103264a5d225396
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
1.js 642 bytes [emitted]
main.js 9.78 KiB [emitted] [name: main]
main.js 9.75 KiB [emitted] [name: main]
Entrypoint main = main.js
./main.js + 1 modules 231 bytes [built]
[no exports used]
@ -2802,7 +2802,7 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = `
chunk default/async-g.js (async-g) 34 bytes <{282}> <{767}> <{786}> <{794}> <{954}> ={568}= [rendered]
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
chunk default/main.js (main) 147 bytes (javascript) 4.85 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
chunk default/main.js (main) 147 bytes (javascript) 4.83 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -2835,7 +2835,7 @@ exports[`StatsTestCases should print correct stats for split-chunks 1`] = `
chunk default/769.js (id hint: vendors) 20 bytes <{179}> ={282}= ={383}= ={568}= ={767}= [rendered] split chunk (cache group: defaultVendors)
> ./c ./index.js 3:0-47
./node_modules/z.js 20 bytes [built]
chunk default/a.js (a) 216 bytes (javascript) 4.84 KiB (runtime) >{137}< >{568}< [entry] [rendered]
chunk default/a.js (a) 216 bytes (javascript) 4.82 KiB (runtime) >{137}< >{568}< [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -2860,7 +2860,7 @@ Child all-chunks:
chunk all-chunks/async-g.js (async-g) 34 bytes <{282}> <{767}> <{786}> <{794}> <{954}> ={568}= [rendered]
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
chunk all-chunks/main.js (main) 147 bytes (javascript) 4.85 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
chunk all-chunks/main.js (main) 147 bytes (javascript) 4.84 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -2900,7 +2900,7 @@ Child all-chunks:
> ./c ./index.js 3:0-47
> ./c c
./node_modules/z.js 20 bytes [built]
chunk all-chunks/a.js (a) 156 bytes (javascript) 6 KiB (runtime) ={282}= ={767}= ={954}= >{137}< >{568}< [entry] [rendered]
chunk all-chunks/a.js (a) 156 bytes (javascript) 5.98 KiB (runtime) ={282}= ={767}= ={954}= >{137}< >{568}< [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -2930,7 +2930,7 @@ Child manual:
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
+ 1 hidden dependent module
chunk manual/main.js (main) 147 bytes (javascript) 4.85 KiB (runtime) >{216}< >{334}< >{383}< >{794}< [entry] [rendered]
chunk manual/main.js (main) 147 bytes (javascript) 4.84 KiB (runtime) >{216}< >{334}< >{383}< >{794}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -2969,7 +2969,7 @@ Child manual:
./c.js 72 bytes [built]
+ 4 hidden root modules
+ 2 hidden dependent modules
chunk manual/a.js (a) 176 bytes (javascript) 5.99 KiB (runtime) ={216}= >{137}< [entry] [rendered]
chunk manual/a.js (a) 176 bytes (javascript) 5.98 KiB (runtime) ={216}= >{137}< [entry] [rendered]
> ./a a
> x a
> y a
@ -2989,7 +2989,7 @@ Child name-too-long:
chunk name-too-long/async-g.js (async-g) 34 bytes <{282}> <{751}> <{767}> <{794}> <{954}> ={568}= [rendered]
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
chunk name-too-long/main.js (main) 147 bytes (javascript) 4.85 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
chunk name-too-long/main.js (main) 147 bytes (javascript) 4.84 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -3019,7 +3019,7 @@ Child name-too-long:
chunk name-too-long/cccccccccccccccccccccccccccccc.js (cccccccccccccccccccccccccccccc) 3.18 KiB ={282}= ={383}= ={568}= ={767}= ={769}= [entry] [rendered]
> ./c cccccccccccccccccccccccccccccc
4 root modules
chunk name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) 6 KiB ={282}= ={767}= ={794}= ={954}= >{137}< >{568}< [entry] [rendered]
chunk name-too-long/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.js (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) 5.98 KiB ={282}= ={767}= ={794}= ={954}= >{137}< >{568}< [entry] [rendered]
> ./a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
7 root modules
chunk name-too-long/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.js (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) 3.18 KiB ={282}= ={334}= ={568}= ={767}= ={954}= [entry] [rendered]
@ -3060,7 +3060,7 @@ Child custom-chunks-filter:
chunk custom-chunks-filter/async-g.js (async-g) 34 bytes <{282}> <{767}> <{786}> <{794}> <{954}> ={568}= [rendered]
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
chunk custom-chunks-filter/main.js (main) 147 bytes (javascript) 4.86 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
chunk custom-chunks-filter/main.js (main) 147 bytes (javascript) 4.85 KiB (runtime) >{282}< >{334}< >{383}< >{568}< >{767}< >{769}< >{794}< >{954}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -3098,7 +3098,7 @@ Child custom-chunks-filter:
> ./c ./index.js 3:0-47
> ./c c
./node_modules/z.js 20 bytes [built]
chunk custom-chunks-filter/a.js (a) 216 bytes (javascript) 4.85 KiB (runtime) >{137}< >{568}< [entry] [rendered]
chunk custom-chunks-filter/a.js (a) 216 bytes (javascript) 4.83 KiB (runtime) >{137}< >{568}< [entry] [rendered]
> ./a a
./a.js + 1 modules 156 bytes [built]
+ 7 hidden root modules
@ -3128,7 +3128,7 @@ Child custom-chunks-filter-in-cache-groups:
> ./g ./a.js 6:0-47
./g.js 34 bytes [built]
+ 1 hidden dependent module
chunk custom-chunks-filter-in-cache-groups/main.js (main) 147 bytes (javascript) 4.88 KiB (runtime) >{216}< >{334}< >{383}< >{794}< [entry] [rendered]
chunk custom-chunks-filter-in-cache-groups/main.js (main) 147 bytes (javascript) 4.87 KiB (runtime) >{216}< >{334}< >{383}< >{794}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules
@ -3163,7 +3163,7 @@ Child custom-chunks-filter-in-cache-groups:
./c.js 72 bytes [built]
+ 4 hidden root modules
+ 2 hidden dependent modules
chunk custom-chunks-filter-in-cache-groups/a.js (a) 236 bytes (javascript) 4.82 KiB (runtime) >{137}< [entry] [rendered]
chunk custom-chunks-filter-in-cache-groups/a.js (a) 236 bytes (javascript) 4.8 KiB (runtime) >{137}< [entry] [rendered]
> ./a a
> x a
> y a
@ -3210,7 +3210,7 @@ chunk common-node_modules_y_js.js (id hint: common) 20 bytes <{main}> ={async-a}
chunk common-node_modules_z_js.js (id hint: common) 20 bytes <{main}> ={async-c}= ={common-d_js}= ={common-f_js}= ={common-node_modules_x_js}= [rendered] split chunk (cache group: b)
> ./c ./index.js 3:0-47
./node_modules/z.js 20 bytes [built]
chunk main.js (main) 147 bytes (javascript) 4.77 KiB (runtime) >{async-a}< >{async-b}< >{async-c}< >{common-d_js}< >{common-f_js}< >{common-node_modules_x_js}< >{common-node_modules_y_js}< >{common-node_modules_z_js}< [entry] [rendered]
chunk main.js (main) 147 bytes (javascript) 4.75 KiB (runtime) >{async-a}< >{async-b}< >{async-c}< >{common-d_js}< >{common-f_js}< >{common-node_modules_x_js}< >{common-node_modules_y_js}< >{common-node_modules_z_js}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 7 hidden root modules"
@ -3218,7 +3218,7 @@ chunk main.js (main) 147 bytes (javascript) 4.77 KiB (runtime) >{async-a}< >{asy
exports[`StatsTestCases should print correct stats for split-chunks-chunk-name 1`] = `
"Entrypoint main = default/main.js
chunk default/main.js (main) 192 bytes (javascript) 4.82 KiB (runtime) >{334}< >{709}< >{794}< [entry] [rendered]
chunk default/main.js (main) 192 bytes (javascript) 4.81 KiB (runtime) >{334}< >{709}< >{794}< [entry] [rendered]
> ./ main
./index.js 192 bytes [built]
+ 7 hidden chunk modules
@ -3244,7 +3244,7 @@ chunk async-g.js (async-g) 101 bytes <{179}> [rendered]
> ./g ./index.js 7:0-47
./g.js 34 bytes [built]
+ 1 hidden dependent module
chunk main.js (main) 343 bytes (javascript) 5.14 KiB (runtime) >{31}< >{137}< >{206}< >{334}< >{383}< >{449}< >{794}< >{804}< [entry] [rendered]
chunk main.js (main) 343 bytes (javascript) 5.13 KiB (runtime) >{31}< >{137}< >{206}< >{334}< >{383}< >{449}< >{794}< >{804}< [entry] [rendered]
> ./ main
./index.js 343 bytes [built]
+ 8 hidden root modules
@ -3275,7 +3275,7 @@ chunk 804.js 134 bytes <{179}> ={334}= ={794}= [rendered] split chunk (cache gro
exports[`StatsTestCases should print correct stats for split-chunks-issue-6413 1`] = `
"Entrypoint main = main.js
chunk main.js (main) 147 bytes (javascript) 4.52 KiB (runtime) >{282}< >{334}< >{383}< >{543}< >{794}< [entry] [rendered]
chunk main.js (main) 147 bytes (javascript) 4.51 KiB (runtime) >{282}< >{334}< >{383}< >{543}< >{794}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 6 hidden root modules
@ -3302,7 +3302,7 @@ chunk async-a.js (async-a) 19 bytes <{179}> ={282}= ={543}= [rendered]
exports[`StatsTestCases should print correct stats for split-chunks-issue-6696 1`] = `
"Entrypoint main = vendors.js main.js
chunk main.js (main) 110 bytes (javascript) 5.67 KiB (runtime) ={216}= >{334}< >{794}< [entry] [rendered]
chunk main.js (main) 110 bytes (javascript) 5.66 KiB (runtime) ={216}= >{334}< >{794}< [entry] [rendered]
> ./ main
./index.js 110 bytes [built]
+ 6 hidden root modules
@ -3323,7 +3323,7 @@ exports[`StatsTestCases should print correct stats for split-chunks-issue-7401 1
"Entrypoint a = 282.js a.js
Entrypoint b = b.js
Chunk Group c = 282.js c.js
chunk b.js (b) 43 bytes (javascript) 4.49 KiB (runtime) >{282}< >{459}< [entry] [rendered]
chunk b.js (b) 43 bytes (javascript) 4.47 KiB (runtime) >{282}< >{459}< [entry] [rendered]
> ./b b
./b.js 43 bytes [built]
+ 6 hidden root modules
@ -3342,7 +3342,7 @@ chunk a.js (a) 12 bytes (javascript) 2.6 KiB (runtime) ={282}= [entry] [rendered
exports[`StatsTestCases should print correct stats for split-chunks-keep-remaining-size 1`] = `
"Entrypoint main = default/main.js
chunk default/main.js (main) 147 bytes (javascript) 5.09 KiB (runtime) >{334}< >{383}< >{794}< >{821}< [entry] [rendered]
chunk default/main.js (main) 147 bytes (javascript) 5.08 KiB (runtime) >{334}< >{383}< >{794}< >{821}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 8 hidden chunk modules
@ -3658,7 +3658,7 @@ Child zero-min:
./node_modules/small.js?2 67 bytes [built]
Child max-async-size:
Entrypoint main = max-async-size-main.js
chunk max-async-size-main.js (main) 2.47 KiB (javascript) 5.13 KiB (runtime) >{342}< >{385}< >{820}< >{920}< [entry] [rendered]
chunk max-async-size-main.js (main) 2.47 KiB (javascript) 5.12 KiB (runtime) >{342}< >{385}< >{820}< >{920}< [entry] [rendered]
> ./async main
./async/index.js 386 bytes [built]
+ 8 hidden root modules
@ -3766,7 +3766,7 @@ chunk default/118.js 110 bytes <{179}> ={334}= ={383}= [rendered] split chunk (c
> ./c ./index.js 3:0-47
./d.js 43 bytes [built]
./f.js 67 bytes [built]
chunk default/main.js (main) 147 bytes (javascript) 5.09 KiB (runtime) >{118}< >{334}< >{383}< >{794}< [entry] [rendered]
chunk default/main.js (main) 147 bytes (javascript) 5.08 KiB (runtime) >{118}< >{334}< >{383}< >{794}< [entry] [rendered]
> ./ main
./index.js 147 bytes [built]
+ 8 hidden root modules
@ -3851,7 +3851,7 @@ WARNING in Terser Plugin: Dropping unused function someUnRemoteUsedFunction5 [we
`;
exports[`StatsTestCases should print correct stats for wasm-explorer-examples-sync 1`] = `
"Hash: 6447a9fca2b71320b7dd
"Hash: 426dfe4bd9e569cd2869
Time: X ms
Built at: 1970-04-20 12:42:42
Asset Size
@ -3876,7 +3876,7 @@ chunk 325.bundle.js 1.54 KiB (javascript) 274 bytes (webassembly) [rendered]
./popcnt.wasm 50 bytes (javascript) 120 bytes (webassembly) [built]
./testFunction.wasm 50 bytes (javascript) 154 bytes (webassembly) [built]
./tests.js 1.44 KiB [built]
chunk bundle.js (main-1df31ce3) 586 bytes (javascript) 5.51 KiB (runtime) [entry] [rendered]
chunk bundle.js (main-1df31ce3) 586 bytes (javascript) 5.49 KiB (runtime) [entry] [rendered]
./index.js 586 bytes [built]
+ 8 hidden chunk modules
chunk 526.bundle.js (id hint: vendors) 34 bytes [rendered] split chunk (cache group: defaultVendors)

View File

@ -1,3 +1,4 @@
/** @type {import("../../../").Configuration} */
module.exports = {
entry: ["./index", "./index2"]
};

View File

@ -1,3 +1,4 @@
/** @type {import("../../../").Configuration} */
module.exports = {
entry: ["react", "react-dom", "lodash"]
};

View File

@ -1,3 +1,4 @@
/** @type {import("../../../").Configuration} */
module.exports = {
entry: "./index"
};

View File

@ -1,3 +1,4 @@
/** @type {import("../../../").Configuration} */
module.exports = {
entry: "./index",
devtool: "eval-cheap-module-source-map"

View File

@ -1,3 +1,4 @@
/** @type {import("../../../").Configuration} */
module.exports = {
entry: "./index"
};

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").WebpackPluginFunction} */
var testPlugin = function () {
var counter = 1;
this.hooks.compilation.tap("TestPlugin", compilation => {
@ -8,6 +9,7 @@ var testPlugin = function () {
});
};
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [testPlugin]
};

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
amd: false
};

View File

@ -1,6 +1,7 @@
const Compilation = require("../../../../").Compilation;
const Source = require("webpack-sources").Source;
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
compiler => {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
output: {

View File

@ -1,6 +1,7 @@
const path = require("path");
const NormalModule = require("../../../../lib/NormalModule");
const NormalModule = require("../../../../").NormalModule;
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
module: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
module: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
module: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
module: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
module: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
output: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
output: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
output: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
module: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
module: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
splitChunks: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
splitChunks: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
performance: {
hints: false

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
splitChunks: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "none",
entry: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
splitChunks: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: {
b: "./entry-b",

View File

@ -1,6 +1,7 @@
/** @typedef {import("../../../../lib/Compilation")} Compilation */
/** @typedef {import("../../../../lib/Module")} Module */
/** @typedef {import("../../../../").Compilation} Compilation */
/** @typedef {import("../../../../").Module} Module */
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: {
entry1: "./entry1",
@ -22,6 +23,7 @@ module.exports = {
for (const [name, group] of compilation.namedChunkGroups) {
/** @type {Map<Module, number>} */
const modules = new Map();
/** @type {Map<Module, number>} */
const modules2 = new Map();
for (const chunk of group.chunks) {
for (const module of compilation.chunkGraph.getChunkModulesIterable(
@ -75,7 +77,13 @@ module.exports = {
asyncIndex2: "0: ./async.js"
});
const indices = Array.from(compilation.modules)
.map(m => [moduleGraph.getPreOrderIndex(m), m])
.map(
m =>
/** @type {[number, Module]} */ ([
moduleGraph.getPreOrderIndex(m),
m
])
)
.filter(p => typeof p[0] === "number")
.sort((a, b) => a[0] - b[0])
.map(
@ -84,7 +92,13 @@ module.exports = {
)
.join(", ");
const indices2 = Array.from(compilation.modules)
.map(m => [moduleGraph.getPostOrderIndex(m), m])
.map(
m =>
/** @type {[number, Module]} */ ([
moduleGraph.getPostOrderIndex(m),
m
])
)
.filter(p => typeof p[0] === "number")
.sort((a, b) => a[0] - b[0])
.map(

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
optimization: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
moduleIds: "hashed"

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
node: {
__dirname: false,

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
module: {
strictExportPresence: true

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: {
entry1: "./entry1",

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
concatenateModules: true

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: {
main: "./index"

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
mode: "production",

View File

@ -1,5 +1,6 @@
var webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [new webpack.ContextExclusionPlugin(/dont/)]
};

View File

@ -1,6 +1,7 @@
var path = require("path");
var webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(

View File

@ -1,5 +1,6 @@
var webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(

View File

@ -1,5 +1,6 @@
var webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(/context-replacement.b$/, /^\.\/only/)

View File

@ -1,6 +1,7 @@
var path = require("path");
var webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
new webpack.ContextReplacementPlugin(

View File

@ -1,6 +1,7 @@
var path = require("path");
var webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
module: {
rules: [

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
target: "web",
output: {

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
output: {

View File

@ -1,5 +1,6 @@
const toml = require("toml");
/** @type {import("../../../../").Configuration[]} */
module.exports = [
{
mode: "development",

View File

@ -5,12 +5,20 @@ const RuntimeGlobals = require("../../../../").RuntimeGlobals;
const Parser = require("../../../../").Parser;
const webpack = require("../../../../");
/** @typedef {import("../../../../lib/Compiler")} Compiler */
/** @typedef {import("../../../../").Compiler} Compiler */
/** @typedef {import("../../../../").ParserState} ParserState */
class LocalizationParser extends Parser {
parse(source, { module }) {
/**
* @param {string | Buffer | Record<string, any>} source input source
* @param {ParserState} state state
* @returns {ParserState} state
*/
parse(source, state) {
if (typeof source !== "string") throw new Error("Unexpected input");
const { module } = state;
module.buildInfo.content = JSON.parse(source);
return true;
return state;
}
}

View File

@ -1,5 +1,6 @@
/** @typedef {import("../../../../lib/Compilation")} Compilation */
/** @typedef {import("../../../../").Compilation} Compilation */
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
usedExports: true,

View File

@ -1,5 +1,6 @@
/** @typedef {import("../../../../lib/Compilation")} Compilation */
/** @typedef {import("../../../../").Compilation} Compilation */
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
usedExports: true,

View File

@ -1,3 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
resolve: Object.freeze({})
// this fails to compile when the object is not cloned

View File

@ -1,4 +1,5 @@
var DelegatedPlugin = require("../../../../").DelegatedPlugin;
/** @type {import("../../../../").Configuration} */
module.exports = {
optimization: {
moduleIds: "hashed"

View File

@ -1,4 +1,5 @@
var DelegatedPlugin = require("../../../../").DelegatedPlugin;
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
new DelegatedPlugin({

View File

@ -0,0 +1,31 @@
module.exports = [
{ code: /DEP_WEBPACK_CHUNK_ADD_MODULE/ },
{ code: /DEP_WEBPACK_CHUNK_CONTAINS_MODULE/ },
{ code: /DEP_WEBPACK_CHUNK_ENTRY_MODULE/ },
{ code: /DEP_WEBPACK_CHUNK_GET_MODULES/ },
{ code: /DEP_WEBPACK_CHUNK_GET_NUMBER_OF_MODULES/ },
{ code: /DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE/ },
{ code: /DEP_WEBPACK_CHUNK_HAS_MODULE_IN_GRAPH/ },
{ code: /DEP_WEBPACK_CHUNK_IS_EMPTY/ },
{ code: /DEP_WEBPACK_CHUNK_MODULES_ITERABLE/ },
{ code: /DEP_WEBPACK_CHUNK_MODULES_SIZE/ },
{ code: /DEP_WEBPACK_CHUNK_REMOVE_MODULE/ },
{ code: /DEP_WEBPACK_CHUNK_SIZE/ },
{ code: /DEP_WEBPACK_MODULE_ADD_CHUNK/ },
{ code: /DEP_WEBPACK_MODULE_CHUNKS_ITERABLE/ },
{ code: /DEP_WEBPACK_MODULE_DEPTH/ },
{ code: /DEP_WEBPACK_MODULE_GET_CHUNKS/ },
{ code: /DEP_WEBPACK_MODULE_GET_NUMBER_OF_CHUNKS/ },
{ code: /DEP_WEBPACK_MODULE_HASH/ },
{ code: /DEP_WEBPACK_MODULE_INDEX2/ },
{ code: /DEP_WEBPACK_MODULE_INDEX/ },
{ code: /DEP_WEBPACK_MODULE_ISSUER/ },
{ code: /DEP_WEBPACK_MODULE_IS_ENTRY_MODULE/ },
{ code: /DEP_WEBPACK_MODULE_IS_IN_CHUNK/ },
{ code: /DEP_WEBPACK_MODULE_OPTIMIZATION_BAILOUT/ },
{ code: /DEP_WEBPACK_MODULE_OPTIONAL/ },
{ code: /DEP_WEBPACK_MODULE_PROFILE/ },
{ code: /DEP_WEBPACK_MODULE_REMOVE_CHUNK/ },
{ code: /DEP_WEBPACK_MODULE_RENDERED_HASHED/ },
{ code: /DEP_WEBPACK_MODULE_USED_EXPORTS/ }
];

View File

@ -0,0 +1,7 @@
import { testExport as importedTestExport } from "./index";
export const testExport = 42;
it("should compile with deprecations", () => {
expect(importedTestExport).toBe(42);
});

View File

@ -0,0 +1,63 @@
const { ChunkGraph, ExternalModule } = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
compiler => {
compiler.hooks.done.tap("Test", ({ compilation }) => {
const { chunkGraph } = compilation;
for (const chunk of compilation.chunks) {
expect(chunk.entryModule).toBe(
[...chunkGraph.getChunkEntryModulesIterable(chunk)][0]
);
expect(chunk.hasEntryModule()).toBe(true);
expect(chunk.getNumberOfModules()).toBe(3);
const module = new ExternalModule("external", "var", "external");
ChunkGraph.setChunkGraphForModule(module, chunkGraph);
chunk.addModule(module);
module.addChunk(chunk);
expect(chunk.getNumberOfModules()).toBe(4);
expect(new Set(chunk.modulesIterable)).toContain(module);
expect(new Set(chunk.getModules())).toContain(chunk.entryModule);
expect(chunk.hasModuleInGraph(m => m === module)).toBe(true);
expect(chunk.containsModule(module)).toBe(true);
chunk.removeModule(module);
module.removeChunk(chunk);
expect(chunk.getNumberOfModules()).toBe(3);
expect(chunk.containsModule(module)).toBe(false);
expect(chunk.isEmpty()).toBe(false);
expect(chunk.modulesSize()).toBeTypeOf("number");
expect(chunk.size()).toBe(chunk.modulesSize() * 10 + 10000);
const m = chunk.entryModule;
expect(m.hash).toMatch(/^[0-9a-f]{32}$/);
expect(m.renderedHash).toMatch(/^[0-9a-f]{20}$/);
expect(m.profile).toBe(undefined);
expect(m.index).toBe(0);
m.index = 1000;
expect(m.index).toBe(1000);
expect(m.index2).toBe(0);
m.index2 = 1000;
expect(m.index2).toBe(1000);
expect(m.depth).toBe(0);
m.depth = 1000;
expect(m.depth).toBe(1000);
expect(m.issuer).toBe(null);
m.issuer = module;
expect(m.issuer).toBe(module);
expect(
typeof m.usedExports === "boolean" ? [] : [...m.usedExports]
).toEqual(["testExport"]);
expect(m.optimizationBailout).toEqual([]);
expect(m.optional).toBe(false);
expect(m.isInChunk(chunk)).toBe(true);
expect(m.isEntryModule()).toBe(true);
expect(m.getChunks()).toEqual([chunk]);
expect(m.getNumberOfChunks()).toBe(1);
expect(Array.from(m.chunksIterable)).toEqual([chunk]);
expect(m.isProvided("testExport")).toBe(true);
expect(m.isProvided("otherExport")).toBe(false);
}
});
}
]
};

View File

@ -0,0 +1,6 @@
module.exports = [
{ code: /DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET/ },
{ code: /DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_INDEXER/ },
{ code: /DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_LENGTH/ },
{ code: /DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_PUSH/ }
];

Some files were not shown because too many files have changed in this diff Show More