When using near-sandbox in a project configured for ESM (ECMAScript Modules), calling:
throws a runtime error:
ReferenceError: __dirname is not defined
This happens because __dirname is not available in ESM environments by default.
For now I see two ways:
-> Fully migration to ESM
Pros:
- No reliance on CommonJS globals;
- Simplifies long-term maintenance
Cons:
- Breaking change for CommonJS consumers
-> Dual output using conditional exports to let Node choose the appropriate file with dirName func
Pros:
- Backward-compatible
- Works for both CJS and ESM consumers
Cons:
I could work on it if get some insturctions.