Skip to content

Commit 09e7eb1

Browse files
authored
fix(vue-jsx): support jsx imports with queries (#7121)
1 parent 7c7dea2 commit 09e7eb1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/plugin-vue-jsx/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ function vueJsxPlugin(options = {}) {
9595
} = options
9696

9797
const filter = createFilter(include || /\.[jt]sx$/, exclude)
98+
const [filepath] = id.split('?')
9899

99-
if (filter(id)) {
100+
// use id for script blocks in Vue SFCs (e.g. `App.vue?vue&type=script&lang.jsx`)
101+
// use filepath for plain jsx files (e.g. App.jsx)
102+
if (filter(id) || filter(filepath)) {
100103
const plugins = [importMeta, [jsx, babelPluginOptions], ...babelPlugins]
101-
if (id.endsWith('.tsx')) {
104+
if (id.endsWith('.tsx') || filepath.endsWith('.tsx')) {
102105
plugins.push([
103106
require('@babel/plugin-transform-typescript'),
104107
// @ts-ignore

0 commit comments

Comments
 (0)