Skip to content

Commit 399e7fb

Browse files
committed
chore: Merge branch 'feat-vue3-jsx' into feat-vue3-option
2 parents af0a3cf + 7131139 commit 399e7fb

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

packages/@vue/babel-preset-app/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Use this option when you have 3rd party dependencies that are not processed by B
8888

8989
- Default: `true`.
9090

91-
Set to `false` to disable JSX support. Or you can toggle [@vue/babel-preset-jsx](https://github.com/vuejs/jsx/tree/dev/packages/babel-preset-jsx) features here.
91+
Set to `false` to disable JSX support. Or you can toggle [@vue/babel-preset-jsx](https://github.com/vuejs/jsx/tree/dev/packages/babel-preset-jsx) (or [@ant-design-vue/babel-plugin-jsx](https://github.com/vueComponent/jsx) for Vue 3 projects) features here.
9292

9393
### loose
9494

packages/@vue/babel-preset-app/index.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,22 @@ module.exports = (context, options = {}) => {
112112

113113
// JSX
114114
if (options.jsx !== false) {
115-
presets.push([require('@vue/babel-preset-jsx'), typeof options.jsx === 'object' ? options.jsx : {}])
115+
let jsxOptions = {}
116+
if (typeof options.jsx === 'object') {
117+
jsxOptions = options.jsx
118+
}
119+
120+
let vueVersion = 2
121+
try {
122+
const Vue = require('vue')
123+
vueVersion = semver.major(Vue.version)
124+
} catch (e) {}
125+
126+
if (vueVersion === 2) {
127+
presets.push([require('@vue/babel-preset-jsx'), jsxOptions])
128+
} else if (vueVersion === 3) {
129+
plugins.push([require('@ant-design-vue/babel-plugin-jsx'), jsxOptions])
130+
}
116131
}
117132

118133
const runtimePath = path.dirname(require.resolve('@babel/runtime/package.json'))

packages/@vue/babel-preset-app/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/babel-preset-app#readme",
2424
"dependencies": {
25+
"@ant-design-vue/babel-plugin-jsx": "^1.0.0-0",
2526
"@babel/core": "^7.9.6",
2627
"@babel/helper-compilation-targets": "^7.9.6",
2728
"@babel/helper-module-imports": "^7.8.3",
@@ -40,11 +41,15 @@
4041
},
4142
"peerDependencies": {
4243
"@babel/core": "*",
43-
"core-js": "^3"
44+
"core-js": "^3",
45+
"vue": "^2 || ^3.0.0-0"
4446
},
4547
"peerDependenciesMeta": {
4648
"core-js": {
4749
"optional": true
50+
},
51+
"vue": {
52+
"optional": true
4853
}
4954
}
5055
}

yarn.lock

+31-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@
99
dependencies:
1010
fswin "^2.17.1227"
1111

12+
"@ant-design-vue/babel-helper-vue-compatible-props@^1.0.0":
13+
version "1.0.0"
14+
resolved "https://registry.yarnpkg.com/@ant-design-vue/babel-helper-vue-compatible-props/-/babel-helper-vue-compatible-props-1.0.0.tgz#1cf8a267e04e7de4bd9207eb457bb40fbe96d69a"
15+
integrity sha512-BHOaxm9EJOqoBYWUMVFKwjgDkdqbGnY1KhQBJwTdrQGRDVjVXkxzyoDGJV52YAGgHQrdaSMWakwZIiTfncsNJQ==
16+
dependencies:
17+
"@ant-design-vue/babel-helper-vue-transform-on" "^1.0.1"
18+
19+
"@ant-design-vue/babel-helper-vue-transform-on@^1.0.0", "@ant-design-vue/babel-helper-vue-transform-on@^1.0.1":
20+
version "1.0.1"
21+
resolved "https://registry.yarnpkg.com/@ant-design-vue/babel-helper-vue-transform-on/-/babel-helper-vue-transform-on-1.0.1.tgz#d219d92f4e1fc5e7add211c347c7fa000518b623"
22+
integrity sha512-dOAPf/tCM2lCG8FhvOMFBaOdMElMEGhOoocMXEWvHW2l1KIex+UibDcq4bdBEJpDMLrnbNOqci9E7P2dARP6lg==
23+
24+
"@ant-design-vue/babel-plugin-jsx@^1.0.0-0":
25+
version "1.0.0-alpha.6"
26+
resolved "https://registry.yarnpkg.com/@ant-design-vue/babel-plugin-jsx/-/babel-plugin-jsx-1.0.0-alpha.6.tgz#bbb844b91c0032922f80e3d1f062177444077dae"
27+
integrity sha512-f95WdmKQkDGfSHHbqQ3xD5B/PPdg/DhHYlZE3UbIAN08e0YcjM+V1QlFAJYDfcefvsmLA/fGu/bIosBPZDZFWg==
28+
dependencies:
29+
"@ant-design-vue/babel-helper-vue-compatible-props" "^1.0.0"
30+
"@ant-design-vue/babel-helper-vue-transform-on" "^1.0.0"
31+
"@babel/helper-module-imports" "^7.0.0"
32+
"@babel/plugin-syntax-jsx" "^7.0.0"
33+
camelcase "^6.0.0"
34+
html-tags "^3.1.0"
35+
svg-tags "^1.0.0"
36+
1237
"@apollo/federation@0.16.2":
1338
version "0.16.2"
1439
resolved "https://registry.yarnpkg.com/@apollo/federation/-/federation-0.16.2.tgz#a6e100e6d89306559023012ed0084a9cc5011dbf"
@@ -486,7 +511,7 @@
486511
dependencies:
487512
"@babel/helper-plugin-utils" "^7.8.0"
488513

489-
"@babel/plugin-syntax-jsx@^7.2.0", "@babel/plugin-syntax-jsx@^7.8.3":
514+
"@babel/plugin-syntax-jsx@^7.0.0", "@babel/plugin-syntax-jsx@^7.2.0", "@babel/plugin-syntax-jsx@^7.8.3":
490515
version "7.10.4"
491516
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.10.4.tgz#39abaae3cbf710c4373d8429484e6ba21340166c"
492517
integrity sha512-KCg9mio9jwiARCB7WAcQ7Y1q+qicILjoK8LP/VkPkEKaf5dkaZZK1EcTe91a3JJlZ3qy6L5s9X52boEYi8DM9g==
@@ -9948,6 +9973,11 @@ html-tags@^2.0.0:
99489973
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b"
99499974
integrity sha1-ELMKOGCF9Dzt41PMj6fLDe7qZos=
99509975

9976+
html-tags@^3.1.0:
9977+
version "3.1.0"
9978+
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"
9979+
integrity sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==
9980+
99519981
html-webpack-plugin@^3.2.0:
99529982
version "3.2.0"
99539983
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz#b01abbd723acaaa7b37b6af4492ebda03d9dd37b"

0 commit comments

Comments
 (0)