Conversation
dfe4825 to
eff42c6
Compare
|
eff42c6 to
8e9629a
Compare
|
All done!
|
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10230/ |
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8210/ |
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "parserOpts": {"createParenthesizedExpressions": true} | |||
There was a problem hiding this comment.
This works because I updated the runner in packages/babel-generator/test/index.js to spread the parserOpts into the parser options.
8e9629a to
e1b1b23
Compare
|
Rebased on top of 2a8ebbe |
e1b1b23 to
f77818a
Compare
|
I'm still interested in getting this feature in. We are using Babel more and more in our tools and using a fork is getting old. Any chance of this getting another review? |
|
This is still blocking us. Any suggestions on how to proceed? |
|
AMP Project also needed this. We solved it by running a custom plugin as the first step in our babel config: // https://github.com/ampproject/amphtml/blob/2dc43d8df8a899f95348c2149aceddc9ca96b5a0/build-system/babel-plugins/babel-plugin-transform-parenthesize-expression/index.js
module.exports = function(babel) {
const {types: t} = babel;
return {
visitor: {
Expression: {
exit(path) {
const {node} = path;
const {parenthesized} = node.extra || {};
if (!parenthesized) {
return;
}
path.replaceWith(t.parenthesizedExpression(node));
path.skip();
},
},
},
};
};A babel-parser config option would be welcome. |
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Apart from some minor comments, this PR looks pretty good.
| return val; | ||
| const parenExpression = this.startNodeAt(startPos, startLoc); | ||
| parenExpression.expression = val; | ||
| this.finishNodeAt( |
There was a problem hiding this comment.
Isn't using this.finishNode enough? The end position should be the correct one at this point I think.
| @@ -0,0 +1 @@ | |||
| ({x}) = {x: 1}; | |||
There was a problem hiding this comment.
Could you also test ([ a ]) = []?
f77818a to
75759f3
Compare
arv
left a comment
There was a problem hiding this comment.
- resolved the merge conflicts
- Use finishNode instead of finishNodeAt
- add test for
([a]) = [] - remove dead code (parseParenExpression)
| @@ -0,0 +1 @@ | |||
| ({x}) = {x: 1}; | |||
| strictMode: ?boolean, | ||
| ranges: boolean, | ||
| tokens: boolean, | ||
| createParenthesizedExpressions: boolean, |
There was a problem hiding this comment.
This also needs to be added to babel-parser/typings/index.d.ts
There was a problem hiding this comment.
I assume you mean packages/babel-parser/typings/babel-parser.d.ts
|
Thanks @danez |
When set to `true` we create `ParenthesizedExpression` nodes instead of setting `extra.parenthesized`.
3f2e477 to
88ed72b
Compare
|
We were waiting to decide to release v7.4 😛 |
|
Whoops, didn't see the milestone. |
This reverts commit dd8b700.
This reverts commit dd8b700.
* Add parser createParenthesizedExpressions option … When set to `true` we create `ParenthesizedExpression` nodes instead of setting `extra.parenthesized`. * Also update babel-parser.d.ts
* Add parser createParenthesizedExpressions option … When set to `true` we create `ParenthesizedExpression` nodes instead of setting `extra.parenthesized`. * Also update babel-parser.d.ts
* Add parser createParenthesizedExpressions option … When set to `true` we create `ParenthesizedExpression` nodes instead of setting `extra.parenthesized`. * Also update babel-parser.d.ts
* Add parser createParenthesizedExpressions option … When set to `true` we create `ParenthesizedExpression` nodes instead of setting `extra.parenthesized`. * Also update babel-parser.d.ts
This adds a parser option called
createParenthesizedExpressions, which when enabled createsParenthesizedExpressionnodes instead of settingextra.parenthesized.