Acorn 6.0.0 released


I’ve just tagged Acorn 6.0.0. This is a backwards-incompatible release. It splits the loose parser and the AST walker off into separate modules (acorn-loose and acorn-walk), and changes the way the plugin system works.

You can get the package from npm as usual, or look at the new patches on GitHub.

Release notes

Bug fixes

Better handle variable-redefinition checks for catch bindings and functions directly under if statements.

Forbid in top-level arrow functions.

Fix issue with parsing a regexp after yield in some contexts.

New features

The package now comes with TypeScript definitions.

Breaking changes

The default value of the ecmaVersion option is now 9 (2018).

Plugins work differently, and will have to be rewritten to work with this version.

The loose parser and walker have been moved into separate packages (acorn-loose and acorn-walk).

The parse_dammit function in the loose parser is now simply called parse.

The ScopeBody and ScopeExpression meta node-types in the AST walker are no longer supported.


To port a plugin from 5.x to 6.0, you’d do roughly the following:

  • Instead of adding a property to acorn.plugins, you now export your plugin as a value.

  • This value is a function from a Parser constructor (class) to an extended version of that class

  • The easiest way to implement this function is to return an anonymous class, something like

    module.exports = function(Parser) {
      return new class extends Parser { /* ... */ }
  • That class will override the same methods that you overrode in the instance before by calling parser.extend, but now overrides them on the class level. To call super methods, you’d use super.method(...) instead of the mechanism that used to be provided by extend.

  • A few methods (most notably parseStatement and parseClassElement — used to be parseClassMethod) have changed signature, and if you call/override them, you’ll have to adjust your code.