mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-24 18:16:36 +00:00
fix(nuxt): use tsx loader for jsx blocks as well (#31014)
This commit is contained in:
parent
0f0a822208
commit
b0729241bc
@ -192,7 +192,7 @@ export function extractScriptContent (sfc: string) {
|
|||||||
for (const match of sfc.matchAll(SFC_SCRIPT_RE)) {
|
for (const match of sfc.matchAll(SFC_SCRIPT_RE)) {
|
||||||
if (match?.groups?.content) {
|
if (match?.groups?.content) {
|
||||||
contents.push({
|
contents.push({
|
||||||
loader: match.groups.attrs?.includes('tsx') ? 'tsx' : 'ts',
|
loader: match.groups.attrs && /[tj]sx/.test(match.groups.attrs) ? 'tsx' : 'ts',
|
||||||
code: match.groups.content.trim(),
|
code: match.groups.content.trim(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,19 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should parse lang="jsx" from vue files', async () => {
|
||||||
|
const fileContents = `
|
||||||
|
<script setup lang="jsx">
|
||||||
|
const foo = <></>;
|
||||||
|
definePageMeta({ name: 'bar' })
|
||||||
|
</script>`
|
||||||
|
|
||||||
|
const meta = await getRouteMeta(fileContents, `/app/pages/index.vue`)
|
||||||
|
expect(meta).toStrictEqual({
|
||||||
|
name: 'bar',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// TODO: https://github.com/nuxt/nuxt/pull/30066
|
// TODO: https://github.com/nuxt/nuxt/pull/30066
|
||||||
it.todo('should handle experimental decorators', async () => {
|
it.todo('should handle experimental decorators', async () => {
|
||||||
const fileContents = `
|
const fileContents = `
|
||||||
|
Loading…
Reference in New Issue
Block a user