1- import { BuildOptions } from "https://deno.land/x/[email protected] /mod.ts" ; 1+ import {
2+ BuildOptions ,
3+ EntryPoint ,
4+ } from "https://deno.land/x/[email protected] /mod.ts" ; 5+ import { expandGlobSync } from "https://deno.land/[email protected] /fs/expand_glob.ts" ; 6+ import {
7+ fromFileUrl ,
8+ join ,
9+ parse ,
10+ relative ,
11+ } from "https://deno.land/[email protected] /path/mod.ts" ; 12+
13+ interface ModuleInfo {
14+ readonly name : string ;
15+ readonly path : string ;
16+ }
17+
18+ function path2EntryPoint ( module : ModuleInfo ) : EntryPoint {
19+ const entryPoint : EntryPoint = {
20+ name : toRelative ( module . name ) ,
21+ path : toRelative ( module . path ) ,
22+ } ;
23+
24+ return entryPoint ;
25+ }
26+
27+ function module2TypeVersions ( modules : readonly ModuleInfo [ ] ) {
28+ const entries = modules . map ( ( { name, path } ) => {
29+ return [ name , [ join ( "types" , toDts ( path ) ) ] ] ;
30+ } ) ;
31+ const map = Object . fromEntries ( entries ) ;
32+
33+ return { "*" : map } ;
34+ }
35+
36+ function toRelative ( path : string ) : string {
37+ return path . startsWith ( "./" ) ? path : "./" + path ;
38+ }
39+
40+ function toDts ( path : string ) : string {
41+ return path . replace ( / .t s $ / , ".d.ts" ) ;
42+ }
43+
44+ const root = fromFileUrl ( import . meta. resolve ( "../" ) ) ;
45+ const entries = expandGlobSync ( "!(_*|*_test.ts)*.ts" , {
46+ includeDirs : false ,
47+ root,
48+ } ) ;
49+
50+ const modules = [ ...entries ] . map ( ( { path } ) => relative ( root , path ) ) . map (
51+ ( path ) => {
52+ const parsed = parse ( path ) ;
53+ const name = join ( parsed . dir , parsed . name ) + ".js" ;
54+
55+ return { name, path } ;
56+ } ,
57+ ) ;
58+
59+ const entryPoints = modules . map ( path2EntryPoint ) ;
60+ const typesVersions = module2TypeVersions ( modules ) ;
261
362export const makeOptions = ( version : string ) : BuildOptions => ( {
463 test : false ,
@@ -7,16 +66,18 @@ export const makeOptions = (version: string): BuildOptions => ({
766 lib : [ "dom" , "esnext" , "dom.iterable" ] ,
867 } ,
968 typeCheck : false ,
10- entryPoints : [ "./mod.ts" ] ,
69+ entryPoints,
1170 outDir : "./npm" ,
1271 package : {
1372 name : "@httpland/http-utils" ,
1473 version,
15- description : "HTTP implementation utility collection" ,
74+ description : "HTTP utility collection for Fetch API " ,
1675 keywords : [
1776 "http" ,
1877 "utility" ,
19- "handler" ,
78+ "collection" ,
79+ "fetch-api" ,
80+ "headers" ,
2081 "request" ,
2182 "response" ,
2283 ] ,
@@ -29,18 +90,22 @@ export const makeOptions = (version: string): BuildOptions => ({
2990 bugs : {
3091 url : "https://github.com/httpland/http-utils/issues" ,
3192 } ,
93+ main : undefined ,
94+ module : undefined ,
95+ types : undefined ,
3296 sideEffects : false ,
3397 type : "module" ,
3498 publishConfig : {
3599 access : "public" ,
36100 } ,
101+ typesVersions,
37102 } ,
38103 packageManager : "pnpm" ,
39104 mappings : {
40- "https://deno.land/x/prelude_js @1.0.0/to_lower_case .ts" : {
41- name : "@miyauci/prelude " ,
42- version : "1.0.0 " ,
43- subPath : "to_lower_case " ,
105+ "https://deno.land/x/isx @1.1.1/is_null .ts" : {
106+ name : "@miyauci/isx " ,
107+ version : "1.1.1 " ,
108+ subPath : "is_null " ,
44109 } ,
45110 } ,
46111} ) ;
0 commit comments