Configuration options for customizing babel-preset-expo behavior per platform or globally.
Core configuration interface for all platform-specific settings.
interface BabelPresetExpoPlatformOptions {
/** Disable or configure the @babel/plugin-proposal-decorators plugin */
decorators?: false | { legacy?: boolean; version?: number };
/** Enable or disable adding the Reanimated plugin by default (default: true) */
reanimated?: boolean;
/** Enable or disable adding the Worklets plugin by default (default: true) */
worklets?: boolean;
/** @deprecated Use jsxRuntime: 'classic' instead */
useTransformReactJSXExperimental?: boolean;
/** Change the policy for handling JSX (default: 'automatic') */
jsxRuntime?: 'classic' | 'automatic';
/** JSX import source when using automatic runtime (default: 'react') */
jsxImportSource?: string;
/** Enable lazy imports for better startup performance */
lazyImports?: boolean;
/** Disable import/export transform for tree shaking */
disableImportExportTransform?: boolean;
/** Disable deep import warnings */
disableDeepImportWarnings?: boolean;
/** Disable Flow type stripping transform */
disableFlowStripTypesTransform?: boolean;
/** Enable or configure Babel runtime transform */
enableBabelRuntime?: boolean | string;
/** Transform profile for Hermes optimization */
unstable_transformProfile?: 'default' | 'hermes-stable' | 'hermes-canary';
/** React Compiler configuration */
'react-compiler'?: false | ReactCompilerOptions;
/** Enable typeof window runtime checks optimization */
minifyTypeofWindow?: boolean;
/** Enable import.meta transform to globalThis registry */
unstable_transformImportMeta?: boolean;
}Controls how JSX is transformed in the build process.
interface JSXOptions {
/** JSX transformation mode */
jsxRuntime?: 'classic' | 'automatic';
/** JSX import source for automatic runtime */
jsxImportSource?: string;
}Usage Examples:
// Use React 17+ automatic JSX (default)
module.exports = {
presets: [
['babel-preset-expo', {
jsxRuntime: 'automatic'
}]
]
};
// Use classic JSX requiring React imports
module.exports = {
presets: [
['babel-preset-expo', {
jsxRuntime: 'classic'
}]
]
};
// Use custom JSX import source (e.g., Preact)
module.exports = {
presets: [
['babel-preset-expo', {
jsxRuntime: 'automatic',
jsxImportSource: 'preact'
}]
]
};Enable or disable specific Babel plugins included in the preset.
interface PluginControlOptions {
/** Enable Reanimated plugin (default: true) */
reanimated?: boolean;
/** Enable Worklets plugin (default: true) */
worklets?: boolean;
/** Configure decorators plugin */
decorators?: false | { legacy?: boolean; version?: number };
}Usage Examples:
// Disable Reanimated plugin
module.exports = {
presets: [
['babel-preset-expo', {
reanimated: false
}]
]
};
// Configure decorators with TypeScript 5 support
module.exports = {
presets: [
['babel-preset-expo', {
decorators: { legacy: false, version: 2023 }
}]
]
};Configure build-time optimizations and transformations.
interface PerformanceOptions {
/** Enable lazy imports for better startup performance */
lazyImports?: boolean;
/** Disable import/export transform for tree shaking */
disableImportExportTransform?: boolean;
/** Transform profile for Hermes JavaScript engine */
unstable_transformProfile?: 'default' | 'hermes-stable' | 'hermes-canary';
/** Optimize typeof window checks */
minifyTypeofWindow?: boolean;
}Usage Examples:
// Enable lazy imports on native platforms
module.exports = {
presets: [
['babel-preset-expo', {
native: {
lazyImports: true
}
}]
]
};
// Optimize for Hermes engine
module.exports = {
presets: [
['babel-preset-expo', {
native: {
unstable_transformProfile: 'hermes-stable'
}
}]
]
};
// Enable tree shaking on web
module.exports = {
presets: [
['babel-preset-expo', {
web: {
disableImportExportTransform: true
}
}]
]
};Configure development-specific features and transformations.
interface DevelopmentOptions {
/** Disable Flow type stripping */
disableFlowStripTypesTransform?: boolean;
/** Enable or configure Babel runtime */
enableBabelRuntime?: boolean | string;
/** Disable deep import warnings */
disableDeepImportWarnings?: boolean;
}The preset applies different defaults based on the target platform:
disableImportExportTransform: true (for tree shaking)minifyTypeofWindow: false (for Web Worker compatibility)disableImportExportTransform: false (Metro doesn't support ESM)unstable_transformProfile: 'hermes-stable' (when Hermes detected)unstable_transformImportMeta: true (import.meta polyfill)minifyTypeofWindow: true (typeof window optimization)