Skip to content

Commit 9c984d1

Browse files
committed
feat: add —expo [bare|managed] option
1 parent 3da7e77 commit 9c984d1

File tree

5 files changed

+3384
-33
lines changed

5 files changed

+3384
-33
lines changed

Diff for: README.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Make sure [npx](https://github.com/npm/npx) is installed and run the following c
1616

1717
`npx react-native-bundle-visualizer`
1818

19+
And when using Expo:
20+
21+
`npx react-native-bundle-visualizer --expo managed`
22+
1923
### Or install as a dev-dependency
2024

2125
`yarn add --dev react-native-bundle-visualizer`
@@ -33,14 +37,15 @@ _or when using npm:_
3337

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

36-
| Option | Description | Example |
37-
| --------------- | ------------------------------------------------------------- | --------------------------------- |
38-
| `platform` | Platform to build (default is **ios**) | `--platform android` |
39-
| `dev` | Dev or production build (default is **false**) | `--dev false` |
40-
| `entry-file` | Entry-file (when omitted tries to auto-resolve it) | `--entry-file ./index.android.js` |
41-
| `bundle-output` | Output bundle-file (default is **tmp**) | `--bundle-output ./myapp.bundle` |
42-
| `verbose` | Dumps additional output to the console (default is **false**) | `--verbose` |
43-
| `reset-cache` | Removes cached react-native files (default is **false**) | `--reset-cache` |
40+
| Option | Description | Example |
41+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
42+
| `platform` | Platform to build (default is **ios**) | `--platform android` |
43+
| `expo` | Expo target, **managed** or **bare**. This ensures that the project is bundled with expo settings and that `.expo` file extensions are handled appropriately. | `--expo bare` |
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.android.js` |
46+
| `bundle-output` | Output bundle-file (default is **tmp**) | `--bundle-output ./myapp.bundle` |
47+
| `verbose` | Dumps additional output to the console (default is **false**) | `--verbose` |
48+
| `reset-cache` | Removes cached react-native files (default is **false**) | `--reset-cache` |
4449

4550
## Usage with older react-native versions and the Haul bundler
4651

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"src"
2222
],
2323
"dependencies": {
24+
"@expo/metro-config": "^0.1.15",
2425
"chalk": "^4.1.0",
2526
"execa": "^4.0.2",
2627
"minimist": "^1.2.5",
@@ -31,6 +32,6 @@
3132
"scripts": {
3233
"test": "yarn test:rn61 && yarn test:expo35",
3334
"test:rn61": "cd test/RN61 && yarn install && npx ../.. && cd ../..",
34-
"test:expo35": "cd test/Expo35 && yarn install && npx ../.. && cd ../.."
35+
"test:expo35": "cd test/Expo35 && yarn install && npx ../.. --expo managed && cd ../.."
3536
}
3637
}

Diff for: src/expo-metro.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { getDefaultConfig } = require('@expo/metro-config');
2+
const config = getDefaultConfig('./');
3+
module.exports = config;

Diff for: src/react-native-bundle-visualizer.js

+7
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const baseDir = os.tmpdir() + '/react-native-bundle-visualizer';
4040
const tmpDir = baseDir + '/' + getAppName();
4141
const entryFile = argv['entry-file'] || getEntryPoint();
4242
const platform = argv.platform || 'ios';
43+
const expoTarget = argv.expo || '';
4344
const dev = argv.dev || false;
4445
const verbose = argv.verbose || false;
4546
const resetCache = argv['reset-cache'] || false;
@@ -78,6 +79,12 @@ if (resetCache) {
7879
commands.push('--reset-cache');
7980
commands.push(resetCache);
8081
}
82+
if (expoTarget) {
83+
process.env.EXPO_TARGET = expoTarget;
84+
commands.push('--config');
85+
commands.push(__dirname + '/expo-metro.config.js');
86+
}
87+
8188
const bundlePromise = execa('./node_modules/.bin/react-native', commands);
8289
bundlePromise.stdout.pipe(process.stdout);
8390

0 commit comments

Comments
 (0)