Skip to content

Commit 0c706d2

Browse files
committed
feature #1399 Remove Vue 2 support leftovers (Kocal)
This PR was merged into the main branch. Discussion ---------- Remove Vue 2 support leftovers | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes <!-- please update CHANGELOG.md file --> | Deprecations? | no <!-- please update CHANGELOG.md file --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility. --> Commits ------- 94619b0 Remove Vue 2 support leftovers
2 parents b8c997b + 94619b0 commit 0c706d2

File tree

11 files changed

+16
-137
lines changed

11 files changed

+16
-137
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This is a new major version that contains several backwards-compatibility breaks
2222
* Update @nuxt/friendly-errors-webpack-plugin to @kocal/friendly-errors-webpack-plugin, a maintained fork of the original plugin
2323
* Update webpack from ^5.74.0 to ^5.82.0
2424
* Update css-minimizer-webpack-plugin to ^8.0.0, see [release notes](https://github.com/webpack/css-minimizer-webpack-plugin/releases/tag/v8.0.0)
25+
* Finish removing Vue 2 support leftovers (JSX code path, `vue-jsx` feature, `version: 2` option, Vue 2 peer dependencies), which was forgotten during v5.0.0
2526

2627
## 5.3.0
2728

lib/WebpackConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ class WebpackConfig {
887887
}
888888

889889
if (key === 'version') {
890-
const validVersions = [2, 3];
890+
const validVersions = [3];
891891
if (!validVersions.includes(vueOptions.version)) {
892892
throw new Error(`"${vueOptions.version}" is not a valid value for the "version" option passed to enableVueLoader(). Valid versions are: ${validVersions.join(', ')}.`);
893893
}

lib/config-generator.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ class ConfigGenerator {
135135

136136
const vueVersion = getVueVersion(this.webpackConfig);
137137
switch (vueVersion) {
138-
case 2:
139-
case '2.7':
140-
throw new Error('The support for Vue 2 has been removed.' +
141-
' Please upgrade to Vue 3, and if necessary remove the "version" setting or set it to 3 when calling ".enableVueLoader()".');
142138
case 3:
143139
config.resolve.alias['vue$'] = 'vue/dist/vue.esm-bundler.js';
144140
break;

lib/features.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ const features = {
101101
],
102102
description: 'load Vue files'
103103
},
104-
'vue-jsx': {
105-
method: 'enableVueLoader()',
106-
packages: [
107-
{ name: '@vue/babel-preset-jsx' },
108-
{ name: '@vue/babel-helper-vue-jsx-merge-props' }
109-
],
110-
description: 'use Vue with JSX support'
111-
},
112104
'vue3-jsx': {
113105
method: 'enableVueLoader()',
114106
packages: [

lib/loaders/babel.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,8 @@ module.exports = {
9797
}
9898

9999
if (webpackConfig.useVueLoader && webpackConfig.vueOptions.useJsx) {
100-
// TODO v5: Only keep the v3 code path
101-
if (webpackConfig.vueOptions.version === 3) {
102-
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('vue3-jsx');
103-
babelConfig.plugins.push(require.resolve('@vue/babel-plugin-jsx'));
104-
} else {
105-
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('vue-jsx');
106-
babelConfig.presets.push(require.resolve('@vue/babel-preset-jsx'));
107-
}
100+
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('vue3-jsx');
101+
babelConfig.plugins.push(require.resolve('@vue/babel-plugin-jsx'));
108102
}
109103

110104
babelConfig = applyOptionsCallback(webpackConfig.babelConfigurationCallback, babelConfig);
@@ -120,7 +114,7 @@ module.exports = {
120114

121115
/**
122116
* @param {WebpackConfig} webpackConfig
123-
* @returns {RegExp} to use for eslint-loader `test` rule
117+
* @returns {RegExp} to use for the Babel loader `test` rule
124118
*/
125119
getTest(webpackConfig) {
126120
const extensions = [

lib/utils/get-vue-version.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ module.exports = function(webpackConfig) {
2929
// detect installed version
3030
const vueVersion = packageHelper.getPackageVersion('vue');
3131
if (null === vueVersion) {
32-
// 2 is the current default version to recommend
3332
return 3;
3433
}
3534

@@ -42,7 +41,8 @@ module.exports = function(webpackConfig) {
4241
}
4342

4443
if (semver.satisfies(vueVersion, '^2')) {
45-
throw new Error('vue version 2 is not supported.');
44+
throw new Error('The support for Vue 2 has been removed.' +
45+
' Please upgrade to Vue 3, and if necessary remove the "version" setting, or set it to 3 when calling ".enableVueLoader()".');
4646
}
4747

4848
logger.warning(`Your version of vue "${vueVersion}" is newer than this version of Encore supports and may or may not function properly.`);

package.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
"@hotwired/stimulus": "^3.0.0",
5555
"@symfony/mock-module": "file:fixtures/stimulus/mock-module",
5656
"@symfony/stimulus-bridge": "^3.0.0 || ^4.0.0",
57-
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
5857
"@vue/babel-plugin-jsx": "^1.0.0",
59-
"@vue/babel-preset-jsx": "^1.0.0",
6058
"@vue/compiler-sfc": "^3.0.2",
6159
"autoprefixer": "^10.2.0",
6260
"chai": "^4.2.0",
@@ -109,10 +107,8 @@
109107
"@babel/preset-react": "^7.9.0",
110108
"@babel/preset-typescript": "^7.0.0",
111109
"@symfony/stimulus-bridge": "^3.0.0 || ^4.0.0",
112-
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
113110
"@vue/babel-plugin-jsx": "^1.0.0",
114-
"@vue/babel-preset-jsx": "^1.0.0",
115-
"@vue/compiler-sfc": "^2.6 || ^3.0.2",
111+
"@vue/compiler-sfc": "^3.0.2",
116112
"fork-ts-checker-webpack-plugin": "^7.0.0 || ^8.0.0 || ^9.0.0",
117113
"handlebars": "^4.7.7",
118114
"handlebars-loader": "^1.7.0",
@@ -152,15 +148,9 @@
152148
"@symfony/stimulus-bridge": {
153149
"optional": true
154150
},
155-
"@vue/babel-helper-vue-jsx-merge-props": {
156-
"optional": true
157-
},
158151
"@vue/babel-plugin-jsx": {
159152
"optional": true
160153
},
161-
"@vue/babel-preset-jsx": {
162-
"optional": true
163-
},
164154
"@vue/compiler-sfc": {
165155
"optional": true
166156
},

test/WebpackConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ describe('WebpackConfig object', function() {
11611161
config.enableVueLoader(() => {}, {
11621162
version: 4,
11631163
});
1164-
}).to.throw('"4" is not a valid value for the "version" option passed to enableVueLoader(). Valid versions are: 2, 3.');
1164+
}).to.throw('"4" is not a valid value for the "version" option passed to enableVueLoader(). Valid versions are: 3.');
11651165
});
11661166
});
11671167

test/loaders/babel.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,18 @@ describe('loaders/babel', function() {
178178
it('getLoaders() with Vue and JSX support', function() {
179179
const config = createConfig();
180180
config.enableVueLoader(() => {}, {
181+
version: 3,
181182
useJsx: true,
182183
});
183184

184185
config.configureBabel(function(babelConfig) {
185-
babelConfig.presets.push('foo');
186+
babelConfig.plugins.push('foo');
186187
});
187188

188189
const actualLoaders = babelLoader.getLoaders(config);
189190

190-
expect(actualLoaders[0].options.presets).to.deep.include.members([
191-
require.resolve('@vue/babel-preset-jsx'),
191+
expect(actualLoaders[0].options.plugins).to.deep.include.members([
192+
require.resolve('@vue/babel-plugin-jsx'),
192193
'foo'
193194
]);
194195
});

test/utils/get-vue-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('get-vue-version', function() {
5656
getPackageVersionStub
5757
.callsFake(() => '2.2.4');
5858

59-
expect(() => getVueVersion(config)).to.throw('vue version 2 is not supported.');
59+
expect(() => getVueVersion(config)).to.throw('The support for Vue 2 has been removed.');
6060
});
6161

6262
it('returns 3 when Vue 3 beta is installed', function() {

0 commit comments

Comments
 (0)