Colin's Blog
  • Home
  • Github
Subscribe
Tagged

rollup

A collection of 1 post

rollup

Rollup: Error parsing /tmp/example.js: The keyword 'await' is reserved (1:18) in /tmp/example.js

解决方法 在 rollup 的配置(如 rollup.config.js)里加入: export default { //..., acorn: { allowReserved: true, }, //..., } 错误分析 一般出现这种错误是由于 js 里使用了保留字(Reserved Word)作为函数名或者变量名导致的, 因为 rollup 使用 acorn 将 js 解析成 AST,而在 acorn 中,只有 ecmascript 3 才被允许使用保 留字作为函数名或变量名,更高版本的 ecmascript 默认会报错,除非使用 allowReserved: true 选项来明确允许使用。 我们写代码时,也会避免使用保留字作为函数名或变量名,但有时会使用它们作为对象的 key 来使用,例如:

Colin Cheng Jul 18, 2016 • 1 min read
Colin's Blog © 2023
Powered by Ghost