Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(dts): apply required defaults to rollup-plugin-dts, closes emitte…
…d dts is bundled source #509
  • Loading branch information
egoist committed Dec 25, 2021
1 parent 8388387 commit 6c44f3d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -76,7 +76,7 @@
"wait-for-expect": "^3.0.2"
},
"peerDependencies": {
"typescript": "^4.5.4"
"typescript": "^4.1.0"
},
"peerDependenciesMeta": {
"typescript": {
Expand Down
14 changes: 14 additions & 0 deletions src/rollup.ts
Expand Up @@ -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),
Expand Down
24 changes: 0 additions & 24 deletions tsup.config.ts
Expand Up @@ -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')
}
})
},
},
],
})

0 comments on commit 6c44f3d

Please sign in to comment.