1
1
import { build , emptyDir } from "@deno/dnt" ;
2
+ import { parse } from "@std/jsonc" ;
2
3
3
4
await emptyDir ( "./npm" ) ;
4
5
@@ -12,104 +13,22 @@ await Deno.writeTextFile(
12
13
( await Deno . readTextFile ( "./deno.jsonc" ) ) . replace (
13
14
"jsr:@progfay/scrapbox-parser" ,
14
15
"npm:@progfay/scrapbox-parser" ,
16
+ ) . replace (
17
+ "jsr:@cosense/types" ,
18
+ "npm:@cosense/types" ,
15
19
) ,
16
20
) ;
17
21
22
+ const config = parse ( await Deno . readTextFile ( "./deno.jsonc" ) ) as {
23
+ exports : Record < string , string > ;
24
+ } ;
25
+
18
26
await build ( {
19
27
entryPoints : [
20
28
"./mod.ts" ,
21
- {
22
- name : "./browser" ,
23
- path : "./browser/mod.ts" ,
24
- } ,
25
- {
26
- name : "./browser/dom" ,
27
- path : "./browser/dom/mod.ts" ,
28
- } ,
29
- {
30
- name : "./browser/websocket" ,
31
- path : "./websocket/mod.ts" ,
32
- } ,
33
- {
34
- name : "./parseAbsoluteLink" ,
35
- path : "./parseAbsoluteLink.ts" ,
36
- } ,
37
- {
38
- name : "./rest" ,
39
- path : "./rest/mod.ts" ,
40
- } ,
41
- {
42
- name : "./text" ,
43
- path : "./text.ts" ,
44
- } ,
45
- {
46
- name : "./title" ,
47
- path : "./title.ts" ,
48
- } ,
49
- {
50
- name : "./websocket" ,
51
- path : "./websocket/mod.ts" ,
52
- } ,
53
- {
54
- name : "./unstable-api" ,
55
- path : "./api.ts" ,
56
- } ,
57
- {
58
- name : "./unstable-api/pages" ,
59
- path : "./api/pages.ts" ,
60
- } ,
61
- {
62
- name : "./unstable-api/pages/project" ,
63
- path : "./api/pages/project.ts" ,
64
- } ,
65
- {
66
- name : "./unstable-api/pages/project/replace" ,
67
- path : "./api/pages/project/replace.ts" ,
68
- } ,
69
- {
70
- name : "./unstable-api/pages/project/replace/links" ,
71
- path : "./api/pages/project/replace/links.ts" ,
72
- } ,
73
- {
74
- name : "./unstable-api/pages/project/search" ,
75
- path : "./api/pages/project/search.ts" ,
76
- } ,
77
- {
78
- name : "./unstable-api/pages/project/search/query" ,
79
- path : "./api/pages/project/search/query.ts" ,
80
- } ,
81
- {
82
- name : "./unstable-api/pages/project/search/titles" ,
83
- path : "./api/pages/project/search/titles.ts" ,
84
- } ,
85
- {
86
- name : "./unstable-api/pages/project/title" ,
87
- path : "./api/pages/project/title.ts" ,
88
- } ,
89
- {
90
- name : "./unstable-api/pages/projects" ,
91
- path : "./api/projects.ts" ,
92
- } ,
93
- {
94
- name : "./unstable-api/pages/projects/project" ,
95
- path : "./api/projects/project.ts" ,
96
- } ,
97
- {
98
- name : "./unstable-api/pages/project/title/text" ,
99
- path : "./api/pages/project/title/text.ts" ,
100
- } ,
101
- {
102
- name : "./unstable-api/pages/project/title/icon" ,
103
- path : "./api/pages/project/title/icon.ts" ,
104
- } ,
105
- {
106
- name : "./unstable-api/users" ,
107
- path : "./api/users.ts" ,
108
- } ,
109
- {
110
- name : "./unstable-api/users/me" ,
111
- path : "./api/users/me.ts" ,
112
- } ,
29
+ ...Object . entries ( config . exports ) . flatMap (
30
+ ( [ name , path ] ) => name === "." ? [ ] : [ { name, path } ] ,
31
+ ) ,
113
32
] ,
114
33
outDir : "./npm" ,
115
34
shims : { deno : "dev" } ,
@@ -141,8 +60,7 @@ await build({
141
60
configFile : new URL ( "../deno_node.jsonc" , import . meta. url ) . href ,
142
61
// Don't run type checking during build to avoid Node.js compatibility issues
143
62
typeCheck : false ,
144
- declaration : "separate" ,
145
- scriptModule : false ,
63
+ declaration : "inline" ,
146
64
compilerOptions : {
147
65
lib : [ "ESNext" , "DOM" , "DOM.Iterable" ] ,
148
66
target : "ES2023" ,
@@ -153,18 +71,25 @@ await build({
153
71
154
72
// ignore snapshot testing & related test files on Node distribution
155
73
const emptyTestFiles = [
156
- "npm/esm/ browser/dom/extractCodeFiles.test.js" ,
157
- "npm/esm/ parser/anchor-fm.test.js" ,
158
- "npm/esm/ parser/spotify.test.js" ,
159
- "npm/esm/ parser/youtube.test.js" ,
160
- "npm/esm/ rest/getCodeBlocks.test.js" ,
161
- "npm/esm/ rest/pages.test.js" ,
162
- "npm/esm/ rest/project.test.js" ,
163
- "npm/esm/ websocket/_codeBlock.test.js" ,
164
- "npm/esm/ websocket/diffToChanges.test.js" ,
74
+ "browser/dom/extractCodeFiles.test.js" ,
75
+ "parser/anchor-fm.test.js" ,
76
+ "parser/spotify.test.js" ,
77
+ "parser/youtube.test.js" ,
78
+ "rest/getCodeBlocks.test.js" ,
79
+ "rest/pages.test.js" ,
80
+ "rest/project.test.js" ,
81
+ "websocket/_codeBlock.test.js" ,
82
+ "websocket/diffToChanges.test.js" ,
165
83
] ;
166
84
await Promise . all (
167
- emptyTestFiles . map ( ( filePath ) => Deno . writeTextFile ( filePath , "" ) ) ,
85
+ emptyTestFiles . map ( ( filePath ) =>
86
+ Deno . writeTextFile ( `npm/esm/${ filePath } ` , "" )
87
+ ) ,
88
+ ) ;
89
+ await Promise . all (
90
+ emptyTestFiles . map ( ( filePath ) =>
91
+ Deno . writeTextFile ( `npm/script/${ filePath } ` , "" )
92
+ ) ,
168
93
) ;
169
94
} ,
170
95
} ) ;
0 commit comments