From 710400a276c53960dd949243d26f555bf91a421f Mon Sep 17 00:00:00 2001 From: qmhc <544022268@qq.com> Date: Tue, 6 Aug 2024 23:06:36 +0800 Subject: [PATCH] fix: resolve module preserve to esnext for rollup fix #358 --- src/rollup.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rollup.ts b/src/rollup.ts index 82aa766..1d46a3c 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -3,14 +3,13 @@ import { resolve } from 'node:path' import { Extractor, ExtractorConfig } from '@microsoft/api-extractor' import { tryGetPkgPath } from './utils' -import type ts from 'typescript' import type { ExtractorLogLevel, IExtractorInvokeOptions } from '@microsoft/api-extractor' import type { RollupConfig } from './types' export interface BundleOptions { root: string, configPath?: string, - compilerOptions: ts.CompilerOptions, + compilerOptions: Record, outDir: string, entryPath: string, fileName: string, @@ -38,6 +37,11 @@ export function rollupDeclarationFiles({ fileName += '.d.ts' } + // Refer to https://github.com/microsoft/rushstack/issues/4863 + if (/preserve/i.test(compilerOptions.module)) { + compilerOptions = { ...compilerOptions, module: 'ESNext' } + } + const extractorConfig = ExtractorConfig.prepare({ configObject: { ...rollupConfig,