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

fix: allow jsx/tsx with webpack #1046

Merged
merged 2 commits into from
Jan 5, 2024
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/bridge/src/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function setupTypescript () {
nuxt.options.build.babel.plugins.unshift(
_require.resolve('@babel/plugin-proposal-optional-chaining'),
_require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
_require.resolve('@babel/plugin-transform-typescript')
[_require.resolve('@babel/plugin-transform-typescript'), { isTSX: true }]
)

extendWebpackConfig((config) => {
Expand Down
6 changes: 6 additions & 0 deletions playground/components/JSX.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default defineComponent({
name: 'JSX',
render () {
return <div>JSX component with jsx extention</div>
}
})
7 changes: 7 additions & 0 deletions playground/components/JsxComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="jsx">
export default {
render () {
return <div class="container">JSX Component</div>
}
}
</script>
10 changes: 10 additions & 0 deletions playground/pages/jsx.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<div>
<JSX />
<JsxComponent />
</div>
</template>

<script setup>
import JSX from '~/components/JSX'
</script>
6 changes: 6 additions & 0 deletions test/bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ describe('pages', () => {
it('uses server Vue build', async () => {
expect(await $fetch('/')).toContain('Rendered on server: true')
})
it('supports jsx', async () => {
const html = await $fetch('/jsx')

expect(html).toContain('JSX component')
expect(html).toContain('JSX component with jsx extention')
})
})

describe('legacy async data', () => {
Expand Down