Skip to content

Commit 069789a

Browse files
authored
Merge pull request webpack#6155 from EugeneHlushko/feature/disallow-load-initial-on-demand
Feature: Disallow to load initial chunk on demand via throwing an error
2 parents fd2607f + cff7e37 commit 069789a

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

lib/AsyncDependencyToInitialChunkWarning.js renamed to lib/AsyncDependencyToInitialChunkError.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
const WebpackError = require("./WebpackError");
88

9-
module.exports = class AsyncDependencyToInitialChunkWarning extends WebpackError {
9+
module.exports = class AsyncDependencyToInitialChunkError extends WebpackError {
1010
constructor(chunkName, module, loc) {
1111
super();
1212

13-
this.name = "AsyncDependencyToInitialChunkWarning";
13+
this.name = "AsyncDependencyToInitialChunkError";
1414
this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`;
1515
this.module = module;
1616
this.origin = module;

lib/Compilation.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const ModuleTemplate = require("./ModuleTemplate");
2424
const RuntimeTemplate = require("./RuntimeTemplate");
2525
const Dependency = require("./Dependency");
2626
const ChunkRenderError = require("./ChunkRenderError");
27-
const AsyncDependencyToInitialChunkWarning = require("./AsyncDependencyToInitialChunkWarning");
27+
const AsyncDependencyToInitialChunkError = require("./AsyncDependencyToInitialChunkError");
2828
const CachedSource = require("webpack-sources").CachedSource;
2929
const Stats = require("./Stats");
3030
const Semaphore = require("./util/Semaphore");
@@ -1031,8 +1031,7 @@ class Compilation extends Tapable {
10311031
if(c === undefined) {
10321032
c = this.namedChunks[b.chunkName];
10331033
if(c && c.isInitial()) {
1034-
// TODO webpack 4: convert this to an error
1035-
this.warnings.push(new AsyncDependencyToInitialChunkWarning(b.chunkName, b.module, b.loc));
1034+
this.errors.push(new AsyncDependencyToInitialChunkError(b.chunkName, b.module, b.loc));
10361035
c = chunk;
10371036
} else {
10381037
c = this.addChunk(b.chunkName, b.module, b.loc);

0 commit comments

Comments
 (0)