language-javascript-semantic icon indicating copy to clipboard operation
language-javascript-semantic copied to clipboard

Update Acorn for ES6 users

Open calebmer opened this issue 10 years ago • 3 comments

The version of acorn bundled with this package does not properly highlight ES6 syntax like keywords such as const, let, and class or features like template strings. The latest version of acorn supports the new ES6 syntax.

calebmer avatar Jun 24 '15 21:06 calebmer

It would also be great for early adopters if ES7 could also be supported. What is the process you used to get the acorn-modified.js file from the acorn project? I could grab it and submit a pull request if you want, and if you don't want a pull request I would still like to know so I can use it in my local project.

calebmer avatar Jul 17 '15 13:07 calebmer

acorn-modified.js is based on acorn.js from Acorn's commit 7f0f07e1f9c227d61147f2962f3418149b55e66a. If you diff the two you should see exactly what has been changed.

It boils down to the two points mentioned in the README:

  • Support for tokenizing unterminated multi-line comments (required to allow incremental, i.e. line-by-line, tokenizing)
  • Reverting to regex- rather than eval-based keyword recognition to work around Atom Shell's CSP restrictions

Of course, I will happily accept any pull request that advances the project! :+1:

p-e-w avatar Jul 20 '15 16:07 p-e-w

@p-e-w You might want to consider Acorn's loose parser and/or plugin system, and the eval problem can be solved with Atom's loophole module (which uses Node's vm module behind the scenes).

dead-claudia avatar Apr 07 '16 02:04 dead-claudia