Description
When using h3-js in an ESM bundler environment (e.g., Nitro/Rollup for Vercel serverless), the build fails with:
ReferenceError: __dirname is not defined in ES module scope
Cause
The compiled out/libh3.js (Emscripten output) references __dirname for Node.js environment detection and file path resolution. This works in CommonJS but fails in ES modules where __dirname doesn't exist.
Environment
- Bundler: Rollup (via Nitro)
- Target: Vercel serverless (ESM)
- h3-js version: 4.4.0
Description
When using
h3-jsin an ESM bundler environment (e.g., Nitro/Rollup for Vercel serverless), the build fails with:Cause
The compiled out/libh3.js (Emscripten output) references __dirname for Node.js environment detection and file path resolution. This works in CommonJS but fails in ES modules where __dirname doesn't exist.
Environment