Skip to content

Commit

Permalink
feat(loadConfig): allow to pass a meta data (#4013)
Browse files Browse the repository at this point in the history
Co-authored-by: neverland <[email protected]>
  • Loading branch information
hasnum-stack and chenjiahan authored Nov 20, 2024
1 parent 8594f32 commit 7937a2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export type ConfigParams = {
env: string;
command: string;
envMode?: string;
meta?: Record<string, unknown>;
};

export type RsbuildConfigAsyncFn = (
Expand Down Expand Up @@ -387,10 +388,12 @@ export async function loadConfig({
cwd = process.cwd(),
path,
envMode,
meta,
}: {
cwd?: string;
path?: string;
envMode?: string;
meta?: Record<string, unknown>;
} = {}): Promise<{ content: RsbuildConfig; filePath: string | null }> {
const configFilePath = resolveConfigPath(cwd, path);

Expand Down Expand Up @@ -439,13 +442,14 @@ export async function loadConfig({
if (typeof configExport === 'function') {
const command = process.argv[2];
const nodeEnv = getNodeEnv();
const params: ConfigParams = {
const configParams: ConfigParams = {
env: nodeEnv,
command,
envMode: envMode || nodeEnv,
meta,
};

const result = await configExport(params);
const result = await configExport(configParams);

if (result === undefined) {
throw new Error('The config function must return a config object.');
Expand Down

0 comments on commit 7937a2c

Please sign in to comment.