metro
metro copied to clipboard
How to include a path to also be transpiled by babel?
Do you want to request a feature or report a bug? Feature
I have a specific node_module, that requires one babel-transpilation (I am using the alias plugin), is there a way to include a node_modules/package
into the transpilation ?
I am sorry if this is in the documentation, but I have not been able to find how to make that specific node_module be included in the transformation.
Hi @Twiggeh - Metro generally transforms everything by default (it has to parse files to understand dependency relationships), so there’s no way to “include” something for transformation.
Could you share some details about your setup, (Expo / bare RN / other, your Metro) and what problem you’re seeing?
Hi! @robhogan
Its the default template setup that you get with npx react-native@latest init AwesomeProject
I have modified the babel.config.js
to include an alias like this:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
alias: {
underscore: 'lodash',
},
},
],
],
};
This alias is unfortunately required for a package inside node_modules
, but it doesn't appear to work for things inside node_modules