2021-08-11 08:13:38 +00:00
|
|
|
const path = require('path')
|
|
|
|
const blacklist = require('metro-config/src/defaults/blacklist')
|
|
|
|
const escape = require('escape-string-regexp')
|
|
|
|
const pak = require('../package.json')
|
2021-07-03 17:51:30 +00:00
|
|
|
|
2021-08-11 08:13:38 +00:00
|
|
|
const root = path.resolve(__dirname, '..')
|
2021-07-03 17:51:30 +00:00
|
|
|
|
|
|
|
const modules = Object.keys({
|
|
|
|
...pak.peerDependencies,
|
2021-08-11 08:13:38 +00:00
|
|
|
})
|
2021-07-03 17:51:30 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
projectRoot: __dirname,
|
|
|
|
watchFolders: [root],
|
|
|
|
|
|
|
|
// We need to make sure that only one version is loaded for peerDependencies
|
|
|
|
// So we blacklist them at the root, and alias them to the versions in example's node_modules
|
|
|
|
resolver: {
|
|
|
|
blacklistRE: blacklist(
|
2021-08-11 08:13:38 +00:00
|
|
|
modules.map((m) => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`))
|
2021-07-03 17:51:30 +00:00
|
|
|
),
|
|
|
|
|
|
|
|
extraNodeModules: modules.reduce((acc, name) => {
|
2021-08-11 08:13:38 +00:00
|
|
|
acc[name] = path.join(__dirname, 'node_modules', name)
|
|
|
|
return acc
|
2021-07-03 17:51:30 +00:00
|
|
|
}, {}),
|
|
|
|
},
|
|
|
|
|
|
|
|
transformer: {
|
|
|
|
getTransformOptions: async () => ({
|
|
|
|
transform: {
|
|
|
|
experimentalImportSupport: false,
|
|
|
|
inlineRequires: true,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
},
|
2021-08-11 08:13:38 +00:00
|
|
|
}
|