通过babel获取流星生成的程序

Már*_*Rak 7 babel meteor

如何在babel插件中知道当前由babel编译的文件是否针对服务器或客户端/浏览器包进行了转换?

Már*_*Rak 0

Meteor 最近在 babel 7 中实现了选项调用程序。要使用它并访问插件中的信息,可以像这样访问 Babel.caller poperty:

let caller;
module.exports = function(Babel) {
    Babel.caller(function(c) {
            caller = { ...c };
    });
    return {
        visitor: {
            BlockStatement(){
                console.log(caller); // logs e.g. {name: "meteor", arch: "web.browser.legacy"}
            }
        }
    };
};
Run Code Online (Sandbox Code Playgroud)