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: defineI18nRoute not working outside setup sugar syntax pages #1929

Merged
merged 1 commit into from Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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