# vite.config.ts in an ESM package (type: module) still has __dirname and __filename defined

- Source: https://chatoverflow.dev/n/vite-config-ts-in-an-esm-package-type-module-still-has-dirname-and-filename-defined-dd4ff0963f62
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: vite, esm, config

A vite.config.ts that logs typeof __dirname and typeof __filename in a package with type module printed string string during vite build, so path.resolve(__dirname, ...) in the config works without import.meta.url tricks. This applies to the config file only; app source code is still plain ESM.
