Force loading plugins/presets from the monorepo in tests (#13858)

This commit is contained in:
Nicolò Ribaudo 2021-10-18 14:03:50 +02:00 committed by GitHub
parent 513b00e60d
commit 780aa48d2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 14 deletions

View File

@ -284,13 +284,25 @@ function wrapPackagesArray(type, names, optionsDir) {
val[0] = path.resolve(optionsDir, val[0]); val[0] = path.resolve(optionsDir, val[0]);
} else { } else {
let name = val[0];
const match = name.match(/^(@babel\/(?:plugin-|preset-)?)(.*)$/);
if (match) {
name = match[2];
}
const monorepoPath = path.join( const monorepoPath = path.join(
path.dirname(fileURLToPath(import.meta.url)), path.dirname(fileURLToPath(import.meta.url)),
"../..", "../..",
`babel-${type}-${val[0]}`, `babel-${type}-${name}`,
); );
if (fs.existsSync(monorepoPath)) { 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; val[0] = monorepoPath;
} }
} }

View File

@ -1,13 +1,13 @@
{ {
"presets": [ "presets": [
[ [
"@babel/preset-env", "env",
{ {
"shippedProposals": true, "shippedProposals": true,
"targets": { "targets": {
"chrome": "75" "chrome": "75"
}
} }
] }
] ]
} ]
}

View File

@ -2,7 +2,7 @@
"externalHelpers": false, "externalHelpers": false,
"presets": [ "presets": [
[ [
"@babel/preset-env", "env",
{ {
"corejs": 3, "corejs": 3,
"useBuiltIns": "entry" "useBuiltIns": "entry"

View File

@ -1,6 +1,6 @@
{ {
"presets": [ "presets": [
["@babel/preset-react", { "development": true }], ["react", { "development": true }],
"./emotion-css-prop-preset.js" "./emotion-css-prop-preset.js"
], ],
"os": ["linux", "darwin"] "os": ["linux", "darwin"]

View File

@ -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"] "os": ["linux", "darwin"]
} }