Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bundling): rspack should allow ES config module imports #29095

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 require(path);
return await import(path);
}

const cleanupTranspiler = registerTsProject(tsConfig);
Expand Down
Loading