Skip to main content

报告问题


一个最小的、可重现的例子

You're expected to provide a [minimal reproducible example] of input code that will demonstrate your issue.

英:You're expected to provide a [minimal reproducible example] of input code that will demonstrate your issue.

要了解此示例,你可以删除部分代码,并在问题不再重现时停止。

英:To get to this example, you can remove bits of your code and stop if your issue ceases to reproduce.

获取提供给 Terser 的源代码

由于用户通常无法控制对 await minify() 或其参数的调用,Terser 提供了 TERSER_DEBUG_DIR 环境变量来使 terser 输出一些调试日志。

英:Because users often don't control the call to await minify() or its arguments, Terser provides a TERSER_DEBUG_DIR environment variable to make terser output some debug logs.

这些日志将包含每个 minify() 调用的输入代码和选项。

英:These logs will contain the input code and options of each minify() call.

TERSER_DEBUG_DIR=/tmp/terser-log-dir command-that-uses-terser
ls /tmp/terser-log-dir
terser-debug-123456.log

如果你不确定如何在 shell 上设置环境变量(上面的示例适用于 bash),你可以尝试使用 cross-env:

英:If you're not sure how to set an environment variable on your shell (the above example works in bash), you can try using cross-env:

> npx cross-env TERSER_DEBUG_DIR=/path/to/logs command-that-uses-terser

堆栈跟踪

在 terser CLI 中,我们使用 source-map-support 来生成良好的错误堆栈。 在你自己的应用中,你应该启用源映射支持(阅读他们的文档)以获得良好的堆栈跟踪,这将帮助你编写好的问题。

英:In the terser CLI we use source-map-support to produce good error stacks. In your own app, you're expected to enable source-map-support (read their docs) to have nice stack traces that will help you write good issues.