react-native-monorepo-config 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +19 -8
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -134,14 +134,6 @@ export function withMetroConfig(baseConfig, { root, dirname, workspaces }) {
134
134
  (m, i, self) => self.lastIndexOf(m) === i // Remove duplicates
135
135
  );
136
136
 
137
- // We need to exclude the peerDependencies we've collected in packages' node_modules
138
- // Otherwise duplicate versions of the same package will be loaded
139
- const blockList = Object.values(packages).flatMap((dir) =>
140
- peers.map(
141
- (m) => new RegExp(`^${escape(path.join(dir, 'node_modules', m))}[\/\\\\]`)
142
- )
143
- );
144
-
145
137
  // When we import a package from the monorepo, metro may not be able to find the deps in blockList
146
138
  // We need to specify them in `extraNodeModules` to tell metro where to find them
147
139
  const extraNodeModules = peers.reduce((acc, name) => {
@@ -154,6 +146,25 @@ export function withMetroConfig(baseConfig, { root, dirname, workspaces }) {
154
146
  return acc;
155
147
  }, {});
156
148
 
149
+ // We need to exclude the peerDependencies we've collected in packages' node_modules
150
+ // Otherwise duplicate versions of the same package will be loaded
151
+ const blockList = Object.values(packages)
152
+ .flatMap((dir) =>
153
+ peers.map((m) => {
154
+ // Skip blocking items that we've specified in extraNodeModules
155
+ const peerPath = path.join(dir, 'node_modules', m);
156
+
157
+ if (extraNodeModules[m] === peerPath) {
158
+ return null;
159
+ }
160
+
161
+ return new RegExp(
162
+ `^${escape(path.join(dir, 'node_modules', m))}[\/\\\\]`
163
+ );
164
+ })
165
+ )
166
+ .filter((value) => value != null);
167
+
157
168
  // If monorepo root is a package, add it to extraNodeModules so metro can find it
158
169
  // Normally monorepo packages are symlinked to node_modules, but the root is not
159
170
  // So we need to add it manually
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-monorepo-config",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Configure Metro for a React Native app in a monorepo",
5
5
  "repository": "https://github.com/satya164/react-native-monorepo-config",
6
6
  "author": "Satyajit Sahoo <satyajit.happy@gmail.com> (https://github.com/satya164/)",
@@ -36,7 +36,8 @@
36
36
  "tagName": "v${version}"
37
37
  },
38
38
  "npm": {
39
- "publish": true
39
+ "publish": true,
40
+ "skipChecks": true
40
41
  },
41
42
  "github": {
42
43
  "release": true