Skip to content

Commit 3fc2f0d

Browse files
committed
fix: add --no-border-checks flag to recover from source-map-explorer errors
1 parent 097c49b commit 3fc2f0d

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

README.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,30 @@ npm install --save-dev react-native-bundle-visualizer ./node_modules/.bin/react-
3838

3939
All command-line arguments are optional. By default a production build will be created for the `ios` platform.
4040

41-
| Option | Description | Example |
42-
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- |
43-
| `platform` | Platform to build (default is **ios**) | `--platform ios` |
44-
| `dev` | Dev or production build (default is **false**) | `--dev false` |
45-
| `entry-file` | Entry-file (when omitted tries to auto-resolve it) | `--entry-file ./index.ios.js` |
46-
| `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][smeo]) | `--format json` |
48-
| `only-mapped` | Exclude "unmapped" bytes from the output (default is **false**). This will result in total counts less than the file size. | `--only-mapped` |
49-
| `verbose` | Dumps additional output to the console (default is **false**) | `--verbose` |
50-
| `reset-cache` | Removes cached react-native files (default is **false**) | `--reset-cache` |
51-
| `--expo` | Set this to true/ false based on whether using expo or not. For eg, set `--expo true` when using expo. Not required to pass this for react-native cli. (default is **false**) | `--expo false` |
41+
| Option | Description | Example |
42+
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
43+
| `platform` | Platform to build (default is **ios**) | `--platform ios` |
44+
| `dev` | Dev or production build (default is **false**) | `--dev false` |
45+
| `entry-file` | Entry-file (when omitted tries to auto-resolve it) | `--entry-file ./index.ios.js` |
46+
| `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][smeo]) | `--format json` |
48+
| `only-mapped` | Exclude "unmapped" bytes from the output (default is **false**). This will result in total counts less than the file size. | `--only-mapped` |
49+
| `verbose` | Dumps additional output to the console (default is **false**) | `--verbose` |
50+
| `reset-cache` | Removes cached react-native files (default is **false**) | `--reset-cache` |
51+
| `--expo` | Set this to true/ false based on whether using expo or not. For eg, set `--expo true` when using expo. Not required to pass this for react-native cli. (default is **false**) | `--expo false` |
52+
| `--no-border-checks` | Pass the same flag to the underlying `source-map-explorer` to disable invalid mapping column/line checks. | `--no-border-checks` |
5253

5354
[smeo]: https://github.com/danvk/source-map-explorer#options
5455

55-
>Use [react-native-bundle-visualizer@2](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v2) when targetting Expo SDK 40 or lower.
56+
> Use [react-native-bundle-visualizer@2](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v2) when targetting Expo SDK 40 or lower.
5657
5758
## Version compatibility
5859

59-
| Version | Comments |
60-
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61-
| 3.x | Compatible with React-Native CLI bootstrapped projects and Expo SDK 41 or higher. |
62-
| [2.x](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v2) | Compatible with React-Native CLI bootstrapped projects and Expo SDK 40 or earlier. |
63-
| [1.x](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v1) | Uses the [Haul bundler](https://github.com/callstack/haul) instead instead of the Metro output. |
60+
| Version | Comments |
61+
| ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
62+
| 3.x | Compatible with React-Native CLI bootstrapped projects and Expo SDK 41 or higher. |
63+
| [2.x](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v2) | Compatible with React-Native CLI bootstrapped projects and Expo SDK 40 or earlier. |
64+
| [1.x](https://github.com/IjzerenHein/react-native-bundle-visualizer/tree/v1) | Uses the [Haul bundler](https://github.com/callstack/haul) instead instead of the Metro output. |
6465

6566
## License
6667

src/react-native-bundle-visualizer.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const bundleOutputSourceMap = bundleOutput + '.map';
6969
const format = argv.format || 'html';
7070
const bundleOutputExplorerFile = path.join(outDir, 'explorer.' + format);
7171
const onlyMapped = !!argv['only-mapped'] || false;
72+
const borderChecks = argv['border-checks'] || false;
7273

7374
// Make sure the temp dir exists
7475
fs.ensureDirSync(baseDir);
@@ -96,7 +97,7 @@ const commands = [
9697
'--sourcemap-output',
9798
bundleOutputSourceMap,
9899
'--minify',
99-
isExpo
100+
isExpo,
100101
];
101102
if (resetCache) {
102103
commands.push('--reset-cache');
@@ -147,6 +148,7 @@ bundlePromise
147148
},
148149
{
149150
onlyMapped,
151+
noBorderChecks: borderChecks === false,
150152
output: {
151153
format,
152154
filename: bundleOutputExplorerFile,
@@ -181,7 +183,5 @@ bundlePromise
181183

182184
// Open output file
183185
return open(bundleOutputExplorerFile);
184-
}).catch(error => console.log(
185-
chalk.red('=== error ==='),
186-
error
187-
));
186+
})
187+
.catch((error) => console.log(chalk.red('=== error ==='), error));

0 commit comments

Comments
 (0)