-
Notifications
You must be signed in to change notification settings - Fork 20
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
Error when minified #7
Comments
regexp-lexer.js is a compiler and not really meant to be 'uglified' as it should run in a developer environment only, so I wonder what your use case is, where you want/need to uglify/compress this particular file. (The generated code on the other hand, i.e. the generated lexer, is meant to be minified as it would be running in any production environment.) |
I'm currently working on a web-based project, where users need a highly dynamical filter language. They have to adapt the language (not just the filters themselves) to their needs/work environment. To create such languages dynamically, they have to be generated on the client, and the code for that should be minified. |
Got it. That's a bit of a challenge. ;-) Anyway, don't know when I get this fixed; for the time being, I would advise to find a way to make sure the critical code parts don't get obfuscated by the minifier -- my bet is that possibly the JisonLexerError 'class' (a (Note to self: I could add a 'crash dump' functionality here a la 85e367d to help us diagnose what exactly is causing the |
…jison@85e367d for the generated *lexer* source code. **Note to self**: we define the utility function here, inside the jison-lex module, as that is the bottom = leaf dependency, while a *truly clean approach* would have `safe-code-exec-and-diag.js` sit in a (new) separate repository and `require()`-d into this module and the `jison` module instead, as `safe-code-exec-and-diag.js` is a generic module & API that is *unrelated* to the specific task of producing a **lexer** run-time source code!
…xer* and *parser* source code, using the `safe-code-exec-and-diag` module/API. **Note to self**: we define the utility function inside the `jison-lex` module as that is the bottom = leaf dependency, while a *truly clean approach* would have `safe-code-exec-and-diag.js` sit in a (new) separate repository and `require()`-d into this module and the `jison` module instead, as `safe-code-exec-and-diag.js` is a generic module & API that is *unrelated* to the specific task of producing a **lexer** run-time source code!
Please check the latest master; the generated code is dumped to file when a crash like that occurs, so that you can diagnose more precisely what went wrong during code generation. (run |
…n our situation(s)) is part of the crash dump file when the generated code crashes on compilation or execution within jison.
… set them via API, parser/lexer grammar input (`%options <camel-casing-option>=<value>`) and/or CLI.
…` and `throwErrorOnFailure` available in the jison API and CLI (`--dump-sourcecode-on-failure` and `--throw-on-compile-failure`), so that users can *disable* these features (both are *enabled* by default) when desired. (Also adjusted the naming of one of the options to `throwErrorOnCompileFailure` to make the option name itself more descriptive of what it's about.)
thank you, I will do that asap. |
…s)) is part of the crash dump file when the generated code crashes on compilation or execution within jison.
…I, parser/lexer grammar input (`%options <camel-casing-option>=<value>`) and/or CLI.
…rOnFailure` available in the jison API and CLI (`--dump-sourcecode-on-failure` and `--throw-on-compile-failure`), so that users can *disable* these features (both are *enabled* by default) when desired. (Also adjusted the naming of one of the options to `throwErrorOnCompileFailure` to make the option name itself more descriptive of what it's about.)
After following your instructions I get the following error message:
This is the failing code (generated by a minified regexp-lexer.js): |
…parser to lexer code generator. Also make sure these generator options are properly stripped from the generated source, since they won't be usable in/from there!
…them slightly more flexible in the light of code generator changes and/or minification processes.
…reCompiler markup to help compression. Also cleaning a few spots in the code to help the code optimizers (google closure compiler / uglifyJS).
…code generator. Also make sure these generator options are properly stripped from the generated source, since they won't be usable in/from there!
…re flexible in the light of code generator changes and/or minification processes.
Hi Stefan, BTW: are you using UglifyJS2 or Google Closure Compiler? |
Here is the error with the new code:
This is the failing code: dump.txt P.S. Currently I'm using a Webpack pipeline using the Uglify loader for minification, as only loaders allow me to exclude specific input files. But I'm very keen on switching to the Google Closure Compiler, which I can only do, when all files and libs are minifiable. |
Hm, looks like maybe this can help resolve this issue: https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#user-content-nocompile Will add that as a quick-fix band-aid to the jison lexer and parser engines as only the generated code (lexer and parser produced using user defined grammars) is meant to be used in production environments, i.e. minified form. |
release v0.6.1-200 uses a different-enough approach now to code generation that this one might now be feasible. (haven't tested it yet, though!) |
@stefan-leye: working on #32 now: this might be of interest to you too as it will make the jison tool itself more amenable to code compressors/rewriters and thus it is expected that once #32 is done, jison should cause minimal or even no trouble for gcc (google closure compiler) either. |
…code components exported into generated parsers and/or lexers WILL NOT carry any undesirable code coverage or other code injection/rewriting/etc. artifacts: the code should be exported to the generated parser/lexer codebase as-is, without running the chance that another outside process (compressor/rewriter) modifies the code in unexpected ways). This should also help to reduce the troubles with #7 . Note: now `actionInclude` section uses the same code extraction logic as any action code chunk, hence now also supports arrow functions, when you happen to have specified one of those via the API.
Closing due to age; please open a fresh issue, referencing this one for future ref on the same or similar subject. |
When minifying jison (and most sepecifically the regexp-lexer.js) an error is thrown when executing the parser generator.
Basically, there seems to be a problem with the minified lexer function, that is translated to a string and back.
The error happens here:
https://github.com/GerHobbelt/jison/blob/master/lib/util/regexp-lexer.js#L1043
I tested it with minification by uglify and goolge-closure.
It would be great, if there was a fix for that.
The text was updated successfully, but these errors were encountered: