diff --git a/packages/ckeditor5-dev-build-tools/src/config.ts b/packages/ckeditor5-dev-build-tools/src/config.ts index cd20ccec8..d7c169ac5 100644 --- a/packages/ckeditor5-dev-build-tools/src/config.ts +++ b/packages/ckeditor5-dev-build-tools/src/config.ts @@ -202,10 +202,7 @@ export async function getRollupConfig( options: BuildOptions ) { /** * Does type checking and generates `.d.ts` files. */ - getOptionalPlugin( - declarations, - getTypeScriptPlugin( { tsconfig, output, sourceMap, declarations } ) - ), + getTypeScriptPlugin( { tsconfig, output, sourceMap, declarations } ), /** * Replaces parts of the source code with the provided values. @@ -309,7 +306,11 @@ function getTypeScriptPlugin( { declaration: declarations, declarationDir: declarations ? path.parse( output ).dir : undefined, compilerOptions: { - emitDeclarationOnly: true + // When `declarations` is set to `true`, we only want to emit declaration files. + emitDeclarationOnly: !!declarations, + + // Otherwise, we don't want to emit anything. + noEmit: !declarations } } ); } diff --git a/packages/ckeditor5-dev-build-tools/tests/config/config.test.ts b/packages/ckeditor5-dev-build-tools/tests/config/config.test.ts index 9f54d89d8..c560c5d76 100644 --- a/packages/ckeditor5-dev-build-tools/tests/config/config.test.ts +++ b/packages/ckeditor5-dev-build-tools/tests/config/config.test.ts @@ -53,7 +53,7 @@ test( '--tsconfig', async () => { expect( fileExists.plugins.some( plugin => plugin?.name === 'typescript' ) ).toBe( true ); expect( fileDoesntExist.plugins.some( plugin => plugin?.name === 'typescript' ) ).toBe( false ); - expect( declarationsFalse.plugins.some( plugin => plugin?.name === 'typescript' ) ).toBe( false ); + expect( declarationsFalse.plugins.some( plugin => plugin?.name === 'typescript' ) ).toBe( true ); } ); test( '--external', async () => {