Skip to content

Commit

Permalink
feat: add --config cli option to commands (#778)
Browse files Browse the repository at this point in the history
* feat: add --config cli option to both commands

* chore: use --config in testers

* refactor: add deprecation notice to webpackConfig option

* feat: use config and fallback to webpackConfig in commands

* chore: add changeset
  • Loading branch information
jbroma authored Nov 3, 2024
1 parent 31d0e32 commit 2344162
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-timers-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack": minor
---

Add `--config` option to commands, deprecate `--webpackConfig` option
4 changes: 2 additions & 2 deletions apps/tester-federation-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start:hostapp": "react-native webpack-start --webpackConfig rspack.config.host-app.mjs",
"start:miniapp": "react-native webpack-start --webpackConfig rspack.config.mini-app.mjs --port 8082"
"start:hostapp": "react-native webpack-start --config rspack.config.host-app.mjs",
"start:miniapp": "react-native webpack-start --config rspack.config.mini-app.mjs --port 8082"
},
"dependencies": {
"@callstack/repack": "workspace:*",
Expand Down
12 changes: 6 additions & 6 deletions apps/tester-federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start:hostapp": "react-native webpack-start --webpackConfig rspack.config.host-app.mjs",
"start:miniapp": "react-native webpack-start --webpackConfig rspack.config.mini-app.mjs --port 8082",
"start:hostapp": "react-native webpack-start --config rspack.config.host-app.mjs",
"start:miniapp": "react-native webpack-start --config rspack.config.mini-app.mjs --port 8082",
"bundle": "pnpm run \"/^bundle:(hostapp|miniapp)$/\"",
"bundle:hostapp": "pnpm run \"/^bundle:hostapp:(ios|android)$/\"",
"bundle:miniapp": "pnpm run \"/^bundle:miniapp:(ios|android)$/\"",
"bundle:hostapp:android": "react-native webpack-bundle --webpackConfig rspack.config.host-app.mjs --platform android --entry-file index.js --dev=false --bundle-output build/host-app/android/output-local/index.android.bundle --assets-dest build/host-app/android/output-local/res",
"bundle:hostapp:ios": "react-native webpack-bundle --webpackConfig rspack.config.host-app.mjs --platform ios --entry-file index.js --dev=false --bundle-output build/host-app/ios/output-local/main.jsbundle --assets-dest build/host-app/ios/output-local",
"bundle:miniapp:android": "react-native webpack-bundle --webpackConfig rspack.config.mini-app.mjs --platform android --entry-file index.js --dev=false --bundle-output build/mini-app/android/output-local/index.android.bundle --assets-dest build/mini-app/android/output-local/res",
"bundle:miniapp:ios": "react-native webpack-bundle --webpackConfig rspack.config.mini-app.mjs --platform ios --entry-file index.js --dev=false --bundle-output build/mini-app/ios/output-local/main.jsbundle --assets-dest build/mini-app/ios/output-local"
"bundle:hostapp:android": "react-native webpack-bundle --config rspack.config.host-app.mjs --platform android --entry-file index.js --dev=false --bundle-output build/host-app/android/output-local/index.android.bundle --assets-dest build/host-app/android/output-local/res",
"bundle:hostapp:ios": "react-native webpack-bundle --config rspack.config.host-app.mjs --platform ios --entry-file index.js --dev=false --bundle-output build/host-app/ios/output-local/main.jsbundle --assets-dest build/host-app/ios/output-local",
"bundle:miniapp:android": "react-native webpack-bundle --config rspack.config.mini-app.mjs --platform android --entry-file index.js --dev=false --bundle-output build/mini-app/android/output-local/index.android.bundle --assets-dest build/mini-app/android/output-local/res",
"bundle:miniapp:ios": "react-native webpack-bundle --config rspack.config.mini-app.mjs --platform ios --entry-file index.js --dev=false --bundle-output build/mini-app/ios/output-local/main.jsbundle --assets-dest build/mini-app/ios/output-local"
},
"dependencies": {
"@callstack/repack": "workspace:*",
Expand Down
15 changes: 13 additions & 2 deletions packages/repack/src/commands/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ export const startCommandOptions = [
name: '--verbose',
description: 'Enables verbose logging',
},
{
name: '--config <path>',
description: 'Path to a bundler config file, e.g webpack.config.js',
parse: (val: string) => path.resolve(val),
},
{
name: '--webpackConfig <path>',
description: 'Path to a Webpack config',
description: 'Path to a bundler config file, e.g webpack.config.js',
parse: (val: string) => path.resolve(val),
},
];
Expand Down Expand Up @@ -146,9 +151,15 @@ export const bundleCommandOptions = [
name: '--watch',
description: 'Watch for file changes',
},
{
name: '--config <path>',
description: 'Path to a bundler config file, e.g webpack.config.js',
parse: (val: string) => path.resolve(val),
},
{
name: '--webpackConfig <path>',
description: 'Path to a Webpack config',
description:
'[DEPRECATED] Path to a bundler config file, e.g webpack.config.js. Please use --config instead.',
parse: (val: string) => path.resolve(val),
},
];
2 changes: 1 addition & 1 deletion packages/repack/src/commands/rspack/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function bundle(
) {
const rspackConfigPath = getRspackConfigFilePath(
cliConfig.root,
args.webpackConfig
args.config ?? args.webpackConfig
);

const cliOptions: BundleCliOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/repack/src/commands/rspack/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function start(
) {
const rspackConfigPath = getRspackConfigFilePath(
cliConfig.root,
args.webpackConfig
args.config ?? args.webpackConfig
);
const { reversePort: reversePortArg, ...restArgs } = args;
const cliOptions: StartCliOptions = {
Expand Down
2 changes: 2 additions & 0 deletions packages/repack/src/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface BundleArguments {
stats?: string;
verbose?: boolean;
watch?: boolean;
config?: string;
webpackConfig?: string;
}

Expand All @@ -28,6 +29,7 @@ export interface StartArguments {
reversePort?: boolean;
silent?: boolean;
verbose?: boolean;
config?: string;
webpackConfig?: string;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/repack/src/commands/webpack/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function bundle(
) {
const webpackConfigPath = getWebpackConfigFilePath(
cliConfig.root,
args.webpackConfig
args.config ?? args.webpackConfig
);

const cliOptions: BundleCliOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/repack/src/commands/webpack/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import type { HMRMessageBody } from './types';
export async function start(_: string[], config: Config, args: StartArguments) {
const webpackConfigPath = getWebpackConfigFilePath(
config.root,
args.webpackConfig
args.config ?? args.webpackConfig
);
const { reversePort: reversePortArg, ...restArgs } = args;
const cliOptions: StartCliOptions = {
Expand Down

0 comments on commit 2344162

Please sign in to comment.