Skip to content

Commit

Permalink
Fix example app metro config (#214)
Browse files Browse the repository at this point in the history
* fix example app package inclusion

* comment and spacing

* Add in reference to metro
  • Loading branch information
Brett Guenther committed Mar 2, 2023
1 parent e9563af commit 954c2f4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
44 changes: 30 additions & 14 deletions example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
// https://github.com/facebook/react-native/issues/24065#issuecomment-537489786
// https://github.com/callstack/react-native-builder-bob

const blacklist = require('metro-config/src/defaults/exclusionList');
const exclusionList = require('metro-config/src/defaults/exclusionList');

const path = require('path');
const escape = require('escape-string-regexp');
const { getDefaultConfig } = require('@expo/metro-config');
const pak = require('../package.json');

const root = path.resolve(__dirname, '..');

const modules = Object.keys({
...pak.peerDependencies,
});

const defaultConfig = getDefaultConfig(__dirname);

module.exports = {
...defaultConfig,
projectRoot: __dirname,
watchFolders: [root],
resolver: {
blacklistRE: blacklist([
/node_modules\/.*\/node_modules\/react-native\/.*/,
])
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
...defaultConfig.resolver,
blacklistRE: exclusionList(
modules.map(
(m) =>
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
)
),
extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {}),
},
};
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"url": "https://github.com/radarlabs/react-native-radar.git"
},
"dependencies": {
"radar-sdk-js": "^3.5.0",
"@react-native-community/netinfo": "^7.1.3"
"@babel/runtime": "^7.21.0",
"@react-native-community/netinfo": "^7.1.3",
"radar-sdk-js": "^3.5.0"
}
}

0 comments on commit 954c2f4

Please sign in to comment.