{"library":"metro-babel-transformer","title":"Metro Babel Transformer","description":"The base Babel transformer for Metro, the JavaScript bundler for React Native. Current stable version is 0.84.3, with frequent releases (~monthly). This package provides the default Babel transformation pipeline used by Metro to transpile JavaScript/TypeScript files. It handles caching, config merging, and integration with Metro's build system. Key differentiators: it is the official transformer maintained by Meta, tightly coupled with Metro's caching and dependency resolution; supports custom Babel configs; and ships TypeScript types natively since v0.83.5. Alternatives like @react-native/babel-transformer exist but this is the core package.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install metro-babel-transformer"],"cli":null},"imports":["import { getTransformOptions } from 'metro-babel-transformer'","import MetroBabelTransformer from 'metro-babel-transformer'","import { customTransformOptions } from 'metro-babel-transformer'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// Example of using metro-babel-transformer programmatically\nimport MetroBabelTransformer from 'metro-babel-transformer';\nimport path from 'path';\n\nconst transformer = MetroBabelTransformer({\n  // Required: root project directory\n  projectRoot: process.cwd(),\n  // Optional: custom Babel config path\n  babelConfigPath: path.join(process.cwd(), 'babel.config.js'),\n});\n\nconst result = transformer({\n  filename: path.resolve('src/index.js'),\n  sourceCode: 'const x = 1;',\n  options: {\n    dev: true,\n    hot: false,\n    platform: 'ios',\n    minify: false,\n    // Add custom transform options if needed\n    customTransformOptions: {},\n  },\n});\n\nconsole.log(result.code);\nconsole.log('Map:', result.map);","lang":"typescript","description":"Shows how to use the transformer function directly: instantiate with project root, then call with file contents.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}