mirror of https://github.com/webpack/webpack.git
Merge branch 'master' into next
This commit is contained in:
commit
82f42e2c67
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Sean Larkin @thelarkinn
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("./WebpackError");
|
||||
|
||||
module.exports = class AsyncDependencyToInitialChunkWarning extends WebpackError {
|
||||
constructor(chunkName, module, loc) {
|
||||
super();
|
||||
|
||||
this.name = "AsyncDependencyToInitialChunkWarning";
|
||||
this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`;
|
||||
this.module = module;
|
||||
this.origin = module;
|
||||
this.originLoc = loc;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
};
|
||||
|
|
@ -20,6 +20,7 @@ const HotUpdateChunkTemplate = require("./HotUpdateChunkTemplate");
|
|||
const ModuleTemplate = require("./ModuleTemplate");
|
||||
const Dependency = require("./Dependency");
|
||||
const ChunkRenderError = require("./ChunkRenderError");
|
||||
const AsyncDependencyToInitialChunkWarning = require("./AsyncDependencyToInitialChunkWarning");
|
||||
const CachedSource = require("webpack-sources").CachedSource;
|
||||
const Stats = require("./Stats");
|
||||
const Semaphore = require("./util/Semaphore");
|
||||
|
|
@ -891,12 +892,19 @@ class Compilation extends Tapable {
|
|||
// but only once (blockChunks map)
|
||||
let c = blockChunks.get(b);
|
||||
if(c === undefined) {
|
||||
c = this.addChunk(b.chunkName, b.module, b.loc);
|
||||
blockChunks.set(b, c);
|
||||
allCreatedChunks.add(c);
|
||||
// We initialize the chunks property
|
||||
// this is later filled with the chunk when needed
|
||||
b.chunks = [];
|
||||
c = this.namedChunks[b.chunkName];
|
||||
if(c && c.isInitial()) {
|
||||
// TODO webpack 4: convert this to an error
|
||||
this.warnings.push(new AsyncDependencyToInitialChunkWarning(b.chunkName, b.module, b.loc));
|
||||
c = chunk;
|
||||
} else {
|
||||
c = this.addChunk(b.chunkName, b.module, b.loc);
|
||||
blockChunks.set(b, c);
|
||||
allCreatedChunks.add(c);
|
||||
// We initialize the chunks property
|
||||
// this is later filled with the chunk when needed
|
||||
b.chunks = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 2. We store the Block+Chunk mapping as dependency for the chunk
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ModuleParseError extends WebpackError {
|
|||
super();
|
||||
|
||||
this.name = "ModuleParseError";
|
||||
this.message = "Module parse failed: " + module.request + " " + err.message;
|
||||
this.message = "Module parse failed: " + err.message;
|
||||
this.message += "\nYou may need an appropriate loader to handle this file type.";
|
||||
if(err.loc && typeof err.loc === "object" && typeof err.loc.line === "number") {
|
||||
var lineNumber = err.loc.line;
|
||||
|
|
|
|||
23
lib/Stats.js
23
lib/Stats.js
|
|
@ -199,15 +199,22 @@ class Stats {
|
|||
text += e.message;
|
||||
if(showErrorDetails && e.details) text += `\n${e.details}`;
|
||||
if(showErrorDetails && e.missing) text += e.missing.map(item => `\n[${item}]`).join("");
|
||||
if(showModuleTrace && e.dependencies && e.origin) {
|
||||
if(showModuleTrace && e.origin) {
|
||||
text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
|
||||
e.dependencies.forEach(dep => {
|
||||
if(!dep.loc) return;
|
||||
if(typeof dep.loc === "string") return;
|
||||
const locInfo = formatLocation(dep.loc);
|
||||
if(!locInfo) return;
|
||||
text += ` ${locInfo}`;
|
||||
});
|
||||
if(typeof e.originLoc === "object") {
|
||||
const locInfo = formatLocation(e.originLoc);
|
||||
if(locInfo)
|
||||
text += ` ${locInfo}`;
|
||||
}
|
||||
if(e.dependencies) {
|
||||
e.dependencies.forEach(dep => {
|
||||
if(!dep.loc) return;
|
||||
if(typeof dep.loc === "string") return;
|
||||
const locInfo = formatLocation(dep.loc);
|
||||
if(!locInfo) return;
|
||||
text += ` ${locInfo}`;
|
||||
});
|
||||
}
|
||||
let current = e.origin;
|
||||
while(current.issuer) {
|
||||
current = current.issuer;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "webpack",
|
||||
"version": "3.7.1",
|
||||
"version": "3.8.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.",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -967,6 +967,7 @@
|
|||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"context": {
|
||||
"type": "string",
|
||||
|
|
@ -989,6 +990,46 @@
|
|||
"type": "boolean",
|
||||
"description": "add assets information"
|
||||
},
|
||||
"env": {
|
||||
"type": "boolean",
|
||||
"description": "add --env information"
|
||||
},
|
||||
"colors": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "`webpack --colors` equivalent"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"bold": {
|
||||
"type": "string"
|
||||
},
|
||||
"red": {
|
||||
"type": "string"
|
||||
},
|
||||
"green": {
|
||||
"type": "string"
|
||||
},
|
||||
"cyan": {
|
||||
"type": "string"
|
||||
},
|
||||
"magenta": {
|
||||
"type": "string"
|
||||
},
|
||||
"yellow": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"maxModules": {
|
||||
"type": "number",
|
||||
"description": "Set the maximum number of modules to be shown"
|
||||
},
|
||||
"chunks": {
|
||||
"type": "boolean",
|
||||
"description": "add chunk information"
|
||||
|
|
@ -1009,6 +1050,10 @@
|
|||
"type": "boolean",
|
||||
"description": "add also information about cached (not built) modules"
|
||||
},
|
||||
"cachedAssets": {
|
||||
"type": "boolean",
|
||||
"description": "Show cached assets (setting this to `false` only shows emitted files)"
|
||||
},
|
||||
"reasons": {
|
||||
"type": "boolean",
|
||||
"description": "add information about the reasons why modules are included"
|
||||
|
|
@ -1033,6 +1078,10 @@
|
|||
"description": "Please use excludeModules instead.",
|
||||
"$ref": "#/definitions/filter-types"
|
||||
},
|
||||
"entrypoints": {
|
||||
"type": "boolean",
|
||||
"description": "Display the entry points with the corresponding bundles"
|
||||
},
|
||||
"errorDetails": {
|
||||
"type": "boolean",
|
||||
"description": "add details to errors (like resolving log)"
|
||||
|
|
@ -1057,6 +1106,10 @@
|
|||
"type": "string",
|
||||
"description": "sort the assets by that field"
|
||||
},
|
||||
"publicPath": {
|
||||
"type": "boolean",
|
||||
"description": "Add public path information"
|
||||
},
|
||||
"providedExports": {
|
||||
"type": "boolean",
|
||||
"description": "show exports provided by modules"
|
||||
|
|
|
|||
|
|
@ -199,6 +199,20 @@ describe("Validation", () => {
|
|||
message: [
|
||||
" - configuration.context: The provided value \"baz\" is not an absolute path!",
|
||||
]
|
||||
}, {
|
||||
name: "missing stats option",
|
||||
config: {
|
||||
entry: "foo.js",
|
||||
stats: {
|
||||
foobar: true
|
||||
}
|
||||
},
|
||||
test(e) {
|
||||
e.message.should.startWith("Invalid configuration object.");
|
||||
e.message.split("\n").slice(1)[0].should.be.eql(
|
||||
" - configuration.stats should be one of these:"
|
||||
);
|
||||
}
|
||||
}];
|
||||
testCases.forEach((testCase) => {
|
||||
it("should fail validation for " + testCase.name, () => {
|
||||
|
|
@ -207,6 +221,12 @@ describe("Validation", () => {
|
|||
} catch(e) {
|
||||
if(!(e instanceof WebpackOptionsValidationError))
|
||||
throw e;
|
||||
|
||||
if(testCase.test) {
|
||||
testCase.test(e);
|
||||
return;
|
||||
}
|
||||
|
||||
e.message.should.startWith("Invalid configuration object.");
|
||||
e.message.split("\n").slice(1).should.be.eql(testCase.message);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
it("should handle reference to entry chunk correctly", function(done) {
|
||||
import(/* webpackChunkName: "main" */"./module-a").then(function(result) {
|
||||
result.default.should.be.eql("ok");
|
||||
done();
|
||||
}).catch(function(e) {
|
||||
done(e);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1 @@
|
|||
export default "ok";
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = [
|
||||
[/It's not allowed to load an initial chunk on demand\. The chunk name "main" is already used by an entrypoint\./],
|
||||
];
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
Time: Xms
|
||||
Asset Size Chunks Chunk Names
|
||||
0.js 839 bytes 0 [emitted] async3
|
||||
1.js 839 bytes 1 [emitted] async2
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module.exports = {
|
|||
},
|
||||
stats: {
|
||||
hash: false,
|
||||
timing: false,
|
||||
timings: false,
|
||||
chunks: true,
|
||||
chunkModules: true,
|
||||
modules: false
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
Time: Xms
|
||||
Asset Size Chunks Chunk Names
|
||||
0.js 761 bytes 0, 3 [emitted]
|
||||
1.js 761 bytes 1, 4 [emitted]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module.exports = {
|
|||
},
|
||||
stats: {
|
||||
hash: false,
|
||||
timing: false,
|
||||
timings: false,
|
||||
chunks: true,
|
||||
chunkModules: true,
|
||||
modules: false
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
import "./b";
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
some
|
||||
code
|
||||
which
|
||||
includes
|
||||
a
|
||||
parser )
|
||||
error
|
||||
in
|
||||
some
|
||||
line
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Asset Size Chunks Chunk Names
|
||||
main.js 3.22 kB 0 [emitted] main
|
||||
[0] (webpack)/test/statsCases/parse-error/index.js 15 bytes {0} [built]
|
||||
[1] (webpack)/test/statsCases/parse-error/a.js 15 bytes {0} [built]
|
||||
[2] (webpack)/test/statsCases/parse-error/b.js 169 bytes {0} [built] [failed] [1 error]
|
||||
|
||||
ERROR in (webpack)/test/statsCases/parse-error/b.js
|
||||
Module parse failed: Unexpected token (6:7)
|
||||
You may need an appropriate loader to handle this file type.
|
||||
| includes
|
||||
| a
|
||||
| parser )
|
||||
| error
|
||||
| in
|
||||
@ (webpack)/test/statsCases/parse-error/a.js 2:0-13
|
||||
@ (webpack)/test/statsCases/parse-error/index.js
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
import "./a";
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
entry: "./index",
|
||||
stats: {
|
||||
timings: false,
|
||||
hash: false,
|
||||
modules: true,
|
||||
chunks: false
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue