Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"]
}