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: Unexpected token #18

Closed
josephg opened this issue Dec 13, 2018 · 9 comments
Closed

Error: Unexpected token #18

josephg opened this issue Dec 13, 2018 · 9 comments

Comments

@josephg
Copy link

josephg commented Dec 13, 2018

Might be related to #14, but I'm getting more parsing errors when browserifying using tinyify. Using tinyify@2.5.0

My target is the json1 OT library at SHA 8907bf44049003efa0e3c26146fd891524b91264

The error seems to be related to environment variable handling. If I change this line:

const RELEASE_MODE = process.env.JSON1_RELEASE_MODE

to

const RELEASE_MODE = 0 // or 1 or any other constant

then browserify runs successfully. It crashes if I use process.env.NODE_ENV === 'production'.

I'll have a deeper look when I have some more time if nobody else gets to it by then.

sephsmac:json1 josephg$ browserify -p tinyify lib/json1.js 
Error: Line 1421: Unexpected token ...
    at ErrorHandler.constructError (/Users/josephg/src/ottypes/json1/node_modules/esprima/dist/esprima.js:5012:22)
    at ErrorHandler.createError (/Users/josephg/src/ottypes/json1/node_modules/esprima/dist/esprima.js:5028:27)
    at Parser.unexpectedTokenError (/Users/josephg/src/ottypes/json1/node_modules/esprima/dist/esprima.js:1985:39)
..
@goto-bus-stop
Copy link
Member

Hmm, envify may not support object rest spread syntax yet.

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Dec 14, 2018

envify uses Esprima which doesn't support {...x}. Esprima's master branch supports it but not the published version.
I tried to quickly switch envify to Acorn but it wasn't as trivial as I hoped. If someone feels like giving that a shot, please do!

@toddself
Copy link
Collaborator

I can try to take a look at this today!

@toddself
Copy link
Collaborator

Took a few days to get to but I'm just working on getting all the tests to pass -- acorn is luckily very similar to esprima :)

@toddself
Copy link
Collaborator

I spoke too soon! Variable assignments are a bit trickier to handle in acorn. Will try to wrap this up tonight

@niftylettuce
Copy link

Had you much luck 🍀 @toddself ?

@goto-bus-stop
Copy link
Member

i had another shot just now and I think i got it to work: hughsk/envify#62

@niftylettuce
Copy link

@goto-bus-stop can we get that merged?

@goto-bus-stop
Copy link
Member

📦 2.5.2

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

Successfully merging a pull request may close this issue.

4 participants