mirror of
https://github.com/egoist/tsup.git
synced 2025-12-08 20:35:58 +00:00
fix: do not use preserveSymlinks: true when bundling dts file
This commit is contained in:
parent
e487ffef8c
commit
112fbf6158
29
tsup.config.ts
Normal file
29
tsup.config.ts
Normal 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')
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user