fix double esbuild-register register

This commit is contained in:
Norbert de Langen 2022-11-16 15:05:12 +01:00
parent cd646a6786
commit f0d350022c
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762

View File

@ -3,7 +3,10 @@ import { getInterpretedFileWithExt } from './interpret-files';
let registered = false;
export function interopRequireDefault(filePath: string) {
if (registered === false) {
// eslint-disable-next-line no-underscore-dangle, global-require
const hasEsbuildBeenRegistered = !!require('module')._extensions['.ts'];
if (registered === false && !hasEsbuildBeenRegistered) {
// eslint-disable-next-line global-require
const { register } = require('esbuild-register/dist/node');
registered = true;