Skip to content

Commit 6de05cf

Browse files
committed
preventing shared entry & split chunks from being used together
1 parent 75ec093 commit 6de05cf

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/WebpackConfig.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ class WebpackConfig {
326326
}
327327

328328
splitEntryChunks() {
329+
if (this.sharedCommonsEntryName) {
330+
throw new Error('Using splitEntryChunks() and createSharedEntry() together is not supported. Use one of these strategies only to optimize your build.');
331+
}
332+
329333
this.shouldSplitEntryChunks = true;
330334
}
331335

@@ -338,6 +342,10 @@ class WebpackConfig {
338342
}
339343

340344
createSharedEntry(name, file) {
345+
if (this.shouldSplitEntryChunks) {
346+
throw new Error('Using splitEntryChunks() and createSharedEntry() together is not supported. Use one of these strategies only to optimize your build.');
347+
}
348+
341349
// don't allow to call this twice
342350
if (this.sharedCommonsEntryName) {
343351
throw new Error('createSharedEntry() cannot be called multiple times: you can only create *one* shared entry.');

test/WebpackConfig.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ describe('WebpackConfig object', () => {
348348
config.createSharedEntry('vendor2', './main');
349349
}).to.throw('cannot be called multiple');
350350
});
351+
352+
it('Calling with splitEntryChunks() is not supported', () => {
353+
const config = createConfig();
354+
config.splitEntryChunks();
355+
356+
expect(() => {
357+
config.createSharedEntry('vendor', './main');
358+
}).to.throw('together is not supported');
359+
});
351360
});
352361

353362
describe('autoProvideVariables', () => {
@@ -451,6 +460,15 @@ describe('WebpackConfig object', () => {
451460
config.configureSplitChunks('FOO');
452461
}).to.throw('must be a callback function');
453462
});
463+
464+
it('Calling with createdSharedEntry() is not supported', () => {
465+
const config = createConfig();
466+
config.createSharedEntry('vendor', './main');
467+
468+
expect(() => {
469+
config.splitEntryChunks();
470+
}).to.throw('together is not supported');
471+
});
454472
});
455473

456474
describe('enablePostCssLoader', () => {

0 commit comments

Comments
 (0)