Skip to content

Commit ae40475

Browse files
committed
feat: Rozenite plugin release
1 parent 7660887 commit ae40475

6 files changed

Lines changed: 59 additions & 8 deletions

File tree

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ With this tool, you can easily explore your app's codebase, identify large or he
1818

1919
### Setup:
2020

21-
#### 1. Install
21+
There are two ways to install the package:
22+
23+
1. As in independent tool
24+
2. Or as a [Rozenite](https://www.rozenite.dev/) plugin (see below).
25+
26+
#### 1. Install (independent tool)
2227

2328
```bash
2429
yarn add -D react-native-bundle-discovery
2530
```
2631

27-
#### 2. Add to your metro.config.js
32+
Add to your `metro.config.js`:
2833

2934
```diff
3035
// metro.config.js
@@ -48,6 +53,46 @@ const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
4853
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
4954
```
5055

56+
---
57+
58+
#### 2. Install as a Rozenite plugin (OPTIONAL)
59+
60+
61+
```bash
62+
yarn dlx rozenite@latest init # init rozenite in your project (from: https://www.rozenite.dev/docs/getting-started)
63+
yarn add -D react-native-bundle-discovery-rozenite-plugin # add the plugin to your project
64+
```
65+
66+
Then in the `metro.config.js` file add the following:
67+
68+
```diff
69+
const { withRozenite } = require('@rozenite/metro');
70+
+const { withRozeniteBundleDiscoveryPlugin } = require('react-native-bundle-discovery-rozenite-plugin');
71+
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
72+
73+
/**
74+
* Metro configuration
75+
* https://reactnative.dev/docs/metro
76+
*
77+
* @type {import('@react-native/metro-config').MetroConfig}
78+
*/
79+
const config = {};
80+
81+
module.exports = withRozenite(
82+
mergeConfig(getDefaultConfig(__dirname), config),
83+
{
84+
+ enhanceMetroConfig: config => withRozeniteBundleDiscoveryPlugin(config, { /* Your Bundle Discovery Options */ }),
85+
enabled: true,
86+
},
87+
);
88+
```
89+
90+
Now you can run `yarn start` and open [React Native DevTools](https://reactnative.dev/docs/react-native-devtools)
91+
92+
93+
---
94+
95+
5196
#### 3. Build the app
5297

5398
As example, for iOS you can run the following command, and it will generate the `metro-stats.json` file in the root of your project:

lib/customSerializer.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function createJsonReport({
9494
includeCode,
9595
outputJsonPath,
9696
rootFolder,
97+
silent,
9798
}) {
9899
const dependencies = Array.from(graph.dependencies.values());
99100

@@ -114,9 +115,11 @@ function createJsonReport({
114115

115116
writeFileSync(outputJsonPath, JSON.stringify(stats));
116117

117-
console.log(
118-
`${chalk.yellow(`[${NAME}]`)}: Saved stats to ${chalk.green(outputJsonPath)}`,
119-
);
118+
if (!silent) {
119+
console.log(
120+
`${chalk.yellow(`[${NAME}]`)}: Saved stats to ${chalk.green(outputJsonPath)}`,
121+
);
122+
}
120123
}
121124

122125
/**
@@ -137,6 +140,7 @@ function createSerializer({
137140
projectRoot,
138141
outputJsonPath,
139142
includeCode = true,
143+
silent = false,
140144
includeEnvs = [],
141145
} = {}) {
142146
const mySerializer = serializer || getDefaultSerializer();
@@ -159,6 +163,7 @@ function createSerializer({
159163
includeCode,
160164
outputJsonPath: myOutputJsonPath,
161165
rootFolder: projectRoot,
166+
silent,
162167
});
163168

164169
return code;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-bundle-discovery",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"main": "index.js",
55
"bin": "lib/bin.js",
66
"repository": "git@github.com:retyui/react-native-bundle-discovery.git",

rozenite/dist/react-native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function injectBundleDiscovery(config, options) {
2929

3030
const newSerializer = createSerializer({
3131
projectRoot: process.cwd(),
32+
silent: true,
3233
...options,
3334
outputJsonPath,
3435
serializer: hasSerializer ? config.serializer.customSerializer : undefined,

rozenite/dist/rozenite.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-bundle-discovery-rozenite-plugin",
3-
"version": "1.0.0-rc.2",
3+
"version": "1.0.0",
44
"description": "Metro Bundle Discovery for Rozenite.",
55
"panels": [
66
{

rozenite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-bundle-discovery-rozenite-plugin",
3-
"version": "1.0.0-rc.2",
3+
"version": "1.0.0",
44
"license": "MIT",
55
"main": "dist/react-native.js",
66
"files": [

0 commit comments

Comments
 (0)