react-native-bundle-discovery 2.1.0-rc.2 → 2.2.0
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.
- package/README.md +6 -27
- package/index.js +0 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/react-native-bundle-discovery)
|
|
4
4
|
[](https://www.npmtrends.com/react-native-bundle-discovery)
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
A simple package that helps developers visualize and analyze the bundle size of React Native apps.
|
|
8
7
|
With this tool, you can easily explore your app's codebase, identify large or heavy packages, and inspect the structure of modules and code within your project.
|
|
9
8
|
|
|
10
9
|
<img width="800" alt="" src="./assets/img.png" />
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
### Packages:
|
|
14
12
|
|
|
15
13
|
- `react-native-bundle-discovery` - simple JS library to generate a JSON report of the bundle.
|
|
@@ -21,7 +19,7 @@ With this tool, you can easily explore your app's codebase, identify large or he
|
|
|
21
19
|
|
|
22
20
|
There are two ways to install the package:
|
|
23
21
|
|
|
24
|
-
1. As in independent tool (UI + CLI)
|
|
22
|
+
1. As in independent tool (UI + CLI)
|
|
25
23
|
2. Or as a [Rozenite](_rozenite/README.md) plugin (see: [_rozenite/README.md](_rozenite/README.md))
|
|
26
24
|
|
|
27
25
|
#### 1. Install (independent tool)
|
|
@@ -99,20 +97,6 @@ npx react-native-bundle-discovery-ui metro-stats.json [--port <port>]
|
|
|
99
97
|
npx react-native-bundle-discovery-ui build metro-stats.json
|
|
100
98
|
```
|
|
101
99
|
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
### Re.Pack Support
|
|
106
|
-
|
|
107
|
-
If you've migrated to [Re.Pack](https://re-pack.dev/docs/guides/bundle-analysis), you can still use this package to analyze bundles generated by Re.Pack.
|
|
108
|
-
|
|
109
|
-
Learn more: [Rsdoctor.md](./Rsdoctor.md)
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
npx react-native-bundle-discovery-ui rsdoctor-data.json --format rsdoctor
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
|
|
116
100
|
---
|
|
117
101
|
|
|
118
102
|
### `react-native-bundle-discovery` JS API
|
|
@@ -126,8 +110,6 @@ npx react-native-bundle-discovery-ui rsdoctor-data.json --format rsdoctor
|
|
|
126
110
|
| outputJsonPath: string | `<root>/metro-stats.json` | The path where the JSON report will be saved. Defaults to `metro-stats.json` in project root. |
|
|
127
111
|
| includeCode: boolean | `true` | Whether to include the source and output code in the JSON report. |
|
|
128
112
|
|
|
129
|
-
|
|
130
|
-
|
|
131
113
|
**⚠️ Be cautious sharing reports with `includeCode` enabled**
|
|
132
114
|
|
|
133
115
|
Enabling this option significantly increases report size and **embeds the source code** of your assets.
|
|
@@ -138,22 +120,19 @@ If your code is proprietary 🔒, share these reports responsibly 🤝!
|
|
|
138
120
|
|
|
139
121
|
### `createResolveRequest(options: ResolveRequestOptions)`
|
|
140
122
|
|
|
141
|
-
| Prop
|
|
142
|
-
|
|
|
143
|
-
| removePromisePolyfill: boolean | `false`
|
|
144
|
-
|
|
|
145
|
-
| removeNewRenderer: boolean | `false` | Whether to remove the new renderer. Set to `true` when New Arch is disabled |
|
|
146
|
-
| removeUTFSequence: boolean | `false` | Remove useless undocumented RN module. |
|
|
123
|
+
| Prop | Default value | Description |
|
|
124
|
+
| ------------------------------ | ------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
125
|
+
| removePromisePolyfill: boolean | `false` | Remove the Promise polyfill as Hermes provide own impl. (issue: [#57702](https://github.com/react/react-native/issues/57702)) |
|
|
126
|
+
| removeUTFSequence: boolean | `false` | Remove useless undocumented RN module. |
|
|
147
127
|
|
|
148
128
|
Helper that creates a custom resolve request function to filter out unnecessary modules from the bundle.
|
|
149
129
|
You can get recommendations during the analysis of the bundle report using the CLI tool.
|
|
150
130
|
|
|
151
131
|
```js
|
|
152
132
|
// metro.config.js
|
|
153
|
-
const {createResolveRequest} = require(
|
|
133
|
+
const { createResolveRequest } = require("react-native-bundle-discovery");
|
|
154
134
|
const resolveRequest = createResolveRequest({
|
|
155
135
|
removePromisePolyfill: true,
|
|
156
|
-
removeOldRenderer: true,
|
|
157
136
|
removeUTFSequence: true,
|
|
158
137
|
});
|
|
159
138
|
const config = {
|
package/index.js
CHANGED
|
@@ -215,8 +215,6 @@ function createSerializer({
|
|
|
215
215
|
*/
|
|
216
216
|
const empty = { type: "empty" };
|
|
217
217
|
const createResolveRequest = ({
|
|
218
|
-
removePromisePolyfill = false, // Remove useless polyfill (Hermes already has Promise)
|
|
219
|
-
removeOldRenderer = false, // Should be true when new ARCH is enabled
|
|
220
218
|
removeNewRenderer = false, // Should be true when new ARCH is disabled
|
|
221
219
|
removeUTFSequence = false, // Remove useless code
|
|
222
220
|
} = {}) => {
|
|
@@ -231,20 +229,6 @@ const createResolveRequest = ({
|
|
|
231
229
|
) {
|
|
232
230
|
return empty;
|
|
233
231
|
}
|
|
234
|
-
if (
|
|
235
|
-
removePromisePolyfill &&
|
|
236
|
-
result?.filePath?.endsWith("/react-native/Libraries/Promise.js")
|
|
237
|
-
) {
|
|
238
|
-
return empty;
|
|
239
|
-
}
|
|
240
|
-
if (
|
|
241
|
-
removeOldRenderer &&
|
|
242
|
-
result?.filePath?.endsWith(
|
|
243
|
-
"/react-native/Libraries/Renderer/shims/ReactNative.js",
|
|
244
|
-
)
|
|
245
|
-
) {
|
|
246
|
-
return empty;
|
|
247
|
-
}
|
|
248
232
|
if (
|
|
249
233
|
removeNewRenderer &&
|
|
250
234
|
result?.filePath?.endsWith(
|
|
@@ -264,8 +248,6 @@ const createResolveRequest = ({
|
|
|
264
248
|
const createProcessModuleFilter =
|
|
265
249
|
({
|
|
266
250
|
removePromisePolyfill = false, // Remove useless polyfill (Hermes already has Promise)
|
|
267
|
-
removeOldRenderer = false, // Should be true when new ARCH is enabled
|
|
268
|
-
removeNewRenderer = false, // Should be true when new ARCH is disabled
|
|
269
251
|
removeUTFSequence = false, // Remove useless code
|
|
270
252
|
} = {}) =>
|
|
271
253
|
(module) => {
|
|
@@ -275,22 +257,6 @@ const createProcessModuleFilter =
|
|
|
275
257
|
) {
|
|
276
258
|
return false;
|
|
277
259
|
}
|
|
278
|
-
if (
|
|
279
|
-
removeOldRenderer &&
|
|
280
|
-
module.path.endsWith(
|
|
281
|
-
"/react-native/Libraries/Renderer/shims/ReactNative.js",
|
|
282
|
-
)
|
|
283
|
-
) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
if (
|
|
287
|
-
removeNewRenderer &&
|
|
288
|
-
module.path.endsWith(
|
|
289
|
-
"/react-native/Libraries/Renderer/shims/ReactFabric.js",
|
|
290
|
-
)
|
|
291
|
-
) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
260
|
if (
|
|
295
261
|
removeUTFSequence &&
|
|
296
262
|
module.path.endsWith("/react-native/Libraries/UTFSequence.js")
|
package/package.json
CHANGED