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

walk.js aborts with error if input contains ES6 code #3

Open
sergejmueller opened this issue Sep 19, 2016 · 8 comments · May be fixed by #6
Open

walk.js aborts with error if input contains ES6 code #3

sergejmueller opened this issue Sep 19, 2016 · 8 comments · May be fixed by #6

Comments

@sergejmueller
Copy link
Contributor

Perhaps because walk.js does not support ES6?

Example: start.js.txt

TypeError: types[type] is not a function
    at walk (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/walk.js:17:16)
    at Object.skip (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/types.js:293:3)
    at walk (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/walk.js:17:16)
    at Object.exports.BinaryExpression.exports.LogicalExpression.exports.AssignmentExpression (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/types.js:243:3)
    at walk (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/walk.js:17:16)
    at Object.skip (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/types.js:293:3)
    at walk (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/walk.js:17:16)
    at Object.exports.ExpressionStatement (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/types.js:32:3)
    at walk (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/walk.js:17:16)
    at Object.skip (/usr/local/lib/node_modules/optimize-js/node_modules/walk-ast/lib/types.js:293:3)
@sergejmueller sergejmueller changed the title walk.js aborts with error if input scripts contains ES6 code walk.js aborts with error if input scripts contains ES6 code Sep 19, 2016
@sergejmueller sergejmueller changed the title walk.js aborts with error if input scripts contains ES6 code walk.js aborts with error if input contains ES6 code Sep 19, 2016
@nolanlawson
Copy link
Owner

I'm using acorn and acorn-walk. Maybe there's a way to make it support ES6?

@sergejmueller
Copy link
Contributor Author

I don't know. A another acorn-walk plugin? https://npmdaily.com/search/acorn

@Rich-Harris Rich-Harris linked a pull request Sep 19, 2016 that will close this issue
@austinkelleher
Copy link
Contributor

This may not work for your use case, but I transpile to ES5 using Babel and then use optimize-js.

@nolanlawson
Copy link
Owner

@Rich-Harris would switching to https://www.npmjs.com/package/estree-walker solve this?

@Rich-Harris
Copy link

@nolanlawson yes

@sanex3339
Copy link

@lattsi
Copy link
Contributor

lattsi commented Nov 8, 2016

this is already patched with the use of estree-walker.

@benderTheCrime
Copy link

benderTheCrime commented Apr 30, 2017

Question: wouldn't it just be possible to give acorn different options? For instance, imports/exports should work just fine if the sourceType: 'module' option was provided.

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.

7 participants