Skip to content

Commit 8d07790

Browse files
committed
WIP Vue3 support
1 parent 9700574 commit 8d07790

File tree

23 files changed

+457
-82
lines changed

23 files changed

+457
-82
lines changed

fixtures/vuejs-css-modules/main_v3.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue';
2+
import App from './App'
3+
4+
createApp(App).mount('#app');
File renamed without changes.

fixtures/vuejs-jsx/main_v3.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue';
2+
import App from './App'
3+
4+
createApp(App).mount('#app');

fixtures/vuejs-typescript/main_v3.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue';
2+
import App from './App.vue';
3+
4+
createApp(App).mount('#app');
File renamed without changes.

fixtures/vuejs/main_v3.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue';
2+
import App from './App'
3+
4+
createApp(App).mount('#app');

lib/WebpackConfig.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class WebpackConfig {
136136
this.babelTypeScriptPresetOptions = {};
137137
this.vueOptions = {
138138
useJsx: false,
139+
version: null,
139140
};
140141
this.eslintOptions = {
141142
lintVue: false,
@@ -749,9 +750,16 @@ class WebpackConfig {
749750
if (!(key in this.vueOptions)) {
750751
throw new Error(`"${key}" is not a valid key for enableVueLoader(). Valid keys: ${Object.keys(this.vueOptions).join(', ')}.`);
751752
}
752-
}
753753

754-
this.vueOptions = vueOptions;
754+
if (key === 'version') {
755+
const validVersions = [2, 3];
756+
if (!validVersions.includes(vueOptions.version)) {
757+
throw new Error(`"${vueOptions.version}" is not a valid value for the "version" option passed to enableVueLoader(). Valid versions are: ${validVersions.join(', ')}.`);
758+
}
759+
}
760+
761+
this.vueOptions[key] = vueOptions[key];
762+
}
755763
}
756764

757765
enableEslintLoader(eslintLoaderOptionsOrCallback = () => {}, eslintOptions = {}) {

lib/config-generator.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const PluginPriorities = require('./plugins/plugin-priorities');
4343
const applyOptionsCallback = require('./utils/apply-options-callback');
4444
const sharedEntryTmpName = require('./utils/sharedEntryTmpName');
4545
const copyEntryTmpName = require('./utils/copyEntryTmpName');
46+
const getVueVersion = require('./utils/get-vue-version');
4647
const tmp = require('tmp');
4748
const fs = require('fs');
4849
const path = require('path');
@@ -101,7 +102,18 @@ class ConfigGenerator {
101102
};
102103

103104
if (this.webpackConfig.useVueLoader) {
104-
config.resolve.alias['vue$'] = 'vue/dist/vue.esm.js';
105+
const vueVersion = getVueVersion(this.webpackConfig);
106+
switch (vueVersion) {
107+
case 2:
108+
config.resolve.alias['vue$'] = 'vue/dist/vue.esm.js';
109+
break;
110+
case 3:
111+
// this may not be needed in the stable release
112+
config.resolve.alias['vue'] = 'vue/dist/vue.esm-bundler.js';
113+
break;
114+
default:
115+
throw new Error(`Invalid vue version ${vueVersion}`);
116+
}
105117
}
106118

107119
if (this.webpackConfig.usePreact && this.webpackConfig.preactOptions.preactCompat) {

0 commit comments

Comments
 (0)