react-native-bundle-discovery 1.2.4 → 1.3.0-rc.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 +10 -6
- package/lib/bin.js +86 -72
- package/lib/server.js +19 -16
- package/package.json +7 -6
- package/lib/.tmp.js +0 -17
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# react-native-bundle-discovery
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/react-native-bundle-discovery)
|
|
4
|
+
[](https://www.npmtrends.com/react-native-bundle-discovery)
|
|
5
|
+
|
|
6
|
+
|
|
3
7
|
A simple package that helps developers visualize and analyze the bundle size of React Native apps.
|
|
4
8
|
With this tool, you can easily explore your app's codebase, identify large or heavy packages, and inspect the structure of modules and code within your project.
|
|
5
9
|
|
|
@@ -144,12 +148,12 @@ Become a financial contributor at [OpenCollective](https://opencollective.com/re
|
|
|
144
148
|
|
|
145
149
|
**Similar projects:**
|
|
146
150
|
|
|
147
|
-
- https://github.com/expo/atlas
|
|
148
|
-
- https://github.com/v3ron/expo-atlas-without-expo
|
|
149
|
-
- https://github.com/callstack/react-native-bundle-visualizer
|
|
150
|
-
- https://github.com/webpack-contrib/webpack-bundle-analyzer
|
|
151
|
-
- https://github.com/
|
|
152
|
-
- [https://github.com/
|
|
151
|
+
- [expo-atlas](https://github.com/expo/atlas) [](https://www.npmtrends.com/expo-atlas) [](https://packagephobia.com/result?p=expo-atlas)
|
|
152
|
+
- [expo-atlas-without-expo](https://github.com/v3ron/expo-atlas-without-expo) [](https://www.npmtrends.com/expo-atlas-without-expo) [](https://packagephobia.com/result?p=expo-atlas-without-expo)
|
|
153
|
+
- [react-native-bundle-visualizer](https://github.com/callstack/react-native-bundle-visualizer) [](https://www.npmtrends.com/react-native-bundle-visualizer)[](https://packagephobia.com/result?p=react-native-bundle-visualizer)
|
|
154
|
+
- [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) [](https://www.npmtrends.com/webpack-bundle-analyzer)[](https://packagephobia.com/result?p=webpack-bundle-analyzer)
|
|
155
|
+
- [bundle-stats](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli#readme) [](https://www.npmtrends.com/bundle-stats)[](https://packagephobia.com/result?p=bundle-stats)
|
|
156
|
+
- [statoscope](https://github.com/statoscope/statoscope) [](https://www.npmtrends.com/@statoscope/cli)[](https://packagephobia.com/result?p=@statoscope/cli)
|
|
153
157
|
|
|
154
158
|
**Built using [Discovery.js](https://github.com/discoveryjs/discovery):**
|
|
155
159
|
|
package/lib/bin.js
CHANGED
|
@@ -1,74 +1,88 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
3
|
-
const { hideBin } = require("yargs/helpers");
|
|
2
|
+
const minimist = require("minimist");
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.
|
|
74
|
-
|
|
4
|
+
function printHelp() {
|
|
5
|
+
console.log(`react-native-bundle-discovery
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
react-native-bundle-discovery server <file> [port] [--verbose]
|
|
9
|
+
react-native-bundle-discovery build <file> [--output <path>] [--clean] [--single-file] [--verbose]
|
|
10
|
+
|
|
11
|
+
Commands:
|
|
12
|
+
server <file> [port] Run a web server to show a Metro bundler stat report
|
|
13
|
+
build <file> Build a HTML report from the Metro bundler stat file
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
-v, --verbose Run with verbose logging
|
|
17
|
+
-o, --output <path> Path for a build result (default: .bundle-discovery)
|
|
18
|
+
-c, --clean Clean output directory before writing build files (default: true)
|
|
19
|
+
-s, --single-file Output report build as a single HTML file (default: true)
|
|
20
|
+
-p, --port <port> Port for server command (same as [port], default: 8079)
|
|
21
|
+
-h, --help Show help
|
|
22
|
+
`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function fail(message) {
|
|
26
|
+
console.error(message);
|
|
27
|
+
console.error("Use --help to see usage.");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const argv = minimist(process.argv.slice(2), {
|
|
32
|
+
alias: {
|
|
33
|
+
v: "verbose",
|
|
34
|
+
h: "help",
|
|
35
|
+
o: "output",
|
|
36
|
+
c: "clean",
|
|
37
|
+
s: "single-file",
|
|
38
|
+
p: "port",
|
|
39
|
+
},
|
|
40
|
+
boolean: ["verbose", "help", "clean", "single-file"],
|
|
41
|
+
string: ["output"],
|
|
42
|
+
default: {
|
|
43
|
+
clean: true,
|
|
44
|
+
"single-file": true,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const command = argv._[0];
|
|
49
|
+
|
|
50
|
+
if (argv.help || !command) {
|
|
51
|
+
printHelp();
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (command === "server") {
|
|
56
|
+
const file = argv._[1];
|
|
57
|
+
if (!file) {
|
|
58
|
+
fail("Missing required argument: <file>");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const rawPort = argv.port ?? argv._[2] ?? 8079;
|
|
62
|
+
const port = Number(rawPort);
|
|
63
|
+
if (!Number.isFinite(port)) {
|
|
64
|
+
fail(`Invalid port: ${rawPort}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const { serve } = require("./server.js");
|
|
68
|
+
return serve(file, port, Boolean(argv.verbose));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (command === "build") {
|
|
72
|
+
const file = argv._[1];
|
|
73
|
+
if (!file) {
|
|
74
|
+
fail("Missing required argument: <file>");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const { buildHtmlPage } = require("./build.js");
|
|
78
|
+
buildHtmlPage(
|
|
79
|
+
file,
|
|
80
|
+
argv.output,
|
|
81
|
+
argv.clean,
|
|
82
|
+
argv["single-file"],
|
|
83
|
+
Boolean(argv.verbose),
|
|
84
|
+
);
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
fail(`Unknown command: ${command}`);
|
package/lib/server.js
CHANGED
|
@@ -2,6 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const chalk = require("chalk");
|
|
4
4
|
const { createServer } = require("@discoveryjs/cli");
|
|
5
|
+
const { silent } = require("@discoveryjs/cli/lib/shared/utils.js");
|
|
5
6
|
const config = require("../.discoveryrc.js");
|
|
6
7
|
|
|
7
8
|
function serve(filePath, port, verbose) {
|
|
@@ -57,22 +58,24 @@ function serve(filePath, port, verbose) {
|
|
|
57
58
|
console.info(`Running server with config: ${chalk.green(configFile)}`);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
chalk.green(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
return silent(() =>
|
|
62
|
+
createServer({
|
|
63
|
+
cache: false,
|
|
64
|
+
minify: true,
|
|
65
|
+
dev: false,
|
|
66
|
+
config: configFile,
|
|
67
|
+
configFile,
|
|
68
|
+
}).then((server) =>
|
|
69
|
+
server.listen(PORT, () => {
|
|
70
|
+
console.log(`========================================`);
|
|
71
|
+
console.log(
|
|
72
|
+
`🚀 Server listen on ${chalk.green.underline(
|
|
73
|
+
chalk.green(`http://localhost:${PORT}`),
|
|
74
|
+
)}`,
|
|
75
|
+
);
|
|
76
|
+
console.log(`========================================`);
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
76
79
|
);
|
|
77
80
|
}
|
|
78
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-bundle-discovery",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-rc.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"bin": "lib/bin.js",
|
|
6
6
|
"repository": "git@github.com:retyui/react-native-bundle-discovery.git",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/parser": "^7.0.0",
|
|
16
|
-
"@discoveryjs/cli": "2.14.
|
|
17
|
-
"@discoveryjs/discovery": "1.0.0-beta.
|
|
16
|
+
"@discoveryjs/cli": "2.14.7",
|
|
17
|
+
"@discoveryjs/discovery": "1.0.0-beta.99",
|
|
18
18
|
"chalk": "^4.1.2",
|
|
19
19
|
"highcharts": "12.2.0",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
20
|
+
"minimist": "^1.2.8",
|
|
21
|
+
"prettier": "^3.8.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"metro": "*"
|
|
@@ -38,5 +38,6 @@
|
|
|
38
38
|
"prepare.js",
|
|
39
39
|
"queryHelpers.js",
|
|
40
40
|
".discoveryrc.js"
|
|
41
|
-
]
|
|
41
|
+
],
|
|
42
|
+
"packageManager": "yarn@4.13.0"
|
|
42
43
|
}
|
package/lib/.tmp.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"name": "react-native-bundle-discovery",
|
|
3
|
-
"data": () => require("/Users/davyd.narbutovich/open-source/bundle-discovery/tmp/_i_metro-stats.json"),
|
|
4
|
-
"setup": "/Users/davyd.narbutovich/open-source/bundle-discovery/setup.js",
|
|
5
|
-
"view": {
|
|
6
|
-
"assets": [
|
|
7
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/views/global.css",
|
|
8
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/pages/default.js",
|
|
9
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/pages/module.js",
|
|
10
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/pages/package.js",
|
|
11
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/views/highcharts.css",
|
|
12
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/views/prettify.js",
|
|
13
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/views/highcharts.js",
|
|
14
|
-
"/Users/davyd.narbutovich/open-source/bundle-discovery/views/foamtree.js"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
};
|