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

Error when building with rollup #25

Closed
download13 opened this issue Apr 8, 2017 · 6 comments
Closed

Error when building with rollup #25

download13 opened this issue Apr 8, 2017 · 6 comments

Comments

@download13
Copy link
Contributor

I keep getting this error when trying to bundle a library with rollup. The library depends on route-parser.

Error loading C:\Users\download\code\modules\swkit\node_modules\route-parser\lib\route\compiled-grammar.js: Invalid labeled declaration (163:8) in C:\Users\download\code\modules\swkit\node_modules\route-parser\lib\route\compiled-grammar.js
SyntaxError: Error loading C:\Users\download\code\modules\swkit\node_modules\route-parser\lib\route\compiled-grammar.js: Invalid labeled declaration (163:8) in C:\Users\download\code\modules\swkit\node_modules\route-parser\lib\route\compiled-grammar.js
    at Parser.pp$4.raise (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:2488:13)
    at Parser.pp$1.parseLabeledStatement (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:1017:10)
    at Parser.pp$1.parseStatement (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:779:19)
    at Parser.pp$1.parseBlock (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:1040:23)
    at Parser.pp$3.parseFunctionBody (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:2362:22)
    at Parser.pp$1.parseFunction (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:1132:8)
    at Parser.pp$3.parseExprAtom (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:1999:17)
    at Parser.pp$3.parseExprSubscripts (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:1872:19)
    at Parser.pp$3.parseMaybeUnary (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:1849:17)
    at Parser.pp$3.parseExprOps (C:\Users\download\code\modules\swkit\node_modules\acorn\dist\acorn.js:1791:19)
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki

I can't tell what's actually wrong in the compiled-grammar.js file at 163:8 but the whole file looks a bit strange. I assume because it was created by a grammar generator.

Is it violating some syntactic rules that the rollup parser enforces? Maybe I should open an issue with jison. Any thoughts?

@download13
Copy link
Contributor Author

download13 commented Apr 8, 2017

Okay, I found the problem. jison was, for a time, not generating strict mode compatible output.

It seems that this was fixed in jison 0.4.16, and route-parser depends on 0.4.17.

Has the compiled-grammar file been regenerated since then? I think that would solve this problem.

@download13
Copy link
Contributor Author

download13 commented Apr 8, 2017

I just regenerated compiled-grammar.js and nothing changed. I know I'm on the latest version of jison, and I checked the fix was present in it's code, but it still keeps generating a file with the _token_stack label in there.

Does anyone know what could be going on here?

@download13
Copy link
Contributor Author

download13 commented Apr 8, 2017

So apparently that commit only fixed the problem if the token-stack option is provided to jison.

As an interim fix, I simply added a line to remove the label manually in the compile_parser.js file.

This produces output that works in strict mode.

You can see the changes in #26. There might be a better way to fix this, but this works for now. I'm trying to see if anyone from jison can fix the underlying problem.

@rcs rcs closed this as completed in #26 Apr 18, 2017
@download13
Copy link
Contributor Author

On a side note: can you push bump the patch version and publish the new code?

I'm depending directly on a git commit right now.

@danday74
Copy link

danday74 commented Sep 8, 2017

great insight into this issue. Please can you explain how to provide the token-stack option to JISON. I have no idea! thanks

@download13
Copy link
Contributor Author

@danday74 new Parser(grammar, {'token-stack': true})

Or you can include it directly in the grammar object:

new Parser({...grammar, options: {'token-stack': true}})

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

No branches or pull requests

2 participants