fix(rspack): handle configs with default exports (#29825)

## Current Behavior
When we resolve the config file for rspack, it can be provided in a few
different formats:

```
config

config.default

config.default.default
```

We do not handle if the config is provided in any of the named default
methods.

## Expected Behavior

Handle named defaults for the resolved user config for Rspack.
This commit is contained in:
Colum Ferry 2025-01-31 14:47:12 +00:00 committed by GitHub
parent 6b9496d8ef
commit 00b9525bef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -3,7 +3,7 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/react",
"projectType": "application",
"implicitDependencies": ["react"],
"implicitDependencies": ["react", "rspack"],
"// targets": "to see all targets run: nx show project e2e-react --web",
"targets": {}
}

View File

@ -13,10 +13,16 @@ export async function getRspackConfigs(
options: NormalizedRspackExecutorSchema & { devServer?: any },
context: ExecutorContext
): Promise<Configuration | Configuration[]> {
let userDefinedConfig = await resolveUserDefinedRspackConfig(
let maybeUserDefinedConfig = await resolveUserDefinedRspackConfig(
options.rspackConfig,
options.tsConfig
);
let userDefinedConfig =
'default' in maybeUserDefinedConfig
? 'default' in maybeUserDefinedConfig.default
? maybeUserDefinedConfig.default.default
: maybeUserDefinedConfig.default
: maybeUserDefinedConfig;
if (typeof userDefinedConfig.then === 'function') {
userDefinedConfig = await userDefinedConfig;