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'],