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

Minor fix to preserveBlankLines (plus an IIFE tweak) #340

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Minor fix to preserveBlankLines (plus an IIFE tweak) #340

wants to merge 3 commits into from

Conversation

ishmal
Copy link

@ishmal ishmal commented Apr 3, 2017

At line 1714, there is a potential bug, if a Program block has a child with no range attached. This can cause an exception:

TypeError: Cannot read property '0' of undefined
    at CodeGenerator.Program (/Volumes/DevPartition/pdev/toolbox/node/m12n/node_modules/escodegen/escodegen.js:1714:93)
    at CodeGenerator.generateStatement (/Volumes/DevPartition/pdev/toolbox/node/m12n/node_modules/escodegen/escodegen.js:2479:33)
    at generateInternal (/Volumes/DevPartition/pdev/toolbox/node/m12n/node_modules/escodegen/escodegen.js:2500:28)
    at Object.generate (/Volumes/DevPartition/pdev/toolbox/node/m12n/node_modules/escodegen/escodegen.js:2569:18)
    at Translator.write (/Volumes/DevPartition/pdev/toolbox/node/m12n/src/translator.js:98:24)
    at DestroyableTransform._transform (/Volumes/DevPartition/pdev/toolbox/node/m12n/src/translator.js:417:23)
    at DestroyableTransform.Transform._read (/Volumes/DevPartition/pdev/toolbox/node/m12n/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)

This fix simply checks for the existence of a range. Made the same fix for BlockStatement.

@ishmal
Copy link
Author

ishmal commented Apr 3, 2017

Hmm. I inadvertently made 2 Pull Requests out of one.

The other one is providing an option to wrap IIFE's in parens.

I can split them and re-submit if you need.

After these tweeks, I can re-serialize 1800 of our messy source files almost flawlessly. Thanks for a VERY useful project.

@ishmal ishmal changed the title Preserve blank fix Minor fix to preserveBlankLines (plus an IIFE tweak) Apr 3, 2017
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.

None yet

2 participants