From 7898936cd8b00fd0b2daeb1ed3e71c838f6263ff Mon Sep 17 00:00:00 2001
From: underfin <2218301630@qq.com>
Date: Tue, 16 Mar 2021 23:09:14 +0800
Subject: [PATCH] fix: handle jsx close #56
---
playground/App.vue | 5 ++++-
playground/TestJsxSFC.vue | 9 +++++++++
src/index.ts | 2 +-
test/util.ts | 4 ++++
4 files changed, 18 insertions(+), 2 deletions(-)
create mode 100644 playground/TestJsxSFC.vue
diff --git a/playground/App.vue b/playground/App.vue
index 9553479..ced37b5 100644
--- a/playground/App.vue
+++ b/playground/App.vue
@@ -7,6 +7,7 @@
+
@@ -17,6 +18,7 @@ import TestCssModules from './css/TestCssModules.vue'
import TestHmr from './hmr/TestHmr.vue'
import TestAssets from './test-assets/TestAssets.vue'
import TestJsx from './TestJsx.tsx'
+import TestJsxSFC from './TestJsxSFC.vue'
export default {
name: 'App',
@@ -26,7 +28,8 @@ export default {
TestCssModules,
TestHmr,
TestAssets,
- TestJsx
+ TestJsx,
+ TestJsxSFC
}
}
diff --git a/playground/TestJsxSFC.vue b/playground/TestJsxSFC.vue
new file mode 100644
index 0000000..34dae95
--- /dev/null
+++ b/playground/TestJsxSFC.vue
@@ -0,0 +1,9 @@
+
diff --git a/src/index.ts b/src/index.ts
index 64702ed..eb4ffba 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -130,7 +130,7 @@ export function createVuePlugin(rawOptions: VueViteOptions = {}): Plugin {
async transform(code, id) {
const { filename, query } = parseVueRequest(id)
- if (!query.vue && /\.(tsx|jsx)$/.test(id)) {
+ if (/\.(tsx|jsx)$/.test(id)) {
return transformVueJsx(code, id, options.jsxOptions)
}
diff --git a/test/util.ts b/test/util.ts
index 321a3dc..639c9eb 100644
--- a/test/util.ts
+++ b/test/util.ts
@@ -201,4 +201,8 @@ export function declareTests(isBuild: boolean) {
test('Jsx', async () => {
expect(await getText('.jsx')).toMatch('JSX works!')
})
+
+ test('JsxSFC', async () => {
+ expect(await getText('.jsx-sfc')).toMatch('JSX & SFC works!')
+ })
}