Skip to content

Commit ec21e25

Browse files
committed
Remove old deprecations
1 parent 24c20b2 commit ec21e25

8 files changed

+37
-144
lines changed

index.js

-32
Original file line numberDiff line numberDiff line change
@@ -1459,38 +1459,6 @@ class Encore {
14591459
runtimeConfig = null;
14601460
webpackConfig = null;
14611461
}
1462-
1463-
/**
1464-
* @deprecated
1465-
* @return {void}
1466-
*/
1467-
configureExtractTextPlugin() {
1468-
throw new Error('The configureExtractTextPlugin() method was removed from Encore. The underlying plugin was removed from Webpack 4.');
1469-
}
1470-
1471-
/**
1472-
* @deprecated
1473-
* @return {void}
1474-
*/
1475-
enableCoffeeScriptLoader() {
1476-
throw new Error('The enableCoffeeScriptLoader() method and CoffeeScript support was removed from Encore due to support problems with Webpack 4. If you are interested in this feature, please submit a pull request!');
1477-
}
1478-
1479-
/**
1480-
* @deprecated
1481-
* @return {void}
1482-
*/
1483-
configureUglifyJsPlugin() {
1484-
throw new Error('The configureUglifyJsPlugin() method was removed from Encore due to uglify-js dropping ES6+ support in its latest version. Please use configureTerserPlugin() instead.');
1485-
}
1486-
1487-
/**
1488-
* @deprecated
1489-
* @return {void}
1490-
*/
1491-
configureLoaderOptionsPlugin() {
1492-
throw new Error('The configureLoaderOptionsPlugin() method was removed from Encore. The underlying plugin should not be needed anymore unless you are using outdated loaders. If that\'s the case you can still add it using addPlugin().');
1493-
}
14941462
}
14951463

14961464
/**

lib/WebpackConfig.js

+9-21
Original file line numberDiff line numberDiff line change
@@ -400,18 +400,12 @@ class WebpackConfig {
400400
const allowedOptionsWithExternalConfig = ['includeNodeModules', 'exclude'];
401401

402402
for (const optionKey of Object.keys(options)) {
403-
let normalizedOptionKey = optionKey;
404-
if (optionKey === 'include_node_modules') {
405-
logger.deprecation('configureBabel: "include_node_modules" is deprecated. Please use "includeNodeModules" instead.');
406-
normalizedOptionKey = 'includeNodeModules';
407-
}
408-
409-
if (this.doesBabelRcFileExist() && !allowedOptionsWithExternalConfig.includes(normalizedOptionKey)) {
410-
logger.warning(`The "${normalizedOptionKey}" option of configureBabel() will not be used because your app already provides an external Babel configuration (a ".babelrc" file, ".babelrc.js" file or "babel" key in "package.json").`);
403+
if (this.doesBabelRcFileExist() && !allowedOptionsWithExternalConfig.includes(optionKey)) {
404+
logger.warning(`The "${optionKey}" option of configureBabel() will not be used because your app already provides an external Babel configuration (a ".babelrc" file, ".babelrc.js" file or "babel" key in "package.json").`);
411405
continue;
412406
}
413407

414-
if (normalizedOptionKey === 'includeNodeModules') {
408+
if (optionKey === 'includeNodeModules') {
415409
if (Object.keys(options).includes('exclude')) {
416410
throw new Error('"includeNodeModules" and "exclude" options can\'t be used together when calling configureBabel().');
417411
}
@@ -440,10 +434,10 @@ class WebpackConfig {
440434
// Exclude other modules
441435
return true;
442436
};
443-
} else if (!(normalizedOptionKey in this.babelOptions)) {
444-
throw new Error(`Invalid option "${normalizedOptionKey}" passed to configureBabel(). Valid keys are ${[...Object.keys(this.babelOptions), 'includeNodeModules'].join(', ')}`);
437+
} else if (!(optionKey in this.babelOptions)) {
438+
throw new Error(`Invalid option "${optionKey}" passed to configureBabel(). Valid keys are ${[...Object.keys(this.babelOptions), 'includeNodeModules'].join(', ')}`);
445439
} else {
446-
this.babelOptions[normalizedOptionKey] = options[optionKey];
440+
this.babelOptions[optionKey] = options[optionKey];
447441
}
448442
}
449443
}
@@ -589,17 +583,11 @@ class WebpackConfig {
589583
this.sassLoaderOptionsCallback = sassLoaderOptionsCallback;
590584

591585
for (const optionKey of Object.keys(options)) {
592-
let normalizedOptionKey = optionKey;
593-
if (optionKey === 'resolve_url_loader') {
594-
logger.deprecation('enableSassLoader: "resolve_url_loader" is deprecated. Please use "resolveUrlLoader" instead.');
595-
normalizedOptionKey = 'resolveUrlLoader';
596-
}
597-
598-
if (!(normalizedOptionKey in this.sassOptions)) {
599-
throw new Error(`Invalid option "${normalizedOptionKey}" passed to enableSassLoader(). Valid keys are ${Object.keys(this.sassOptions).join(', ')}`);
586+
if (!(optionKey in this.sassOptions)) {
587+
throw new Error(`Invalid option "${optionKey}" passed to enableSassLoader(). Valid keys are ${Object.keys(this.sassOptions).join(', ')}`);
600588
}
601589

602-
this.sassOptions[normalizedOptionKey] = options[optionKey];
590+
this.sassOptions[optionKey] = options[optionKey];
603591
}
604592
}
605593

lib/config-generator.js

+5-29
Original file line numberDiff line numberDiff line change
@@ -507,36 +507,12 @@ class ConfigGenerator {
507507
splitChunks.cacheGroups = cacheGroups;
508508
}
509509

510-
switch (this.webpackConfig.shouldUseSingleRuntimeChunk) {
511-
case true:
512-
// causes a runtime.js to be emitted with the Webpack runtime
513-
// this is important as a default because it causes different entry
514-
// files to "share" modules, instead of each module getting their own
515-
// fresh version of each module.
516-
optimization.runtimeChunk = 'single';
517-
break;
518-
case false:
519-
// add no runtimeChunk configuration
520-
break;
521-
case null:
522-
/*
523-
* Not setting this option explicitly is deprecated.
524-
*/
525-
logger.deprecation('Either the Encore.enableSingleRuntimeChunk() or Encore.disableSingleRuntimeChunk() method should be called.');
526-
if (this.webpackConfig.sharedCommonsEntryName) {
527-
logger.deprecation('Because you\'re using createSharedEntry(), the recommended setting is Encore.enableSingleRuntimeChunk().');
528-
logger.deprecation('After calling Encore.enableSingleRuntimeChunk(), the "manifest.js" file will be called "runtime.js": your script tag will need to be updated.');
529-
// output it, but keep the old filename
530-
optimization.runtimeChunk = {
531-
name: 'manifest'
532-
};
533-
} else {
534-
logger.deprecation('The recommended setting is Encore.enableSingleRuntimeChunk().');
535-
logger.deprecation('After calling Encore.enableSingleRuntimeChunk(), a new "runtime.js" will be output and should be included on your page before any other script tags for Encore files.');
536-
// do not output the runtime
537-
}
510+
if (this.webpackConfig.shouldUseSingleRuntimeChunk === null) {
511+
throw new Error('Either the Encore.enableSingleRuntimeChunk() or Encore.disableSingleRuntimeChunk() method should be called. The recommended setting is Encore.enableSingleRuntimeChunk().');
512+
}
538513

