Skip to content

Commit 2af8cbb

Browse files
committed
fix: upgrade rolldown, fix dts comment & banner
1 parent f0ef731 commit 2af8cbb

File tree

9 files changed

+212
-200
lines changed

9 files changed

+212
-200
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tsdown",
33
"version": "0.15.0",
4-
"packageManager": "pnpm@10.15.1",
4+
"packageManager": "pnpm@10.16.0",
55
"description": "The Elegant Bundler for Libraries",
66
"type": "module",
77
"license": "MIT",

pnpm-lock.yaml

Lines changed: 180 additions & 179 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ catalogs:
3737
vite: npm:rolldown-vite@latest
3838
vitepress: ^2.0.0-alpha.12
3939
vitepress-plugin-group-icons: ^1.6.3
40-
vitepress-plugin-llms: ^1.7.4
40+
vitepress-plugin-llms: ^1.7.5
4141
vue: ^3.5.21
42-
vue-tsc: ^3.0.6
42+
vue-tsc: ^3.0.7
4343

4444
prod:
4545
ansis: ^4.1.0
@@ -50,7 +50,7 @@ catalogs:
5050
empathic: ^2.0.0
5151
hookable: ^5.5.3
5252
rolldown: latest
53-
rolldown-plugin-dts: ^0.16.2
53+
rolldown-plugin-dts: ^0.16.5
5454
semver: ^7.7.2
5555
tinyexec: ^1.0.1
5656
tinyglobby: ^0.2.15

src/features/output.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,29 @@ export interface ChunkAddonObject {
9090
}
9191
export type ChunkAddonFunction = (ctx: {
9292
format: Format
93-
}) => ChunkAddonObject | undefined
94-
export type ChunkAddon = ChunkAddonObject | ChunkAddonFunction
93+
fileName: string
94+
}) => ChunkAddonObject | string | undefined
95+
export type ChunkAddon = ChunkAddonObject | ChunkAddonFunction | string
9596

9697
export function resolveChunkAddon(
9798
chunkAddon: ChunkAddon | undefined,
9899
format: NormalizedFormat,
100+
dts?: boolean,
99101
): AddonFunction | undefined {
100102
if (!chunkAddon) return
101103

102104
return (chunk: RenderedChunk) => {
105+
if (!dts && RE_DTS.test(chunk.fileName)) return ''
106+
103107
if (typeof chunkAddon === 'function') {
104-
chunkAddon = chunkAddon({ format })
108+
chunkAddon = chunkAddon({
109+
format,
110+
fileName: chunk.fileName,
111+
})
112+
}
113+
114+
if (typeof chunkAddon === 'string') {
115+
return chunkAddon
105116
}
106117

107118
switch (true) {

src/features/rolldown.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export async function resolveInputOptions(
8585
name,
8686
logger,
8787
cjsDefault,
88+
banner,
89+
footer,
8890
} = config
8991

9092
const plugins: RolldownPluginOption = []
@@ -99,7 +101,12 @@ export async function resolveInputOptions(
99101

100102
if (dts) {
101103
const { dts: dtsPlugin } = await import('rolldown-plugin-dts')
102-
const options: DtsOptions = { tsconfig, ...dts }
104+
const options: DtsOptions = {
105+
tsconfig,
106+
banner: resolveChunkAddon(banner, format, true),
107+
footer: resolveChunkAddon(footer, format, true),
108+
...dts,
109+
}
103110

104111
if (format === 'es') {
105112
plugins.push(dtsPlugin(options))

tests/__snapshots__/banner-and-footer-option.snap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```ts
44
// dts banner
5-
export {};
5+
export { };
66
// dts footer
77
```
88
## index.js

tests/__snapshots__/issues/206.snap.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
```ts
44
export * from "pkg1";
5-
export {};
65
```
76
## index.js
87

tests/__snapshots__/issues/61.snap.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ import * as debug from "debug";
55

66
//#region rolldown:runtime
77
var __defProp = Object.defineProperty;
8-
var __export = (target, all) => {
8+
var __export = (all) => {
9+
let target = {};
910
for (var name in all) __defProp(target, name, {
1011
get: all[name],
1112
enumerable: true
1213
});
14+
return target;
1315
};
1416

1517
//#endregion
1618
//#region src/foo.ts
17-
var foo_exports = {};
18-
__export(foo_exports, { foo: () => foo });
19+
var foo_exports = __export({ foo: () => foo });
1920
const foo = 1;
2021

2122
//#endregion
2223
//#region bar.ts
23-
var bar_exports = {};
24-
__export(bar_exports, { bar: () => bar });
24+
var bar_exports = __export({ bar: () => bar });
2525
const bar = 2;
2626

2727
//#endregion

tests/__snapshots__/resolve-dependency-for-dts.snap.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ type Options = {
1818
*/
1919
last?: string;
2020
};
21-
/**
22-
* Get all parent directories of {@link base}.
23-
* Stops after {@link Options['last']} is processed.
24-
*
25-
* @returns An array of absolute paths of all parent directories.
26-
*/
2721
export { type Options };
2822
```
2923
## index.js

0 commit comments

Comments
 (0)