Skip to content

Instantly share code, notes, and snippets.

@marsch
Created May 5, 2021 17:09
Show Gist options
  • Save marsch/c7506bd2787f420080d4ae4788838895 to your computer and use it in GitHub Desktop.
Save marsch/c7506bd2787f420080d4ae4788838895 to your computer and use it in GitHub Desktop.
metro with symlink support
const fs = require('fs')
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const isSymlink = dependency =>
fs.lstatSync(`node_modules/${dependency}`).isSymbolicLink()
const packageJson = require(`./package.json`)
const watchFolders = [
...Object.keys(packageJson.devDependencies || {}),
...Object.keys(packageJson.dependencies || {}),
]
.filter(isSymlink)
.filter(dep => fs.existsSync(`node_modules/${dep}`))
.map(dep => fs.realpathSync(`node_modules/${dep}`))
module.exports = {
watchFolders,
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment