|
6 | 6 | *
|
7 | 7 | */
|
8 | 8 |
|
| 9 | +import {logger} from '@react-native-community/cli-tools'; |
| 10 | +import type {Config} from '@react-native-community/cli-types'; |
| 11 | +import chalk from 'chalk'; |
| 12 | +import fs from 'fs'; |
| 13 | +import type {ConfigT} from 'metro-config'; |
9 | 14 | import Server from 'metro/src/Server';
|
10 | 15 | import outputBundle from 'metro/src/shared/output/bundle';
|
11 | 16 | import type {BundleOptions} from 'metro/src/shared/types';
|
12 |
| -import type {ConfigT} from 'metro-config'; |
13 | 17 | import path from 'path';
|
14 |
| -import chalk from 'chalk'; |
| 18 | +import {default as loadMetroConfig} from '../../tools/loadMetroConfig'; |
15 | 19 | import {CommandLineArgs} from './bundleCommandLineArgs';
|
16 |
| -import type {Config} from '@react-native-community/cli-types'; |
17 | 20 | import saveAssets from './saveAssets';
|
18 |
| -import {default as loadMetroConfig} from '../../tools/loadMetroConfig'; |
19 |
| -import {logger} from '@react-native-community/cli-tools'; |
20 | 21 |
|
21 | 22 | interface RequestOptions {
|
22 | 23 | entryFile: string;
|
@@ -91,6 +92,10 @@ export async function buildBundleWithConfig(
|
91 | 92 | try {
|
92 | 93 | const bundle = await output.build(server, requestOpts);
|
93 | 94 |
|
| 95 | + // Ensure destination directory exists before saving the bundle |
| 96 | + const mkdirOptions = {recursive: true, mode: 0o755} as const; |
| 97 | + fs.mkdirSync(path.dirname(args.bundleOutput), mkdirOptions); |
| 98 | + |
94 | 99 | await output.save(bundle, args, logger.info);
|
95 | 100 |
|
96 | 101 | // Save the assets of the bundle
|
|
0 commit comments