Skip to content

Commit a39f4a0

Browse files
committed
feature #1308 Drop Vue 2 support (End-Of-Life), only Vue 3 is supported (Kocal)
This PR was merged into the main branch. Discussion ---------- Drop Vue 2 support (End-Of-Life), only Vue 3 is supported Close #1283. Vue 2 reached its end of life months ago, let's remove it for the next major version of Encore. It also allows us to close #1272. Commits ------- ea6ba90 Drop Vue 2 support (End-Of-Life), only Vue 3 is supported
2 parents 10d65fa + ea6ba90 commit a39f4a0

File tree

10 files changed

+24
-77
lines changed

10 files changed

+24
-77
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This is a new major version that contains several backwards-compatibility breaks
88

99
* #1307 Drop `webpack-cli` 4 support, only `webpack-cli` ^5.1.4 is supported (@Kocal)
1010

11+
* #1308 Drop Vue 2 support (End-Of-Life), only Vue 3 is supported (@Kocal)
12+
1113
## 4.7.0
1214

1315
### Features

lib/config-generator.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,8 @@ class ConfigGenerator {
133133
switch (vueVersion) {
134134
case 2:
135135
case '2.7':
136-
logger.deprecation('The support for Vue 2 is deprecated and will be removed in the next major version of Encore.' +
136+
throw new Error('The support for Vue 2 has been removed.' +
137137
' Please upgrade to Vue 3, and if necessary remove the "version" setting or set it to 3 when calling ".enableVueLoader()".');
138-
139-
config.resolve.alias['vue$'] = 'vue/dist/vue.esm.js';
140-
break;
141138
case 3:
142139
config.resolve.alias['vue$'] = 'vue/dist/vue.esm-bundler.js';
143140
break;

lib/features.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,6 @@ const features = {
8585
],
8686
description: 'process TypeScript files with Babel'
8787
},
88-
vue2: {
89-
method: 'enableVueLoader()',
90-
// vue is needed so the end-user can do things
91-
// vue-template-compiler is a peer dep of vue-loader
92-
packages: [
93-
{ name: 'vue', version: '^2.5' },
94-
{ name: 'vue-loader', version: '^15.9.5' },
95-
{ name: 'vue-template-compiler' }
96-
],
97-
description: 'load Vue files'
98-
},
99-
'vue2.7': {
100-
method: 'enableVueLoader()',
101-
// vue is needed so the end-user can do things
102-
packages: [
103-
{ name: 'vue', version: '^2.7' },
104-
{ name: 'vue-loader', version: '^15.10.0' },
105-
],
106-
description: 'load Vue files'
107-
},
10888
vue3: {
10989
method: 'enableVueLoader()',
11090
// vue is needed so the end-user can do things

lib/friendly-errors/transformers/missing-loader.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ function isMissingLoaderError(e) {
2626
}
2727

2828
function isErrorFromVueLoader(filename) {
29-
// vue2
30-
if (filename.includes('??vue-loader-options')) {
31-
return true;
32-
}
33-
3429
// vue3
3530
if (/vue-loader\/dist(\/index\.js)?\?\?/.test(filename)) {
3631
return true;
@@ -48,7 +43,6 @@ function getFileExtension(filename) {
4843
// ??vue-loader-options
4944
if (isErrorFromVueLoader(filename)) {
5045
// vue is strange, the "filename" is reported as something like
51-
// vue2: /path/to/project/node_modules/vue-loader/lib??vue-loader-options!./vuejs/App.vue?vue&type=style&index=1&lang=scss
5246
// vue3: /path/to/project/node_modules/vue-loader/dist??ref--4-0!./vuejs/App.vue?vue&type=style&index=1&lang=scss
5347
const langPos = filename.indexOf('lang=') + 5;
5448
let endLangPos = filename.indexOf('&', langPos);

lib/utils/get-vue-version.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,7 @@ module.exports = function(webpackConfig) {
2727
const vueVersion = packageHelper.getPackageVersion('vue');
2828
if (null === vueVersion) {
2929
// 2 is the current default version to recommend
30-
return 2;
31-
}
32-
33-
if (semver.satisfies(vueVersion, '^2.7')) {
34-
return '2.7';
35-
}
36-
37-
if (semver.satisfies(vueVersion, '^2')) {
38-
return 2;
30+
return 3;
3931
}
4032

4133
if (semver.satisfies(vueVersion, '^3.0.0-beta.1')) {
@@ -46,6 +38,10 @@ module.exports = function(webpackConfig) {
4638
throw new Error('vue version 1 is not supported.');
4739
}
4840

41+
if (semver.satisfies(vueVersion, '^2')) {
42+
throw new Error('vue version 2 is not supported.');
43+
}
44+
4945
logger.warning(`Your version of vue "${vueVersion}" is newer than this version of Encore supports and may or may not function properly.`);
5046

5147
return 3;

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"typescript": "^4.3.2 || ^5.0.0",
9797
"vue": "^3.2.14",
9898
"vue-loader": "^17.0.0",
99-
"vue-template-compiler": "^2.5",
10099
"webpack": "^5.72",
101100
"webpack-cli": "^5.1.4",
102101
"webpack-notifier": "^1.15.0",
@@ -129,9 +128,8 @@
129128
"stylus-loader": "^7.0.0 || ^8.1.0",
130129
"ts-loader": "^9.0.0",
131130
"typescript": "^4.2.2 || ^5.0.0",
132-
"vue": "^2.6 || ^3.2.14",
133-
"vue-loader": "^15.0.11 || ^17.0.0",
134-
"vue-template-compiler": "^2.5",
131+
"vue": "^3.2.14",
132+
"vue-loader": "^17.0.0",
135133
"webpack": "^5.72",
136134
"webpack-cli": "^5.1.4",
137135
"webpack-notifier": "^1.15.0"
@@ -221,9 +219,6 @@
221219
"vue-loader": {
222220
"optional": true
223221
},
224-
"vue-template-compiler": {
225-
"optional": true
226-
},
227222
"webpack": {
228223
"optional": false
229224
},

test/config-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ describe('The config-generator function', () => {
526526
const config = createConfig();
527527
config.outputPath = '/tmp/output/public-path';
528528
config.publicPath = '/public-path';
529-
config.enableVueLoader(() => {}, { version: 2 }); // Adds the 'vue$' alias
529+
config.enableVueLoader(() => {}, { version: 3 }); // Adds the 'vue$' alias
530530
config.enablePreactPreset({ preactCompat: true }); // Adds the 'react' and 'react-dom' aliases
531531
config.addAliases({
532532
'foo': 'bar',

test/functional.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -762,28 +762,25 @@ describe('Functional tests using webpack', function() {
762762
config.addEntry('page2', './preact/main');
763763

764764
// Move Vue.js code into its own chunk
765-
const isVue2 = getVueVersion(config) === 2;
766765
config.addCacheGroup('vuejs', {
767-
test: isVue2 ?
768-
/[\\/]node_modules[\\/]vue[\\/]/ :
769-
/[\\/]node_modules[\\/]@vue[\\/]/
766+
test: /[\\/]node_modules[\\/]@vue[\\/]/
770767
});
771768

772769
testSetup.runWebpack(config, (webpackAssert) => {
773770
// Vue.js code should be present in common.js but not in page1.js/page2.js
774771
webpackAssert.assertOutputFileContains(
775772
'vuejs.js',
776-
`/***/ "../../node_modules/${isVue2 ? 'vue' : '@vue'}/`
773+
'/***/ "../../node_modules/@vue/'
777774
);
778775

779776
webpackAssert.assertOutputFileDoesNotContain(
780777
'page1.js',
781-
`/***/ "../../node_modules/${isVue2 ? 'vue' : '@vue'}/`
778+
'/***/ "../../node_modules/@vue/'
782779
);
783780

784781
webpackAssert.assertOutputFileDoesNotContain(
785782
'page2.js',
786-
`/***/ "../../node_modules/${isVue2 ? 'vue' : '@vue'}/`
783+
'/***/ "../../node_modules/@vue/'
787784
);
788785

789786
// Preact code should be present in page2.js only
@@ -842,10 +839,9 @@ describe('Functional tests using webpack', function() {
842839
config.addEntry('page2', './preact/main');
843840

844841
// Move both vue.js and preact code into their own chunk
845-
const isVue2 = getVueVersion(config) === 2;
846842
config.addCacheGroup('common', {
847843
node_modules: [
848-
isVue2 ? 'vue' : '@vue',
844+
'@vue',
849845
'preact'
850846
]
851847
});
@@ -854,17 +850,17 @@ describe('Functional tests using webpack', function() {
854850
// Vue.js code should be present in common.js but not in page1.js/page2.js
855851
webpackAssert.assertOutputFileContains(
856852
'common.js',
857-
`/***/ "../../node_modules/${isVue2 ? 'vue' : '@vue'}/`
853+
'/***/ "../../node_modules/@vue/'
858854
);
859855

860856
webpackAssert.assertOutputFileDoesNotContain(
861857
'page1.js',
862-
`/***/ "../../node_modules/${isVue2 ? 'vue' : '@vue'}/`
858+
'/***/ "../../node_modules/@vue/'
863859
);
864860

865861
webpackAssert.assertOutputFileDoesNotContain(
866862
'page2.js',
867-
`/***/ "../../node_modules/${isVue2 ? 'vue' : '@vue'}/`
863+
'/***/ "../../node_modules/@vue/'
868864
);
869865

870866
// Preact code should be present in common.js but not in page1.js/page2.js

test/utils/get-vue-version.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ describe('get-vue-version', () => {
3636

3737
it('returns the value configured in Webpack.config.js', () => {
3838
const config = createWebpackConfig();
39-
config.vueOptions.version = 3;
39+
config.vueOptions.version = 4;
4040

41-
expect(getVueVersion(config)).to.equal(3);
41+
expect(getVueVersion(config)).to.equal(4);
4242
});
4343

4444
it('returns the default recommended version when vue is not installed', () => {
4545
const config = createWebpackConfig();
4646
getPackageVersionStub
4747
.callsFake(() => null);
4848

49-
expect(getVueVersion(config)).to.equal(2);
49+
expect(getVueVersion(config)).to.equal(3);
5050
});
5151

52-
it('return 2 when Vue 2 is installed', () => {
52+
it('throw an error when Vue 2 is installed', () => {
5353
const config = createWebpackConfig();
5454
getPackageVersionStub
5555
.callsFake(() => '2.2.4');
5656

57-
expect(getVueVersion(config)).to.equal(2);
57+
expect(() => getVueVersion(config)).to.throw('vue version 2 is not supported.');
5858
});
5959

6060
it('returns 3 when Vue 3 beta is installed', () => {

yarn.lock

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2964,11 +2964,6 @@ data-urls@^1.0.0:
29642964
whatwg-mimetype "^2.2.0"
29652965
whatwg-url "^7.0.0"
29662966

2967-
de-indent@^1.0.2:
2968-
version "1.0.2"
2969-
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
2970-
integrity sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==
2971-
29722967
debug@2.6.9:
29732968
version "2.6.9"
29742969
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -7183,14 +7178,6 @@ vue-loader@^17.0.0:
71837178
hash-sum "^2.0.0"
71847179
watchpack "^2.4.0"
71857180

7186-
vue-template-compiler@^2.5:
7187-
version "2.7.16"
7188-
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.7.16.tgz#c81b2d47753264c77ac03b9966a46637482bb03b"
7189-
integrity sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==
7190-
dependencies:
7191-
de-indent "^1.0.2"
7192-
he "^1.2.0"
7193-
71947181
vue@^3.2.14:
71957182
version "3.4.38"
71967183
resolved "https://registry.yarnpkg.com/vue/-/vue-3.4.38.tgz#0ccbb64ed03ef3c4ab73e540793290b18e7c4236"

0 commit comments

Comments
 (0)