Skip to content

Commit 127d88c

Browse files
committed
refactor tsdown.config.ts
1 parent 97d7827 commit 127d88c

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

tsdown.config.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
import { resolve } from "node:path";
2-
import { type Options, defineConfig } from "tsdown";
3-
4-
type ModuleFormat = Extract<Options["format"], string>;
5-
6-
const FORMAT_ENTRY_FILE_NAMES_MAP = {
7-
es: "[name].mjs",
8-
esm: "[name].mjs",
9-
module: "[name].mjs",
10-
cjs: "[name].cjs",
11-
commonjs: "[name].cjs",
12-
umd: "scrapbox-parser.umd.js",
13-
iife: undefined,
14-
} as const satisfies Record<ModuleFormat, string | undefined>;
2+
import { defineConfig } from "tsdown";
153

164
export default defineConfig([
175
{
@@ -23,12 +11,17 @@ export default defineConfig([
2311
platform: "neutral",
2412
outDir: "out",
2513
clean: true,
26-
outputOptions: ({ format, entryFileNames, ...options }) => ({
14+
globalName: "ScrapboxParser",
15+
outputOptions: ({ entryFileNames, ...options }, format) => ({
2716
...options,
28-
format,
29-
name: "ScrapboxParser",
3017
entryFileNames:
31-
(format && FORMAT_ENTRY_FILE_NAMES_MAP[format]) || entryFileNames,
18+
(
19+
{
20+
es: "[name].mjs",
21+
cjs: "[name].cjs",
22+
umd: "scrapbox-parser.umd.js",
23+
} satisfies { [K in typeof format]?: string }
24+
)[format] ?? entryFileNames,
3225
}),
3326
},
3427
]);

0 commit comments

Comments
 (0)