Pegjs: option to generate an es module instead of commonjs module

Created on 25 Mar 2021  ·  12Comments  ·  Source: pegjs/pegjs

Issue type

Feature Request:

Description

When pegjs produces an output .js file, it is in common js format:

module.exports = {
  SyntaxError: peg$SyntaxError,
  parse:       peg$parse
};

I want the output as an es module instead:

export { peg$parse as parse, peg$SyntaxError as SyntaxError };

Most helpful comment

Yes, it's resolved in Peggy. We're working toward a first release within days, I hope.

All 12 comments

I'm not sure, but from the PR description, this may have been resolved on the Peggy fork: https://github.com/peggyjs/peggy/pull/11

It looks like Peggy is gaining some momentum as an active replacement for pegjs.

Yes, it's resolved in Peggy. We're working toward a first release within days, I hope.

That's fantastic! Really nice to see this project coming back to life.

oh wow, that _is_ fantastic news. pegjs has one of the most pleasant syntaxes, so I'm really happy to see peggy breathe new life into it! Will head over there and start exploring. :)

We just did a pre-release version of peggy, 1.0.0-rc.0. Can a few of you try this out in your existing projects, please? We'll do a full release as soon as we have a few data points.

@hildjj I might try it, if it's suitable as a drop in replacement for PEGjs. Meaning if I don't have to change any of my grammars or actions, I'll give it a try

I've definitely been meaning to try this in my own project, just haven't gotten to it yet https://github.com/mreinstein/constraint-solver/issues/5

The intent is that you just s/pegjs/peggy/g and nothing changes other than you get support. :)

I'll try to find some time this afternoon to take it for a spin, I'm definitely keen/excited to try this, just overworked at the moment. :)

Well, as far as the online version goes, it all checks out, so consider me migrated

Same, I'm migragted to peggy!

Was this page helpful?
0 / 5 - 0 ratings