Overruled @babel/helpers to fix how initializers play with decorated properties. Thus circumventing the imperformant and lengthy code being generated by babel in the non-legacy option.
29 lines
620 B
JavaScript
29 lines
620 B
JavaScript
const defineHelper = require("../../../helpers/define-helper").default;
|
|
|
|
const dependency = defineHelper(__dirname, "dependency", `
|
|
let foo = "dependency";
|
|
export default function fn() { return foo }
|
|
`);
|
|
|
|
const main = defineHelper(__dirname, "main", `
|
|
import dep from "${dependency}";
|
|
|
|
let foo = "main";
|
|
|
|
export default function helper() {
|
|
return dep() + foo;
|
|
}
|
|
`);
|
|
|
|
module.exports = function() {
|
|
return {
|
|
visitor: {
|
|
Identifier(path) {
|
|
if (path.node.name !== "REPLACE_ME") return;
|
|
const helper = this.addHelper(main);
|
|
path.replaceWith(helper);
|
|
},
|
|
},
|
|
};
|
|
};
|