diff --git a/package.json b/package.json index 18ad2091..3ab32497 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "wait-for-expect": "^3.0.2" }, "peerDependencies": { - "typescript": "^4.5.4" + "typescript": "^4.1.0" }, "peerDependenciesMeta": { "typescript": { diff --git a/src/rollup.ts b/src/rollup.ts index d01a3e05..b309c8d7 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -155,6 +155,20 @@ const getRollupConfig = async ( compilerOptions: { ...compilerOptions, baseUrl: path.resolve(compilerOptions.baseUrl || '.'), + // Ensure ".d.ts" modules are generated + declaration: true, + // Skip ".js" generation + noEmit: false, + emitDeclarationOnly: true, + // Skip code generation when error occurs + noEmitOnError: true, + // Avoid extra work + checkJs: false, + declarationMap: false, + skipLibCheck: true, + preserveSymlinks: false, + // Ensure we can parse the latest code + target: ts.ScriptTarget.ESNext, }, }), ].filter(Boolean), diff --git a/tsup.config.ts b/tsup.config.ts index f13b48d5..18f862e1 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -9,28 +9,4 @@ export default defineConfig({ // otherwise `Options` will not be exported by `tsup`, not sure how this happens, probbably a bug in rollup-plugin-dts entry: './src/index.ts', }, - esbuildPlugins: [ - { - name: 'patch-rollup-plugin-dts', - setup(build) { - let removed = false - build.onLoad({ filter: /rollup-plugin-dts/ }, async (args) => { - const code = await fs.promises.readFile(args.path, 'utf-8') - const RE = /preserveSymlinks:\s+true,/ - if (RE.test(code)) { - removed = true - } - return { - contents: code.replace(RE, ''), - loader: 'js', - } - }) - build.onEnd(() => { - if (!removed) { - throw new Error('rollup-plugin-dts was not patched') - } - }) - }, - }, - ], })