Skip to content

Commit

Permalink
fix(bundling): add awaits
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Nov 27, 2024
1 parent e0f17c2 commit 4d571e8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/rspack/src/executors/rspack/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { join } from 'path';
import { ExecutorContext } from '@nx/devkit';
import { type Configuration } from '@rspack/core';
import {
Expand All @@ -14,7 +13,7 @@ export async function getRspackConfigs(
options: NormalizedRspackExecutorSchema & { devServer?: any },
context: ExecutorContext
): Promise<Configuration | Configuration[]> {
let userDefinedConfig = resolveUserDefinedRspackConfig(
let userDefinedConfig = await resolveUserDefinedRspackConfig(
options.rspackConfig,
options.tsConfig
);
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function createRspackTargets(
): Promise<RspackTargets> {
const namedInputs = getNamedInputs(projectRoot, context);

const rspackConfig = resolveUserDefinedRspackConfig(
const rspackConfig = await resolveUserDefinedRspackConfig(
join(context.workspaceRoot, configFilePath),
getRootTsConfigPath(),
true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { clearRequireCache } from '@nx/devkit/src/utils/config-utils';
import { registerTsProject } from '@nx/js/src/internal';

export function resolveUserDefinedRspackConfig(
export async function resolveUserDefinedRspackConfig(
path: string,
tsConfig: string,
/** Skip require cache and return latest content */
Expand All @@ -18,7 +18,7 @@ export function resolveUserDefinedRspackConfig(
// Don't transpile non-TS files. This prevents workspaces libs from being registered via tsconfig-paths.
// There's an issue here with Nx workspace where loading plugins from source (via tsconfig-paths) can lead to errors.
if (!/\.(ts|mts|cts)$/.test(path)) {
return import(path);
return await import(path);
}

const cleanupTranspiler = registerTsProject(tsConfig);
Expand Down

0 comments on commit 4d571e8

Please sign in to comment.