digital-loukoum / esrun

Simple wrapper around esbuild to execute a Typescript file
MIT License
173 stars 11 forks source link

Can't access `__dirname` and `__filename` #13

Closed MatteoGauthier closed 2 years ago

MatteoGauthier commented 2 years ago
/[eval1]:2
console.log(__dirname);
            ^

ReferenceError: __dirname is not defined in ES module scope
    at file:///Users/matteogauthier/x/remotely/[eval1]:2:13
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async ESMLoader.eval (node:internal/modules/esm/loader:214:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)
iRoachie commented 2 years ago

Not supported in esm. https://nodejs.org/api/esm.html#no-__filename-or-__dirname

jlarmstrongiv commented 2 years ago

Would be nice to add a shim like tsup

Gin-Quin commented 2 years ago

Should work since version 3.2.4