Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/shy-impalas-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack": patch
---

Drop having `@react-native-community/cli` as peer dependency
6 changes: 0 additions & 6 deletions packages/repack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
},
"peerDependencies": {
"@module-federation/enhanced": ">=0.6.10",
"@react-native-community/cli": "*",
"@react-native-community/cli-tools": "*",
"@react-native-community/cli-types": "*",
"@rspack/core": ">=1",
"react-native": ">=0.74",
"webpack": ">=5.90"
Expand Down Expand Up @@ -107,9 +104,6 @@
"@babel/plugin-transform-modules-commonjs": "^7.23.2",
"@module-federation/enhanced": "0.8.9",
"@module-federation/sdk": "0.6.10",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-tools": "15.0.1",
"@react-native-community/cli-types": "15.0.1",
"@rspack/core": "catalog:",
"@swc/helpers": "catalog:",
"@types/dedent": "^0.7.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/repack/src/commands/common/cliError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { VERBOSE_ENV_KEY } from '../../env.js';

export class CLIError extends Error {
constructor(message: string) {
super(message);
this.name = 'CLIError';

// hide stack trace in non-verbose mode
if (!process.env[VERBOSE_ENV_KEY]) {
this.stack = undefined;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
DEFAULT_RSPACK_CONFIG_LOCATIONS,
DEFAULT_WEBPACK_CONFIG_LOCATIONS,
} from '../../consts.js';
import { CLIError } from '../error.js';
import { CLIError } from '../cliError.js';

function discoverConfigFilePath(root: string, candidates: string[]) {
for (const candidate of candidates) {
Expand Down
11 changes: 0 additions & 11 deletions packages/repack/src/commands/common/error.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/repack/src/commands/rspack/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
import memfs from 'memfs';
import type { Reporter } from '../../logging/types.js';
import type { HMRMessage } from '../../types.js';
import { CLIError } from '../common/error.js';
import { CLIError } from '../common/cliError.js';
import { adaptFilenameToPlatform, runAdbReverse } from '../common/index.js';
import { DEV_SERVER_ASSET_TYPES } from '../consts.js';
import type { CompilerAsset } from './types.js';
Expand Down
17 changes: 6 additions & 11 deletions packages/repack/src/commands/rspack/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import type { Config } from '@react-native-community/cli-types';
import { type Configuration, rspack } from '@rspack/core';
import type { Stats } from '@rspack/core';
import { CLIError } from '../common/cliError.js';
import { makeCompilerConfig } from '../common/config/makeCompilerConfig.js';
import { CLIError } from '../common/error.js';
import { normalizeStatsOptions, writeStats } from '../common/index.js';
import { setupEnvironment } from '../common/setupEnvironment.js';
import type { BundleArguments } from '../types.js';
import type { BundleArguments, CliConfig } from '../types.js';

/**
* Bundle command for React Native Community CLI.
* It runs Rspack, builds bundle and saves it alongside any other assets and Source Map
* to filesystem.
* Bundle command that builds and saves the bundle
* alongside any other assets to filesystem using Webpack.
*
* @param _ Original, non-parsed arguments that were provided when running this command.
* @param config React Native Community CLI configuration object.
* @param cliConfig Configuration object containing platform and project settings.
* @param args Parsed command line arguments.
*
* @internal
* @category CLI command
*/
export async function bundle(
_: string[],
cliConfig: Config,
cliConfig: CliConfig,
args: BundleArguments
) {
const [config] = await makeCompilerConfig<Configuration>({
Expand Down
16 changes: 6 additions & 10 deletions packages/repack/src/commands/rspack/start.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Config } from '@react-native-community/cli-types';
import type { Configuration } from '@rspack/core';
import packageJson from '../../../package.json';
import {
Expand All @@ -8,8 +7,8 @@ import {
composeReporters,
makeLogEntryFromFastifyLog,
} from '../../logging/index.js';
import { CLIError } from '../common/cliError.js';
import { makeCompilerConfig } from '../common/config/makeCompilerConfig.js';
import { CLIError } from '../common/error.js';
import {
getMimeType,
parseFileUrl,
Expand All @@ -18,24 +17,21 @@ import {
import { runAdbReverse } from '../common/index.js';
import logo from '../common/logo.js';
import { setupEnvironment } from '../common/setupEnvironment.js';
import type { StartArguments } from '../types.js';
import type { CliConfig, StartArguments } from '../types.js';
import { Compiler } from './Compiler.js';

/**
* Start command for React Native Community CLI.
* It runs `@callstack/repack-dev-server` to provide Development Server functionality to React Native apps
* Start command that runs a development server.
* It runs `@callstack/repack-dev-server` to provide Development Server functionality
* in development mode.
*
* @param _ Original, non-parsed arguments that were provided when running this command.
* @param config React Native Community CLI configuration object.
* @param cliConfig Configuration object containing platform and project settings.
* @param args Parsed command line arguments.
*
* @internal
* @category CLI command
*/
export async function start(
_: string[],
cliConfig: Config,
cliConfig: CliConfig,
args: StartArguments
) {
const detectedPlatforms = Object.keys(cliConfig.platforms);
Expand Down
17 changes: 8 additions & 9 deletions packages/repack/src/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,21 @@ export interface StartArguments {
webpackConfig?: string;
}

interface CommonCliOptions {
config: {
root: string;
platforms: string[];
bundlerConfigPath: string;
reactNativePath: string;
};
export interface CliConfig {
root: string;
platforms: string[];
reactNativePath: string;
}

export interface StartCliOptions extends CommonCliOptions {
export interface StartCliOptions {
command: 'start';
config: CliConfig;
arguments: { start: StartArguments };
}

export interface BundleCliOptions extends CommonCliOptions {
export interface BundleCliOptions {
command: 'bundle';
config: CliConfig;
arguments: { bundle: BundleArguments };
}

Expand Down
2 changes: 1 addition & 1 deletion packages/repack/src/commands/webpack/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { SendProgress } from '@callstack/repack-dev-server';
import type webpack from 'webpack';
import { WORKER_ENV_KEY } from '../../env.js';
import type { LogType, Reporter } from '../../logging/types.js';
import { CLIError } from '../common/error.js';
import { CLIError } from '../common/cliError.js';
import { DEV_SERVER_ASSET_TYPES } from '../consts.js';
import type { StartArguments } from '../types.js';
import type {
Expand Down
17 changes: 6 additions & 11 deletions packages/repack/src/commands/webpack/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import type { Config } from '@react-native-community/cli-types';
import webpack, { type Configuration } from 'webpack';
import { CLIError } from '../common/cliError.js';
import { makeCompilerConfig } from '../common/config/makeCompilerConfig.js';
import { CLIError } from '../common/error.js';
import { normalizeStatsOptions, writeStats } from '../common/index.js';
import { setupEnvironment } from '../common/setupEnvironment.js';
import type { BundleArguments } from '../types.js';
import type { BundleArguments, CliConfig } from '../types.js';
/**
* Bundle command for React Native Community CLI.
* It runs Webpack, builds bundle and saves it alongside any other assets and Source Map
* to filesystem.
* Bundle command that builds and saves the bundle
* alongside any other assets to filesystem using Webpack.
*
* @param _ Original, non-parsed arguments that were provided when running this command.
* @param config React Native Community CLI configuration object.
* @param cliConfig Configuration object containing platform and project settings.
* @param args Parsed command line arguments.
*
* @internal
* @category CLI command
*/
export async function bundle(
_: string[],
cliConfig: Config,
cliConfig: CliConfig,
args: BundleArguments
) {
const [config] = await makeCompilerConfig<Configuration>({
Expand Down
16 changes: 6 additions & 10 deletions packages/repack/src/commands/webpack/start.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-expect-error type-only import
import type { Server } from '@callstack/repack-dev-server';
import type { Config } from '@react-native-community/cli-types';
import type { Configuration, StatsCompilation } from 'webpack';
import packageJson from '../../../package.json';
import {
Expand All @@ -11,8 +10,8 @@ import {
makeLogEntryFromFastifyLog,
} from '../../logging/index.js';
import type { HMRMessage } from '../../types.js';
import { CLIError } from '../common/cliError.js';
import { makeCompilerConfig } from '../common/config/makeCompilerConfig.js';
import { CLIError } from '../common/error.js';
import {
getMimeType,
parseFileUrl,
Expand All @@ -21,24 +20,21 @@ import {
} from '../common/index.js';
import logo from '../common/logo.js';
import { setupEnvironment } from '../common/setupEnvironment.js';
import type { StartArguments } from '../types.js';
import type { CliConfig, StartArguments } from '../types.js';
import { Compiler } from './Compiler.js';

/**
* Start command for React Native Community CLI.
* It runs `@callstack/repack-dev-server` to provide Development Server functionality to React Native apps
* Start command that runs a development server.
* It runs `@callstack/repack-dev-server` to provide Development Server functionality
* in development mode.
*
* @param _ Original, non-parsed arguments that were provided when running this command.
* @param config React Native Community CLI configuration object.
* @param cliConfig Configuration object containing platform and project settings.
* @param args Parsed command line arguments.
*
* @internal
* @category CLI command
*/
export async function start(
_: string[],
cliConfig: Config,
cliConfig: CliConfig,
args: StartArguments
) {
const detectedPlatforms = Object.keys(cliConfig.platforms);
Expand Down
9 changes: 0 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.