Skip to content

Commit

Permalink
fix: defineI18nRoute not working outside setup sugar syntax pages (nu…
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Mar 14, 2023
1 parent 40ffc98 commit a0e2372
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/pages.ts
Expand Up @@ -245,16 +245,19 @@ function readComponent(target: string) {
try {
const content = fs.readFileSync(target, 'utf8').toString()
const { descriptor } = parseSFC(content)
if (!descriptor.scriptSetup) {

if (!content.includes('defineI18nRoute')) {
return options
}

const desc = compileScript(descriptor, { id: target })
const { scriptSetupAst } = desc
const { scriptSetupAst, scriptAst } = desc

let extract = ''
if (scriptSetupAst) {
const genericSetupAst = scriptSetupAst || scriptAst
if (genericSetupAst) {
const s = new MagicString(desc.loc.source)
scriptSetupAst.forEach(ast => {
genericSetupAst.forEach(ast => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
walk(ast as any, {
enter(_node) {
Expand Down

0 comments on commit a0e2372

Please sign in to comment.