Haxe/Nodejs 调试 - 源映射
Haxe/Nodejs debugging - Source mapping
如何在 nodejs 上启用源映射?我希望堆栈跟踪映射到 .hx 文件而不是生成的 .js 文件。
Main.hx:
package;
class Main
{
public static function main()
throw "test";
}
build.hxml:
-lib hxnodejs
-cp src
-js bin/index.js
-main Main
输出:(cd bin && node index.js
)
/Users/kevin/Codes/testnodejs/bin/index.js:10
throw new js__$Boot_HaxeError("test");
^
Error: test
at Function.Main.main (/Users/kevin/Codes/testnodejs/bin/index.js:10:8)
at console.undefined.log (/Users/kevin/Codes/testnodejs/bin/index.js:21:6)
at Object. (/Users/kevin/Codes/testnodejs/bin/index.js:22:3)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
从 npm
安装 "source-map-support"
npm install source-map-support
在您的 hxml 中启用 -debug
(以便 Haxe 生成源映射文件)
运行 install()
在程序的开头:
js.Lib.require('source-map-support').install();
将 wrapCallSite 函数分配给 haxe.CallStack
haxe.CallStack.wrapCallSite = js.Lib.require('source-map-support').wrapCallSite;
如何在 nodejs 上启用源映射?我希望堆栈跟踪映射到 .hx 文件而不是生成的 .js 文件。
Main.hx:
package;
class Main
{
public static function main()
throw "test";
}
build.hxml:
-lib hxnodejs
-cp src
-js bin/index.js
-main Main
输出:(cd bin && node index.js
)
/Users/kevin/Codes/testnodejs/bin/index.js:10
throw new js__$Boot_HaxeError("test");
^
Error: test
at Function.Main.main (/Users/kevin/Codes/testnodejs/bin/index.js:10:8)
at console.undefined.log (/Users/kevin/Codes/testnodejs/bin/index.js:21:6)
at Object. (/Users/kevin/Codes/testnodejs/bin/index.js:22:3)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
从 npm
安装 "source-map-support"npm install source-map-support
在您的 hxml 中启用
-debug
(以便 Haxe 生成源映射文件)运行
install()
在程序的开头:js.Lib.require('source-map-support').install();
将 wrapCallSite 函数分配给 haxe.CallStack
haxe.CallStack.wrapCallSite = js.Lib.require('source-map-support').wrapCallSite;