react-native-bundle-discovery 2.0.0-rc.1 → 2.0.0-rc.2

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 +47 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -115,8 +115,12 @@ function createJsonReport({
115
115
  outputJsonPath,
116
116
  rootFolder,
117
117
  silent,
118
+ options,
118
119
  }) {
119
- const dependencies = Array.from(graph.dependencies.values());
120
+ const { processModuleFilter = () => true } = options || {};
121
+ const dependencies = Array.from(graph.dependencies.values()).filter(
122
+ processModuleFilter,
123
+ );
120
124
 
121
125
  const stats = {
122
126
  date: Date.now(),
@@ -184,6 +188,7 @@ function createSerializer({
184
188
  outputJsonPath: myOutputJsonPath,
185
189
  rootFolder: projectRoot,
186
190
  silent,
191
+ options,
187
192
  });
188
193
 
189
194
  return code;
@@ -192,4 +197,44 @@ function createSerializer({
192
197
  return customSerializer;
193
198
  }
194
199
 
195
- module.exports = { createSerializer };
200
+ const createProcessModuleFilter =
201
+ ({
202
+ removePromisePolyfill = false, // Remove useless polyfill (Hermes already has Promise)
203
+ removeOldRenderer = false, // Should be true when new ARCH is enabled
204
+ removeNewRenderer = false, // Should be true when new ARCH is disabled
205
+ removeUTFSequence = false, // Remove useless code
206
+ } = {}) =>
207
+ (module) => {
208
+ if (
209
+ removePromisePolyfill &&
210
+ module.path.endsWith("/react-native/Libraries/Promise.js")
211
+ ) {
212
+ return false;
213
+ }
214
+ if (
215
+ removeOldRenderer &&
216
+ module.path.endsWith(
217
+ "/react-native/Libraries/Renderer/shims/ReactNative.js",
218
+ )
219
+ ) {
220
+ return false;
221
+ }
222
+ if (
223
+ removeNewRenderer &&
224
+ module.path.endsWith(
225
+ "/react-native/Libraries/Renderer/shims/ReactFabric.js",
226
+ )
227
+ ) {
228
+ return false;
229
+ }
230
+ if (
231
+ removeUTFSequence &&
232
+ module.path.endsWith("/react-native/Libraries/UTFSequence.js")
233
+ ) {
234
+ return false;
235
+ }
236
+
237
+ return true;
238
+ };
239
+
240
+ module.exports = { createSerializer, createProcessModuleFilter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bundle-discovery",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.2",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:retyui/react-native-bundle-discovery.git",
6
6
  "author": "David <4661784+retyui@users.noreply.github.com>",