You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
chenjiahan
changed the title
[Bug]: Can not use import.meta.dirname in rsbuild.config.ts
[Feature]: Support for using import.meta.dirname in rsbuild.config.ts
Nov 12, 2024
Version
Details
I want to use
import.meta.dirname
API in rsbuild config file which is supportted in esm module since node v20.11.0but 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 likepnpm.overrides
to change the installed jiti version, and only downgrade tofileURLToPath(import.meta.url)
's function call.Is there any problem upgrading the
jiti
version? Theimport.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 upgradejiti
?Reproduce link
https://codesandbox.io/p/devbox/ts-config-esm-37nx8q
Reproduce Steps
run
dev
taskThe text was updated successfully, but these errors were encountered: