Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass moduleMain option to generator #316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deathcap
Copy link

Allows using the --moduleMain argument with the command-line interface, to define an alternate exports.main implementation.

Without this change, it is only possible (as far as I can tell) to set moduleMain through the module API but not the CLI. (You can also specify %option moduleMain in the grammar jison input file, but it generates invalid JavaScript then - only appears to be possible set it to "true", but a function is required).

Tested this change with make test, all pass

@illuxio
Copy link

illuxio commented Feb 10, 2016

+1

@ahamid
Copy link

ahamid commented Jan 11, 2017

Yes, please! The default main breaks commonjs modules used in browser (fs not available).

@ftes
Copy link

ftes commented Aug 28, 2018

Anything missing here? Any way to help?

@@ -145,6 +145,9 @@ cli.generateParserString = function generateParserString(opts, grammar) {
if (opts.moduleName) {
settings.moduleName = opts.moduleName;
}
if (opts.moduleMain) {
settings.moduleMain = opts.moduleMain;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No parsing necessary here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just a string of source code, isn't it?

@dobesv
Copy link

dobesv commented Jan 28, 2020

It would be great to have this, making people stub out fs in their webpack config is a nuisance.

@dobesv
Copy link

dobesv commented Jan 28, 2020

For now it seems I can install the forked version, like this:

yarn add -D jison@https://github.com/deathcap/jison.git#modulemain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants