babel/babel · error · Error
`isPluginRequired` has been removed in Babel 8. Please use `
Error message
`isPluginRequired` has been removed in Babel 8. Please use `isRequired` from `@babel/helper-compilation-targets` instead.
What it means
@babel/preset-env still exports `isPluginRequired` for backwards compatibility, but its body (index.ts:40-44) unconditionally throws. In Babel 8 the capability moved to `@babel/helper-compilation-targets` as `isRequired`, so any call to the old export is dead code.
Source
Thrown at packages/babel-preset-env/src/index.ts:41
import pluginCoreJS3 from "babel-plugin-polyfill-corejs3";
import getTargets, {
prettifyTargets,
filterItems,
} from "@babel/helper-compilation-targets";
import type { Targets } from "@babel/helper-compilation-targets";
import availablePlugins from "./available-plugins.ts";
import { declarePreset } from "@babel/helper-plugin-utils";
import type { BuiltInsOption, ModuleOption, Options } from "./types.d.ts";
export type { Options };
/**
* @deprecated Use `isRequired` from `@babel/helper-compilation-targets` instead.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function isPluginRequired(targets: Targets, support: Targets) {
throw new Error(
"`isPluginRequired` has been removed in Babel 8. Please use `isRequired` from `@babel/helper-compilation-targets` instead.",
);
}
function filterStageFromList(
list: Record<string, Targets>,
stageList: Set<string>,
) {
return Object.keys(list).reduce((result, item) => {
if (!stageList.has(item)) {
// @ts-expect-error todo: refine result types
result[item] = list[item];
}
return result;
}, {});
}
View on GitHub (pinned to 06b6eae39d)
Solutions
- Replace the import: `import { isRequired } from '@babel/helper-compilation-targets'`.
- Call `isRequired(targets, pluginCompatData)` with the same two-argument shape.
Example fix
// before
import { isPluginRequired } from "@babel/preset-env";
isPluginRequired(targets, { chrome: "60" });
// after
import { isRequired } from "@babel/helper-compilation-targets";
isRequired({ chrome: "60" }, pluginCompat); Defensive patterns
Strategy: validation
Validate before calling
// do not import isPluginRequired from @babel/preset-env
import { isRequired } from "@babel/helper-compilation-targets"; Prevention
- Grep the codebase for `isPluginRequired` immediately after upgrading.
- Switch to `isRequired` from `@babel/helper-compilation-targets` proactively.
When it happens
Trigger: Importing `{ isPluginRequired }` from `@babel/preset-env` and invoking it: `isPluginRequired(targets, support)`.
Common situations: Build scripts, CLIs, or codemods that computed whether a transform was needed via preset-env's old export and were never migrated during the Babel 8 upgrade.
Related errors
- The 'useBuiltIns' option has been removed. Please use babel-
- The .legacy option has been removed in Babel 8. Use .version
- The .decoratorsBeforeExport option has been removed in Babel
- The 'useBuiltIns' option has been removed. The @babel/runtim
- The 'useBuiltIns' option has been removed. Use the 'corejs'o
AI-assisted analysis of babel/babel@06b6eae39d (2026-08-03).
Data as JSON: /data/errors/cb0c4075a458305c.json.
Report an issue: GitHub.