egoist / esbuild-register

Transpile JSX, TypeScript and esnext features on the fly with esbuild
MIT License
990 stars 52 forks source link

Multiple declarations of __esbuild_register_import_meta_url__ #82

Open marionebl opened 1 year ago

marionebl commented 1 year ago

After bumping to 3.4.1 from 3.3.3 I'm encountering the following exception in cases where esbuild-register is registered more than once.

SyntaxError: Identifier '__esbuild_register_import_meta_url__' has already been declared​​

The workaround for this in cases where I can control the registration is

if (!('.ts' in require.extensions)) {
  require('esbuild-register/dist/node').register();
}

In some cases I can not control the registration though so the discussed workaround can't be applied. This is the case e.g. for jest configuration files authored in TypeScript.