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

Disable unused moduleMain code for browserify compatibility #4

Merged
merged 3 commits into from
Jan 10, 2016

Conversation

deathcap
Copy link
Member

The jison parser generator by default will generate a command-line interface built into the parser. node-mojangson only uses the parser object and not the command-line interface, and has no way to access it, so it can be safely disabled -- since it causes compatibility issues with some browserify transforms (and is unused): zaach/jison#300 browserify/static-eval#12)

Unfortunately, the jison command does not accept the option to disable moduleMain (open pull request to jison: zaach/jison#316 Pass moduleMain option to generator), so I had to write a simple script using the jison API to generate the grammar as part of the prepublish script. Not too happy about this, would be a much simpler change if zaach/jison#316 is accepted:

-   "prepublish": "node jison_generate.js",
+   "prepublish": "jison grammar.json --moduleMain 'function() {}'",

but jison last published a release in 2014, there is still an open question about its maintenance path going forward zaach/jison#297 so I think a workaround using the API instead of CLI is most expedient for now, though admittedly less than ideal.

This change also slightly reduces the generated file size, removing what was only dead code.

The jison parser generator by default will generate a command-line
interface built into the parser. node-mojangson only uses the parser
object and not the command-line interface, and has no way to access it,
so it can be safely disabled -- since it causes compatibility issues
with some browserify transforms (and is unused), see:

zaach/jison#300
browserify/static-eval#12
@deathcap deathcap changed the title Disable unused moduleMain code for browserify compatibility [WIP] Disable unused moduleMain code for browserify compatibility Jan 10, 2016
@deathcap
Copy link
Member Author

Ugh sorry, tests passed locally on my system, but because I was using the latest jison dev version from https://github.com/zaach/jison - not the old 0.4.15 release on NPM. Marking as [WIP]

update: the tests are hitting this (fixed in master) jison bug: zaach/jison#267

@deathcap
Copy link
Member Author

Updated to use https://github.com/deathcap/jison/tree/modulemain (until zaach/jison#316 can be merged), tests now pass

@deathcap deathcap changed the title [WIP] Disable unused moduleMain code for browserify compatibility Disable unused moduleMain code for browserify compatibility Jan 10, 2016
rom1504 added a commit that referenced this pull request Jan 10, 2016
Disable unused moduleMain code for browserify compatibility
@rom1504 rom1504 merged commit 7b64a0c into PrismarineJS:master Jan 10, 2016
@rom1504
Copy link
Member

rom1504 commented Jan 10, 2016

Released as 0.2.2

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.

2 participants