Skip to content

修复编译错误、添加cors支持#3

Open
skydog221 wants to merge 2 commits intoRundll86:feature/v2from
skydog221:feature/v2
Open

修复编译错误、添加cors支持#3
skydog221 wants to merge 2 commits intoRundll86:feature/v2from
skydog221:feature/v2

Conversation

@skydog221
Copy link

CORS 支持

在 devServer 配置中添加了 CORS headers

修复编译问题

问题原因:

chalk-template 1.1.0 版本是一个纯 ES 模块,不能在 CommonJS 环境中使用 require() 导入
项目的 TypeScript 配置将模块编译为 CommonJS 格式 ("module": "commonjs")
这导致了 ERR_REQUIRE_ESM 错误
解决方案:
我将 chalk-template 替换为 chalk,具体修改如下:

移除了 ES 模块导入:

// 删除
import chalkTemplate from 'chalk-template';
// 添加
import chalk from 'chalk';

替换了模板字符串调用:

// 从
chalkTemplate`{gray ${pad(currentNativeId)}} | {red DISABLED}`

// 改为
`${chalk.gray(pad(currentNativeId))} | ${chalk.red('DISABLED')}`

保持了相同的颜色效果.

Tip

由于使用了代码自动格式化插件,Diff可能不易阅读,很抱歉对开发者带来了麻烦

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.

1 participant