Skip to content

Commit

Permalink
fix(better-define): support mixed setup blocks
Browse files Browse the repository at this point in the history
closes #268
  • Loading branch information
sxzz committed Feb 16, 2023
1 parent 219646f commit 4844ebd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/spotty-buses-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@vue-macros/better-define': patch
'@vue-macros/api': patch
---

support mixed setup blocks for `better-define`
3 changes: 1 addition & 2 deletions packages/api/src/vue/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export async function analyzeSFC(
s: MagicString,
sfc: SFC
): Promise<AnalyzeResult> {
if (sfc.script || !sfc.scriptSetup)
throw new Error('Only <script setup> is supported')
if (!sfc.scriptSetup) throw new Error('Only <script setup> is supported')

const { scriptSetup } = sfc

Expand Down
2 changes: 1 addition & 1 deletion packages/better-define/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function transformBetterDefine(
) {
const s = new MagicString(code)
const sfc = parseSFC(code, id)
if (sfc.script || !sfc.scriptSetup) return
if (!sfc.scriptSetup) return

const offset = sfc.scriptSetup.loc.start.offset
const result = await analyzeSFC(s, sfc)
Expand Down

1 comment on commit 4844ebd

@vercel
Copy link

@vercel vercel bot commented on 4844ebd Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

unplugin-vue-macros-coverage – ./

vue-macros-coverage.vercel.app
unplugin-vue-macros-coverage-sxzz.vercel.app
unplugin-vue-macros-coverage-git-main-sxzz.vercel.app

Please sign in to comment.