@expo/metro-config
This package contains the default Metro config that is required for bundling Expo apps.
metro.config.js
const { getDefaultConfig } = require('expo/metro-config');
const config = getDefaultConfig(__dirname);
module.exports = config;
Exotic
Most of the Exotic mode performance benefits have been integrated in the default Expo CLI bundling pipeline (e.g. less AST cloning, faster worker creation), and as such, the feature no longer needs to be enabled/disabled. Setting mode: "exotic"
will no longer have any additional effects over the default.
If you'd like to use different transformers (e.g. Sucrase) for different files, you can still create a custom transformer and refine it for your project needs.
Custom transformers
Caution: This is an advanced feature for developers who need to speed up the bundling of very large apps.
You can use @expo/metro-config/transformer
to create a custom multi-rule transformer. This is useful for running fewer transformations on node modules and speeding up bundling.
metro.transformer.js
const { createExoticTransformer } = require('@expo/metro-config/transformer');
module.exports = createExoticTransformer({
transpileModules: ['@stripe/stripe-react-native'],
});
Then use it in your project:
metro.config.js
const { getDefaultConfig } = require('@expo/metro-config');
const config = getDefaultConfig(__dirname);
config.transformer.babelTransformerPath = require.resolve('./metro.transformer');
module.exports = config;