react-native-bundle-discovery 1.2.0 → 1.2.1

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 CHANGED
@@ -18,13 +18,18 @@ With this tool, you can easily explore your app's codebase, identify large or he
18
18
 
19
19
  ### Setup:
20
20
 
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)
22
27
 
23
28
  ```bash
24
29
  yarn add -D react-native-bundle-discovery
25
30
  ```
26
31
 
27
- #### 2. Add to your metro.config.js
32
+ Add to your `metro.config.js`:
28
33
 
29
34
  ```diff
30
35
  // metro.config.js
@@ -48,6 +53,46 @@ const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
48
53
  module.exports = mergeConfig(getDefaultConfig(__dirname), config);
49
54
  ```
50
55
 
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
+
51
96
  #### 3. Build the app
52
97
 
53
98
  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:
@@ -61,7 +106,9 @@ npx react-native bundle \
61
106
  --assets-dest ios/assets
62
107
  ```
63
108
 
64
- #### 4. View the report in the browser
109
+ #### 4. CLI
110
+
111
+ ##### 4.1 View the report in the browser
65
112
 
66
113
  Run webserver to view the report:
67
114
 
@@ -69,7 +116,7 @@ Run webserver to view the report:
69
116
  npx react-native-bundle-discovery server metro-stats.json [--port <port>]
70
117
  ```
71
118
 
72
- #### 4. Build the HTML report
119
+ ##### 4.2 Build the HTML report
73
120
 
74
121
  Run the following command to generate an HTML report from the JSON file:
75
122
 
@@ -102,7 +149,7 @@ Become a financial contributor at [OpenCollective](https://opencollective.com/re
102
149
  - https://github.com/callstack/react-native-bundle-visualizer
103
150
  - https://github.com/webpack-contrib/webpack-bundle-analyzer
104
151
  - https://github.com/statoscope/statoscope
105
- - https://github.com/relative-ci/bundle-stats/tree/master/packages/cli
152
+ - [https://github.com/relative-ci/bundle-stats/tree/master/packages/cli](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli#readme)
106
153
 
107
154
  **Built using [Discovery.js](https://github.com/discoveryjs/discovery):**
108
155
 
package/lib/.tmp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  "name": "react-native-bundle-discovery",
3
- "data": () => require("/Users/davyd.narbutovich/open-source/bundle-discovery/tmp/rocket-chat-metro-stats.json"),
3
+ "data": () => require("/Users/davyd.narbutovich/open-source/bundle-discovery/tmp/dtv-metro-stats.json"),
4
4
  "setup": "/Users/davyd.narbutovich/open-source/bundle-discovery/setup.js",
5
5
  "view": {
6
6
  "assets": [
@@ -94,6 +94,7 @@ function createJsonReport({
94
94
  includeCode,
95
95
  outputJsonPath,
96
96
  rootFolder,
97
+ silent,
97
98
  }) {
98
99
  const dependencies = Array.from(graph.dependencies.values());
99
100
 
@@ -114,9 +115,11 @@ function createJsonReport({
114
115
 
115
116
  writeFileSync(outputJsonPath, JSON.stringify(stats));
116
117
 
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
+ }
120
123
  }
121
124
 
122
125
  /**
@@ -137,6 +140,7 @@ function createSerializer({
137
140
  projectRoot,
138
141
  outputJsonPath,
139
142
  includeCode = true,
143
+ silent = false,
140
144
  includeEnvs = [],
141
145
  } = {}) {
142
146
  const mySerializer = serializer || getDefaultSerializer();
@@ -159,6 +163,7 @@ function createSerializer({
159
163
  includeCode,
160
164
  outputJsonPath: myOutputJsonPath,
161
165
  rootFolder: projectRoot,
166
+ silent,
162
167
  });
163
168
 
164
169
  return code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bundle-discovery",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "main": "index.js",
5
5
  "bin": "lib/bin.js",
6
6
  "repository": "git@github.com:retyui/react-native-bundle-discovery.git",