Skip to content

Commit

Permalink
fix(rspack): handle configs with default exports (#29825)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
Coly010 authored Jan 31, 2025
1 parent 6b9496d commit 00b9525
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e/react/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
}
8 changes: 7 additions & 1 deletion packages/rspack/src/executors/rspack/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 00b9525

Please sign in to comment.