How to use the transformFromAst function from babel-core

Find comprehensive JavaScript babel-core.transformFromAst code examples handpicked from public code repositorys.

18
19
20
21
22
23
24
25
26
27
    dependencies.push(node.source.value);
  },
});

const id = ID++;
const {code} = transformFromAst(ast, null, {
  presets: ['env'],
});

const customCode = loader(filename, code)
fork icon87
star icon0
watch icon63

+ 3 other calls in file

40
41
42
43
44
45
46
47
48
49
  ImportDeclaration: ({ node }) => {
    dependencies.push(node.source.value)
  }
})
// 通过 AST 将代码转为 ES5
const { code } = transformFromAst(ast, null, {
  presets: ['env']
})
return {
  filePath,
fork icon51
star icon470
watch icon47

+ 3 other calls in file

182
183
184
185
186
187
188
189
190
191
  babelrc: false,
  compact: true,
};

const result = transformResult.ast
  ? babel.transformFromAst(transformResult.ast, code, babelOptions)
  : babel.transform(code, babelOptions);
const {ast} = result;
invariant(ast != null, 'Missing AST in babel transform results.');
return {ast, code: result.code, map: result.map};
fork icon0
star icon2
watch icon18

18
19
20
21
22
23
24
25
26
27
  },
});

const id = ID++;

const { code } = babel.transformFromAst(ast, null, {
  presets: ["env"],
});

return {
fork icon0
star icon1
watch icon0

59
60
61
62
63
64
65
66
67
68
            module.styles.push(value) // css 依赖 后续未实现 
        }
    }
})

let { code } = transformFromAst(ast, null, {
    presets: ['env']
})

// 移除代码中的CSS module
fork icon0
star icon0
watch icon1

+ 33 other calls in file