diff --git a/Taskfile b/Taskfile index a497dfe1..420cffb7 100644 --- a/Taskfile +++ b/Taskfile @@ -9,7 +9,7 @@ build() { # https://esbuild.github.io/api/#target cp -fv src/bin.js dist cp -fv README.md LICENSE dist - npx pkgroll --target=es2020 + npx pkgroll --target=es2020 --export-condition=node cat package.json | jq '.main = "./index.cjs"' | jq '.types = "./index.d.ts"' | jq '.exports.".".require = "./index.cjs"' | diff --git a/src/generate.ts b/src/generate.ts index 3d3fde74..9d88d3e6 100644 --- a/src/generate.ts +++ b/src/generate.ts @@ -1,6 +1,5 @@ import { GeneratorOptions } from '@prisma/generator-helper'; import { ok } from 'assert'; -import AwaitEventEmitter from 'await-event-emitter'; import { mapKeys } from 'lodash'; import { Project, QuoteKind } from 'ts-morph'; @@ -30,12 +29,13 @@ import { ObjectSettings, OutputType, } from './types'; +const AwaitEventEmitter = require('await-event-emitter').default; export async function generate( args: GeneratorOptions & { skipAddOutputSourceFiles?: boolean; connectCallback?: ( - emitter: AwaitEventEmitter, + emitter: typeof import('await-event-emitter'), eventArguments: EventArguments, ) => void | Promise; }, @@ -53,7 +53,10 @@ export async function generate( if (config.emitBlocks.prismaEnums || config.emitBlocks.schemaEnums) { eventEmitter.on('EnumType', registerEnum); } - if (config.emitBlocks.outputs || config.emitBlocks.models && !config.omitModelsCount) { + if ( + config.emitBlocks.outputs || + (config.emitBlocks.models && !config.omitModelsCount) + ) { eventEmitter.on('OutputType', outputType); } config.emitBlocks.models && eventEmitter.on('ModelOutputType', modelOutputType);