core icon indicating copy to clipboard operation
core copied to clipboard

Replace Cherow by Babel or Acorn in Node Loader Bootstrap.js

Open viferga opened this issue 4 years ago • 1 comments

🚀 Feature

The idea of this is to get rid from cherow and implement a fully standard compliant parser with latest ES standards. The cherow library is already deprecated.

Is your feature request related to a problem?

Not yet, but as this library is deprecated, we will have problems supporting new standards.

Describe the solution you'd like

Any of the aforementioned will be enough. Speed is important but to be standard compliant is has a higher priority in the list.

Describe alternatives you've considered

Babel: https://github.com/babel/babel Acorn: https://github.com/acornjs/acorn

There's an important requirement which is, whenever selection we do, it should be able to be packaged in a self contained manner, without any dependencies. This is very important because for packaging npm packages in Guix it's a nightmare.

We should end up with something like this: https://github.com/metacall/distributable/blob/e3c07dcd22292283645450e7beb35292a0d38545/source/metacall.scm#L90

Additional context

For more information, check the current cherow implementation:

  • Include: https://github.com/metacall/core/blob/4baa35658e316ba8848a2bf966ec09197a7bfef6/source/loaders/node_loader/bootstrap/lib/bootstrap.js#L10
  • Parsing: https://github.com/metacall/core/blob/4baa35658e316ba8848a2bf966ec09197a7bfef6/source/loaders/node_loader/bootstrap/lib/bootstrap.js#L238

The implementation is a little bit tricky because it loads first the functions and then converts them to string in order to get the type info. Maybe we can improve this.

viferga avatar Apr 22 '21 10:04 viferga

@trgwii suggested https://github.com/eslint/espree

I think it may be a better alternative, but it must be investigated.

viferga avatar Apr 22 '21 12:04 viferga