For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/utils/get-dirname.md.

getDirname

Convert a file:/// URL to an absolute directory path. This utility is particularly useful in ESM Rspack/webpack configs where __dirname is not available.

Parameters

type GetDirname = (fileUrl: string) => string;

fileUrl

  • Type: string
  • Required: true

The file:/// URL of a module, typically obtained from import.meta.url.

Example

rspack.config.mjs
import * as Repack from "@callstack/repack";

export default (env) => {
  const { context = Repack.getDirname(import.meta.url) } = env;

  return {
    // ... config
  };
};

Need React or React Native expertise you can count on?