You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Workerd DevTools中启用Source Maps的问题咨询

Cloudflare Worker 本地开发 Source Maps 配置方案

问题解决步骤

目前wrangler dev --experimental-local模式默认未自动启用Source Maps,但可以通过配置手动开启,利用esbuild的内联Source Map支持解决你的问题:

1. 修改 wrangler.toml 配置

在项目根目录的wrangler.toml中添加esbuild相关配置,开启内联Source Maps:

[build.esbuild]
sourcemap = "inline"

如果需要自定义构建命令,也可以用以下方式:

[build]
command = "esbuild src/index.ts --bundle --sourcemap=inline --outfile=dist/index.js"

2. 验证效果

重新运行你的开发命令:

wrangler dev src/index.ts --experimental-local --port 8701

此时Chrome DevTools的Sources面板应该能加载到原始TypeScript源码,console.log输出的日志也会指向原始文件的行号。

额外排查建议

如果配置后仍未生效:

  • 确保wrangler为最新版本,执行npm update wrangler更新
  • 检查Chrome DevTools设置,确认「Enable JavaScript source maps」选项已勾选(路径:DevTools设置 → 实验功能/Sources面板设置)
  • 关闭并重新打开DevTools,或清空浏览器缓存后重试

内容的提问来源于stack exchange,提问作者zino

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 02:09:56