Skip to content

Commit

Permalink
feat: add --custom-resolver-options to bundle command (facebook#4…
Browse files Browse the repository at this point in the history
…2333)

Summary:
Added `--custom-resolver-options` to `--bundle` command. This options is also [available](https://github.com/facebook/metro/blob/main/docs/CLI.md#options) in Metro's CLI.

## Changelog:

[INTERNAL] [ADDED] - Add `--resolver-options` to `bundle` command

Pull Request resolved: facebook#42333

Test Plan:
1. Build all packages by running `yarn build` in the root
2. Go to `packages/rn-tester` and run `npx react-native bundle --custom-resolver-options key=value` and the options should be passed to the Config.

Reviewed By: blakef

Differential Revision: D52869452

Pulled By: huntie

fbshipit-source-id: 9a2c2d94b72cfb47477cf58b9c0472c5a8551c84
  • Loading branch information
szymonrybczak authored and facebook-github-bot committed Jan 18, 2024
1 parent 8ac08c8 commit 31a162f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type BundleCommandArgs = {
verbose: boolean,
unstableTransformProfile: string,
indexedRamBundle?: boolean,
customResolverOptions?: Record<string, string>,
};

async function buildBundle(
Expand Down Expand Up @@ -99,6 +100,7 @@ async function buildBundleWithConfig(
minify: args.minify !== undefined ? args.minify : !args.dev,
platform: args.platform,
unstable_transformProfile: args.unstableTransformProfile,
customResolverOptions: args.customResolverOptions,
};
const server = new Server(config);

Expand Down
12 changes: 12 additions & 0 deletions packages/community-cli-plugin/src/commands/bundle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ const bundleCommand: Command = {
description: 'Path to the CLI configuration file',
parse: (val: string): string => path.resolve(val),
},
{
name: '--custom-resolver-options <string>',
description: 'Custom resolver options, format: key=value,key2=value2.',
parse: (val: string): Record<string, string> => {
return Object.fromEntries(
val.split(',').map(option => {
const [key, value] = option.split('=');
return [key, value];
}),
);
},
},
],
};

Expand Down

0 comments on commit 31a162f

Please sign in to comment.