-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
200 lines (183 loc) · 5.58 KB
/
types.ts
File metadata and controls
200 lines (183 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import type { BuildOptions as ESBuildOptions, OutputFile, PartialMessage } from 'esbuild'
import type {
GeneratedCodeOptions,
OutputOptions,
Plugin,
RollupOptions,
TreeshakingOptions,
} from 'rollup'
import type { IndexedSourceMapConsumer } from 'source-map'
export type BuildLogLevel = Exclude<BuildOptions['logLevel'], undefined>
/**
* ESBuild options that esroll manages internally and excludes from user configuration.
*/
export type BuildOptionsExcluded =
| 'absPaths'
| 'allowOverwrite'
| 'bundle'
| 'entryPoints'
| 'format'
| 'globalName'
| 'metafile'
| 'minify'
| 'outdir'
| 'outfile'
| 'sourcemap'
| 'stdin'
| 'tsconfigRaw'
| 'write'
/**
* Configuration options for the build process.
*
* Extends esbuild's build options while omitting options that conflict with the esroll's internal
* behavior. Adds support for declaration file generation, documentation extraction, and rollup
* integration.
*/
export interface BuildOptions extends Omit<ESBuildOptions, BuildOptionsExcluded> {
/**
* Entry point files to bundle.
*/
entryPoints: string[]
/**
* Generate TypeScript declaration files (.d.ts).
*
* @remarks
*
* Either this property or {@link BuildOptions.outdir | outdir} must be set. When enabled,
* declaration files are generated alongside documentation extraction.
*/
declaration?: boolean
/**
* Bundle declaration files.
*
* @remarks
*
* Requires {@link BuildOptions.declaration | declaration} to be true.
*/
declarationRollup?: boolean
/**
* Package declarations to bundle with declaration rollup.
*
* @remarks
*
* Requires {@link BuildOptions.declarationRollup | declarationRollup} to be true.
*/
declarationRollupPackages?: string[]
/**
* Generate API documentation.
*
* @remarks
*
* Requires {@link BuildOptions.declaration | declaration} to be true. When set to `true`,
* documentation is generated and either replaces or appends the matching section in `README.md`.
* When set to a string, the value identifies an alternate markdown file that must sit directly
* inside the package directory and receives the same replacement or append behavior described by
* {@link BuildOptions.documentationHeading | documentationHeading}.
*/
documentation?: boolean | string
/**
* Include forgotten exports in the documentation.
*
* @remarks
*
* Requires {@link BuildOptions.documentation | documentation} to be true.
*/
documentationIncludeForgottenExports?: boolean
/**
* Markdown heading that identifies the API documentation section.
*
* @remarks
*
* The value must include the leading `#` markers, whose count determines the required heading
* depth. External markdown provided through {@link BuildOptions.documentation | documentation}
* must contain a heading whose depth and text match this configuration; matching sections are
* replaced and the content is appended when no matching heading exists. Applies when {@link
* BuildOptions.documentation | documentation} is `true` or set to a string.
*
* @defaultValue '# API'
*/
documentationHeading?: string
/**
* Logging verbosity level.
*
* @defaultValue 'info'
*/
logLevel?: 'error' | 'info' | 'silent'
/**
* Output file directory for bundled source files.
*
* @remarks
*
* At least one of {@link BuildOptions.outdir | outdir} or {@link BuildOptions.declaration |
* declaration} must be set. When specified, source files are bundled to this directory.
*/
outdir?: string
/**
* Rollup bundler configuration.
*/
rollup?: {
output?: { generatedCode?: GeneratedCodeOptions } & Partial<
Pick<
OutputOptions,
| 'exports'
| 'externalImportAttributes'
| 'importAttributesKey'
| 'minifyInternalExports'
| 'sanitizeFileName'
// | 'experimentalMinChunkSize'
// | 'sourcemapIgnoreList'
// | 'sourcemapPathTransform'
>
>
plugins?: Plugin[]
treeshake?: TreeshakingOptions
} & Partial<Pick<RollupOptions, 'experimentalLogSideEffects' | 'maxParallelFileOps'>>
/**
* Source map generation mode.
*
* @remarks
*
* Controls whether and how source maps are generated for the bundled output.
*
* - When set to false or undefined, no source maps are produced.
*
* - When set to true or 'linked', the bundler generates separate .map files alongside the output
* files and appends a sourceMappingURL comment to each output file that references its
* corresponding map file location.
*
* - The 'inline' mode embeds source maps directly into the output files as base64-encoded data
* URIs.
*
* - The 'external' mode writes source maps to separate .map files alongside the output files but
* omits the sourceMappingURL comment
*
*/
sourcemap?: boolean | 'external' | 'inline' | 'linked'
}
/**
* Result of a build operation.
*/
export interface BuildResult {
/**
* Errors that occurred during the build.
*/
errors: PartialMessage[]
/**
* Paths of generated output files.
*/
outputFiles: Array<Pick<OutputFile, 'path'>>
/**
* Warnings that occurred during the build.
*/
warnings: PartialMessage[]
}
export type BuildSourceMapConsumers = Partial<Record<string, IndexedSourceMapConsumer>>
export type BuildMessages = Pick<BuildResult, 'errors' | 'warnings'>
export interface CommonOptions extends BuildOptions {
hasColor: boolean
logLevel: 'error' | 'info' | 'silent'
pathDirectoryPackage: string
result: BuildResult
pathFilePackageJSON?: string
pathFileTSConfig?: string
}