我如何在babel插件中知道当前由babel转译的文件是为服务器还是客户端/浏览器包转译的?
发布于 2018-09-13 22:25:22
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"}
}
}
};
};https://stackoverflow.com/questions/52048926
复制相似问题