Get which program is generated in meteor by babel

Viewed 81

How can I know in babel plugin whether files currently transpiled by babel are transpiled for server or client/browser package?

1 Answers

Meteor recently implemented option caller available in babel 7. To use it and access information in plugin, one can access Babel.caller poperty like this:

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"}
            }
        }
    };
};
Related