Skip to content

Commit 5442edc

Browse files
fix(vue3): fix jsx support
1 parent b4a1d28 commit 5442edc

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@types/babel__code-frame": "^7.0.2",
4848
"@types/babel__core": "^7.1.12",
4949
"@types/babel__traverse": "^7.11.0",
50+
"@vue/babel-plugin-jsx": "^1.0.3",
5051
"@vue/compiler-dom": "^3.0.7",
5152
"@vue/compiler-sfc": "^3.0.7",
5253
"@vue/component-compiler-utils": "^3.2.0",

src/createVue3SFCModule.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import {
2727
// @ts-ignore (Could not find a declaration file for module '@babel/plugin-transform-modules-commonjs')
2828
import babelPluginTransformModulesCommonjs from '@babel/plugin-transform-modules-commonjs'
2929

30+
// https://github.com/vuejs/jsx-next
31+
import jsx from '@vue/babel-plugin-jsx'
32+
3033
import {
3134
formatErrorLineColumn,
3235
formatError,
@@ -182,6 +185,7 @@ export async function createSFCModule(source : string, filename : string, option
182185
sourceMaps: genSourcemap, // https://babeljs.io/docs/en/options#sourcemaps
183186
plugins: [ // https://babeljs.io/docs/en/options#plugins
184187
babelPluginTransformModulesCommonjs, // https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#options
188+
jsx,
185189
...additionalBabelPlugins,
186190
],
187191
babelrc: false,

yarn.lock

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
dependencies:
142142
"@babel/types" "^7.13.0"
143143

144-
"@babel/helper-module-imports@^7.12.13":
144+
"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.13":
145145
version "7.12.13"
146146
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.13.tgz#ec67e4404f41750463e455cc3203f6a32e93fcb0"
147147
integrity sha512-NGmfvRp9Rqxy0uHSSVP+SRIW1q31a7Ji10cLBcqSDUngGentY4FRiHOFZFE1CLU5eiL0oE8reH7Tg1y99TDM/g==
@@ -416,6 +416,13 @@
416416
dependencies:
417417
"@babel/helper-plugin-utils" "^7.8.0"
418418

419+
"@babel/plugin-syntax-jsx@^7.0.0":
420+
version "7.12.13"
421+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.12.13.tgz#044fb81ebad6698fe62c478875575bcbb9b70f15"
422+
integrity sha512-d4HM23Q1K7oq/SLNmG6mRt85l2csmQ0cHRaxRXjKW0YFdEXqlZ5kzFQKH5Uc3rDJECgu+yCRgPkG04Mm98R/1g==
423+
dependencies:
424+
"@babel/helper-plugin-utils" "^7.12.13"
425+
419426
"@babel/plugin-syntax-logical-assignment-operators@^7.10.4", "@babel/plugin-syntax-logical-assignment-operators@^7.8.3":
420427
version "7.10.4"
421428
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699"
@@ -817,7 +824,7 @@
817824
dependencies:
818825
regenerator-runtime "^0.13.4"
819826

820-
"@babel/template@^7.12.13", "@babel/template@^7.3.3":
827+
"@babel/template@^7.0.0", "@babel/template@^7.12.13", "@babel/template@^7.3.3":
821828
version "7.12.13"
822829
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.13.tgz#530265be8a2589dbb37523844c5bcb55947fb327"
823830
integrity sha512-/7xxiGA57xMo/P2GVvdEumr8ONhFOhfgq2ihK3h1e6THqzTAkHbkXgB0xI9yeTfIUoH3+oAeHhqm/I43OTbbjA==
@@ -826,7 +833,7 @@
826833
"@babel/parser" "^7.12.13"
827834
"@babel/types" "^7.12.13"
828835

829-
"@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0":
836+
"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0":
830837
version "7.13.0"
831838
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.13.0.tgz#6d95752475f86ee7ded06536de309a65fc8966cc"
832839
integrity sha512-xys5xi5JEhzC3RzEmSGrs/b3pJW/o87SypZ+G/PhaE7uqVQNv/jlmVIBXuoh5atqQ434LfXV+sf23Oxj0bchJQ==
@@ -1213,6 +1220,26 @@
12131220
dependencies:
12141221
"@types/node" "*"
12151222

1223+
"@vue/babel-helper-vue-transform-on@^1.0.2":
1224+
version "1.0.2"
1225+
resolved "https://registry.yarnpkg.com/@vue/babel-helper-vue-transform-on/-/babel-helper-vue-transform-on-1.0.2.tgz#9b9c691cd06fc855221a2475c3cc831d774bc7dc"
1226+
integrity sha512-hz4R8tS5jMn8lDq6iD+yWL6XNB699pGIVLk7WSJnn1dbpjaazsjZQkieJoRX6gW5zpYSCFqQ7jUquPNY65tQYA==
1227+
1228+
"@vue/babel-plugin-jsx@^1.0.3":
1229+
version "1.0.3"
1230+
resolved "https://registry.yarnpkg.com/@vue/babel-plugin-jsx/-/babel-plugin-jsx-1.0.3.tgz#ad5ee86ebc9fc40900add9914534e223c719eace"
1231+
integrity sha512-+52ZQFmrM0yh61dQlgwQlfHZXmYbswbQEL25SOSt9QkjegAdfIGu87oELw0l8H6cuJYazZCiNjPR9eU++ZIbxg==
1232+
dependencies:
1233+
"@babel/helper-module-imports" "^7.0.0"
1234+
"@babel/plugin-syntax-jsx" "^7.0.0"
1235+
"@babel/template" "^7.0.0"
1236+
"@babel/traverse" "^7.0.0"
1237+
"@babel/types" "^7.0.0"
1238+
"@vue/babel-helper-vue-transform-on" "^1.0.2"
1239+
camelcase "^6.0.0"
1240+
html-tags "^3.1.0"
1241+
svg-tags "^1.0.0"
1242+
12161243
12171244
version "3.0.7"
12181245
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.7.tgz#421782a4c67cc3f2b7c30457ef446d74f8524f74"
@@ -3444,6 +3471,11 @@ html-escaper@^2.0.0:
34443471
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"
34453472
integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==
34463473

3474+
html-tags@^3.1.0:
3475+
version "3.1.0"
3476+
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"
3477+
integrity sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==
3478+
34473479
http-signature@~1.2.0:
34483480
version "1.2.0"
34493481
resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1"
@@ -6255,6 +6287,11 @@ supports-hyperlinks@^2.0.0:
62556287
has-flag "^4.0.0"
62566288
supports-color "^7.0.0"
62576289

6290+
svg-tags@^1.0.0:
6291+
version "1.0.0"
6292+
resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764"
6293+
integrity sha1-WPcc7jvVGbWdSyqEO2x95krAR2Q=
6294+
62586295
symbol-tree@^3.2.4:
62596296
version "3.2.4"
62606297
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"

0 commit comments

Comments
 (0)