folke / esbuild-runner

⚡️ Super-fast on-the-fly transpilation of modern JS, TypeScript and JSX using esbuild
https://www.npmjs.com/package/esbuild-runner
Apache License 2.0
712 stars 24 forks source link

Correctly handle `require.main === module` #53

Open qpwo opened 2 years ago

qpwo commented 2 years ago

If I import a function from one script into another then require.main === module is true in both so they both fully run. This is different behavior from node and ts-node.

https://github.com/evanw/esbuild/issues/2121

https://github.com/qpwo/esbuild-issue-2121