Skip to content

Commit 128ec00

Browse files
committed
Adding a warning of you accidentally override a core cache group
1 parent a7fbde3 commit 128ec00

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/config/validator.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class Validator {
2626
this._validatePublicPathAndManifestKeyPrefix();
2727

2828
this._validateDevServer();
29+
30+
this._validateSharedEntryName();
2931
}
3032

3133
_validateBasic() {
@@ -66,6 +68,12 @@ class Validator {
6668
logger.warning(`Passing an absolute URL to setPublicPath() *and* using the dev-server can cause issues. Your assets will load from the publicPath (${this.webpackConfig.publicPath}) instead of from the dev server URL (${this.webpackConfig.runtimeConfig.devServerUrl}).`);
6769
}
6870
}
71+
72+
_validateSharedEntryName() {
73+
if (['vendors', 'default'].includes(this.webpackConfig.sharedCommonsEntryName)) {
74+
logger.warning(`Passing "${this.webpackConfig.sharedCommonsEntryName}" to createSharedEntry() is not recommended, as it will override the built-in cache group by this name.`);
75+
}
76+
}
6977
}
7078

7179
module.exports = function(webpackConfig) {

test/config/validator.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,18 @@ describe('The validator function', () => {
8282
expect(logger.getMessages().warning).to.have.lengthOf(1);
8383
expect(logger.getMessages().warning[0]).to.include('Passing an absolute URL to setPublicPath() *and* using the dev-server can cause issues');
8484
});
85+
86+
it('warning with createSharedEntry() and core cache group name', () => {
87+
const config = createConfig();
88+
config.outputPath = '/tmp/public/build';
89+
config.setPublicPath('/build');
90+
config.createSharedEntry('vendors', './main');
91+
92+
logger.reset();
93+
logger.quiet();
94+
validator(config);
95+
96+
expect(logger.getMessages().warning).to.have.lengthOf(1);
97+
expect(logger.getMessages().warning[0]).to.include('Passing "vendors" to createSharedEntry() is not recommended');
98+
});
8599
});

0 commit comments

Comments
 (0)