Merge branch 'profiling-race' into jest

# Conflicts:
#	lib/debug/ProfilingPlugin.js
#	test/ConfigTestCases.test.js
#	test/DependenciesBlockVariable.unittest.js
#	test/Examples.test.js
#	test/ExternalModule.unittest.js
#	test/HotTestCases.test.js
#	test/Schemas.lint.js
#	test/WebEnvironmentPlugin.unittest.js
#	test/cases/mjs/non-mjs-namespace-object-lazy/index.js
#	test/cases/runtime/module-caching/index.js
#	test/compareLocations.unittest.js
#	test/configCases/library/1-use-library/index.js
#	test/configCases/plugins/define-plugin/index.js
#	yarn.lock
This commit is contained in:
Bazyli Brzóska 2018-03-07 21:56:06 +01:00
commit b579658d22
100 changed files with 450 additions and 217 deletions

View File

@ -1,6 +1,6 @@
<div align="center">
<a href="https://github.com/webpack/webpack">
<img width="200" heigth="200" src="https://webpack.js.org/assets/icon-square-big.svg">
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
<br>
<br>
@ -15,7 +15,7 @@
[![licenses][licenses]][licenses-url]
<br>
<a href="https://npmjs.com/package/webpack">
<a href="https://npmcharts.com/compare/webpack?minimal=true">
<img src="https://img.shields.io/npm/dm/webpack.svg">
</a>
<a href="https://opencollective.com/webpack#backer">

View File

@ -1,4 +1,4 @@
This example illustrates how common modules from deep ancestors of an entry point can be split into a seperate common chunk
This example illustrates how common modules from deep ancestors of an entry point can be split into a separate common chunk
* `pageA` and `pageB` are dynamically required
* `pageC` and `pageA` both require the `reusableComponent`
@ -93,7 +93,7 @@ module.exports = {
},
optimization: {
splitChunks: {
minSize: 0 // This example is too small, in pratice you can use the defaults
minSize: 0 // This example is too small, in practice you can use the defaults
},
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
},

View File

@ -1,4 +1,4 @@
This example illustrates how common modules from deep ancestors of an entry point can be split into a seperate common chunk
This example illustrates how common modules from deep ancestors of an entry point can be split into a separate common chunk
* `pageA` and `pageB` are dynamically required
* `pageC` and `pageA` both require the `reusableComponent`

View File

@ -8,7 +8,7 @@ module.exports = {
},
optimization: {
splitChunks: {
minSize: 0 // This example is too small, in pratice you can use the defaults
minSize: 0 // This example is too small, in practice you can use the defaults
},
occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
},

View File

@ -1,6 +1,6 @@
This is the vendor build part.
It's built separatly from the app part. The vendors dll is only built when vendors has changed and not while the normal development cycle.
It's built separately from the app part. The vendors dll is only built when vendors has changed and not while the normal development cycle.
The DllPlugin in combination with the `output.library` option exposes the internal require function as global variable in the target environment.

View File

@ -1,6 +1,6 @@
This is the vendor build part.
It's built separatly from the app part. The vendors dll is only built when vendors has changed and not while the normal development cycle.
It's built separately from the app part. The vendors dll is only built when vendors has changed and not while the normal development cycle.
The DllPlugin in combination with the `output.library` option exposes the internal require function as global variable in the target environment.

View File

@ -16,7 +16,7 @@ The example entry references two chunks:
These chunks share modules `a` and `b`. The optimization extract these into chunk Z:
Note: Actually the optimization compare size of chunk Z to some minimum value, but this is disabled from this example. In pratice there is no configuration needed for this.
Note: Actually the optimization compare size of chunk Z to some minimum value, but this is disabled from this example. In practice there is no configuration needed for this.
* entry chunk
* async require -> chunk X & Z

View File

@ -16,7 +16,7 @@ The example entry references two chunks:
These chunks share modules `a` and `b`. The optimization extract these into chunk Z:
Note: Actually the optimization compare size of chunk Z to some minimum value, but this is disabled from this example. In pratice there is no configuration needed for this.
Note: Actually the optimization compare size of chunk Z to some minimum value, but this is disabled from this example. In practice there is no configuration needed for this.
* entry chunk
* async require -> chunk X & Z

View File

@ -29,7 +29,7 @@ exports.readFile = function() {};
// using module.exports would be equivalent,
// webpack doesn't care which syntax is used
// AMD modules are also possible and equvivalent to CommonJs modules
// AMD modules are also possible and equivalent to CommonJs modules
```
# reexport-commonjs.js
@ -192,7 +192,7 @@ exports.readFile = function() {};
// using module.exports would be equivalent,
// webpack doesn't care which syntax is used
// AMD modules are also possible and equvivalent to CommonJs modules
// AMD modules are also possible and equivalent to CommonJs modules
/***/ }),

View File

@ -4,4 +4,4 @@ exports.readFile = function() {};
// using module.exports would be equivalent,
// webpack doesn't care which syntax is used
// AMD modules are also possible and equvivalent to CommonJs modules
// AMD modules are also possible and equivalent to CommonJs modules

View File

@ -12,7 +12,7 @@ delete require.cache[aId];
// require module again, it should be reexecuted
var a2 = require("./a");
// vertify it
// verify it
if(a == a2) throw new Error("Cache clear failed :(");
```
@ -123,7 +123,7 @@ delete __webpack_require__.c[aId];
// require module again, it should be reexecuted
var a2 = __webpack_require__(/*! ./a */ 1);
// vertify it
// verify it
if(a == a2) throw new Error("Cache clear failed :(");
/***/ }),

View File

@ -9,5 +9,5 @@ delete require.cache[aId];
// require module again, it should be reexecuted
var a2 = require("./a");
// vertify it
// verify it
if(a == a2) throw new Error("Cache clear failed :(");

View File

@ -18,7 +18,7 @@ webpack therefore uses a approach called **"Partial Scope Hoisting"** or "Module
![](graph3.png)
While module concatentation identifiers in modules are renamed to avoid conflicts and internal imports are simplified. External imports and exports from the root module use the existing ESM constructs.
While module concatenation identifiers in modules are renamed to avoid conflicts and internal imports are simplified. External imports and exports from the root module use the existing ESM constructs.
# example.js

View File

@ -18,7 +18,7 @@ webpack therefore uses a approach called **"Partial Scope Hoisting"** or "Module
![](graph3.png)
While module concatentation identifiers in modules are renamed to avoid conflicts and internal imports are simplified. External imports and exports from the root module use the existing ESM constructs.
While module concatenation identifiers in modules are renamed to avoid conflicts and internal imports are simplified. External imports and exports from the root module use the existing ESM constructs.
# example.js

View File

@ -242,7 +242,7 @@ export function fibonacciJavascript(i) {
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
/******/ // object with all compiled WebAssmbly.Modules
/******/ // object with all compiled WebAssembly.Modules
/******/ __webpack_require__.w = {};
/******/
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];

View File

