Registry / web-framework / babel-react-components

babel-react-components

JSON →
library1.1.0jsnpmunverified

Utility library for identifying and working with React components in Babel AST transformations. Version 1.1.0 provides helper functions like isReactComponentClass to detect React component classes in Babel plugin development. Limited release cadence; focuses on providing reliable helpers for Babel plugin authors. Differentiates by specifically targeting React class components detection with accurate Babel path checking.

npm install babel-react-components
INSTALL
IMPORT
SIG · BABEL-REACT-COMPON
B
babel-react-components
web-frameworkjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isReactComponentClass
import { isReactComponentClass } from 'babel-react-components'
const isReactComponentClass = require('babel-react-components').isReactComponentClass
ESM only; CJS require not supported.
isReactComponentClass (type import)
import type { isReactComponentClass } from 'babel-react-components'
import { isReactComponentClass } from 'babel-react-components'
If using TypeScript, prefer type import to avoid runtime bundling.
default import
import * as BabelReactComponents from 'babel-react-components'
import BabelReactComponents from 'babel-react-components'
No default export; must use namespace or named imports.

Shows how to use isReactComponentClass in a Babel plugin visitor to detect React class components.

import { isReactComponentClass } from 'babel-react-components'; export default function babelPlugin() { return { visitor: { ClassDeclaration(path) { if (isReactComponentClass(path)) { console.log('Found React component:', path.node.id.name); } } } }; }
Debug
Known issues
gotchaThe function only works on Babel AST paths, not on regular JavaScript objects or source code strings.
fix
Ensure you pass a Babel NodePath object, not a node or code string.
affects: >=1.0
gotchaMay not detect functional components or components created with React.forwardRef or React.memo.
fix
Use additional checks for ArrowFunctionExpression, FunctionDeclaration, CallExpression with member expression (React.forwardRef), etc.
affects: >=1.0
Errors
Common errors & fixes
TypeError: isReactComponentClass is not a function
Importing incorrectly, likely using default import or CJS require.
fix
Use named import: import { isReactComponentClass } from 'babel-react-components'
Cannot find module 'babel-react-components'
Package not installed or incorrectly referenced in tsconfig.json paths.
fix
Run npm install babel-react-components or add to package.json dependencies.
TypeScript error: 'isReactComponentClass' cannot be used as a value because it was imported using 'import type'.
Using type-only import for a runtime function.
fix
Change to regular import: import { isReactComponentClass } from 'babel-react-components'
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
babel-react-components — npm install babel-react-components · libregistry