Skip to content

Commit 8c2daab

Browse files
committed
Release v4
- Node.js 20+ - Removed `fs-extra` - Use `node:` imports - Update dependencies - Update README.md
1 parent f8a535c commit 8c2daab

File tree

5 files changed

+251
-169
lines changed

5 files changed

+251
-169
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19+
nodejs-version: [24, 22, 20] # Three latest major versions of Node.js
1920
rn-version: [latest, 0.83.4, 0.82.1] # Three latest major versions of React Native
2021
steps:
2122
- name: Checkout
2223
uses: actions/checkout@v6
2324

24-
- name: Use Node.js ${{ env.NODEJS_VERSION }}
25+
- name: Use Node.js ${{ matrix.nodejs-version }}
2526
uses: actions/setup-node@v6
2627
with:
27-
node-version: ${{ env.NODEJS_VERSION }}
28+
node-version: ${{ matrix.nodejs-version }}
2829
cache: 'yarn'
2930

3031
- name: Install node_modules in ${{ github.workspace }}
@@ -47,15 +48,16 @@ jobs:
4748
runs-on: ubuntu-latest
4849
strategy:
4950
matrix:
51+
nodejs-version: [24, 22, 20]
5052
expo-sdk: [ 55, 54, 53 ] # Three latest major Expo SDK versions
5153
steps:
5254
- name: Checkout
5355
uses: actions/checkout@v6
5456

55-
- name: Use Node.js ${{ env.NODEJS_VERSION }}
57+
- name: Use Node.js ${{ matrix.nodejs-version }}
5658
uses: actions/setup-node@v6
5759
with:
58-
node-version: ${{ env.NODEJS_VERSION }}
60+
node-version: ${{ matrix.nodejs-version }}
5961
cache: 'yarn'
6062

6163
- name: Install node_modules in ${{ github.workspace }}

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
# react-native-bundle-visualizer
22

3-
See what's inside of your react-native bundle 📦
3+
See what's inside your react-native bundle 📦
44

55
![bundle-visualizer-animation](./react-native-bundle-visualizer2.gif)
66

77
Uses the awesome [source-map-explorer](https://github.com/danvk/source-map-explorer) to visualize the output of the [Metro bundler](https://github.com/facebook/metro).
88

99
## Purpose
1010

11-
Sometimes, importing a single javascript library can drastically increase your bundle size. This package helps you to identify such a library, so you can keep the bundle size low and loading times fast.
11+
Sometimes, importing a single JavaScript library can drastically increase your bundle size. This package helps you to identify such a library, so you can keep the bundle size low and loading times fast.
1212

1313
## Usage
1414

15-
Make sure [npx](https://github.com/npm/npx) is installed and run the following command in your project root
16-
17-
`npx react-native-bundle-visualizer`
18-
19-
### Or install as a dev-dependency
15+
Using `npx` is the recommended way to run the visualizer
2016

2117
```sh
22-
yarn add --dev react-native-bundle-visualizer
18+
# React Native 0.72+
19+
npx react-native-bundle-visualizer@latest
20+
# or Expo SDK 50+
21+
npx react-native-bundle-visualizer@latest --expo
2322
```
2423

25-
And run it:
24+
### Or you can install as a dev-dependency
2625

27-
```
28-
yarn run react-native-bundle-visualizer
26+
```sh
27+
yarn add --dev react-native-bundle-visualizer
28+
# or npm
29+
npm install --save-dev react-native-bundle-visualizer
2930
```
3031

31-
_or when using npm:_
32+
To run the local version of visualizer, use the following command:
3233

33-
```
34-
npm install --save-dev react-native-bundle-visualizer ./node_modules/.bin/react-native-bundle-visualizer
34+
```sh
35+
npx react-native-bundle-visualizer # if installed by yarn or npm
36+
yarn run react-native-bundle-visualizer # if installed by Yarn
3537
```
3638

3739
## Command line arguments
@@ -58,11 +60,13 @@ All command-line arguments are optional. By default a production build will be c
5860
## Version compatibility
5961

6062
| Version | Comments |
61-
| ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
62-
| 3.x | Compatible with React-Native CLI bootstrapped projects and Expo SDK 41 or higher. |
63+
|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
64+
| 4.x | Compatible with React Native 0.72+ or Expo SDK 50+ |
65+
| [3.x](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v3) | Compatible with React-Native CLI bootstrapped projects and Expo SDK 41 or higher. |
6366
| [2.x](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v2) | Compatible with React-Native CLI bootstrapped projects and Expo SDK 40 or earlier. |
6467
| [1.x](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v1) | Uses the [Haul bundler](https://github.com/callstack/haul) instead instead of the Metro output. |
6568

69+
6670
## License
6771

6872
[MIT](./LICENSE.txt)

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-bundle-visualizer",
3-
"version": "3.2.0",
3+
"version": "4.0.0",
44
"description": "See what's inside your react-native bundle",
55
"author": "IjzerenHein <hrutjes@gmail.com>",
66
"keywords": [
@@ -22,15 +22,17 @@
2222
],
2323
"dependencies": {
2424
"chalk": "^4.1.2",
25-
"execa": "^5.1.1",
26-
"fs-extra": "^10.0.0",
27-
"minimist": "^1.2.5",
28-
"open": "^8.4.0",
25+
"execa": "^9.6.1",
26+
"minimist": "^1.2.8",
27+
"open": "^11.0.0",
2928
"source-map-explorer": "^2.5.3"
3029
},
3130
"scripts": {
3231
"test": "yarn test:rn && yarn test:expo",
3332
"test:rn": "cd test/RN64 && yarn install && npx ../.. && cd ../..",
3433
"test:expo": "cd test/Expo42 && yarn install && npx ../.. --expo=true && cd ../.."
34+
},
35+
"engines": {
36+
"node": ">=20"
3537
}
3638
}

src/react-native-bundle-visualizer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/env node
2+
const fs = require('node:fs');
3+
const os = require('node:os');
4+
const process = require('node:process');
5+
const path = require('node:path');
26
const chalk = require('chalk');
3-
const fs = require('fs-extra');
4-
const os = require('os');
5-
const process = require('process');
6-
const path = require('path');
77
const argv = require('minimist')(process.argv.slice(2));
8-
const execa = require('execa');
9-
const open = require('open');
8+
const {execa} = require('execa');
9+
const open = require('open').default;
1010
const {explore} = require('source-map-explorer');
1111
const pkgJSON = JSON.parse(fs.readFileSync('./package.json'));
1212

@@ -74,8 +74,8 @@ const borderChecks = argv['border-checks'] === true;
7474
const errorOnFail = argv['error-on-fail'] || false;
7575

7676
// Make sure the temp dir exists
77-
fs.ensureDirSync(baseDir);
78-
fs.ensureDirSync(tmpDir);
77+
fs.mkdirSync(baseDir, { recursive: true });
78+
fs.mkdirSync(tmpDir, { recursive: true });
7979

8080
// Try to obtain the previous file size
8181
let prevBundleSize;
@@ -162,7 +162,7 @@ bundlePromise
162162
);
163163

164164
// Make sure the explorer output dir is removed
165-
fs.removeSync(outDir);
165+
fs.rmSync(outDir, { recursive: true, force: true });
166166
return explore(
167167
{
168168
code: bundleOutput,

0 commit comments

Comments
 (0)