--enable-source-maps
版本历史
| 版本 | 变更 |
|---|---|
| v15.11.0, v14.18.0 | 此 API 不再是实验的。 |
| v12.12.0 | 新增于: v12.12.0 |
为堆栈跟踪启用 源映射 v3 支持。
\Enable Source Map v3 support for stack traces.
当使用转译器(例如 TypeScript)时,应用抛出的堆栈跟踪会引用转译后的代码,而不是原始的源位置。--enable-source-maps 启用源映射缓存并尽最大努力报告相对于原始源文件的堆栈跟踪。
\When using a transpiler, such as TypeScript, stack traces thrown by an
application reference the transpiled code, not the original source position.
--enable-source-maps enables caching of Source Maps and makes a best
effort to report stack traces relative to the original source file.
覆盖 Error.prepareStackTrace 可防止 --enable-source-maps 修改堆栈跟踪。
\Overriding Error.prepareStackTrace prevents --enable-source-maps from
modifying the stack trace.
注意,启用源映射会在访问 Error.stack 时给你的应用引入延迟。如果你在应用中频繁访问 Error.stack,则考虑 --enable-source-maps 的性能影响
\Note, enabling source maps can introduce latency to your application
when Error.stack is accessed. If you access Error.stack frequently
in your application, take into account the performance implications
of --enable-source-maps.