The BabelLoader
runs Babel transformations for JavaScript and TypeScript sources in React Native projects. It chooses the parser based on source type: hermes-parser
for JavaScript and Flow-typed files, and Babel's standard parser for TypeScript files.
There are two similarly named loaders: @callstack/repack/babel-loader
(this loader) and babel-loader
from npm. This loader is tailored for Re.Pack and aims for Metro parity, so the same Babel config used in Metro works as-is in Re.Pack. It automatically selects the parser by source type (Hermes parser for JS/JSX and Flow, Babel parser for TypeScript).
It is also optimized for parallel transforms. In Rspack, enable experiments.parallelLoader
to fan out transforms; in webpack, pair it with thread-loader
to run a worker pool. On projects with heavier Babel pipelines, this often translates into noticeably faster builds.
All options from the Babel options documentation are supported. See Babel TransformOptions below for more details.
string
Optional path to use for importing hermes-parser
. By default, the path is obtained automatically.
HermesParserOverrides
{ babel: true, reactRuntimeTarget: '19' }
Overrides passed to hermes-parser
when parsing non-TypeScript files.
You can pass any standard Babel options (e.g. presets
, plugins
, overrides
, etc.). Source maps are enabled automatically for application code and disabled for node_modules
by default.