Skip to content

Commit

Permalink
Force loading plugins/presets from the monorepo in tests (#13858)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Oct 18, 2021
1 parent 513b00e commit 780aa48
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
14 changes: 13 additions & 1 deletion packages/babel-helper-fixtures/src/index.ts
Expand Up @@ -284,13 +284,25 @@ function wrapPackagesArray(type, names, optionsDir) {

val[0] = path.resolve(optionsDir, val[0]);
} else {
let name = val[0];
const match = name.match(/^(@babel\/(?:plugin-|preset-)?)(.*)$/);
if (match) {
name = match[2];
}

const monorepoPath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
"../..",
`babel-${type}-${val[0]}`,
`babel-${type}-${name}`,
);

if (fs.existsSync(monorepoPath)) {
if (match) {
throw new Error(
`Remove the "${match[1]}" prefix from "${val[0]}", to load it from the monorepo`,
);
}

val[0] = monorepoPath;
}
}
Expand Down
@@ -1,13 +1,13 @@
{
"presets": [
[
"@babel/preset-env",
{
"shippedProposals": true,
"targets": {
"chrome": "75"
}
"presets": [
[
"env",
{
"shippedProposals": true,
"targets": {
"chrome": "75"
}
]
}
]
}
]
}
Expand Up @@ -2,7 +2,7 @@
"externalHelpers": false,
"presets": [
[
"@babel/preset-env",
"env",
{
"corejs": 3,
"useBuiltIns": "entry"
Expand Down
@@ -1,6 +1,6 @@
{
"presets": [
["@babel/preset-react", { "development": true }],
["react", { "development": true }],
"./emotion-css-prop-preset.js"
],
"os": ["linux", "darwin"]
Expand Down
@@ -1,4 +1,7 @@
{
"presets": [["@babel/preset-react", { "development": true, "runtime": "classic" }], "./my-preset"],
"presets": [
["react", { "development": true, "runtime": "classic" }],
"./my-preset"
],
"os": ["linux", "darwin"]
}

0 comments on commit 780aa48

Please sign in to comment.