react-native-bundle-discovery-ui 2.7.0 → 2.9.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/CHANGELOG.md +32 -0
- package/README.md +12 -227
- package/assets/global.css +769 -53
- package/dist/bin.js +61 -16
- package/dist/client/issues.js +5 -0
- package/dist/client/pages/_common.js +258 -86
- package/dist/client/pages/_module.js +347 -0
- package/dist/client/pages/default.js +145 -62
- package/dist/client/pages/module.js +2 -309
- package/dist/client/pages/moduleDiff.js +76 -0
- package/dist/client/pages/package.js +172 -154
- package/dist/client/prepare.js +15 -0
- package/dist/client/queryHelpers.js +445 -81
- package/dist/client/views/{_theme.js → _colorScheme.js} +2 -9
- package/dist/client/views/_html.js +52 -0
- package/dist/client/views/codeDiff.js +66 -0
- package/dist/client/views/compare.js +237 -0
- package/dist/client/views/importGraph.js +255 -0
- package/dist/client/views/insights.js +80 -0
- package/dist/client/views/moduleOverview.js +134 -0
- package/dist/client/views/packageOverview.js +114 -0
- package/dist/client/views/persistedFilterInput.js +27 -0
- package/dist/client/views/reportBar.js +89 -0
- package/dist/client/views/treemap.js +598 -0
- package/dist/discoveryrc.js +26 -7
- package/dist/rsdoctor.js +5 -101
- package/dist/src-Bp8pPQrQ.js +1545 -0
- package/package.json +5 -3
- package/assets/highcharts.css +0 -1
- package/dist/client/_virtual/_rolldown/runtime.js +0 -37
- package/dist/client/views/foamtree.js +0 -103
- package/dist/client/views/highcharts.js +0 -33
- package/dist/src-BSLX-He2.js +0 -36
- package/vendors/foamtree.js +0 -9008
- package/vendors/high-contrast-dark.js +0 -1
- package/vendors/highcharts-exporting.js +0 -13
- package/vendors/highcharts-networkgraph.js +0 -1
- package/vendors/highcharts.js +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# react-native-bundle-discovery-ui
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#23](https://github.com/retyui/react-native-bundle-discovery/pull/23) [`9a7d932`](https://github.com/retyui/react-native-bundle-discovery/commit/9a7d9325d6039354ba661d68b47eef85dc8334ff) Thanks [@retyui](https://github.com/retyui)! - New `--compare <before.json>` option for the `server` and `build` commands: adds a "Compare" tab to the default page with the difference between the two reports (bundle size, modules and packages count, new duplicates and deprecated packages, package version changes, added/removed/changed modules). Uses the same comparison as `react-native-bundle-discovery-cli compare`.
|
|
8
|
+
|
|
9
|
+
- [#23](https://github.com/retyui/react-native-bundle-discovery/pull/23) [`1819d53`](https://github.com/retyui/react-native-bundle-discovery/commit/1819d53c4c0b560f186c90d8cf9cfabf52d2be5e) Thanks [@retyui](https://github.com/retyui)! - Module page: the "Imported by" graph is drawn with D3 (a tree from the current module to its importers, sized by module size, with zoom/pan, hover highlighting and click to open a module). Highcharts and the vendored `vendors/` files were removed.
|
|
10
|
+
|
|
11
|
+
- [#23](https://github.com/retyui/react-native-bundle-discovery/pull/23) [`6271156`](https://github.com/retyui/react-native-bundle-discovery/commit/627115602e54b474670fcaf42b1599570fc76940) Thanks [@retyui](https://github.com/retyui)! - New default "Insights" tab: bundle summary cards, heaviest packages and own modules, and the optimization recommendations of the `analyze` CLI command ranked by estimated savings (production reports only). Header badges show the share of the bundle, the treemap can be colored by package, file type or issues (duplicates / removable code), the "Duplicates" tab lists duplicate packages with possible savings, and the package page shows the shortest import chain ("Why is this in my bundle?").
|
|
12
|
+
|
|
13
|
+
- [`237407e`](https://github.com/retyui/react-native-bundle-discovery/commit/237407e43ffaf3a298f86fce71ff0e3850e5015f) Thanks [@retyui](https://github.com/retyui)! - Module page: new header with package/version and status chips, stat cards (size share and rank, transform delta, lines, package share, imports, importers, duplicates) and a new Imports tab.
|
|
14
|
+
|
|
15
|
+
- [#23](https://github.com/retyui/react-native-bundle-discovery/pull/23) [`2cfe22d`](https://github.com/retyui/react-native-bundle-discovery/commit/2cfe22dda8ded6fd37076aadde194a4142c46c7a) Thanks [@retyui](https://github.com/retyui)! - Package page: new header with versions, status and recommendation chips and quick links, stat cards (bundle share and rank, files, copies with possible savings, importers, publish date) and tabs for files, importers, the import chain and versions. Fixes a package page showing files of another package whose name contains the requested one (e.g. `react` and `react-native`).
|
|
16
|
+
|
|
17
|
+
- [#23](https://github.com/retyui/react-native-bundle-discovery/pull/23) [`a910869`](https://github.com/retyui/react-native-bundle-discovery/commit/a910869464542f8bdfe62776ca8f608610a3a735) Thanks [@retyui](https://github.com/retyui)! - Default page: the row of badges on top is replaced with a compact report bar: platform, a warning for dev or unminified bundles (green "Production · Minified" otherwise), the total size with a "your code / node_modules" split bar, and the report build date.
|
|
18
|
+
|
|
19
|
+
- [#20](https://github.com/retyui/react-native-bundle-discovery/pull/20) [`5817574`](https://github.com/retyui/react-native-bundle-discovery/commit/58175749496a860dbfa87da7fbdd7a9e8dd67844) Thanks [@retyui](https://github.com/retyui)! - Packages and Modules tabs: show the total size of filtered items and allow sorting by size, name or duplicates.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#23](https://github.com/retyui/react-native-bundle-discovery/pull/23) [`d40a350`](https://github.com/retyui/react-native-bundle-discovery/commit/d40a350eb97f2077a84c28421d2d063288167577) Thanks [@retyui](https://github.com/retyui)! - Treemap: more vivid colors with cushion shading, and sub-folders of a package get a slightly shifted hue so big packages show their structure.
|
|
24
|
+
|
|
25
|
+
- [#23](https://github.com/retyui/react-native-bundle-discovery/pull/23) [`2cfe22d`](https://github.com/retyui/react-native-bundle-discovery/commit/2cfe22dda8ded6fd37076aadde194a4142c46c7a) Thanks [@retyui](https://github.com/retyui)! - Packages tab: remove the "Copy list" and "Ask ChatGPT" buttons. Packages and Modules tabs: "Sort by" is now on the left of the filter.
|
|
26
|
+
|
|
27
|
+
- [`9331e2f`](https://github.com/retyui/react-native-bundle-discovery/commit/9331e2f875f4b6cdeeda4ccda2ac5bb2c03700cd) Thanks [@retyui](https://github.com/retyui)! - Packages and Modules tabs: keep the entered filter value after opening a package/module page and navigating back.
|
|
28
|
+
|
|
29
|
+
## 2.8.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- [`64fd3fd`](https://github.com/retyui/react-native-bundle-discovery/commit/64fd3fdb878fa539ed3c9f032588c61d301f61d1) Thanks [@retyui](https://github.com/retyui)! - Support [esbuild metafile](https://esbuild.github.io/api/#metafile) as input (e.g. from `@rnx-kit/metro-serializer-esbuild` with the `metafile` option), with module sizes after tree shaking.
|
|
34
|
+
|
|
3
35
|
## 2.7.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -7,237 +7,22 @@
|
|
|
7
7
|
Visualize and analyze the JS bundle of your React Native app. Find heavy packages, duplicates and deprecated
|
|
8
8
|
dependencies, inspect every module, and catch bundle size regressions in CI.
|
|
9
9
|
|
|
10
|
-
<
|
|
10
|
+
<picture>
|
|
11
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/overview-dark.jpg" />
|
|
12
|
+
<img width="800" alt="Bundle Discovery UI: Treemap, Insights and Packages tabs" src="./assets/overview.jpg" />
|
|
13
|
+
</picture>
|
|
11
14
|
|
|
12
|
-
##
|
|
15
|
+
## Documentation
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
- [Packages](#packages)
|
|
16
|
-
- [Quick start](#quick-start)
|
|
17
|
-
- [Other setups](#other-setups)
|
|
18
|
-
- [Usage](#usage)
|
|
19
|
-
- [UI](#ui)
|
|
20
|
-
- [CLI](#cli)
|
|
21
|
-
- [Bundle size checks in CI](#bundle-size-checks-in-ci)
|
|
22
|
-
- [API](#api)
|
|
23
|
-
- [`createSerializer`](#createserializeroptions)
|
|
24
|
-
- [`createResolveRequest`](#createresolverequestoptions)
|
|
25
|
-
- [Similar projects](#similar-projects)
|
|
26
|
-
- [Support the project](#support-the-project)
|
|
27
|
-
- [License](#license)
|
|
17
|
+
📖 **[retyui.github.io/bundle-discovery](https://retyui.github.io/bundle-discovery/)**
|
|
28
18
|
|
|
29
|
-
|
|
19
|
+
🚀 **[Live demo](https://retyui.github.io/bundle-discovery-demo/)**: see the UI with a real report in compare mode.
|
|
30
20
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
## Packages
|
|
38
|
-
|
|
39
|
-
| Package | What it does | Required |
|
|
40
|
-
| ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | -------- |
|
|
41
|
-
| `react-native-bundle-discovery` | Generates a JSON report (`metro-stats.json`) of your bundle | ✅ Yes |
|
|
42
|
-
| `react-native-bundle-discovery-ui` | Shows the report in the browser | Optional |
|
|
43
|
-
| `react-native-bundle-discovery-cli` | Analyzes and compares reports in the terminal / CI | Optional |
|
|
44
|
-
| [`react-native-bundle-discovery-rozenite-plugin`](./packages/rozenite-plugin/README.md) | Shows the UI inside [React Native DevTools](https://reactnative.dev/docs/react-native-devtools) | Optional |
|
|
45
|
-
|
|
46
|
-
## Quick start
|
|
47
|
-
|
|
48
|
-
This setup is for a standard **Metro** project.
|
|
49
|
-
Using Re.Pack or Rozenite? See [Other setups](#other-setups).
|
|
50
|
-
|
|
51
|
-
> [!TIP]
|
|
52
|
-
> **Using an AI coding agent?** Skip the manual steps below. Point your agent (Claude Code, Cursor, Codex, etc.)
|
|
53
|
-
> at the [`setup-react-native-bundle-discovery`](./skills/setup-react-native-bundle-discovery/SKILL.md) skill.
|
|
54
|
-
> It installs the package and sets up Metro or Re.Pack for you:
|
|
55
|
-
>
|
|
56
|
-
> ```bash
|
|
57
|
-
> npx skills add retyui/react-native-bundle-discovery
|
|
58
|
-
> ```
|
|
59
|
-
|
|
60
|
-
### 1. Install
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
yarn add -D react-native-bundle-discovery # required: generates the report
|
|
64
|
-
yarn add -D react-native-bundle-discovery-ui # optional: browser UI
|
|
65
|
-
yarn add -D react-native-bundle-discovery-cli # optional: CLI
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 2. Configure Metro
|
|
69
|
-
|
|
70
|
-
```diff
|
|
71
|
-
// metro.config.js
|
|
72
|
-
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
|
73
|
-
+const { createSerializer } = require('react-native-bundle-discovery');
|
|
74
|
-
|
|
75
|
-
-const config = {};
|
|
76
|
-
+const config = {
|
|
77
|
-
+ serializer: {
|
|
78
|
-
+ customSerializer: createSerializer({
|
|
79
|
-
+ projectRoot: __dirname, // ⚠️ In a monorepo, use the monorepo root instead
|
|
80
|
-
+ }),
|
|
81
|
-
+ },
|
|
82
|
-
+};
|
|
83
|
-
|
|
84
|
-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
See all options in [`createSerializer`](#createserializeroptions).
|
|
88
|
-
|
|
89
|
-
### 3. Build a release bundle
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npx react-native bundle \
|
|
93
|
-
--entry-file index.js \
|
|
94
|
-
--platform ios \
|
|
95
|
-
--dev false \
|
|
96
|
-
--bundle-output ios/main.jsbundle \
|
|
97
|
-
--assets-dest ios/assets
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
This writes `metro-stats.json` to your project root.
|
|
101
|
-
|
|
102
|
-
### 4. Explore the report
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
npx react-native-bundle-discovery-ui metro-stats.json # open in the browser
|
|
106
|
-
npx react-native-bundle-discovery-cli metro-stats.json # get recommendations in the terminal
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Other setups
|
|
110
|
-
|
|
111
|
-
| Setup | Guide |
|
|
112
|
-
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
113
|
-
| Re.Pack (Rspack / Webpack) | [Re.Pack.md](./Re.Pack.md) |
|
|
114
|
-
| React Native DevTools | [Rozenite plugin](./packages/rozenite-plugin/README.md) |
|
|
115
|
-
| AI coding agent | Point your agent at the [`setup-react-native-bundle-discovery`](./skills/setup-react-native-bundle-discovery/SKILL.md) skill |
|
|
116
|
-
|
|
117
|
-
## Usage
|
|
118
|
-
|
|
119
|
-
### UI
|
|
120
|
-
|
|
121
|
-
Requires `react-native-bundle-discovery-ui`.
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
# Start a local server (default port: 8079)
|
|
125
|
-
npx react-native-bundle-discovery-ui metro-stats.json [--port <port>]
|
|
126
|
-
|
|
127
|
-
# Build a static HTML report (default output: .bundle-discovery)
|
|
128
|
-
npx react-native-bundle-discovery-ui build metro-stats.json [--output <path>]
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### CLI
|
|
132
|
-
|
|
133
|
-
Requires `react-native-bundle-discovery-cli`. Run any command with `--help` to see all options.
|
|
134
|
-
|
|
135
|
-
| Command | Description |
|
|
136
|
-
| ---------- | --------------------------------------------- |
|
|
137
|
-
| _(none)_ | Show recommended optimizations for the bundle |
|
|
138
|
-
| `packages` | List all packages in the bundle |
|
|
139
|
-
| `modules` | List the heaviest modules |
|
|
140
|
-
| `compare` | Compare two reports |
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
# Recommended optimizations
|
|
144
|
-
npx react-native-bundle-discovery-cli metro-stats.json
|
|
145
|
-
|
|
146
|
-
# All packages
|
|
147
|
-
npx react-native-bundle-discovery-cli packages metro-stats.json [--sort size|name] [--format json|table|default]
|
|
148
|
-
|
|
149
|
-
# Heaviest modules (default --limit: 50, use 0 to show all)
|
|
150
|
-
# --filter accepts plain text (case-insensitive) or a regexp, e.g. --filter '/\.json/i'
|
|
151
|
-
npx react-native-bundle-discovery-cli modules metro-stats.json [--limit 50] [--filter <text|/regexp/>] [--sort size|name] [--format json|table|default]
|
|
152
|
-
|
|
153
|
-
# Diff two reports: total size, added/removed/changed modules and packages,
|
|
154
|
-
# version changes, new duplicates and new deprecated packages
|
|
155
|
-
npx react-native-bundle-discovery-cli compare --before main-stats.json --after pr-stats.json [--limit 50] [--format json|markdown|default]
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Bundle size checks in CI
|
|
159
|
-
|
|
160
|
-
`compare` exits with code `1` when any check fails:
|
|
161
|
-
|
|
162
|
-
| Option | Fails when | Example |
|
|
163
|
-
| -------------------- | ------------------------------------------------------------- | ------------------------------- |
|
|
164
|
-
| `--fail-on-increase` | The bundle grows more than the limit (bytes or % of "before") | `50KB`, `0.5MB`, `51200`, `5%` |
|
|
165
|
-
| `--max-size` | The "after" bundle is bigger than the limit | `3MB` |
|
|
166
|
-
| `--fail-on` | New duplicate and/or deprecated packages appear | `new-duplicates,new-deprecated` |
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
npx react-native-bundle-discovery-cli compare --before main-stats.json --after pr-stats.json \
|
|
170
|
-
--fail-on-increase 50KB \
|
|
171
|
-
--max-size 3MB \
|
|
172
|
-
--fail-on new-duplicates,new-deprecated
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
**GitHub Actions** works out of the box: the markdown report is added to the job summary and failed checks
|
|
176
|
-
are shown as error annotations.
|
|
177
|
-
|
|
178
|
-
```yaml
|
|
179
|
-
- run: npx react-native-bundle-discovery-cli compare --before main-stats.json --after pr-stats.json --fail-on-increase 5%
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
To post the report as a PR comment, use `--format markdown`.
|
|
183
|
-
|
|
184
|
-
## API
|
|
185
|
-
|
|
186
|
-
Exported from `react-native-bundle-discovery`.
|
|
187
|
-
|
|
188
|
-
### `createSerializer(options)`
|
|
189
|
-
|
|
190
|
-
Creates a Metro serializer that writes the JSON report. Use it as `serializer.customSerializer` (see [Quick start](#2-configure-metro)).
|
|
191
|
-
|
|
192
|
-
| Option | Type | Default | Description |
|
|
193
|
-
| ----------------------- | ---------- | -------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
194
|
-
| `projectRoot` | `string` | **Required** | Project root. ⚠️ In a monorepo, use the monorepo root, not the app package directory. |
|
|
195
|
-
| `outputJsonPath` | `string` | `<projectRoot>/metro-stats.json` | Where to save the report. |
|
|
196
|
-
| `includeCode` | `boolean` | `true` | Include source and bundled code of each module in the report (larger file). |
|
|
197
|
-
| `includeEnvs` | `string[]` | `[]` | Names of environment variables to include in the report. |
|
|
198
|
-
| `fetchPackagesMetadata` | `boolean` | `true` | Fetch package metadata (publish date, deprecation, latest version) from the npm registry. |
|
|
199
|
-
| `silent` | `boolean` | `false` | Disable log output. |
|
|
200
|
-
| `serializer` | `Function` | Metro default serializer | Custom serializer to wrap. |
|
|
201
|
-
|
|
202
|
-
> [!WARNING]
|
|
203
|
-
> With `includeCode: true` (the default) the report **contains your source code**.
|
|
204
|
-
> If your code is proprietary, be careful who you share the report with.
|
|
205
|
-
|
|
206
|
-
### `createResolveRequest(options)`
|
|
207
|
-
|
|
208
|
-
Creates a Metro `resolveRequest` that removes unnecessary React Native modules from **release** bundles
|
|
209
|
-
(dev builds are not affected). The CLI recommends these options when they apply to your bundle.
|
|
210
|
-
|
|
211
|
-
| Option | Type | Default | Description |
|
|
212
|
-
| ------------------- | --------- | ------- | -------------------------------------------------------------------------------- |
|
|
213
|
-
| `removeUTFSequence` | `boolean` | `false` | Remove the unused `react-native/Libraries/UTFSequence.js` module. |
|
|
214
|
-
| `removeNewRenderer` | `boolean` | `false` | Remove the Fabric renderer. Enable only if the New Architecture is **disabled**. |
|
|
215
|
-
|
|
216
|
-
```js
|
|
217
|
-
// metro.config.js
|
|
218
|
-
const { createResolveRequest } = require("react-native-bundle-discovery");
|
|
219
|
-
|
|
220
|
-
const config = {
|
|
221
|
-
resolver: {
|
|
222
|
-
resolveRequest: createResolveRequest({
|
|
223
|
-
removeUTFSequence: true,
|
|
224
|
-
}),
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
## Similar projects
|
|
230
|
-
|
|
231
|
-
- [expo-atlas](https://github.com/expo/atlas)
|
|
232
|
-
- [expo-atlas-without-expo](https://github.com/v3ron/expo-atlas-without-expo)
|
|
233
|
-
- [react-native-bundle-visualizer](https://github.com/callstack/react-native-bundle-visualizer)
|
|
234
|
-
- [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)
|
|
235
|
-
- [bundle-stats](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli#readme)
|
|
236
|
-
- [statoscope](https://github.com/statoscope/statoscope)
|
|
237
|
-
|
|
238
|
-
Built with [Discovery.js](https://github.com/discoveryjs/discovery)
|
|
239
|
-
([views showcase](https://discoveryjs.github.io/discovery/#views-showcase),
|
|
240
|
-
[Jora syntax](https://discoveryjs.github.io/jora/#article:jora-syntax-operators)).
|
|
21
|
+
- [Quick start](https://retyui.github.io/bundle-discovery/docs/getting-started/quick-start)
|
|
22
|
+
- [UI](https://retyui.github.io/bundle-discovery/docs/guides/ui) and [CLI](https://retyui.github.io/bundle-discovery/docs/guides/cli)
|
|
23
|
+
- [Bundle size checks in CI](https://retyui.github.io/bundle-discovery/docs/guides/ci)
|
|
24
|
+
- [Re.Pack](https://retyui.github.io/bundle-discovery/docs/guides/repack), [rnx-kit](https://retyui.github.io/bundle-discovery/docs/guides/rnx-kit) and [React Native DevTools](https://retyui.github.io/bundle-discovery/docs/guides/rozenite)
|
|
25
|
+
- [API](https://retyui.github.io/bundle-discovery/docs/api/create-serializer)
|
|
241
26
|
|
|
242
27
|
## Support the project
|
|
243
28
|
|