Skip to content

Commit b9e1fe6

Browse files
committed
feat: add support for Yarn monorepos
1 parent 6830dde commit b9e1fe6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/react-native-bundle-visualizer.js

100644100755
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ function getEntryPoint() {
3535
return entry;
3636
}
3737

38+
function getReactNativeBin() {
39+
const localBin = './node_modules/.bin/react-native';
40+
if (fs.existsSync(localBin)) return localBin;
41+
try {
42+
const reactNativeDir = path.dirname(
43+
require.resolve('react-native/package.json')
44+
);
45+
return path.join(reactNativeDir, './cli.js');
46+
} catch (e) {
47+
console.error(
48+
chalk.red.bold(
49+
`React-native binary could not be located. Please report this issue with environment info to:\n`
50+
),
51+
chalk.blue.bold(`-> ${require('../package.json').bugs}`)
52+
);
53+
}
54+
}
55+
3856
// Get (default) arguments
3957
const baseDir = path.join(os.tmpdir(), 'react-native-bundle-visualizer');
4058
const tmpDir = path.join(baseDir, getAppName());
@@ -92,7 +110,8 @@ if (expoTargetDeprecated) {
92110
);
93111
}
94112

95-
const bundlePromise = execa('./node_modules/.bin/react-native', commands);
113+
const reactNativeBin = getReactNativeBin();
114+
const bundlePromise = execa(reactNativeBin, commands);
96115
bundlePromise.stdout.pipe(process.stdout);
97116

98117
// Upon bundle completion, run `source-map-explorer`

0 commit comments

Comments
 (0)