mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 10:04:05 +00:00
fix(nuxt): register/scan plugins with jsx/tsx extensions (#26230)
This commit is contained in:
parent
e889a7df59
commit
2baaab9893
@ -150,8 +150,8 @@ export async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
|
|||||||
...(config.plugins || []),
|
...(config.plugins || []),
|
||||||
...config.srcDir
|
...config.srcDir
|
||||||
? await resolveFiles(config.srcDir, [
|
? await resolveFiles(config.srcDir, [
|
||||||
`${pluginDir}/*.{ts,js,mjs,cjs,mts,cts}`,
|
`${pluginDir}/*{${nuxt.options.extensions.join(',')}}`,
|
||||||
`${pluginDir}/*/index.*{ts,js,mjs,cjs,mts,cts}` // TODO: remove, only scan top-level plugins #18418
|
`${pluginDir}/*/index{${nuxt.options.extensions.join(',')}}` // TODO: remove, only scan top-level plugins #18418
|
||||||
])
|
])
|
||||||
: []
|
: []
|
||||||
].map(plugin => normalizePlugin(plugin as NuxtPlugin)))
|
].map(plugin => normalizePlugin(plugin as NuxtPlugin)))
|
||||||
|
@ -47,7 +47,7 @@ export async function extractMetadata (code: string) {
|
|||||||
if (metaCache[code]) {
|
if (metaCache[code]) {
|
||||||
return metaCache[code]
|
return metaCache[code]
|
||||||
}
|
}
|
||||||
const js = await transform(code, { loader: 'ts' })
|
const js = await transform(code, { loader: 'tsx' })
|
||||||
walk(parse(js.code, {
|
walk(parse(js.code, {
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
ecmaVersion: 'latest'
|
ecmaVersion: 'latest'
|
||||||
|
@ -10,7 +10,7 @@ describe('plugin-metadata', () => {
|
|||||||
name: 'test',
|
name: 'test',
|
||||||
enforce: 'post',
|
enforce: 'post',
|
||||||
hooks: { 'app:mounted': () => {} },
|
hooks: { 'app:mounted': () => {} },
|
||||||
setup: () => {},
|
setup: () => { return { provide: { jsx: '[JSX]' } } },
|
||||||
order: 1
|
order: 1
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ describe('plugin-metadata', () => {
|
|||||||
|
|
||||||
const meta = await extractMetadata([
|
const meta = await extractMetadata([
|
||||||
'export default defineNuxtPlugin({',
|
'export default defineNuxtPlugin({',
|
||||||
...obj.map(([key, value]) => `${key}: ${typeof value === 'function' ? value.toString() : JSON.stringify(value)},`),
|
...obj.map(([key, value]) => `${key}: ${typeof value === 'function' ? value.toString().replace('"[JSX]"', '() => <span>JSX</span>') : JSON.stringify(value)},`),
|
||||||
'})'
|
'})'
|
||||||
].join('\n'))
|
].join('\n'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user