-
Notifications
You must be signed in to change notification settings - Fork 482
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
Start babel 6 upgrade #218
Conversation
stage: 0, | ||
locations: true, | ||
ranges: true | ||
presets: ['es2015', 'stage-0', 'react'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only need to parse the ast correct? You can just use babylon
for that and use the seperate babel-traverse
package.
Example of what I did with babylon options: https://github.com/cst/cst/blob/master/src/Parser.js#L73-L94
You can use |
Hi, guys What's status of this branch now? Still failed to generate docs for babel@6 projects.
|
@RobinQu I got stuck on the previously-noted issue: benjamn/ast-types#132 - given that ast-types doesn't support everything Babel now outputs, and Babel's traversal is quite a bit different, this is more than a swap-in upgrade. I'll switch back onto this task after the --access flag is done, and possibly node v5 support. |
Just pushed some updates: now uses babylon, tries to use traverse. Any ideas from @hzoo @thejameskyle would be much appreciated; it doesn't seem like babylon or babel-traverse have any documentation and are pretty tricky to decipher. |
You can check https://github.com/babel/babel-eslint/blob/master/index.js#L372-L394 - the babylon options you are passing in are for v5. Babylon has options in the readme https://github.com/babel/babel/tree/master/packages/babylon. You can also check out https://github.com/thejameskyle/babel-plugin-handbook#babylon |
|
||
var visited = {}; | ||
|
||
function walkComments(ast, type, includeContext) { | ||
types.visit(ast, { | ||
visitNode: function (path) { | ||
traverse(ast, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this throws with
Error: You must pass a scope and parentPath unless traversing a Program/File got a undefined node
at traverse (/Users/tmcw/src/documentation/node_modules/babel-traverse/lib/index.js:55:13)
at walkComments (/Users/tmcw/src/documentation/lib/parsers/javascript.js:47:5)
at parseJavaScript (/Users/tmcw/src/documentation/lib/parsers/javascript.js:96:3)
Parsing with babylon is working, but traversing the generated AST doesn't work and I can't find a simple example of using |
@@ -28,7 +28,7 @@ module.exports = function () { | |||
} | |||
} | |||
|
|||
types.visit(comment.context.ast, { | |||
babel.traverse(comment.context.ast, { | |||
visitClassDeclaration: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The traverse api uses the nodes as the keys like ClassDeclaration
{
visitor: {
BinaryExpression(path) {
// ...
}
}
};```
Trying to configure babelify with presets fails with
No notes about a relative dir in the babelify readme. |
@@ -26,7 +26,7 @@ function dependencyStream(indexes, options, callback) { | |||
}, | |||
transform: [babelify.configure({ | |||
sourceMap: false, | |||
stage: 0 | |||
plugins: ['es2015', 'stage-0', 'react'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presets
here
Upstream issue for enter() method: https://phabricator.babeljs.io/T6740 |
visitTypeAlias: function () { | ||
FunctionDeclaration: visitFunction, | ||
FunctionExpression: visitFunction, | ||
ArrowFunctionExpression: visitFunction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want you can also visit any node with the Function
alias including ClassMethod
and ObjectMethod
(in addition to what you have)
Upstream for failure to use deepEqual: https://phabricator.babeljs.io/T6775?workflow=create#R - removeProperties does not provide a JSON-serializable output. |
Going to give this a second try now that we use traversal less. |
Fixes #211
Traversal with ast-types is broken because babel is departing from ESTree benjamn/ast-types#132
Going to test out babel's own traversal.