Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
fix: handle jsx
Browse files Browse the repository at this point in the history
close #56
  • Loading branch information
underfin committed Mar 16, 2021
1 parent 50a4dbd commit 7898936
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion playground/App.vue
Expand Up @@ -7,6 +7,7 @@
<TestHmr/>
<TestAssets/>
<TestJsx/>
<TestJsxSFC/>
</div>
</template>

Expand All @@ -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',
Expand All @@ -26,7 +28,8 @@ export default {
TestCssModules,
TestHmr,
TestAssets,
TestJsx
TestJsx,
TestJsxSFC
}
}
</script>
9 changes: 9 additions & 0 deletions playground/TestJsxSFC.vue
@@ -0,0 +1,9 @@
<script lang="tsx">
const word: string = 'JSX & SFC works!'
export default {
render() {
return <div class={'jsx-sfc'}> {word} </div>
}
}
</script>
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -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)
}

Expand Down
4 changes: 4 additions & 0 deletions test/util.ts
Expand Up @@ -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!')
})
}

0 comments on commit 7898936

Please sign in to comment.