Skip to content
Merged
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
7 changes: 1 addition & 6 deletions e2e/cases/cli/config-loader/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { execSync } from 'node:child_process';
import path from 'node:path';
import { globContentJSON, rspackOnlyTest } from '@e2e/helper';
import { expect, test } from '@playwright/test';
import { expect } from '@playwright/test';

rspackOnlyTest('should use Node.js native loader to load config', async () => {
// TODO: fix this test on Windows
if (process.platform === 'win32') {
test.skip();
}

execSync('npx rsbuild build --config-loader native', {
cwd: __dirname,
env: {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import { createRequire } from 'node:module';
import { dirname, isAbsolute, join } from 'node:path';
import { pathToFileURL } from 'node:url';
import type { ChokidarOptions } from '../compiled/chokidar/index.js';
import RspackChain from '../compiled/rspack-chain/index.js';
import {
Expand Down Expand Up @@ -472,7 +473,8 @@ export async function loadConfig({

if (loader === 'native' || /\.(?:js|mjs|cjs)$/.test(configFilePath)) {
try {
const exportModule = await import(`${configFilePath}?t=${Date.now()}`);
const configFileURL = pathToFileURL(configFilePath).href;
const exportModule = await import(`${configFileURL}?t=${Date.now()}`);
configExport = exportModule.default ? exportModule.default : exportModule;
} catch (err) {
if (loader === 'native') {
Expand Down