babel-plugin-transform-typescript-metadata-macro
Version:
Babel plugin to emit decorator metadata like typescript compiler
37 lines (30 loc) • 883 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _transform = require("./transform");
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
return {
visitor: {
Program(programPath) {
/**
* We need to traverse the program right here since
* `@babel/preset-typescript` removes imports at this level.
*
* Since we need to convert some typings into **bindings**, used in
* `Reflect.metadata` calls, we need to process them **before**
* the typescript preset.
*/
programPath.traverse({
ClassDeclaration(path) {
(0, _transform.transform)(path);
}
});
}
}
};
});
exports.default = _default;