How to use the file function from babel-types
Find comprehensive JavaScript babel-types.file code examples handpicked from public code repositorys.
66 67 68 69 70 71 72 73 74 75
return true; }; function evaluateExpression(node) { // Wrap the node in a standalone program so we can traverse it node = babelTypes.file(babelTypes.program([babelTypes.expressionStatement(node)])); // Find the first expression and evaluate it. let res = null; traverse(node, {
0
49
1
+ 5 other calls in file
GitHub: bmeck/babel-analysis
27 28 29 30 31 32 33 34 35 36
Object.assign(new Block, {name: 'root'}), Object.assign(new Block, {name: 'end'}) ); const subtraversal = (path) => { traverse( t.file( Object.assign(t.program([ path.isStatement() ? path.node : Object.assign(t.expressionStatement(path.node), {loc:path.node.loc})
5
9
5
+ 10 other calls in file
83 84 85 86 87 88 89 90 91 92
} else { programBody.push(node) } }) let esFile = t.file(t.program(programBody), ast.comments, ast.tokens) let output = generate(esFile).code // writeFileSync(`${distBasePath}${fileTailPath}.ast`, JSON.stringify(ast))
1
7
2
+ 6 other calls in file
GitHub: Philmod/parcel
132 133 134 135 136 137 138 139 140 141
}); } function evaluateExpression(node) { // Wrap the node in a standalone program so we can traverse it node = types.file(types.program([types.expressionStatement(node)])); // Find the first expression and evaluate it. let res = null; traverse(node, {
0
1
2
GitHub: sbekrin/cljs-babel
13 14 15 16 17 18 19 20 21 22
} switch (node.constructor) { case l.ProgramNode: { const root = translate(node.program); const program = Array.isArray(root) ? root : [root]; return t.file( t.program( program.map( node => (t.isStatement(node) ? node : t.expressionStatement(node)) ),
1
10
2
+ 9 other calls in file
babel-types.identifier is the most popular function in babel-types (4076 examples)