Skip to content

fix: 修复 script-setup-compiler 中 formatCodeFrame 不是函数的报错#2472

Merged
hiyuki merged 2 commits intomasterfrom
fix/script-setup-compiler-code-frame
May 6, 2026
Merged

fix: 修复 script-setup-compiler 中 formatCodeFrame 不是函数的报错#2472
hiyuki merged 2 commits intomasterfrom
fix/script-setup-compiler-code-frame

Conversation

@mackwang112
Copy link
Copy Markdown
Collaborator

@mackwang112 mackwang112 commented Apr 28, 2026

标题:
fix: 修复 script-setup-compiler 中 formatCodeFrame 不是函数的报错

描述:

Summary

  • @babel/code-frame v7 不再将函数作为默认导出,改为具名导出 codeFrameColumns
  • 修复导入方式:const { codeFrameColumns: formatCodeFrame } = require('@babel/code-frame')

Test plan

  • 触发编译宏调用错误(如重复调用 defineProps()),确认错误信息中代码帧正常输出
  • 正常编译 <script setup> 文件,确认无回归

@mackwang112 mackwang112 force-pushed the fix/script-setup-compiler-code-frame branch from 7395379 to 12b0419 Compare April 28, 2026 04:05
将 @babel/code-frame 的导入方式从默认导出改为具名导出 codeFrameColumns,
并更新调用签名以传入 node.loc 对象。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mackwang112 mackwang112 force-pushed the fix/script-setup-compiler-code-frame branch from 12b0419 to 42ed218 Compare April 28, 2026 04:07
@hiyuki hiyuki merged commit 86397b5 into master May 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants