Babel plugin to instrument React components with custom transforms
Build a helper that runs a Babel transform to instrument React-style class components while filtering out classes without render methods. Rely on the provided dependency to perform detection and wrapping rather than reimplementing component parsing logic.
@generates
export interface TransformOptions {
/** Extra superclass patterns to consider when detecting class components */
superClasses?: string[];
/** Optional file name to use in generated metadata */
filename?: string;
}
/**
* Transforms source code by applying the configured component-wrapping plugin.
* Returns both the compiled code and component metadata emitted by the transform.
*/
export function transformWithClassGate(
source: string,
options?: TransformOptions
): { code: string; metadata: Record<string, { displayName?: string; isInFunction: boolean }> };Provides the component-detection and wrapping transform used during compilation.
tessl i tessl/npm-babel-plugin-react-transform@3.0.0evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9