ES6类型="模块"破解语法错误堆栈跟踪(Chrome 61)

时间:2017-10-08 12:41:58

标签: javascript google-chrome module ecmascript-6 es6-modules

This question表示Chrome 61不支持ES6模块加载,但这似乎与hereherehere相矛盾。无论哪种方式,这不是我的问题,因为我似乎在我当前的代码中使用它。

问题是这样的:当我用type="module"加载脚本时,我在加载的脚本上的堆栈跟踪消失了。例如:

index.html
---
<script type="module" src="app.js"></script>

app.js
---
import ErrorModule from "../../modules/error-module.js"

error-module.js
--
//console.log"(syntax error");
throw new Error("thrown error");

使用上面的代码,抛出的错误完美无缺。但是,如果我取消注释语法错误,我的堆栈跟踪会被压缩,我所看到的就是:Not very helpful

如何通过模块获取完整的堆栈跟踪来解决Chrome 61上的这些讨厌的语法错误?

1 个答案:

答案 0 :(得分:0)

现在我已经升级到Chrome 62,这个问题似乎已经解决了,所以看起来这是Chrome的ES6模块实现的问题。