-
-
Notifications
You must be signed in to change notification settings - Fork 257
Description
Version
System:
OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (2) x64 AMD EPYC
Memory: 1.77 GB / 4.01 GB
Container: Yes
Shell: Unknown
npmPackages:
@rsbuild/core: ^0.7.9 => 0.7.9
@rsbuild/plugin-react: ^0.7.9 => 0.7.9Details
I want to use import.meta.dirname API in rsbuild config file which is supportted in esm module since node v20.11.0
import { defineConfig } from "@rsbuild/core";
import { pluginReact } from "@rsbuild/plugin-react";
console.log(import.meta.dirname);
export default defineConfig({
plugins: [pluginReact()],
});
but it will throw a SyntaxError:

From the error stack, I learned that rsbuild loads the config file with jiti. After some attempts, I discovered that rsbuild precompiles an old version of jiti code which doesn't support import.meta.dirname in its distribution. This means I can't use methods like pnpm.overrides to change the installed jiti version, and only downgrade to fileURLToPath(import.meta.url)'s function call.
Is there any problem upgrading the jiti version? The import.meta.dirname API has supportted in v2.1.0 .It would be great if I could see this feature supported in the next version.
If not, could you explain why and if there's another way to use import.meta.dirname or plans to upgrade jiti?
Reproduce link
https://codesandbox.io/p/devbox/ts-config-esm-37nx8q
Reproduce Steps
run dev task