in packages/metro-react-native-babel-transformer/src/index.js [127:181]
function buildBabelConfig(
filename,
options,
plugins?: Plugins = [],
): BabelCoreOptions {
const babelRC = getBabelRC(options);
const extraConfig: BabelCoreOptions = {
babelrc:
typeof options.enableBabelRCLookup === 'boolean'
? options.enableBabelRCLookup
: true,
code: false,
filename,
highlightCode: true,
};
let config: BabelCoreOptions = {
...babelRC,
...extraConfig,
};
// Add extra plugins
const extraPlugins = [];
if (options.inlineRequires) {
extraPlugins.push(inlineRequiresPlugin);
}
const withExtrPlugins = (config.plugins = extraPlugins.concat(
config.plugins,
plugins,
));
if (options.dev && options.hot) {
// Note: this intentionally doesn't include the path separator because
// I'm not sure which one it should use on Windows, and false positives
// are unlikely anyway. If you later decide to include the separator,
// don't forget that the string usually *starts* with "node_modules" so
// the first one often won't be there.
const mayContainEditableReactComponents =
filename.indexOf('node_modules') === -1;
if (mayContainEditableReactComponents) {
const hmrConfig = makeHMRConfig();
hmrConfig.plugins = withExtrPlugins.concat(hmrConfig.plugins);
config = Object.assign({}, config, hmrConfig);
}
}
return {
...babelRC,
...config,
};
}