Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 4 additions & 39 deletions flow-typed/npm/@react-native-community/cli-tools_v12.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,15 @@ declare module '@react-native-community/cli-tools' {
constructor(msg: string, originalError?: Error | mixed | string): this;
}

declare export function getPidFromPort(port: number): number | null;

declare export function handlePortUnavailable(
initialPort: number,
projectRoot: string,
initialPackager?: boolean,
): Promise<{
port: number,
packager: boolean,
}>;

declare export function hookStdout(callback: Function): () => void;

declare export function isPackagerRunning(
packagerPort: string | number | void,
): Promise<
| {
status: 'running',
root: string,
}
| 'not_running'
| 'unrecognized',
>;

declare export const logger: $ReadOnly<{
success: (...message: Array<string>) => void,
info: (...message: Array<string>) => void,
warn: (...message: Array<string>) => void,
error: (...message: Array<string>) => void,
debug: (...message: Array<string>) => void,
error: (...message: Array<string>) => void,
log: (...message: Array<string>) => void,
setVerbose: (level: boolean) => void,
isVerbose: () => boolean,
disable: () => void,
enable: () => void,
info: (...message: Array<string>) => void,
warn: (...message: Array<string>) => void,
...
}>;

declare export function logAlreadyRunningBundler(port: number): void;

declare export function resolveNodeModuleDir(
root: string,
packageName: string,
): string;

declare export const version: $ReadOnly<{
logIfUpdateAvailable: (projectRoot: string) => Promise<void>,
}>;
Expand Down
6 changes: 3 additions & 3 deletions packages/community-cli-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Start the React Native development server.
#### Usage

```sh
react-native start [options]
npx react-native start [options]
```

#### Options
Expand Down Expand Up @@ -45,7 +45,7 @@ Build the bundle for the provided JavaScript entry file.
#### Usage

```sh
react-native bundle --entry-file <path> [options]
npx react-native bundle --entry-file <path> [options]
```

#### Options
Expand Down Expand Up @@ -75,7 +75,7 @@ Build the [RAM bundle](https://reactnative.dev/docs/ram-bundles-inline-requires)
#### Usage

```sh
react-native ram-bundle --entry-file <path> [options]
npx react-native ram-bundle --entry-file <path> [options]
```

#### Options
Expand Down
6 changes: 3 additions & 3 deletions packages/community-cli-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native/community-cli-plugin",
"version": "0.73.0",
"version": "0.73.1",
"description": "Core CLI commands for React Native",
"keywords": [
"react-native",
Expand All @@ -23,8 +23,8 @@
],
"dependencies": {
"@react-native/dev-middleware": "^0.73.0",
"@react-native-community/cli-server-api": "12.0.0-alpha.9",
"@react-native-community/cli-tools": "12.0.0-alpha.9",
"@react-native-community/cli-server-api": "12.0.0-alpha.11",
"@react-native-community/cli-tools": "12.0.0-alpha.11",
"@react-native/metro-babel-transformer": "^0.73.11",
"chalk": "^4.0.0",
"execa": "^5.1.1",
Expand Down
45 changes: 35 additions & 10 deletions packages/community-cli-plugin/src/commands/bundle/buildBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,57 @@
import type {Config} from '@react-native-community/cli-types';
import type {RequestOptions} from 'metro/src/shared/types.flow';
import type {ConfigT} from 'metro-config';
import type {CommandLineArgs} from './bundleCommandLineArgs';

import Server from 'metro/src/Server';
const outputBundle = require('metro/src/shared/output/bundle');
import metroBundle from 'metro/src/shared/output/bundle';
import metroRamBundle from 'metro/src/shared/output/RamBundle';
import path from 'path';
import chalk from 'chalk';
import saveAssets from './saveAssets';
import {default as loadMetroConfig} from '../../utils/loadMetroConfig';
import loadMetroConfig from '../../utils/loadMetroConfig';
import {logger} from '@react-native-community/cli-tools';

export type BundleCommandArgs = {
assetsDest?: string,
assetCatalogDest?: string,
entryFile: string,
resetCache: boolean,
resetGlobalCache: boolean,
transformer?: string,
minify?: boolean,
config?: string,
platform: string,
dev: boolean,
bundleOutput: string,
bundleEncoding?: 'utf8' | 'utf16le' | 'ascii',
maxWorkers?: number,
sourcemapOutput?: string,
sourcemapSourcesRoot?: string,
sourcemapUseAbsolutePath: boolean,
verbose: boolean,
unstableTransformProfile: string,
indexedRamBundle?: boolean,
};

async function buildBundle(
args: CommandLineArgs,
_argv: Array<string>,
ctx: Config,
output: typeof outputBundle = outputBundle,
args: BundleCommandArgs,
bundleImpl: typeof metroBundle | typeof metroRamBundle = metroBundle,
): Promise<void> {
const config = await loadMetroConfig(ctx, {
maxWorkers: args.maxWorkers,
resetCache: args.resetCache,
config: args.config,
});

return buildBundleWithConfig(args, config, output);
return buildBundleWithConfig(args, config, bundleImpl);
}

async function buildBundleWithConfig(
args: CommandLineArgs,
args: BundleCommandArgs,
config: ConfigT,
output: typeof outputBundle = outputBundle,
bundleImpl: typeof metroBundle | typeof metroRamBundle = metroBundle,
): Promise<void> {
if (config.resolver.platforms.indexOf(args.platform) === -1) {
logger.error(
Expand Down Expand Up @@ -80,11 +103,13 @@ async function buildBundleWithConfig(
const server = new Server(config);

try {
const bundle = await output.build(server, requestOpts);
const bundle = await bundleImpl.build(server, requestOpts);

// $FlowIgnore[class-object-subtyping]
// $FlowIgnore[incompatible-call]
await output.save(bundle, args, logger.info);
// $FlowIgnore[prop-missing]
// $FlowIgnore[incompatible-exact]
await bundleImpl.save(bundle, args, logger.info);

// Save the assets of the bundle
const outputAssets = await server.getAssets({
Expand Down
38 changes: 0 additions & 38 deletions packages/community-cli-plugin/src/commands/bundle/bundle.js

This file was deleted.

This file was deleted.

Loading