react-native-bundle-discovery 1.0.0-rc.11 → 1.0.0-rc.13
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 +28 -3
- package/lib/customSerializer.js +7 -4
- package/package.json +2 -3
- package/queryHelpers.js +1 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Currently, everything is in a very early stage. The project is not yet ready for use.
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
<img width="800" src="
|
|
7
|
+
<img width="800" alt="" src="./assets/img.png" />
|
|
8
8
|
|
|
9
9
|
### Setup:
|
|
10
10
|
|
|
@@ -25,7 +25,7 @@ const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
|
|
|
25
25
|
+ projectRoot: __dirname,
|
|
26
26
|
+ //^^^ ⚠️ WARNING: In a monorepo setup, this should point to the monorepo root,
|
|
27
27
|
+ // not the individual package directory.
|
|
28
|
-
+})
|
|
28
|
+
+});
|
|
29
29
|
|
|
30
30
|
-const config = {};
|
|
31
31
|
+const config = {
|
|
@@ -37,7 +37,31 @@ const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
|
|
|
37
37
|
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
#### 3. Build the app
|
|
41
|
+
|
|
42
|
+
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:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx react-native bundle \
|
|
46
|
+
--entry-file index.js \
|
|
47
|
+
--platform ios \
|
|
48
|
+
--dev false \
|
|
49
|
+
--bundle-output ios/main.jsbundle \
|
|
50
|
+
--assets-dest ios/assets
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### 4. View the report
|
|
54
|
+
|
|
55
|
+
Run webserver to view the report:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx react-native-bundle-discovery metro-stats.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
40
63
|
**Similar projects:**
|
|
64
|
+
|
|
41
65
|
- https://github.com/expo/atlas
|
|
42
66
|
- https://github.com/v3ron/expo-atlas-without-expo
|
|
43
67
|
- https://github.com/callstack/react-native-bundle-visualizer
|
|
@@ -45,7 +69,8 @@ module.exports = mergeConfig(getDefaultConfig(__dirname), config);
|
|
|
45
69
|
- https://github.com/statoscope/statoscope
|
|
46
70
|
- https://github.com/relative-ci/bundle-stats/tree/master/packages/cli
|
|
47
71
|
|
|
72
|
+
---
|
|
48
73
|
|
|
49
|
-
**
|
|
74
|
+
**Built using Discovery.js:**
|
|
50
75
|
- Build blocks for pages: https://discoveryjs.github.io/discovery/#views-showcase
|
|
51
76
|
- Jora syntax: https://discoveryjs.github.io/jora/#article:jora-syntax-operators
|
package/lib/customSerializer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const { writeFileSync, existsSync } = require("
|
|
2
|
-
const { resolve } = require("
|
|
3
|
-
const { Buffer } = require("
|
|
1
|
+
const { writeFileSync, existsSync } = require("fs");
|
|
2
|
+
const { resolve } = require("path");
|
|
3
|
+
const { Buffer } = require("buffer");
|
|
4
|
+
const chalk = require("chalk");
|
|
4
5
|
|
|
5
6
|
const NAME = require("../package.json").name;
|
|
6
7
|
|
|
@@ -113,7 +114,9 @@ function createJsonReport({
|
|
|
113
114
|
|
|
114
115
|
writeFileSync(outputJsonPath, JSON.stringify(stats));
|
|
115
116
|
|
|
116
|
-
console.log(
|
|
117
|
+
console.log(
|
|
118
|
+
`${chalk.yellow(`[${NAME}]`)}: Saved stats to ${chalk.green(outputJsonPath)}`,
|
|
119
|
+
);
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bundle-discovery",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.13",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"bin": "lib/bin.js",
|
|
6
6
|
"repository": "git@github.com:retyui/react-native-bundle-discovery.git",
|
|
@@ -38,6 +38,5 @@
|
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"prettier": "3.5.3"
|
|
41
|
-
}
|
|
42
|
-
"packageManager": "yarn@4.6.0"
|
|
41
|
+
}
|
|
43
42
|
}
|
package/queryHelpers.js
CHANGED
|
@@ -260,9 +260,7 @@ function flattenTree(
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
function sumSizes(node) {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
const isFile = isEmpty(node.children);
|
|
263
|
+
const isFile = Object.keys(node.children).length === 0;
|
|
266
264
|
let totalFiles = isFile ? 1 : 0;
|
|
267
265
|
let totalSize = node.size || 0;
|
|
268
266
|
for (const key in node.children) {
|