@@ -18,45 +18,62 @@ import fs from 'fs/promises'
18
18
import { generateDtsBundle } from 'dts-bundle-generator'
19
19
import glob from 'fast-glob'
20
20
21
- const entry = {
22
- filePath : './src/vendor.ts' ,
23
- outFile : './build/vendor.d.ts' ,
24
- libraries : {
25
- allowedTypesLibraries : [ 'node' ] , // args['external-types'],
26
- inlinedLibraries : [
27
- '@nodelib/fs.stat' ,
28
- '@nodelib/fs.scandir' ,
29
- '@nodelib/fs.walk' ,
30
- 'fast-glob' ,
31
- '@types/jsonfile' ,
32
- 'node-fetch-native' ,
33
- 'chalk' ,
34
- 'globby' ,
35
- '@types/minimist' ,
36
- '@types/which' ,
37
- 'zurk' ,
38
- '@webpod/ps' ,
39
- '@webpod/ingrid' ,
40
- 'depseek' ,
41
- ] , // args['external-inlines'],
21
+ const output = {
22
+ inlineDeclareExternals : true ,
23
+ inlineDeclareGlobals : true ,
24
+ sortNodes : false ,
25
+ exportReferencedTypes : false , //args['export-referenced-types'],
26
+ }
27
+ const entries = [
28
+ {
29
+ filePath : './src/vendor-extra.ts' ,
30
+ outFile : './build/vendor-extra.d.ts' ,
31
+ libraries : {
32
+ allowedTypesLibraries : [ 'node' ] , // args['external-types'],
33
+ inlinedLibraries : [
34
+ '@nodelib/fs.stat' ,
35
+ '@nodelib/fs.scandir' ,
36
+ '@nodelib/fs.walk' ,
37
+ 'fast-glob' ,
38
+ '@types/jsonfile' ,
39
+ 'node-fetch-native' ,
40
+ // 'chalk',
41
+ 'globby' ,
42
+ // '@types/minimist',
43
+ // '@types/which',
44
+ // 'zurk',
45
+ // '@webpod/ps',
46
+ '@webpod/ingrid' ,
47
+ 'depseek' ,
48
+ ] , // args['external-inlines'],
49
+ } ,
50
+ output,
42
51
} ,
43
- output : {
44
- inlineDeclareExternals : true ,
45
- inlineDeclareGlobals : true ,
46
- sortNodes : false ,
47
- exportReferencedTypes : false , //args['export-referenced-types'],
52
+ {
53
+ filePath : './src/vendor-core.ts' ,
54
+ outFile : './build/vendor-core.d.ts' ,
55
+ libraries : {
56
+ allowedTypesLibraries : [ 'node' ] , // args['external-types'],
57
+ inlinedLibraries : [
58
+ '@types/which' ,
59
+ '@webpod/ps' ,
60
+ '@webpod/ingrid' ,
61
+ 'chalk' ,
62
+ 'zurk' ,
63
+ ] , // args['external-inlines'],
64
+ } ,
65
+ output,
48
66
} ,
49
- }
67
+ ]
50
68
51
69
const compilationOptions = {
52
70
preferredConfigPath : './tsconfig.prod.json' , // args.project,
53
71
followSymlinks : true ,
54
72
}
55
73
56
- let [ result ] = generateDtsBundle ( [ entry ] , compilationOptions )
57
-
58
- // generateDtsBundle cannot handle the circular refs on types inlining, so we need to help it manually:
59
- /*
74
+ const results = generateDtsBundle ( entries , compilationOptions )
75
+ // generateDtsBundle cannot handle the circular refs on types inlining, so we need to help it manually:
76
+ /*
60
77
build/vendor.d.ts(163,7): error TS2456: Type alias 'Options' circularly references itself.
61
78
build/vendor.d.ts(164,7): error TS2456: Type alias 'Entry' circularly references itself.
62
79
build/vendor.d.ts(165,7): error TS2456: Type alias 'Task' circularly references itself.
@@ -65,17 +82,28 @@ build/vendor.d.ts(167,7): error TS2456: Type alias 'FileSystemAdapter' circularl
65
82
build/vendor.d.ts(197,48): error TS2694: Namespace 'FastGlob' has no exported member 'FastGlobOptions
66
83
*/
67
84
68
- result = result
69
- . replace ( 'type Options = Options;' , 'export {Options};' )
70
- . replace ( 'type Task = Task;' , 'export {Task};' )
71
- . replace ( 'type Pattern = Pattern;' , 'export {Pattern};' )
72
- . replace ( 'FastGlob.FastGlobOptions' , 'FastGlob.Options' )
73
- . replace ( 'type Entry =' , 'export type Entry =' )
85
+ . map ( ( r ) =>
86
+ r
87
+ . replace ( 'type Options = Options;' , 'export {Options};' )
88
+ . replace ( 'type Task = Task;' , 'export {Task};' )
89
+ . replace ( 'type Pattern = Pattern;' , 'export {Pattern};' )
90
+ . replace ( 'FastGlob.FastGlobOptions' , 'FastGlob.Options' )
91
+ . replace ( 'type Entry =' , 'export type Entry =' )
92
+ )
74
93
75
- await fs . writeFile ( entry . outFile , result , 'utf8' )
94
+ for ( const i in results ) {
95
+ const entry = entries [ i ]
96
+ const result = results [ i ]
97
+
98
+ await fs . writeFile ( entry . outFile , result , 'utf8' )
99
+ }
76
100
77
101
// Replaces redundant triple-slash directives
78
- for ( const dts of await glob ( [ 'build/**/*.d.ts' , '!build/vendor.d.ts' ] ) ) {
102
+ for ( const dts of await glob ( [
103
+ 'build/**/*.d.ts' ,
104
+ '!build/vendor.d.ts' ,
105
+ '!build/core-vendor.d.ts' ,
106
+ ] ) ) {
79
107
const contents = ( await fs . readFile ( dts , 'utf8' ) )
80
108
. split ( '\n' )
81
109
. filter ( ( line ) => ! line . startsWith ( '/// <reference types' ) )
0 commit comments