11import { build , emptyDir } from "@deno/dnt" ;
2+ import { parse } from "@std/jsonc" ;
23
34await emptyDir ( "./npm" ) ;
45
@@ -12,104 +13,22 @@ await Deno.writeTextFile(
1213 ( await Deno . readTextFile ( "./deno.jsonc" ) ) . replace (
1314 "jsr:@progfay/scrapbox-parser" ,
1415 "npm:@progfay/scrapbox-parser" ,
16+ ) . replace (
17+ "jsr:@cosense/types" ,
18+ "npm:@cosense/types" ,
1519 ) ,
1620) ;
1721
22+ const config = parse ( await Deno . readTextFile ( "./deno.jsonc" ) ) as {
23+ exports : Record < string , string > ;
24+ } ;
25+
1826await build ( {
1927 entryPoints : [
2028 "./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+ ) ,
11332 ] ,
11433 outDir : "./npm" ,
11534 shims : { deno : "dev" } ,
@@ -141,8 +60,7 @@ await build({
14160 configFile : new URL ( "../deno_node.jsonc" , import . meta. url ) . href ,
14261 // Don't run type checking during build to avoid Node.js compatibility issues
14362 typeCheck : false ,
144- declaration : "separate" ,
145- scriptModule : false ,
63+ declaration : "inline" ,
14664 compilerOptions : {
14765 lib : [ "ESNext" , "DOM" , "DOM.Iterable" ] ,
14866 target : "ES2023" ,
@@ -153,18 +71,25 @@ await build({
15371
15472 // ignore snapshot testing & related test files on Node distribution
15573 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" ,
16583 ] ;
16684 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+ ) ,
16893 ) ;
16994 } ,
17095} ) ;
0 commit comments