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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # react-native-bundle-discovery
2
2
 
3
+ [![react-native-bundle-discovery on npm](https://badgen.net/npm/v/react-native-bundle-discovery)](https://www.npmjs.com/package/react-native-bundle-discovery)
4
+ [![react-native-bundle-discovery downloads](https://badgen.net/npm/dm/react-native-bundle-discovery)](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/statoscope/statoscope
152
- - [https://github.com/relative-ci/bundle-stats/tree/master/packages/cli](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli#readme)
151
+ - [expo-atlas](https://github.com/expo/atlas) [![expo-atlas downloads](https://badgen.net/npm/dm/expo-atlas)](https://www.npmtrends.com/expo-atlas) [![expo-atlas install size](https://packagephobia.com/badge?p=expo-atlas)](https://packagephobia.com/result?p=expo-atlas)
152
+ - [expo-atlas-without-expo](https://github.com/v3ron/expo-atlas-without-expo) [![expo-atlas-without-expo downloads](https://badgen.net/npm/dm/expo-atlas-without-expo)](https://www.npmtrends.com/expo-atlas-without-expo) [![expo-atlas-without-expo install size](https://packagephobia.com/badge?p=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) [![react-native-bundle-visualizer downloads](https://badgen.net/npm/dm/react-native-bundle-visualizer)](https://www.npmtrends.com/react-native-bundle-visualizer)[![react-native-bundle-visualizer install size](https://packagephobia.com/badge?p=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) [![webpack-bundle-analyzer downloads](https://badgen.net/npm/dm/webpack-bundle-analyzer)](https://www.npmtrends.com/webpack-bundle-analyzer)[![webpack-bundle-analyzer install size](https://packagephobia.com/badge?p=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) [![bundle-stats downloads](https://badgen.net/npm/dm/bundle-stats)](https://www.npmtrends.com/bundle-stats)[![bundle-stats install size](https://packagephobia.com/badge?p=bundle-stats)](https://packagephobia.com/result?p=bundle-stats)
156
+ - [statoscope](https://github.com/statoscope/statoscope) [![@statoscope/cli downloads](https://badgen.net/npm/dm/@statoscope/cli)](https://www.npmtrends.com/@statoscope/cli)[![@statoscope/cli install size](https://packagephobia.com/badge?p=@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 yargs = require("yargs");
3
- const { hideBin } = require("yargs/helpers");
2
+ const minimist = require("minimist");
4
3
 
5
- yargs(hideBin(process.argv))
6
- .command(
7
- "server <file> [port]",
8
- "🚀 Run a web server to show a Metro bundler stat report",
9
- (yargs) => {
10
- return yargs
11
- .positional("file", {
12
- describe: "Path to the Metro bundler report json file",
13
- type: "string",
14
- demandOption: true,
15
- })
16
- .positional("port", {
17
- describe:
18
- "🔌 Port to start the server on (also can be set with PORT env. var.)",
19
- type: "number",
20
- default: 8079,
21
- });
22
- },
23
- (argv) => {
24
- const { serve } = require("./server.js");
25
- serve(argv.file, argv.port, argv.verbose);
26
- },
27
- )
28
- .command(
29
- "build <file>",
30
- "📦 Build a HTML report from the Metro bundler stat file",
31
- (yargs) => {
32
- return yargs
33
- .positional("file", {
34
- describe: "Path to the Metro bundler report json file",
35
- type: "string",
36
- demandOption: true,
37
- })
38
- .option("output", {
39
- alias: "o",
40
- describe: "Path for a build result",
41
- type: "string",
42
- default: ".bundle-discovery",
43
- })
44
- .option("clean", {
45
- alias: "c",
46
- describe: "Clean the output directory before emit a build files",
47
- type: "boolean",
48
- default: true,
49
- })
50
- .option("single-file", {
51
- alias: "s",
52
- describe: "Output a report build as a single HTML file",
53
- type: "boolean",
54
- default: true,
55
- });
56
- },
57
- (argv) => {
58
- const { buildHtmlPage } = require("./build.js");
59
- buildHtmlPage(
60
- argv.file,
61
- argv.output,
62
- argv.clean,
63
- argv.singleFile,
64
- argv.verbose,
65
- );
66
- },
67
- )
68
- .option("verbose", {
69
- alias: "v",
70
- type: "boolean",
71
- description: "Run with verbose logging",
72
- })
73
- .help()
74
- .parse();
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
- createServer({
61
- cache: false,
62
- minify: true,
63
- dev: false,
64
- config: configFile,
65
- configFile,
66
- }).then((server) =>
67
- server.listen(PORT, () => {
68
- console.log(`========================================`);
69
- console.log(
70
- `🚀 Server listen on ${chalk.green.underline(
71
- chalk.green(`http://localhost:${PORT}`),
72
- )}`,
73
- );
74
- console.log(`========================================`);
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.2.4",
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.2",
17
- "@discoveryjs/discovery": "1.0.0-beta.93",
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
- "prettier": "^3.5.3",
21
- "yargs": "^17.7.2"
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
- };