How to use the transformFromAst function from @babel/core

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

40
41
42
43
44
45
46
47
48
49
        //保存所依赖的模块
        dependencies[node.source.value] = newFile
    }
})
//通过@babel/core和@babel/preset-env进行代码的转换
const {code} = babel.transformFromAst(ast, null, {
    presets: ["@babel/preset-env"]
})
return{
    filename,//该文件名
fork icon75
star icon567
watch icon63

33
34
35
36
37
38
39
40
41
42
43
        'throwExpressions',
        'topLevelAwait'
    ]
});


const ret = babel.transformFromAst(ast, null, {
    presets: [
        // 'es2015'
    ],
    plugins: [
fork icon0
star icon1
watch icon0

125
126
127
128
129
130
131
132
133
// [ './info.js' ] ------dependencies------
// [ './const.js' ] ------dependencies------
// [] ------dependencies------

// 转化为 es5 代码
const { code } = babel.transformFromAst(ast, null, {
  presets: ['@babel/preset-env'],
  plugins: [],
})
fork icon0
star icon0
watch icon0