@ -245,7 +245,7 @@ class ChunkGroup {
* we need to iterate again over the children
* to remove this from the childs parents.
* This can not be done in the above loop
* as it is not garuanteed that `this._parents` contains anything.
* as it is not guaranteed that `this._parents` contains anything.
*/
for (const chunkGroup of this._children) {
// remove this as parent of every "sub chunk"

View File

@ -1338,7 +1338,7 @@ class Compilation extends Tapable {
const depChunkGroup = dep.chunkGroup;
const depBlock = dep.block;
// 6. Connnect block with chunk
// 6. Connect block with chunk
GraphHelpers.connectDependenciesBlockAndChunkGroup(
depBlock,
depChunkGroup

View File

@ -269,12 +269,12 @@ class ContextModule extends Module {
getReturn(type) {
if (type === 1) return "module";
if (type === 2)
return 'Object.assign({/* fake namespace object */}, module, { "default": module })';
return 'Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module })';
if (type === 0) {
if (this.options.namespaceObject === "strict") {
return '/* fake namespace object */ { "default": module }';
} else {
return '(typeof module === "object" && module && module.__esModule ? module : /* fake namespace object */ { "default": module })';
return '(typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }))';
}
}
}
@ -373,7 +373,7 @@ function webpackAsyncContext(req) {
}
function webpackAsyncContextResolve(req) {
// Here Promise.resolve().then() is used instead of new Promise() to prevent
// uncatched exception popping up in devtools
// uncaught exception popping up in devtools
return Promise.resolve().then(function() {
var id = map[req];
if(!(id + 1)) { // check for number or string
@ -410,7 +410,7 @@ function webpackAsyncContext(req) {
}
function webpackAsyncContextResolve(req) {
// Here Promise.resolve().then() is used instead of new Promise() to prevent
// uncatched exception popping up in devtools
// uncaught exception popping up in devtools
return Promise.resolve().then(function() {
var id = map[req];
if(!(id + 1)) { // check for number or string
@ -547,7 +547,7 @@ webpackEmptyContext.id = ${JSON.stringify(id)};`;
getSourceForEmptyAsyncContext(id) {
return `function webpackEmptyAsyncContext(req) {
// Here Promise.resolve().then() is used instead of new Promise() to prevent
// uncatched exception popping up in devtools
// uncaught exception popping up in devtools
return Promise.resolve().then(function() {
var e = new Error('Cannot find module "' + req + '".');
e.code = 'MODULE_NOT_FOUND';

View File

@ -174,8 +174,8 @@ module.exports = class ContextModuleFactory extends Tapable {
if (!files || files.length === 0) return callback(null, []);
asyncLib.map(
files.filter(p => p.indexOf(".") !== 0),
(seqment, callback) => {
const subResource = path.join(directory, seqment);
(segment, callback) => {
const subResource = path.join(directory, segment);
if (!exclude || !subResource.match(exclude)) {
fs.stat(subResource, (err, stat) => {

View File

@ -122,7 +122,7 @@ class DefinePlugin {
* this is needed in case there is a recursion in the DefinePlugin
* to prevent an endless recursion
* e.g.: new DefinePlugin({
* "typeof a": "tyepof b",
* "typeof a": "typeof b",
* "typeof b": "typeof a"
* });
*/

View File

@ -18,7 +18,7 @@ exports.cutOffByFlag = (stack, flag) => {
exports.cutOffLoaderExecution = stack =>
exports.cutOffByFlag(stack, loaderFlag);
exports.cutOffWebpackOptinos = stack =>
exports.cutOffWebpackOptions = stack =>
exports.cutOffByFlag(stack, webpackOptionsFlag);
exports.cutOffMultilineMessage = (stack, message) => {
@ -51,7 +51,7 @@ exports.cleanUp = (stack, message) => {
};
exports.cleanUpWebpackOptions = (stack, message) => {
stack = exports.cutOffWebpackOptinos(stack);
stack = exports.cutOffWebpackOptions(stack);
stack = exports.cutOffMultilineMessage(stack, message);
return stack;
};

View File

@ -53,7 +53,7 @@ class JavascriptGenerator {
/**
* Get the variables of all blocks that we need to inject.
* These will contain the variable name and its expression.
* The name will be added as a paramter in a IIFE the expression as its value.
* The name will be added as a parameter in a IIFE the expression as its value.
*/
const vars = block.variables.reduce((result, value) => {
const variable = this.sourceVariables(

View File

@ -85,7 +85,7 @@ class JavascriptModulesPlugin {
(source, chunk, hash, moduleTemplate, dependencyTemplates) => {
return Template.renderChunkModules(
chunk,
() => true,
m => typeof m.source === "function",
moduleTemplate,
dependencyTemplates,
"/******/ "
@ -100,7 +100,10 @@ class JavascriptModulesPlugin {
const moduleTemplates = options.moduleTemplates;
const dependencyTemplates = options.dependencyTemplates;
const filenameTemplate = outputOptions.chunkFilename;
let filenameTemplate;
if (chunk.filenameTemplate)
filenameTemplate = chunk.filenameTemplate;
else filenameTemplate = outputOptions.chunkFilename;
result.push({
render: () =>
@ -128,7 +131,7 @@ class JavascriptModulesPlugin {
renderJavascript(chunkTemplate, chunk, moduleTemplate, dependencyTemplates) {
const moduleSources = Template.renderChunkModules(
chunk,
m => true,
m => typeof m.source === "function",
moduleTemplate,
dependencyTemplates
);

View File

@ -21,13 +21,13 @@ const SyncBailHook = require("tapable").SyncBailHook;
// __webpack_require__.p = the bundle public path
// __webpack_require__.i = the identity function used for harmony imports
// __webpack_require__.e = the chunk ensure function
// __webpack_require__.d = the exported propery define getter function
// __webpack_require__.d = the exported property define getter function
// __webpack_require__.o = Object.prototype.hasOwnProperty.call
// __webpack_require__.r = define compatibility on export
// __webpack_require__.n = compatibility get default export
// __webpack_require__.h = the webpack hash
// __webpack_require__.w = an object containing all installed WebAssembly.Modules keys by module id
// __webpack_require__.oe = the uncatched error handler for the webpack runtime
// __webpack_require__.oe = the uncaught error handler for the webpack runtime
// __webpack_require__.nc = the script nonce
module.exports = class MainTemplate extends Tapable {

View File

@ -267,7 +267,7 @@ class NormalModule extends Module {
}
markModuleAsErrored(error) {
// Restore build meta from successfull build to keep importing state
// Restore build meta from successful build to keep importing state
this.buildMeta = Object.assign({}, this._lastSuccessfulBuildMeta);
this.error = error;

View File

@ -2008,7 +2008,7 @@ class Parser extends Tapable {
free = true;
exprName.push(this.scope.renames.get("this"));
} else if (expr.type === "ThisExpression") {
free = false;
free = this.scope.topLevelScope;
exprName.push("this");
} else {
return null;

View File

@ -31,8 +31,8 @@ class RequestShortener {
}
const dirname = path.dirname(directory);
const endsWithSeperator = SEPARATOR_REGEXP.test(dirname);
const parentDirectory = endsWithSeperator
const endsWithSeparator = SEPARATOR_REGEXP.test(dirname);
const parentDirectory = endsWithSeparator
? dirname.substr(0, dirname.length - 1)
: dirname;
if (parentDirectory && parentDirectory !== directory) {

View File

@ -94,7 +94,7 @@ module.exports = class RuntimeTemplate {
} else {
return `Object(function() { var module = ${
rawModule
}; return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; }())`;
}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }())`;
}
}
@ -150,7 +150,7 @@ module.exports = class RuntimeTemplate {
} else {
getModuleFunction = `function() { ${header}var module = ${
rawModule
}; return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; }`;
}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }`;
}
return `${promise || "Promise.resolve()"}.then(${getModuleFunction})`;

View File

@ -28,7 +28,7 @@ class Stats {
}
// create a chain of filters
// if they return "true" a warning should be surpressed
// if they return "true" a warning should be suppressed
const normalizedWarningsFilters = [].concat(warningsFilter).map(filter => {
if (typeof filter === "string") {
return warning => warning.includes(filter);
@ -136,6 +136,10 @@ class Stats {
options.nestedModules,
true
);
const showModuleAssets = optionOrLocalFallback(
options.moduleAssets,
!forToString
);
const showDepth = optionOrLocalFallback(options.depth, !forToString);
const showCachedModules = optionOrLocalFallback(options.cached, true);
const showCachedAssets = optionOrLocalFallback(options.cachedAssets, true);
@ -417,7 +421,6 @@ class Stats {
optional: module.optional,
prefetched: module.prefetched,
chunks: Array.from(module.chunksIterable, chunk => chunk.id),
assets: Object.keys(module.assets || {}),
issuer: module.issuer && module.issuer.identifier(),
issuerId: module.issuer && module.issuer.id,
issuerName:
@ -435,6 +438,9 @@ class Stats {
errors: module.errors ? module.errors.length : 0,
warnings: module.warnings ? module.warnings.length : 0
};
if (showModuleAssets) {
obj.assets = Object.keys(module.buildInfo.assets || {});
}
if (showReasons) {
obj.reasons = module.reasons
.map(reason => {
@ -867,6 +873,13 @@ class Stats {
if (module.built) {
colors.green(" [built]");
}
if (module.assets && module.assets.length) {
colors.magenta(
` [${module.assets.length} asset${
module.assets.length === 1 ? "" : "s"
}]`
);
}
if (module.prefetched) {
colors.magenta(" [prefetched]");
}

View File

@ -264,10 +264,14 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
apply: compiler => {
// Lazy load the uglifyjs plugin
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const SourceMapDevToolPlugin = require("./SourceMapDevToolPlugin");
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: options.devtool && /source-?map/.test(options.devtool)
sourceMap:
(options.devtool && /source-?map/.test(options.devtool)) ||
(options.plugins &&
options.plugins.some(p => p instanceof SourceMapDevToolPlugin))
}).apply(compiler);
}
}

View File

@ -169,7 +169,7 @@ class WebpackOptionsValidationError extends WebpackError {
baseMessage +
"\n" +
"For typos: please correct them.\n" +
"For loader options: webpack 2 no longer allows custom properties in configuration.\n" +
"For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.\n" +
" Loaders should be updated to allow passing options via loader options in module.rules.\n" +
" Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
" plugins: [\n" +

View File

@ -73,7 +73,7 @@ class Profiler {
/**
* @param {string} outputPath The location where to write the log.
* @returns {{trace: ?, counter: number, profiler: Profiler, fsStream: WriteStream}} The trace object
* @returns {{trace: ?, counter: number, profiler: Profiler, end: Function}} The trace object
*/
function createTrace(outputPath) {
const trace = new Trace({
@ -121,7 +121,7 @@ function createTrace(outputPath) {
trace,
counter,
profiler,
fsStream
end: callback => fsStream.end(callback)
};
}
@ -181,7 +181,7 @@ class ProfilingPlugin {
if (parsedResults === undefined) {
tracer.profiler.destroy();
tracer.trace.flush();
tracer.fsStream.end(callback);
tracer.end(callback);
return;
}
@ -229,7 +229,7 @@ class ProfilingPlugin {
tracer.profiler.destroy();
tracer.trace.flush();
tracer.fsStream.end(callback);
tracer.end(callback);
});
}
);
@ -371,7 +371,7 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
return (...args) => {
// eslint-disable-line
const id = ++tracer.counter;
// Do not instrument outself due to the CPU
// Do not instrument ourself due to the CPU
// profile needing to be the last event in the trace.
if (name === pluginName) {
return fn(...args);

View File

@ -450,7 +450,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
case "reexport-non-harmony-default":
return (
"/* harmony reexport (default from non-hamory) */ " +
"/* harmony reexport (default from non-harmony) */ " +
this.getReexportStatement(
module,
module.isUsed(mode.name),
@ -461,7 +461,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
case "reexport-fake-namespace-object":
return (
"/* harmony reexport (fake namespace object from non-hamory) */ " +
"/* harmony reexport (fake namespace object from non-harmony) */ " +
this.getReexportFakeNamespaceObjectStatement(
module,
module.isUsed(mode.name),
@ -471,7 +471,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
case "rexport-non-harmony-undefined":
return (
"/* harmony reexport (non default export from non-hamory) */ " +
"/* harmony reexport (non default export from non-harmony) */ " +
this.getReexportStatement(
module,
module.isUsed(mode.name),
@ -482,7 +482,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
case "reexport-non-harmony-default-strict":
return (
"/* harmony reexport (default from non-hamory) */ " +
"/* harmony reexport (default from non-harmony) */ " +
this.getReexportStatement(
module,
module.isUsed(mode.name),

View File

@ -43,7 +43,7 @@ module.exports = class NodeMainTemplatePlugin {
return Template.asString([
source,
"",
"// uncatched error handler for webpack runtime",
"// uncaught error handler for webpack runtime",
`${mainTemplate.requireFn}.oe = function(err) {`,
Template.indent([
"process.nextTick(function() {",

View File

@ -97,7 +97,7 @@ class ReadFileCompileWasmMainTemplatePlugin {
return Template.asString([
source,
"",
"// object with all compiled WebAssmbly.Modules",
"// object with all compiled WebAssembly.Modules",
`${mainTemplate.requireFn}.w = {};`
]);
}

View File

@ -38,7 +38,7 @@ class EnsureChunkConditionsPlugin {
// We reached the entrypoint: fail
if (chunkGroup.isInitial()) {
throw new Error(
"Cannot fullfill chunk condition of " + module.identifier()
"Cannot fullfil chunk condition of " + module.identifier()
);
}
// Try placing in all parents

View File

@ -281,9 +281,16 @@ class ModuleConcatenationPlugin {
for (const reason of newModule.reasons) {
reason.dependency.module = newModule;
}
for (const dep of newModule.dependencies) {
// TODO: remove when LTS node version contains fixed v8 version
// @see https://github.com/webpack/webpack/pull/6613
// Turbofan does not correctly inline for-of loops with polymorphic input arrays.
// Work around issue by using a standard for loop and assigning dep.module.reasons
for (let i = 0; i < newModule.dependencies.length; i++) {
let dep = newModule.dependencies[i];
if (dep.module) {
for (const reason of dep.module.reasons) {
let reasons = dep.module.reasons;
for (let j = 0; j < reasons.length; j++) {
let reason = reasons[j];
if (reason.dependency === dep) reason.module = newModule;
}
}
@ -375,21 +382,16 @@ class ModuleConcatenationPlugin {
}
}
// Eagerly try to add imports too if possible
for (const imp of this.getImports(module)) {
const problem = this.tryToAdd(
testConfig,
imp,
possibleModules,
failureCache
);
if (problem) {
config.addWarning(module, problem);
}
}
// Commit experimental changes
config.set(testConfig);
// Eagerly try to add imports too if possible
for (const imp of this.getImports(module)) {
const problem = this.tryToAdd(config, imp, possibleModules, failureCache);
if (problem) {
config.addWarning(imp, problem);
}
}
return null;
}
}

View File

@ -83,7 +83,7 @@ module.exports = class SplitChunksPlugin {
this.options = SplitChunksPlugin.normalizeOptions(options);
}
static normalizeOptions(options) {
static normalizeOptions(options = {}) {
return {
chunks: options.chunks || "all",
minSize: options.minSize || 0,
@ -91,6 +91,7 @@ module.exports = class SplitChunksPlugin {
maxAsyncRequests: options.maxAsyncRequests || 1,
maxInitialRequests: options.maxInitialRequests || 1,
getName: SplitChunksPlugin.normalizeName(options.name) || (() => {}),
filename: options.filename || undefined,
getCacheGroups: SplitChunksPlugin.normalizeCacheGroups(
options.cacheGroups
)
@ -169,6 +170,7 @@ module.exports = class SplitChunksPlugin {
minChunks: option.minChunks,
maxAsyncRequests: option.maxAsyncRequests,
maxInitialRequests: option.maxInitialRequests,
filename: option.filename,
reuseExistingChunk: option.reuseExistingChunk
});
}
@ -277,6 +279,10 @@ module.exports = class SplitChunksPlugin {
cacheGroupSource.getName !== undefined
? cacheGroupSource.getName
: this.options.getName,
filename:
cacheGroupSource.filename !== undefined
? cacheGroupSource.filename
: this.options.filename,
reuseExistingChunk: cacheGroupSource.reuseExistingChunk
};
// For all combination of chunk selection
@ -431,7 +437,7 @@ module.exports = class SplitChunksPlugin {
}
if (chunkName) {
newChunk.chunkReason += ` (name: ${chunkName})`;
// If the choosen name is already an entry point we remove the entry point
// If the chosen name is already an entry point we remove the entry point
const entrypoint = compilation.entrypoints.get(chunkName);
if (entrypoint) {
compilation.entrypoints.delete(chunkName);
@ -439,6 +445,17 @@ module.exports = class SplitChunksPlugin {
newChunk.entryModule = undefined;
}
}
if (item.cacheGroup.filename) {
if (!newChunk.isOnlyInitial()) {
throw new Error(
"SplitChunksPlugin: You are trying to set a filename for a chunk which is (also) loaded on demand. " +
"The runtime can only handle loading of chunks which match the chunkFilename schema. " +
"Using a custom filename would fail at runtime. " +
`(cache group: ${item.cacheGroup.key})`
);
}
newChunk.filenameTemplate = item.cacheGroup.filename;
}
if (!isReused) {
// Add all modules to the new chunk
for (const module of item.modules) {

View File

@ -104,7 +104,7 @@ class FetchCompileWasmMainTemplatePlugin {
return Template.asString([
source,
"",
"// object with all compiled WebAssmbly.Modules",
"// object with all compiled WebAssembly.Modules",
`${mainTemplate.requireFn}.w = {};`
]);
}

View File

@ -13,6 +13,7 @@ const validateSchema = require("./validateSchema");
const WebpackOptionsValidationError = require("./WebpackOptionsValidationError");
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
const RemovedPluginError = require("./RemovedPluginError");
const version = require("../package.json").version;
const webpack = (options, callback) => {
const webpackOptionsValidationErrors = validateSchema(
@ -60,6 +61,7 @@ const webpack = (options, callback) => {
};
exports = module.exports = webpack;
exports.version = version;
webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter;
webpack.WebpackOptionsApply = WebpackOptionsApply;
@ -87,6 +89,7 @@ exportPlugins(exports, {
ContextExclusionPlugin: () => require("./ContextExclusionPlugin"),
ContextReplacementPlugin: () => require("./ContextReplacementPlugin"),
DefinePlugin: () => require("./DefinePlugin"),
Dependency: () => require("./Dependency"),
DllPlugin: () => require("./DllPlugin"),
DllReferencePlugin: () => require("./DllReferencePlugin"),
EnvironmentPlugin: () => require("./EnvironmentPlugin"),
@ -101,6 +104,7 @@ exportPlugins(exports, {
LoaderOptionsPlugin: () => require("./LoaderOptionsPlugin"),
LoaderTargetPlugin: () => require("./LoaderTargetPlugin"),
MemoryOutputFileSystem: () => require("./MemoryOutputFileSystem"),
Module: () => require("./Module"),
ModuleFilenameHelpers: () => require("./ModuleFilenameHelpers"),
NamedChunksPlugin: () => require("./NamedChunksPlugin"),
NamedModulesPlugin: () => require("./NamedModulesPlugin"),
@ -114,6 +118,7 @@ exportPlugins(exports, {
SingleEntryPlugin: () => require("./SingleEntryPlugin"),
SourceMapDevToolPlugin: () => require("./SourceMapDevToolPlugin"),
Stats: () => require("./Stats"),
Template: () => require("./Template"),
UmdMainTemplatePlugin: () => require("./UmdMainTemplatePlugin"),
WatchIgnorePlugin: () => require("./WatchIgnorePlugin")
});

View File

@ -196,7 +196,7 @@ rules:
# Add tests-needed label depending on codedov status
# Add tests-needed label depending on codecov status
# comment to point the user writing test cases
# comment in case of success
- filters:
@ -446,7 +446,7 @@ rules:
---
This issue was moved from {{owner}}/{{repo}}#{{issue.number}} by @{{comment.actor.login}}. Orginal issue was by @{{issue.user.login}}.
This issue was moved from {{owner}}/{{repo}}#{{issue.number}} by @{{comment.actor.login}}. Original issue was by @{{issue.user.login}}.
{{{comment_match.[2]}}}
comment:

View File

@ -1,6 +1,6 @@
{
"name": "webpack",
"version": "4.0.0",
"version": "4.1.0",
"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",
@ -22,7 +22,7 @@
"schema-utils": "^0.4.2",
"tapable": "^1.0.0",
"uglifyjs-webpack-plugin": "^1.1.1",
"watchpack": "^1.4.0",
"watchpack": "^1.5.0",
"webpack-sources": "^1.0.1"
},
"devDependencies": {

View File

@ -680,7 +680,7 @@
]
},
"moduleExtensions": {
"description": "Extenstions added to the module request when trying to find the module",
"description": "Extensions added to the module request when trying to find the module",
"anyOf": [
{
"$ref": "#/definitions/common.arrayOfStringValues"
@ -718,7 +718,7 @@
"type": "boolean"
},
"concord": {
"description": "Enable condord resolving extras",
"description": "Enable concord resolving extras",
"type": "boolean"
},
"unsafeCache": {
@ -1377,6 +1377,11 @@
}
]
},
"filename": {
"description": "Sets the template for the filename for created chunks (Only works for initial chunks)",
"type": "string",
"minLength": 1
},
"cacheGroups": {
"description": "Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks)",
"type": "object",
@ -1468,6 +1473,11 @@
"type": "string"
}
]
},
"filename": {
"description": "Sets the template for the filename for created chunks (Only works for initial chunks)",
"type": "string",
"minLength": 1
}
}
}
@ -1757,6 +1767,10 @@
"type": "boolean",
"description": "add information about modules nested in other modules (like with module concatenation)"
},
"moduleAssets": {
"type": "boolean",
"description": "add information about assets inside modules"
},
"children": {
"type": "boolean",
"description": "add children information"

View File

@ -4,63 +4,63 @@ const sinon = require("sinon");
const DependenciesBlockVariable = require("../lib/DependenciesBlockVariable");
describe("DependenciesBlockVariable", () => {
const sandbox = sinon.sandbox.create();
const dependencyMock = {
constructor: {
name: "DependencyMock"
},
disconnect: sandbox.spy(),
updateHash: sandbox.spy()
};
const DependenciesBlockVariableInstance = new DependenciesBlockVariable(
"dependencies-name",
"expression",
[dependencyMock]
);
let DependenciesBlockVariableInstance, dependencyMock, sandbox;
afterEach(() => {
sandbox.restore();
before(() => {
sandbox = sinon.sandbox.create();
dependencyMock = {
constructor: {
name: "DependencyMock"
},
disconnect: sandbox.spy(),
updateHash: sandbox.spy()
};
DependenciesBlockVariableInstance = new DependenciesBlockVariable(
"dependencies-name",
"expression",
[dependencyMock]
);
});
describe("hasDependencies", () => {
it("returns `true` if has dependencies", () => {
afterEach(() => sandbox.restore());
describe("hasDependencies", () =>
it("returns `true` if has dependencies", () =>
expect(DependenciesBlockVariableInstance.hasDependencies()).toBe(true);
});
});
describe("disconnect", () => {
describe("disconnect", () =>
it("trigger dependencies disconnection", () => {
DependenciesBlockVariableInstance.disconnect();
expect(dependencyMock.disconnect.calledOnce).toBe(true);
});
});
}));
describe("updateHash", () => {
const hash = {
update: sandbox.spy()
};
let hash;
before(() => {
hash = {
update: sandbox.spy()
};
DependenciesBlockVariableInstance.updateHash(hash);
});
DependenciesBlockVariableInstance.updateHash(hash);
it("should update hash dependencies with name", () => {
it("should update hash dependencies with name", () =>
expect(hash.update.calledWith("dependencies-name")).toBe(true);
});
it("should update hash dependencies with expression", () => {
it("should update hash dependencies with expression", () =>
expect(hash.update.calledWith("expression")).toBe(true);
});
it("should update hash inside dependencies", () => {
it("should update hash inside dependencies", () =>
expect(dependencyMock.updateHash.calledOnce).toBe(true);
});
});
describe("expressionSource", () => {
const applyMock = sandbox.spy();
let dependencyTemplates, applyMock;
it("aplies information inside dependency templates", () => {
const dependencyTemplates = {
get() {
before(() => (applyMock = sandbox.spy()));
it("applies information inside dependency templates", () => {
dependencyTemplates = {
get: function() {
return {
apply: applyMock
};
@ -74,9 +74,9 @@ describe("DependenciesBlockVariable", () => {
expect(applyMock.calledOnce).toBe(true);
});
it("aplies information inside dependency templates", () => {
const dependencyTemplates = {
get() {
it("applies information inside dependency templates", () => {
dependencyTemplates = {
get: function() {
return false;
}
};

View File

@ -56,7 +56,7 @@ describe("Examples", () => {
done();
});
},
20000
30000
);
});
});

View File

@ -45,7 +45,7 @@ describe("ExternalModule", () => {
it("calls getSource with the result of getSourceString", () => {
// set up
const expectedString = "something expected stringy";
const expectedSource = "something expected sourcy";
const expectedSource = "something expected source";
externalModule.getSource = sinon.stub().returns(expectedSource);
externalModule.getSourceString = sinon.stub().returns(expectedString);
@ -203,8 +203,8 @@ describe("ExternalModule", () => {
// check
expect(result).toEqual(expected);
});
describe("given an optinal check is set", () => {
it("ads a check for the existance of the variable before looking it up", () => {
describe("given an optional check is set", function() {
it("ads a check for the existence of the variable before looking it up", () => {
// set up
const id = "someId";
const optional = true;
@ -236,8 +236,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_someId__;`;
// check
expect(result).toEqual(expected);
});
describe("given an optinal check is requested", () => {
it("checks for the existance of the request setting it", () => {
describe("given an optional check is requested", function() {
it("checks for the existence of the request setting it", () => {
// set up
const optional = true;
const expected = `if(typeof some/request === 'undefined') {var e = new Error("Cannot find module \\"some/request\\""); e.code = 'MODULE_NOT_FOUND'; throw e;}

View File

@ -26,7 +26,7 @@ describe("HotTestCases", () => {
category.tests.forEach(testName => {
describe(testName, () => {
let exportedTests = [];
it(testName + " should compile", done => {
it(testName + " should compile", done => {
const testDirectory = path.join(casesPath, category.name, testName);
const outputDirectory = path.join(
__dirname,
@ -171,7 +171,7 @@ describe("HotTestCases", () => {
});
});
});
});
}, 10000);
});
});
});

View File

@ -43,7 +43,7 @@ describe("LocalModulesHelpers", () => {
).toBe(null);
});
it("returns local module informtion", () => {
it("returns local module information", () => {
const state = {
module: "module_sample",
localModules: [

View File

@ -3,7 +3,7 @@
const packageJSON = require("../package.json");
const MultiStats = require("../lib/MultiStats");
const createStat = overides => {
const createStat = overrides => {
return Object.assign(
{
hash: "foo",
@ -20,10 +20,10 @@ const createStat = overides => {
warnings: [],
errors: []
},
overides
overrides
)
},
overides
overrides
);
};

View File

@ -59,7 +59,7 @@ describe("RawModule", () => {
it(
"returns a new RawSource instance with sourceStr attribute provided " +
"as constructor argument if useSourceMap is falsey",
"as constructor argument if useSourceMap is falsy",
() => {
const rawSource = new RawSource(myRawModule.sourceStr);
myRawModule.useSourceMap = false;

View File

@ -386,7 +386,7 @@ describe("RuleSet", () => {
expect(match(loader, "style.css")).toEqual(["style-loader", "css-loader"]);
});
it("should work when using an array of functions returning either a loader obejct or loader name string", () => {
it("should work when using an array of functions returning either a loader object or loader name string", () => {
const loader = new RuleSet([
{
test: /\.css$/,

View File

@ -118,8 +118,8 @@ describe("Schemas", () => {
});
}
if ("properties" in item) {
it("should have additionalProperties set to some value when descriping properties", () => {
expect(item.additionalProperties).toBeDefined();
it("should have additionalProperties set to some value when describing properties", () => {
expect(item. additionalProperties).toBeDefined();
});
Object.keys(item.properties).forEach(name => {
describe(`> '${name}'`, () => {

View File

@ -174,7 +174,7 @@ describe("Validation", () => {
oneOf: [
{
test: "/a",
paser: {
passer: {
amd: false
}
}
@ -184,7 +184,7 @@ describe("Validation", () => {
}
},
message: [
" - configuration.module.rules[0].oneOf[0] has an unknown property 'paser'. These properties are valid:",
" - configuration.module.rules[0].oneOf[0] has an unknown property 'passer'. These properties are valid:",
" object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, resolve?, sideEffects?, query?, type?, resource?, resourceQuery?, compiler?, rules?, test?, use? }",
" -> A rule"
]
@ -201,7 +201,7 @@ describe("Validation", () => {
"loader?, module?, name?, node?, output?, optimization?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, " +
"recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }",
" For typos: please correct them.",
" For loader options: webpack 2 no longer allows custom properties in configuration.",
" For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.",
" Loaders should be updated to allow passing options via loader options in module.rules.",
" Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:",
" plugins: [",

View File

@ -14,7 +14,7 @@ describe("WebEnvironmentPlugin", () => {
WebEnvironmentPluginInstance.apply(compileSpy);
it("should set compiler.outputFileSystem information with the same as setted in WebEnvironmentPlugin", () => {
it("should set compiler.outputFileSystem information with the same as set in WebEnvironmentPlugin", () => {
expect(compileSpy.outputFileSystem).toBe(
WebEnvironmentPluginInstance.outputFileSystem
);

View File

@ -34,7 +34,7 @@ describe("main", function() {
// Comments work!
exports.ok = true;
test(require("subcontent") === "replaced", "node_modules should be replaced with web_modules");
test(require("subcontent2/file.js") === "orginal", "node_modules should still work when web_modules exists");
test(require("subcontent2/file.js") === "original", "node_modules should still work when web_modules exists");
done();
});
});

View File

@ -1441,7 +1441,7 @@ exports.cursor = {
};
/**
* Outut the given `failures` as a list.
* Output the given `failures` as a list.
*
* @param {Array} failures
* @api public
@ -2777,7 +2777,7 @@ function NyanCat(runner) {
, width = Base.window.width * .75 | 0
, rainbowColors = this.rainbowColors = self.generateColors()
, colorIndex = this.colorIndex = 0
, numerOfLines = this.numberOfLines = 4
, numberOfLines = this.numberOfLines = 4
, trajectories = this.trajectories = [[], [], [], []]
, nyanCatWidth = this.nyanCatWidth = 11
, trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth)

View File

@ -1 +1 @@
module.exports = "orginal";
module.exports = "original";

View File

@ -1,4 +1,4 @@
module.exports = [
[/There are multiple modules with names that only differ in casing/, /case-sensistive.A\.js/, /case-sensistive.a\.js/],
[/There are multiple modules with names that only differ in casing/, /case-sensistive.B.file\.js/, /case-sensistive.b.file\.js/]
[/There are multiple modules with names that only differ in casing/, /case-sensitive.A\.js/, /case-sensitive.a\.js/],
[/There are multiple modules with names that only differ in casing/, /case-sensitive.B.file\.js/, /case-sensitive.b.file\.js/]
];

View File

@ -1,6 +1,6 @@
it("should receive a namespace object when importing commonjs", function(done) {
import("./cjs").then(function(result) {
expect(result).toEqual({ default: { named: "named", default: "default" } });
expect(result).toEqual({ named: "named", default: { named: "named", default: "default" } });
done();
}).catch(done);
});
@ -60,9 +60,9 @@ function promiseTest(promise, equalsTo) {
it("should receive a namespace object when importing commonjs via context", function() {
return Promise.all([
promiseTest(contextCJS("one"), { default: { named: "named", default: "default" } }),
promiseTest(contextCJS("one"), { named: "named", default: { named: "named", default: "default" } }),
promiseTest(contextCJS("two"), { __esModule: true, named: "named", default: "default" }),
promiseTest(contextCJS("three"), { default: { named: "named", default: "default" } }),
promiseTest(contextCJS("three"), { named: "named", default: { named: "named", default: "default" } }),
promiseTest(contextCJS("null"), { default: null })
]);
});
@ -77,7 +77,7 @@ it("should receive a namespace object when importing harmony via context", funct
it("should receive a namespace object when importing mixed content via context", function() {
return Promise.all([
promiseTest(contextMixed("one"), { default: { named: "named", default: "default" } }),
promiseTest(contextMixed("one"), { named: "named", default: { named: "named", default: "default" } }),
promiseTest(contextMixed("two"), { __esModule: true, named: "named", default: "default" }),
promiseTest(contextMixed("three"), { named: "named", default: "default" }),
promiseTest(contextMixed("null"), { default: null })

View File

@ -52,7 +52,7 @@ it("should be able to use require.js-style define with arrow functions", functio
});
});
it("should be able to use require.js-style define, optional dependancies, not exist, with arrow function", function(done) {
it("should be able to use require.js-style define, optional dependencies, not exist, with arrow function", function(done) {
define("name", ["./optional"], (optional) => {
expect(optional.b).toBeFalsy();
done();

View File

@ -52,7 +52,7 @@ it("should be able to use require.js-style define", function(done) {
});
});
it("should be able to use require.js-style define, optional dependancies, not exist", function(done) {
it("should be able to use require.js-style define, optional dependencies, not exist", function(done) {
define("name", ["./optional"], function(optional) {
expect(optional.b).toBeFalsy();
done();

View File

@ -8,7 +8,7 @@ it("should pass when required by CommonJS module", function () {
it("should pass when use babeljs transpiler", function() {
//the following are generated code by use babeljs.
// use it this way will save trouble to setup babel-loader
// the babeljs transpiled code depends on the __esMoudule to be set
// the babeljs transpiled code depends on the __esModule to be set
var _test = require('./a');
var _test2 = _interopRequireDefault(_test);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

View File

@ -33,7 +33,7 @@ it("should parse cujojs UMD modules with deps", function() {
expect(module.exports).toBe(1234);
});
it("should parse cujojs UMD modules with inlinded deps", function() {
it("should parse cujojs UMD modules with inlined deps", function() {
(function (define) {
// using the define signature that triggers AMD-wrapped CommonJS

View File

@ -1,24 +1,24 @@
it("should cache modules correctly", function(done) {
delete require.cache[require.resolve("./singluar.js")];
expect(require("./singluar.js").value).toBe(1);
expect((require("./singluar.js")).value).toBe(1);
delete require.cache[require.resolve("./singular.js")];
expect(require("./singular.js").value).toBe(1);
expect((require("./singular.js")).value).toBe(1);
require("./sing" + "luar.js").value = 2;
expect(require("./singluar.js").value).toBe(2);
expect(require("./singular.js").value).toBe(2);
require.ensure(["./two.js"], function(require) {
expect(require("./singluar.js").value).toBe(2);
expect(require("./singular.js").value).toBe(2);
done();
});
});
it("should be able the remove modules from cache with require.cache and require.resolve", function() {
var singlarObj = require("./singluar2");
var singlarId = require.resolve("./singluar2");
var singlarIdInConditional = require.resolve(true ? "./singluar2" : "./singluar");
if(typeof singlarId !== "number" && typeof singlarId !== "string")
var singularObj = require("./singular2");
var singularId = require.resolve("./singular2");
var singularIdInConditional = require.resolve(true ? "./singular2" : "./singular");
if(typeof singularId !== "number" && typeof singularId !== "string")
throw new Error("require.resolve should return a number or string");
expect(singlarIdInConditional).toBe(singlarId);
expect(singularIdInConditional).toBe(singularId);
expect(require.cache).toBeTypeOf("object");
expect(require.cache[singlarId]).toBeTypeOf("object");
delete require.cache[singlarId];
expect(require("./singluar2")).not.toBe(singlarObj);
expect(require.cache[singularId]).toBeTypeOf("object");
delete require.cache[singularId];
expect(require("./singular2")).not.toBe(singularObj);
});

View File

@ -1,13 +1,13 @@
"use strict";
const compareLocations = require("../lib/compareLocations");
const createPosition = overides => {
const createPosition = overrides => {
return Object.assign(
{
line: 10,
column: 5
},
overides
overrides
);
};

View File

@ -0,0 +1,9 @@
it("should create a vendor file", function() {
var fs = require("fs");
var path = require("path");
if(!fs.existsSync(path.join(__dirname, "vendor.js")))
throw new Error("vendor.js file was not created");
});
require.include("test");

View File

@ -0,0 +1 @@
// empty

View File

@ -0,0 +1,19 @@
module.exports = {
mode: "development",
node: {
__dirname: false,
__filename: false
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: "initial",
filename: "vendor.js",
enforce: true
}
}
}
}
};

View File

@ -1,7 +1,7 @@
import d from "library";
import { a, b, external } from "library";
it("should be able to import hamorny exports from library (" + NAME + ")", function() {
it("should be able to import harmony exports from library (" + NAME + ")", function() {
expect(d).toBe("default-value");
expect(a).toBe("a");
expect(b).toBe("b");

View File

@ -81,7 +81,7 @@ it("should assign to process.env", function() {
process.env.TEST = "test";
expect(process.env.TEST).toBe("test");
});
it("should not have brakets on start", function() {
it("should not have brackets on start", function() {
function f() {
throw new Error("should not be called");
}
@ -90,12 +90,12 @@ it("should not have brakets on start", function() {
});
it("should not explode on recursive typeof calls", function() {
expect(typeof wurst).toEqual("undefined"); // <- is recursivly defined in config
expect(typeof wurst).toEqual("undefined"); // <- is recursively defined in config
});
it("should not explode on recursive statements", function() {
expect(function() {
wurst; // <- is recursivly defined in config
wurst; // <- is recursively defined in config
}).toThrowError("suppe is not defined");
});

View File

@ -1,4 +1,4 @@
it("should contain the custom progres messages", function() {
it("should contain the custom progress messages", function() {
var data = require(__dirname + "/data");
expect(data).toContain("optimizing");
expect(data).toContain("optimizing|CustomPlugin");

View File

@ -16,6 +16,10 @@ it("should provide a module for a nested var within a IIFE's argument", function
}(process));
});
it("should provide a module for thisExpression", () => {
(this.aaa).should.be.eql("aaa");
});
it("should provide a module for a nested var within a IIFE's this", function() {
(function() {
expect((this.env.NODE_ENV)).toBe("development");

View File

@ -9,7 +9,8 @@ module.exports = {
es2015: "./harmony",
es2015_name: ["./harmony", "default"],
es2015_alias: ["./harmony", "alias"],
es2015_year: ["./harmony", "year"]
es2015_year: ["./harmony", "year"],
"this.aaa": "./aaa"
})
]
};

View File

@ -0,0 +1 @@
module.exports = "a";

View File

@ -0,0 +1,6 @@
require("should");
it("should run", function() {
var a = require("./a");
a.should.be.eql("a");
});

View File

@ -0,0 +1,5 @@
module.exports = {
findBundle: function(i, options) {
return ["vendor.js", "main.js"];
}
};

View File

@ -0,0 +1,16 @@
const SplitChunksPlugin = require("../../../../lib/optimize/SplitChunksPlugin");
module.exports = {
entry: {
vendor: ["./a"],
main: "./index"
},
target: "web",
output: {
filename: "[name].js"
},
optimization: {
splitChunks: false
},
plugins: [new SplitChunksPlugin()]
};

View File

@ -9,8 +9,8 @@ describe("util/identifier", () => {
let context, pathConstruct, expected;
beforeEach(() => {
context = "/some/dir/";
pathConstruct = "/some/dir/to/somwhere|some/other/dir!../more/dir";
expected = "to/somwhere|some/other/dir!../more/dir";
pathConstruct = "/some/dir/to/somewhere|some/other/dir!../more/dir";
expected = "to/somewhere|some/other/dir!../more/dir";
});
it("computes the correct relative results for the path construct", () => {

View File

@ -5,7 +5,7 @@ Child fitting:
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
fb95acf7c457672e70d0.js 1.05 KiB 0 [emitted]
a1e683753eca705a0882.js 9.92 KiB 1 [emitted]
a1e683753eca705a0882.js 9.97 KiB 1 [emitted]
d43339a3d0f86c6b8d90.js 1.94 KiB 2 [emitted]
6c7fb52c5514dbfbf094.js 1.94 KiB 3 [emitted]
Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js
@ -31,7 +31,7 @@ Child content-change:
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
fb95acf7c457672e70d0.js 1.05 KiB 0 [emitted]
a1e683753eca705a0882.js 9.92 KiB 1 [emitted]
a1e683753eca705a0882.js 9.97 KiB 1 [emitted]
d43339a3d0f86c6b8d90.js 1.94 KiB 2 [emitted]
6c7fb52c5514dbfbf094.js 1.94 KiB 3 [emitted]
Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js

View File

@ -3,7 +3,7 @@ Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
0.js 149 bytes 0 [emitted]
entry.js 7.63 KiB 1 [emitted] entry
entry.js 7.79 KiB 1 [emitted] entry
Entrypoint entry = entry.js
[0] ./modules/b.js 22 bytes {0} [built]
[1] ./entry.js 120 bytes {1} [built]

View File

@ -4,7 +4,7 @@ Child 1 chunks:
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
bundle.js 5.52 KiB 0 [emitted] main
bundle.js 5.68 KiB 0 [emitted] main
Entrypoint main = bundle.js
chunk {0} bundle.js (main) 191 bytes <{0}> >{0}< [entry] [rendered]
[0] ./index.js 73 bytes {0} [built]
@ -17,9 +17,9 @@ Child 2 chunks:
Hash: f90c7b21ae5c6e853a0d
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
0.bundle.js 912 bytes 0 [emitted]
bundle.js 7.14 KiB 1 [emitted] main
Asset Size Chunks Chunk Names
0.bundle.js 1 KiB 0 [emitted]
bundle.js 7.19 KiB 1 [emitted] main
Entrypoint main = bundle.js
chunk {0} 0.bundle.js 118 bytes <{0}> <{1}> >{0}< [rendered]
[0] ./d.js 22 bytes {0} [built]
@ -34,9 +34,9 @@ Child 3 chunks:
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
0.bundle.js 774 bytes 0 [emitted]
0.bundle.js 886 bytes 0 [emitted]
1.bundle.js 245 bytes 1 [emitted]
bundle.js 7.14 KiB 2 [emitted] main
bundle.js 7.19 KiB 2 [emitted] main
Entrypoint main = bundle.js
chunk {0} 0.bundle.js 74 bytes <{0}> <{2}> >{0}< >{1}< [rendered]
[0] ./d.js 22 bytes {0} [built]
@ -54,8 +54,8 @@ Child 4 chunks:
Asset Size Chunks Chunk Names
0.bundle.js 236 bytes 0 [emitted]
1.bundle.js 245 bytes 1 [emitted]
2.bundle.js 603 bytes 2 [emitted]
bundle.js 7.14 KiB 3 [emitted] main
2.bundle.js 715 bytes 2 [emitted]
bundle.js 7.19 KiB 3 [emitted] main
Entrypoint main = bundle.js
chunk {0} 0.bundle.js 44 bytes <{2}> <{3}> [rendered]
[0] ./d.js 22 bytes {0} [built]

View File

@ -0,0 +1,12 @@
Hash: d71bd16b0b20f34e994a
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Entrypoint main = main.js
chunk {0} 0.js 68 bytes <{1}> [rendered]
[0] ./node_modules/a/1.png 51 bytes {0} [built] [1 asset]
[1] ./node_modules/a/index.js 17 bytes {0} [built]
chunk {1} main.js (main) 12 bytes >{0}< [entry] [rendered]
[2] ./index.js 12 bytes {1} [built]
[0] ./node_modules/a/1.png 51 bytes {0} [built] [1 asset]
[1] ./node_modules/a/index.js 17 bytes {0} [built]
[2] ./index.js 12 bytes {1} [built]

View File

@ -0,0 +1 @@
import('a')

BIN
test/statsCases/module-assets/node_modules/a/1.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -0,0 +1 @@
import './1.png'

View File

@ -0,0 +1,26 @@
module.exports = {
mode: "production",
entry: "./index",
stats: {
assets: false,
chunks: true,
chunkModules: true,
modules: true,
moduleAssets: true
},
module: {
rules: [
{
test: /\.png$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]"
}
}
]
}
]
}
};

View File

@ -2,9 +2,9 @@ Hash: c5b0089a4015e8744f8e
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
chunk-containing-__a_js.js 453 bytes chunk-containing-__a_js [emitted]
chunk-containing-__a_js.js 509 bytes chunk-containing-__a_js [emitted]
chunk-containing-__b_js.js 173 bytes chunk-containing-__b_js [emitted]
entry.js 7.17 KiB entry [emitted] entry
entry.js 7.28 KiB entry [emitted] entry
Entrypoint entry = entry.js
[0] ./modules/b.js 22 bytes {chunk-containing-__b_js} [built]
[1] ./modules/a.js 37 bytes {chunk-containing-__a_js} [built]

View File

@ -0,0 +1 @@
import "./concatenated1";

View File

@ -0,0 +1 @@
import { x } from "./concatenated2";

View File

@ -0,0 +1,2 @@
import { y } from "external";
export var x = y;

View File

@ -1,21 +1,29 @@
Hash: 2f9dacd48c09c3072b04
Hash: 123228577e0595ae0a8e
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Entrypoint index = index.js
Entrypoint entry = entry.js
[0] ./entry.js 32 bytes {0} {1} [built]
[0] ./entry.js 32 bytes {1} {2} [built]
ModuleConcatenation bailout: Module is an entry point
[1] ./ref-from-cjs.js 45 bytes {0} [built]
[1] ./ref-from-cjs.js 45 bytes {1} [built]
ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./cjs.js (referenced with cjs require)
[2] ./index.js 150 bytes {0} [built]
ModuleConcatenation bailout: Module is an entry point
[3] ./cjs.js 59 bytes {0} [built]
[2] external "external" 42 bytes {1} [built]
ModuleConcatenation bailout: Module is not an ECMAScript module
[4] ./eval.js 35 bytes {0} [built]
[3] ./concatenated.js + 2 modules 116 bytes {0} [built]
ModuleConcatenation bailout: Cannot concat with external "external" (<- Module is not an ECMAScript module)
| ./concatenated.js 26 bytes [built]
| ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./index.js (referenced with import())
| ./concatenated1.js 37 bytes [built]
| ./concatenated2.js 48 bytes [built]
[4] ./index.js 176 bytes {1} [built]
ModuleConcatenation bailout: Module is an entry point
[5] ./cjs.js 59 bytes {1} [built]
ModuleConcatenation bailout: Module is not an ECMAScript module
[6] ./eval.js 35 bytes {1} [built]
ModuleConcatenation bailout: Module uses eval()
[5] ./injected-vars.js 40 bytes {0} [built]
[7] ./injected-vars.js 40 bytes {1} [built]
ModuleConcatenation bailout: Module uses injected variables (__dirname, __filename)
[6] ./module-id.js 26 bytes {0} [built]
[8] ./module-id.js 26 bytes {1} [built]
ModuleConcatenation bailout: Module uses module.id
[7] ./module-loaded.js 30 bytes {0} [built]
[9] ./module-loaded.js 30 bytes {1} [built]
ModuleConcatenation bailout: Module uses module.loaded

View File

@ -5,3 +5,4 @@ import "./injected-vars";
import "./module-id";
import "./module-loaded";
import "./ref-from-cjs";
import("./concatenated");

View File

@ -8,6 +8,7 @@ module.exports = {
output: {
filename: "[name].js"
},
externals: ["external"],
stats: {
assets: false,
optimizationBailout: true

View File

@ -159,6 +159,13 @@ anymatch@^1.3.0:
micromatch "^2.1.5"
normalize-path "^2.0.0"
anymatch@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb"
dependencies:
micromatch "^3.1.4"
normalize-path "^2.1.1"
append-transform@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991"
@ -284,7 +291,7 @@ async@1.x, async@^1.4.0:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
async@^2.1.2, async@^2.1.4:
async@^2.1.4:
version "2.6.0"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4"
dependencies:
@ -561,7 +568,7 @@ braces@^1.8.2:
preserve "^0.2.0"
repeat-element "^1.1.2"
braces@^2.3.1:
braces@^2.3.0, braces@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.1.tgz#7086c913b4e5a08dbe37ac0ee6a2500c4ba691bb"
dependencies:
@ -795,18 +802,21 @@ chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
chokidar@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
chokidar@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.2.tgz#4dc65139eeb2714977735b6a35d06e97b494dfd7"
dependencies:
anymatch "^1.3.0"
anymatch "^2.0.0"
async-each "^1.0.0"
glob-parent "^2.0.0"
braces "^2.3.0"
glob-parent "^3.1.0"
inherits "^2.0.1"
is-binary-path "^1.0.0"
is-glob "^2.0.0"
is-glob "^4.0.0"
normalize-path "^2.1.1"
path-is-absolute "^1.0.0"
readdirp "^2.0.0"
upath "^1.0.0"
optionalDependencies:
fsevents "^1.0.0"
@ -2143,6 +2153,13 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"
glob-parent@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae"
dependencies:
is-glob "^3.1.0"
path-dirname "^1.0.0"
glob@7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
@ -2615,6 +2632,10 @@ is-extglob@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0"
is-extglob@^2.1.0, is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
is-finite@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa"
@ -2641,6 +2662,18 @@ is-glob@^2.0.0, is-glob@^2.0.1:
dependencies:
is-extglob "^1.0.0"
is-glob@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a"
dependencies:
is-extglob "^2.1.0"
is-glob@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0"
dependencies:
is-extglob "^2.1.1"
is-my-json-valid@^2.12.4:
version "2.17.1"
resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz#3da98914a70a22f0a8563ef1511a246c6fc55471"
@ -3596,6 +3629,24 @@ micromatch@^2.1.5, micromatch@^2.3.11:
parse-glob "^3.0.4"
regex-cache "^0.4.2"
micromatch@^3.1.4:
version "3.1.9"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.9.tgz#15dc93175ae39e52e93087847096effc73efcf89"
dependencies:
arr-diff "^4.0.0"
array-unique "^0.3.2"
braces "^2.3.1"
define-property "^2.0.2"
extend-shallow "^3.0.2"
extglob "^2.0.4"
fragment-cache "^0.2.1"
kind-of "^6.0.2"
nanomatch "^1.2.9"
object.pick "^1.3.0"
regex-not "^1.0.0"
snapdragon "^0.8.1"
to-regex "^3.0.1"
micromatch@^3.1.8:
version "3.1.8"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.8.tgz#5c8caa008de588eebb395e8c0ad12c128f25fff1"
@ -3868,7 +3919,7 @@ normalize-package-data@^2.3.2:
semver "2 || 3 || 4 || 5"
validate-npm-package-license "^3.0.1"
normalize-path@^2.0.0, normalize-path@^2.0.1:
normalize-path@^2.0.0, normalize-path@^2.0.1, normalize-path@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9"
dependencies:
@ -4102,6 +4153,10 @@ path-browserify@0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a"
path-dirname@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
path-exists@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b"
@ -5773,6 +5828,10 @@ unset-value@^1.0.0:
has-value "^0.3.1"
isobject "^3.0.0"
upath@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/upath/-/upath-1.0.4.tgz#ee2321ba0a786c50973db043a50b7bcba822361d"
urix@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
@ -5883,13 +5942,13 @@ watch@~0.18.0:
exec-sh "^0.2.0"
minimist "^1.2.0"
watchpack@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.4.0.tgz#4a1472bcbb952bd0a9bb4036801f954dfb39faac"
watchpack@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.5.0.tgz#231e783af830a22f8966f65c4c4bacc814072eed"
dependencies:
async "^2.1.2"
chokidar "^1.7.0"
chokidar "^2.0.2"
graceful-fs "^4.1.2"
neo-async "^2.5.0"
webidl-conversions@^4.0.1, webidl-conversions@^4.0.2:
version "4.0.2"