Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use Vue 3 JSX plugin if Vue 3 is detected in the project #5665

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@vue/babel-preset-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Use this option when you have 3rd party dependencies that are not processed by B

- Default: `true`.

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.
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.

### loose

Expand Down
17 changes: 16 additions & 1 deletion packages/@vue/babel-preset-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,22 @@ module.exports = (context, options = {}) => {

// JSX
if (options.jsx !== false) {
presets.push([require('@vue/babel-preset-jsx'), typeof options.jsx === 'object' ? options.jsx : {}])
let jsxOptions = {}
if (typeof options.jsx === 'object') {
jsxOptions = options.jsx
}

let vueVersion = 2
try {
const Vue = require('vue')
vueVersion = semver.major(Vue.version)
} catch (e) {}

if (vueVersion === 2) {
presets.push([require('@vue/babel-preset-jsx'), jsxOptions])
} else if (vueVersion === 3) {
plugins.push([require('@ant-design-vue/babel-plugin-jsx'), jsxOptions])
}
}

const runtimePath = path.dirname(require.resolve('@babel/runtime/package.json'))
Expand Down
7 changes: 6 additions & 1 deletion packages/@vue/babel-preset-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/babel-preset-app#readme",
"dependencies": {
"@ant-design-vue/babel-plugin-jsx": "^1.0.0-0",
"@babel/core": "^7.9.6",
"@babel/helper-compilation-targets": "^7.9.6",
"@babel/helper-module-imports": "^7.8.3",
Expand All @@ -40,11 +41,15 @@
},
"peerDependencies": {
"@babel/core": "*",
"core-js": "^3"
"core-js": "^3",
"vue": "^2 || ^3.0.0-0"
},
"peerDependenciesMeta": {
"core-js": {
"optional": true
},
"vue": {
"optional": true
}
}
}
47 changes: 47 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@
dependencies:
fswin "^2.17.1227"

"@ant-design-vue/babel-helper-vue-compatible-props@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@ant-design-vue/babel-helper-vue-compatible-props/-/babel-helper-vue-compatible-props-1.0.0.tgz#1cf8a267e04e7de4bd9207eb457bb40fbe96d69a"
integrity sha512-BHOaxm9EJOqoBYWUMVFKwjgDkdqbGnY1KhQBJwTdrQGRDVjVXkxzyoDGJV52YAGgHQrdaSMWakwZIiTfncsNJQ==
dependencies:
"@ant-design-vue/babel-helper-vue-transform-on" "^1.0.1"

"@ant-design-vue/babel-helper-vue-transform-on@^1.0.0", "@ant-design-vue/babel-helper-vue-transform-on@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@ant-design-vue/babel-helper-vue-transform-on/-/babel-helper-vue-transform-on-1.0.1.tgz#d219d92f4e1fc5e7add211c347c7fa000518b623"
integrity sha512-dOAPf/tCM2lCG8FhvOMFBaOdMElMEGhOoocMXEWvHW2l1KIex+UibDcq4bdBEJpDMLrnbNOqci9E7P2dARP6lg==

"@ant-design-vue/babel-plugin-jsx@^1.0.0-0":
version "1.0.0-alpha.6"
resolved "https://registry.yarnpkg.com/@ant-design-vue/babel-plugin-jsx/-/babel-plugin-jsx-1.0.0-alpha.6.tgz#bbb844b91c0032922f80e3d1f062177444077dae"
integrity sha512-f95WdmKQkDGfSHHbqQ3xD5B/PPdg/DhHYlZE3UbIAN08e0YcjM+V1QlFAJYDfcefvsmLA/fGu/bIosBPZDZFWg==
dependencies:
"@ant-design-vue/babel-helper-vue-compatible-props" "^1.0.0"
"@ant-design-vue/babel-helper-vue-transform-on" "^1.0.0"
"@babel/helper-module-imports" "^7.0.0"
"@babel/plugin-syntax-jsx" "^7.0.0"
camelcase "^6.0.0"
html-tags "^3.1.0"
svg-tags "^1.0.0"

"@apollo/federation@0.11.3":
version "0.11.3"
resolved "https://registry.yarnpkg.com/@apollo/federation/-/federation-0.11.3.tgz#82252205c7f90fc69034f2a0073efa71aad52d0e"
Expand Down Expand Up @@ -516,6 +541,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.3.tgz#aac45cccf8bc1873b99a85f34bceef3beb5d3244"
integrity sha512-j/+j8NAWUTxOtx4LKHybpSClxHoq6I91DQ/mKgAXn5oNUPIUiGppjPIX3TDtJWPrdfP9Kfl7e4fgVMiQR9VE/g==

"@babel/helper-plugin-utils@^7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375"
integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg==

"@babel/helper-regex@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.10.1.tgz#021cf1a7ba99822f993222a001cc3fec83255b96"
Expand Down Expand Up @@ -952,6 +982,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-jsx@^7.0.0":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.10.4.tgz#39abaae3cbf710c4373d8429484e6ba21340166c"
integrity sha512-KCg9mio9jwiARCB7WAcQ7Y1q+qicILjoK8LP/VkPkEKaf5dkaZZK1EcTe91a3JJlZ3qy6L5s9X52boEYi8DM9g==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"

"@babel/plugin-syntax-jsx@^7.2.0", "@babel/plugin-syntax-jsx@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.8.3.tgz#521b06c83c40480f1e58b4fd33b92eceb1d6ea94"
Expand Down Expand Up @@ -6270,6 +6307,11 @@ camelcase@^5.0.0, camelcase@^5.2.0, camelcase@^5.3.1:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==

camelcase@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.0.0.tgz#5259f7c30e35e278f1bdc2a4d91230b37cad981e"
integrity sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w==

caniuse-api@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0"
Expand Down Expand Up @@ -10953,6 +10995,11 @@ html-tags@^2.0.0:
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b"
integrity sha1-ELMKOGCF9Dzt41PMj6fLDe7qZos=

html-tags@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"
integrity sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==

html-webpack-plugin@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz#b01abbd723acaaa7b37b6af4492ebda03d9dd37b"
Expand Down