From 112fbf6158c3bc60c694a5ed61bc70cd08088c4e Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Fri, 12 Nov 2021 14:53:28 +0800 Subject: [PATCH] fix: do not use `preserveSymlinks: true` when bundling dts file --- tsup.config.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tsup.config.ts diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 000000000..18091652f --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,29 @@ +import fs from 'fs' +import { defineConfig } from './src' + +export default defineConfig({ + 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') + } + }) + }, + }, + ], +})