Make sure to actually use yarn to install the main-packages, otherwise the packages.json#resolutions property will not be used and @babel/helpers would not get overruled
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.
This commit is contained in:
26
packages/babel-helpers/test/helpers/define-helper.js
Normal file
26
packages/babel-helpers/test/helpers/define-helper.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import path from "path";
|
||||
import template from "@babel/template";
|
||||
import helpers from "../../lib/helpers";
|
||||
|
||||
function getHelperId(dir, name) {
|
||||
const testName = path.basename(dir);
|
||||
return `_$_${testName}_${name}`;
|
||||
}
|
||||
|
||||
export default function defineHelper(
|
||||
dir: string,
|
||||
name: string,
|
||||
code: string,
|
||||
): string {
|
||||
const id = getHelperId(dir, name);
|
||||
if (id in helpers) {
|
||||
throw new Error(`The ${id} helper is already defined.`);
|
||||
}
|
||||
Object.defineProperty(helpers, id, {
|
||||
value: {
|
||||
minVersion: "7.0.0-beta.0",
|
||||
ast: template.program(code),
|
||||
},
|
||||
});
|
||||
return id;
|
||||
}
|
||||
Reference in New Issue
Block a user