Skip to content

Commit 4ad126c

Browse files
committed
feat: add —format [html|json|tsv] option
1 parent 4597f6c commit 4ad126c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ All command-line arguments are optional. By default a production build will be c
4444
| `dev` | Dev or production build (default is **false**) | `--dev false` |
4545
| `entry-file` | Entry-file (when omitted tries to auto-resolve it) | `--entry-file ./index.android.js` |
4646
| `bundle-output` | Output bundle-file (default is **tmp**) | `--bundle-output ./myapp.bundle` |
47+
| `format` | Output format **html**, **json** or **tsv** (default is **html**) (see [source-map-explorer options](https://github.com/danvk/source-map-explorer#options)) | `--format json` |
4748
| `verbose` | Dumps additional output to the console (default is **false**) | `--verbose` |
4849
| `reset-cache` | Removes cached react-native files (default is **false**) | `--reset-cache` |
4950

src/react-native-bundle-visualizer.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const resetCache = argv['reset-cache'] || false;
4747
const bundleOutput =
4848
argv['bundle-output'] || tmpDir + '/' + platform + '.bundle';
4949
const bundleOutputSourceMap = bundleOutput + '.map';
50-
const bundleOutputExplorerHTML = tmpDir + '/output/explorer.html';
50+
const format = argv.format || 'html';
51+
const bundleOutputExplorerFile = tmpDir + '/output/explorer.' + format;
5152

5253
// Make sure the temp dir exists
5354
if (!fs.existsSync(baseDir)) fs.mkdirSync(baseDir);
@@ -128,14 +129,14 @@ bundlePromise
128129
},
129130
{
130131
output: {
131-
format: 'html',
132-
filename: bundleOutputExplorerHTML,
132+
format,
133+
filename: bundleOutputExplorerFile,
133134
},
134135
}
135136
);
136137
}
137138

138-
// Log info and open html file
139+
// Log info and open output file
139140
)
140141
.then((result) => {
141142
if (verbose) {
@@ -159,6 +160,6 @@ bundlePromise
159160
});
160161
}
161162

162-
// Open html file
163-
return open(bundleOutputExplorerHTML);
163+
// Open output file
164+
return open(bundleOutputExplorerFile);
164165
});

0 commit comments

Comments
 (0)