File tree Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Original file line number Diff line number Diff line change 1
1
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" ;
15
3
16
4
export default defineConfig ( [
17
5
{
@@ -23,12 +11,17 @@ export default defineConfig([
23
11
platform : "neutral" ,
24
12
outDir : "out" ,
25
13
clean : true ,
26
- outputOptions : ( { format, entryFileNames, ...options } ) => ( {
14
+ globalName : "ScrapboxParser" ,
15
+ outputOptions : ( { entryFileNames, ...options } , format ) => ( {
27
16
...options ,
28
- format,
29
- name : "ScrapboxParser" ,
30
17
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 ,
32
25
} ) ,
33
26
} ,
34
27
] ) ;
You can’t perform that action at this time.
0 commit comments