539-
break;
514+
if (this.webpackConfig.shouldUseSingleRuntimeChunk) {
515+
optimization.runtimeChunk = 'single';
540516
}
541517

542518
optimization.splitChunks = applyOptionsCallback(

lib/webpack/webpack-manifest-plugin.js

-15
This file was deleted.

test/WebpackConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ describe('WebpackConfig object', () => {
546546

547547
it('Calling with "includeNodeModules" option', () => {
548548
const config = createConfig();
549-
config.configureBabel(() => {}, { include_node_modules: ['foo', 'bar'] });
549+
config.configureBabel(() => {}, { includeNodeModules: ['foo', 'bar'] });
550550

551551
expect(config.babelOptions.exclude).to.be.a('Function');
552552

test/bin/encore.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ describe('bin/encore.js', function() {
3939
`
4040
const Encore = require('../../index.js');
4141
Encore
42+
.enableSingleRuntimeChunk()
4243
.setOutputPath('build/')
4344
.setPublicPath('/build')
4445
.addEntry('main', './js/no_require')
@@ -69,6 +70,7 @@ module.exports = Encore.getWebpackConfig();
6970
`
7071
const Encore = require('../../index.js');
7172
Encore
73+
.enableSingleRuntimeChunk()
7274
.setOutputPath('build/')
7375
.setPublicPath('/build')
7476
.addEntry('main', './js/no_require')
@@ -88,7 +90,12 @@ module.exports = Encore.getWebpackConfig();
8890

8991
expect(parsedOutput).to.be.an('object');
9092
expect(parsedOutput.modules).to.be.an('array');
91-
expect(parsedOutput.modules.length).to.equal(2);
93+
94+
// We expect 3 modules there:
95+
// - webpack/runtime/jsonp chunk loading
96+
// - webpack/runtime/compat
97+
// - ./js/no_require.js
98+
expect(parsedOutput.modules.length).to.equal(3);
9299

93100
done();
94101
});
@@ -103,6 +110,7 @@ module.exports = Encore.getWebpackConfig();
103110
`
104111
const Encore = require('../../index.js');
105112
Encore
113+
.enableSingleRuntimeChunk()
106114
.setOutputPath('build/')
107115
.setPublicPath('/build')
108116
.addEntry('main', './js/no_require')
@@ -135,6 +143,7 @@ module.exports = Encore.getWebpackConfig();
135143
`
136144
const Encore = require('../../index.js');
137145
Encore
146+
.enableSingleRuntimeChunk()
138147
.setOutputPath('build/')
139148
.setPublicPath('/build')
140149
.addEntry('main', './js/no_require')
@@ -173,6 +182,7 @@ module.exports = Encore.getWebpackConfig();
173182
`
174183
const Encore = require('../../index.js');
175184
Encore
185+
.enableSingleRuntimeChunk()
176186
.setOutputPath('build/')
177187
.setPublicPath('/build')
178188
.addEntry('main', './js/no_require')
@@ -212,6 +222,7 @@ module.exports = Encore.getWebpackConfig();
212222
`
213223
const Encore = require('../../index.js');
214224
Encore
225+
.enableSingleRuntimeChunk()
215226
.setOutputPath('build/')
216227
.setPublicPath('/build')
217228
.enableSingleRuntimeChuck()

test/config-generator.js

+7-15
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ function createConfig(runtimeConfig = null) {
3737
runtimeConfig.babelRcFileExists = false;
3838
}
3939

40-
return new WebpackConfig(runtimeConfig);
40+
const config = new WebpackConfig(runtimeConfig);
41+
config.enableSingleRuntimeChunk();
42+
43+
return config;
4144
}
4245

4346
function findPlugin(pluginConstructor, plugins) {
@@ -957,25 +960,14 @@ describe('The config-generator function', () => {
957960
expect(logger.getMessages().deprecation).to.be.empty;
958961
});
959962

960-
it('Not set + createSharedEntry()', () => {
963+
it('Not set should throw an error', () => {
961964
const config = createConfig();
962965
config.outputPath = '/tmp/public/build';
966+
config.shouldUseSingleRuntimeChunk = null;
963967
config.setPublicPath('/build/');
964968
config.createSharedEntry('foo', 'bar.js');
965969

966-
const actualConfig = configGenerator(config);
967-
expect(actualConfig.optimization.runtimeChunk.name).to.equal('manifest');
968-
expect(JSON.stringify(logger.getMessages().deprecation)).to.contain('the recommended setting is Encore.enableSingleRuntimeChunk()');
969-
});
970-
971-
it('Not set without createSharedEntry()', () => {
972-
const config = createConfig();
973-
config.outputPath = '/tmp/public/build';
974-
config.setPublicPath('/build/');
975-
976-
const actualConfig = configGenerator(config);
977-
expect(actualConfig.optimization.runtimeChunk).to.be.undefined;
978-
expect(JSON.stringify(logger.getMessages().deprecation)).to.contain('the recommended setting is Encore.enableSingleRuntimeChunk()');
970+
expect(() => configGenerator(config)).to.throw('Either the Encore.enableSingleRuntimeChunk() or Encore.disableSingleRuntimeChunk() method should be called');
979971
});
980972
});
981973

test/functional.js

+3-30
Original file line numberDiff line numberDiff line change
@@ -812,36 +812,6 @@ describe('Functional tests using webpack', function() {
812812
});
813813
});
814814

815-
it('createdSharedEntry() with shouldUseSingleRuntimeChunk not set', (done) => {
816-
const config = createWebpackConfig('www/build', 'dev');
817-
// set back to the "not set" value
818-
config.shouldUseSingleRuntimeChunk = null;
819-
config.setPublicPath('/build');
820-
config.addEntry('main', ['./js/no_require', './js/code_splitting', './js/arrow_function', './js/print_to_app']);
821-
config.createSharedEntry('shared', './js/shared_example');
822-
823-
testSetup.runWebpack(config, (webpackAssert) => {
824-
// should be called manifest.js
825-
webpackAssert.assertOutputFileContains(
826-
'manifest.js',
827-
'function __webpack_require__'
828-
);
829-
830-
testSetup.requestTestPage(
831-
path.join(config.getContext(), 'www'),
832-
[
833-
'build/manifest.js',
834-
'build/shared.js',
835-
],
836-
(browser) => {
837-
// assert that the javascript brought into shared is executed
838-
browser.assert.text('#app', 'Welcome to Encore!');
839-
done();
840-
}
841-
);
842-
});
843-
});
844-
845815
it('createdSharedEntry() does not run shared code twice', (done) => {
846816
const config = createWebpackConfig('www/build', 'dev');
847817
config.setPublicPath('/build');
@@ -990,6 +960,7 @@ module.exports = {
990960
);
991961

992962
const config = testSetup.createWebpackConfig(appDir, 'www/build', 'dev');
963+
config.enableSingleRuntimeChunk();
993964
config.setPublicPath('/build');
994965
// load a file that @import's another file, so that we can
995966
// test that @import resources are parsed through postcss
@@ -1088,6 +1059,7 @@ module.exports = {
10881059
);
10891060

10901061
const config = testSetup.createWebpackConfig(appDir, 'www/build', 'dev');
1062+
config.enableSingleRuntimeChunk();
10911063
config.setPublicPath('/build');
10921064
config.addEntry('main', './js/class-syntax');
10931065

@@ -1133,6 +1105,7 @@ module.exports = {
11331105
);
11341106

11351107
const config = testSetup.createWebpackConfig(appDir, 'www/build', 'dev');
1108+
config.enableSingleRuntimeChunk();
11361109
config.setPublicPath('/build');
11371110
config.addEntry('main', './js/class-syntax');
11381111

0 commit comments

Comments
 (0)