From f29ff3a8b6d3070738d2666efe4ec204459d0287 Mon Sep 17 00:00:00 2001 From: Aelita Date: Sat, 23 Mar 2024 19:14:22 +1100 Subject: [PATCH] fix: dynamic require of "tty" is not supported --- cjs-shim.ts | 8 ++++++++ tsup.config.ts | 1 + 2 files changed, 9 insertions(+) create mode 100644 cjs-shim.ts diff --git a/cjs-shim.ts b/cjs-shim.ts new file mode 100644 index 0000000..57a0f58 --- /dev/null +++ b/cjs-shim.ts @@ -0,0 +1,8 @@ +import { createRequire } from 'node:module' +import { dirname } from 'node:path' +import { fileURLToPath } from 'node:url' + + +globalThis.require = createRequire(import.meta.url) +globalThis.__filename = fileURLToPath(import.meta.url) +globalThis.__dirname = dirname(__filename) diff --git a/tsup.config.ts b/tsup.config.ts index 171c4c5..58d39cf 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -5,6 +5,7 @@ export default defineConfig({ entry: [ 'src/index.ts', ], + inject: ['cjs-shim.ts'], external: ['@next/eslint-plugin-next'], shims: true, format: ['cjs', 'esm'],