fix: do not use preserveSymlinks: true when bundling dts file

This commit is contained in:
EGOIST 2021-11-12 14:53:28 +08:00
parent e487ffef8c
commit 112fbf6158

29
tsup.config.ts Normal file
View File

@ -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')
}
})
},
},
],
})