Skip to content

Commit 707b737

Browse files
committed
Remove old deprecations
1 parent d86e210 commit 707b737

File tree

8 files changed

+37
-148
lines changed

8 files changed

+37
-148
lines changed

index.js

Lines changed: 0 additions & 32 deletions
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

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,12 @@ class WebpackConfig {
401401
const allowedOptionsWithExternalConfig = ['includeNodeModules', 'exclude'];
402402

403403
for (const optionKey of Object.keys(options)) {
404-
let normalizedOptionKey = optionKey;
405-
if (optionKey === 'include_node_modules') {
406-
logger.deprecation('configureBabel: "include_node_modules" is deprecated. Please use "includeNodeModules" instead.');
407-
normalizedOptionKey = 'includeNodeModules';
408-
}
409-
410-
if (['useBuiltIns', 'corejs'].includes(optionKey)) {
411-
logger.deprecation(`configureBabel: "${optionKey}" is deprecated. Please use configureBabelPresetEnv() instead.`);
412-
}
413-
414-
if (this.doesBabelRcFileExist() && !allowedOptionsWithExternalConfig.includes(normalizedOptionKey)) {
415-
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").`);
404+
if (this.doesBabelRcFileExist() && !allowedOptionsWithExternalConfig.includes(optionKey)) {
405+
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").`);
416406
continue;
417407
}
418408

419-
if (normalizedOptionKey === 'includeNodeModules') {
409+
if (optionKey === 'includeNodeModules') {
420410
if (Object.keys(options).includes('exclude')) {
421411
throw new Error('"includeNodeModules" and "exclude" options can\'t be used together when calling configureBabel().');
422412
}
@@ -445,10 +435,10 @@ class WebpackConfig {
445435
// Exclude other modules
446436
return true;
447437
};
448-
} else if (!(normalizedOptionKey in this.babelOptions)) {
449-
throw new Error(`Invalid option "${normalizedOptionKey}" passed to configureBabel(). Valid keys are ${[...Object.keys(this.babelOptions), 'includeNodeModules'].join(', ')}`);
438+
} else if (!(optionKey in this.babelOptions)) {
439+
throw new Error(`Invalid option "${optionKey}" passed to configureBabel(). Valid keys are ${[...Object.keys(this.babelOptions), 'includeNodeModules'].join(', ')}`);
450440
} else {
451-
this.babelOptions[normalizedOptionKey] = options[optionKey];
441+
this.babelOptions[optionKey] = options[optionKey];
452442
}
453443
}
454444
}
@@ -602,17 +592,11 @@ class WebpackConfig {
602592
this.sassLoaderOptionsCallback = sassLoaderOptionsCallback;
603593

604594
for (const optionKey of Object.keys(options)) {
605-
let normalizedOptionKey = optionKey;
606-
if (optionKey === 'resolve_url_loader') {
607-
logger.deprecation('enableSassLoader: "resolve_url_loader" is deprecated. Please use "resolveUrlLoader" instead.');
608-
normalizedOptionKey = 'resolveUrlLoader';
609-
}
610-
611-
if (!(normalizedOptionKey in this.sassOptions)) {
612-
throw new Error(`Invalid option "${normalizedOptionKey}" passed to enableSassLoader(). Valid keys are ${Object.keys(this.sassOptions).join(', ')}`);
595+
if (!(optionKey in this.sassOptions)) {
596+
throw new Error(`Invalid option "${optionKey}" passed to enableSassLoader(). Valid keys are ${Object.keys(this.sassOptions).join(', ')}`);
613597
}
614598

615-
this.sassOptions[normalizedOptionKey] = options[optionKey];
599+
this.sassOptions[optionKey] = options[optionKey];
616600
}
617601
}
618602

lib/config-generator.js

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -509,36 +509,12 @@ class ConfigGenerator {
509509
splitChunks.cacheGroups = cacheGroups;
510510
}
511511

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

541-
break;
516+
if (this.webpackConfig.shouldUseSingleRuntimeChunk) {
517+
optimization.runtimeChunk = 'single';
542518
}
543519

544520
optimization.splitChunks = applyOptionsCallback(

lib/webpack/webpack-manifest-plugin.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/WebpackConfig.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 12 additions & 1 deletion
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

Lines changed: 7 additions & 15 deletions
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) {
@@ -979,25 +982,14 @@ describe('The config-generator function', () => {
979982
expect(logger.getMessages().deprecation).to.be.empty;
980983
});
981984

982-
it('Not set + createSharedEntry()', () => {
985+
it('Not set should throw an error', () => {
983986
const config = createConfig();
984987
config.outputPath = '/tmp/public/build';
988+
config.shouldUseSingleRuntimeChunk = null;
985989
config.setPublicPath('/build/');
986990
config.createSharedEntry('foo', 'bar.js');
987991

988-
const actualConfig = configGenerator(config);
989-
expect(actualConfig.optimization.runtimeChunk.name).to.equal('manifest');
990-
expect(JSON.stringify(logger.getMessages().deprecation)).to.contain('the recommended setting is Encore.enableSingleRuntimeChunk()');
991-
});
992-
993-
it('Not set without createSharedEntry()', () => {
994-
const config = createConfig();
995-
config.outputPath = '/tmp/public/build';
996-
config.setPublicPath('/build/');
997-
998-
const actualConfig = configGenerator(config);
999-
expect(actualConfig.optimization.runtimeChunk).to.be.undefined;
1000-
expect(JSON.stringify(logger.getMessages().deprecation)).to.contain('the recommended setting is Encore.enableSingleRuntimeChunk()');
992+
expect(() => configGenerator(config)).to.throw('Either the Encore.enableSingleRuntimeChunk() or Encore.disableSingleRuntimeChunk() method should be called');
1001993
});
1002994
});
1003995

test/functional.js

Lines changed: 3 additions & 30 deletions
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)