@sanity/pkg-utils 5.0.7 → 5.0.8-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/index.cjs +29 -2
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.d.cts +535 -0
- package/dist/index.js +29 -2
- package/dist/index.js.map +1 -1
- package/package.json +28 -24
- package/src/node/printExtractMessages.ts +2 -2
- package/src/node/tasks/dts/buildTypes.ts +12 -1
- package/src/node/tasks/dts/createApiExtractorConfig.ts +23 -3
- package/src/node/tasks/dts/doExtract.ts +1 -0
- package/src/node/tasks/dts/extractModuleBlocks.ts +2 -2
- package/src/node/tasks/dts/extractTypes.ts +4 -0
package/dist/cli.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var cac = require("cac");
|
|
|
3
3
|
function _interopDefaultCompat(e) {
|
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
5
5
|
}
|
|
6
|
-
var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "5.0.
|
|
6
|
+
var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "5.0.8-canary.0";
|
|
7
7
|
const cli = cac__default.default();
|
|
8
8
|
cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
|
|
9
9
|
const { checkAction } = await Promise.resolve().then(function() {
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import {ExtractorMessage} from '@microsoft/api-extractor'
|
|
2
|
+
import {IExtractorMessagesConfig} from '@microsoft/api-extractor'
|
|
3
|
+
import type {NormalizedOutputOptions} from 'rollup'
|
|
4
|
+
import {Observable} from 'rxjs'
|
|
5
|
+
import type {PluginItem} from '@babel/core'
|
|
6
|
+
import type {Plugin as RollupPlugin} from 'rollup'
|
|
7
|
+
import {RollupWatcherEvent} from 'rollup'
|
|
8
|
+
import type {TreeshakingOptions} from 'rollup'
|
|
9
|
+
import ts from 'typescript'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Build the distribution files of a npm package.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {build} from '@sanity/pkg-utils'
|
|
17
|
+
*
|
|
18
|
+
* build({
|
|
19
|
+
* cwd: process.cwd(),
|
|
20
|
+
* tsconfig: 'tsconfig.dist.json,
|
|
21
|
+
* }).then(() => {
|
|
22
|
+
* console.log('successfully built')
|
|
23
|
+
* }).catch((err) => {
|
|
24
|
+
* console.log(`build error: ${err.message}`)
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function build(options: {
|
|
31
|
+
cwd: string
|
|
32
|
+
emitDeclarationOnly?: boolean
|
|
33
|
+
strict?: boolean
|
|
34
|
+
tsconfig?: string
|
|
35
|
+
}): Promise<void>
|
|
36
|
+
|
|
37
|
+
/** @internal */
|
|
38
|
+
export declare interface BuildContext {
|
|
39
|
+
config?: PkgConfigOptions
|
|
40
|
+
cwd: string
|
|
41
|
+
distPath: string
|
|
42
|
+
emitDeclarationOnly: boolean
|
|
43
|
+
exports: PkgExports | undefined
|
|
44
|
+
extMap: PkgExtMap
|
|
45
|
+
external: string[]
|
|
46
|
+
files: BuildFile[]
|
|
47
|
+
logger: Logger
|
|
48
|
+
pkg: PackageJSON
|
|
49
|
+
runtime: PkgRuntime
|
|
50
|
+
strict: boolean
|
|
51
|
+
target: Record<PkgRuntime, string[]>
|
|
52
|
+
ts: {
|
|
53
|
+
config?: ts.ParsedCommandLine
|
|
54
|
+
configPath?: string
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @internal */
|
|
59
|
+
export declare interface BuildFile {
|
|
60
|
+
type: 'asset' | 'chunk' | 'types'
|
|
61
|
+
path: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @internal */
|
|
65
|
+
export declare type BuildTask = DtsTask | RollupTask
|
|
66
|
+
|
|
67
|
+
/** @internal */
|
|
68
|
+
export declare interface BuildTaskHandlers {
|
|
69
|
+
'build:dts': TaskHandler<DtsTask, DtsResult>
|
|
70
|
+
'build:js': TaskHandler<RollupTask>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @internal */
|
|
74
|
+
export declare const buildTaskHandlers: BuildTaskHandlers
|
|
75
|
+
|
|
76
|
+
/** @public */
|
|
77
|
+
export declare function check(options: {
|
|
78
|
+
cwd: string
|
|
79
|
+
strict?: boolean
|
|
80
|
+
tsconfig?: string
|
|
81
|
+
}): Promise<void>
|
|
82
|
+
|
|
83
|
+
/** @internal */
|
|
84
|
+
export declare function createFromTemplate(options: {
|
|
85
|
+
cwd: string
|
|
86
|
+
logger: Logger
|
|
87
|
+
packagePath: string
|
|
88
|
+
template: PkgTemplate
|
|
89
|
+
}): Promise<void>
|
|
90
|
+
|
|
91
|
+
/** @internal */
|
|
92
|
+
export declare function createLogger(): Logger
|
|
93
|
+
|
|
94
|
+
/** @public */
|
|
95
|
+
export declare const DEFAULT_BROWSERSLIST_QUERY: string[]
|
|
96
|
+
|
|
97
|
+
/** @internal */
|
|
98
|
+
export declare const DEFAULT_PKG_EXT_MAP: PkgExtMap
|
|
99
|
+
|
|
100
|
+
/** @public */
|
|
101
|
+
export declare function defineConfig(configOptions: PkgConfigOptions): PkgConfigOptions
|
|
102
|
+
|
|
103
|
+
/** @public */
|
|
104
|
+
export declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>
|
|
105
|
+
|
|
106
|
+
/** @internal */
|
|
107
|
+
export declare interface DtsResult {
|
|
108
|
+
type: 'dts'
|
|
109
|
+
messages: ExtractorMessage[]
|
|
110
|
+
results: {
|
|
111
|
+
sourcePath: string
|
|
112
|
+
filePath: string
|
|
113
|
+
}[]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** @internal */
|
|
117
|
+
export declare interface DtsTask {
|
|
118
|
+
type: 'build:dts'
|
|
119
|
+
entries: {
|
|
120
|
+
exportPath: string
|
|
121
|
+
importId: string
|
|
122
|
+
sourcePath: string
|
|
123
|
+
targetPath: string
|
|
124
|
+
}[]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** @internal */
|
|
128
|
+
export declare const dtsTask: TaskHandler<DtsTask, DtsResult>
|
|
129
|
+
|
|
130
|
+
/** @internal */
|
|
131
|
+
export declare interface DtsWatchTask {
|
|
132
|
+
type: 'watch:dts'
|
|
133
|
+
entries: {
|
|
134
|
+
exportPath: string
|
|
135
|
+
importId: string
|
|
136
|
+
sourcePath: string
|
|
137
|
+
targetPath: string
|
|
138
|
+
}[]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** @internal */
|
|
142
|
+
export declare const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult>
|
|
143
|
+
|
|
144
|
+
/** @internal */
|
|
145
|
+
export declare function getExtractMessagesConfig(options: {
|
|
146
|
+
rules: NonNullable<PkgConfigOptions['extract']>['rules']
|
|
147
|
+
}): IExtractorMessagesConfig
|
|
148
|
+
|
|
149
|
+
/** @internal */
|
|
150
|
+
export declare function getPkgExtMap(options: {legacyExports: boolean}): PkgExtMap
|
|
151
|
+
|
|
152
|
+
/** @public */
|
|
153
|
+
export declare function init(options: {cwd: string; path: string}): Promise<void>
|
|
154
|
+
|
|
155
|
+
/** @internal */
|
|
156
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>
|
|
157
|
+
|
|
158
|
+
/** @internal */
|
|
159
|
+
export declare function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined>
|
|
160
|
+
|
|
161
|
+
/** @internal */
|
|
162
|
+
export declare function loadPkg(options: {cwd: string}): Promise<PackageJSON>
|
|
163
|
+
|
|
164
|
+
/** @internal */
|
|
165
|
+
export declare function loadPkgWithReporting(options: {
|
|
166
|
+
cwd: string
|
|
167
|
+
logger: Logger
|
|
168
|
+
}): Promise<PackageJSON>
|
|
169
|
+
|
|
170
|
+
/** @internal */
|
|
171
|
+
export declare function loadTSConfig(options: {
|
|
172
|
+
cwd: string
|
|
173
|
+
tsconfigPath: string
|
|
174
|
+
}): Promise<ts.ParsedCommandLine | undefined>
|
|
175
|
+
|
|
176
|
+
/** @internal */
|
|
177
|
+
export declare interface Logger {
|
|
178
|
+
log: (...args: unknown[]) => void
|
|
179
|
+
info: (...args: unknown[]) => void
|
|
180
|
+
warn: (...args: unknown[]) => void
|
|
181
|
+
error: (...args: unknown[]) => void
|
|
182
|
+
success: (...args: unknown[]) => void
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** @internal */
|
|
186
|
+
export declare interface PackageJSON {
|
|
187
|
+
type?: 'commonjs' | 'module'
|
|
188
|
+
version: string
|
|
189
|
+
private?: boolean
|
|
190
|
+
author?:
|
|
191
|
+
| string
|
|
192
|
+
| {
|
|
193
|
+
name: string
|
|
194
|
+
email?: string
|
|
195
|
+
url?: string
|
|
196
|
+
}
|
|
197
|
+
name: string
|
|
198
|
+
description?: string
|
|
199
|
+
keywords?: string[]
|
|
200
|
+
bin?: Record<string, string>
|
|
201
|
+
dependencies?: Record<string, string | undefined>
|
|
202
|
+
devDependencies?: Record<string, string | undefined>
|
|
203
|
+
peerDependencies?: Record<string, string | undefined>
|
|
204
|
+
exports?: Record<
|
|
205
|
+
string,
|
|
206
|
+
| `./${string}.json`
|
|
207
|
+
| {
|
|
208
|
+
source: string
|
|
209
|
+
types?: string
|
|
210
|
+
browser?: {
|
|
211
|
+
source: string
|
|
212
|
+
import?: string
|
|
213
|
+
require?: string
|
|
214
|
+
}
|
|
215
|
+
node?: {
|
|
216
|
+
source?: string
|
|
217
|
+
module?: string
|
|
218
|
+
import?: string
|
|
219
|
+
require?: string
|
|
220
|
+
}
|
|
221
|
+
module?: string
|
|
222
|
+
import?: string
|
|
223
|
+
require?: string
|
|
224
|
+
default: string
|
|
225
|
+
}
|
|
226
|
+
| {
|
|
227
|
+
types?: string
|
|
228
|
+
svelte: string
|
|
229
|
+
default?: string
|
|
230
|
+
}
|
|
231
|
+
>
|
|
232
|
+
main?: string
|
|
233
|
+
browser?: Record<string, string>
|
|
234
|
+
source?: string
|
|
235
|
+
module?: string
|
|
236
|
+
types?: string
|
|
237
|
+
files?: string[]
|
|
238
|
+
scripts?: Record<string, string | undefined>
|
|
239
|
+
browserslist?: string | string[]
|
|
240
|
+
sideEffects?: boolean | string[]
|
|
241
|
+
engines?: {
|
|
242
|
+
node?: string
|
|
243
|
+
npm?: string
|
|
244
|
+
}
|
|
245
|
+
repository?:
|
|
246
|
+
| string
|
|
247
|
+
| {
|
|
248
|
+
type: 'git'
|
|
249
|
+
url: string
|
|
250
|
+
}
|
|
251
|
+
bugs?:
|
|
252
|
+
| string
|
|
253
|
+
| {
|
|
254
|
+
url: string
|
|
255
|
+
email?: string
|
|
256
|
+
}
|
|
257
|
+
homepage?: string
|
|
258
|
+
license?: string
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** @internal */
|
|
262
|
+
export declare function parseExports(options: {
|
|
263
|
+
extMap: PkgExtMap
|
|
264
|
+
pkg: PackageJSON
|
|
265
|
+
strict: boolean
|
|
266
|
+
}): (PkgExport & {
|
|
267
|
+
_path: string
|
|
268
|
+
})[]
|
|
269
|
+
|
|
270
|
+
/** @public */
|
|
271
|
+
export declare interface PkgBundle {
|
|
272
|
+
source: string
|
|
273
|
+
import?: string
|
|
274
|
+
require?: string
|
|
275
|
+
runtime?: PkgRuntime
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** @public */
|
|
279
|
+
export declare interface PkgConfigOptions {
|
|
280
|
+
/** @alpha */
|
|
281
|
+
babel?: {
|
|
282
|
+
plugins?: PluginItem[] | null | undefined
|
|
283
|
+
}
|
|
284
|
+
bundles?: PkgBundle[]
|
|
285
|
+
/** @alpha */
|
|
286
|
+
define?: Record<string, string | number | boolean | undefined | null>
|
|
287
|
+
/**
|
|
288
|
+
* Directory of distributed & bundled files.
|
|
289
|
+
*/
|
|
290
|
+
dist?: string
|
|
291
|
+
exports?: PkgConfigProperty<PkgExports>
|
|
292
|
+
extract?: {
|
|
293
|
+
bundledPackages?: string[]
|
|
294
|
+
customTags?: TSDocCustomTag[]
|
|
295
|
+
rules?: {
|
|
296
|
+
'ae-forgotten-export'?: PkgRuleLevel
|
|
297
|
+
'ae-incompatible-release-tags'?: PkgRuleLevel
|
|
298
|
+
'ae-internal-missing-underscore'?: PkgRuleLevel
|
|
299
|
+
'ae-missing-release-tag'?: PkgRuleLevel
|
|
300
|
+
'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel
|
|
301
|
+
'tsdoc-undefined-tag'?: PkgRuleLevel
|
|
302
|
+
'tsdoc-unsupported-tag'?: PkgRuleLevel
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Packages to exclude from bundles.
|
|
307
|
+
*/
|
|
308
|
+
external?: PkgConfigProperty<string[]>
|
|
309
|
+
/**
|
|
310
|
+
* Defaults to `"automatic"`
|
|
311
|
+
*/
|
|
312
|
+
jsx?: 'transform' | 'preserve' | 'automatic'
|
|
313
|
+
/**
|
|
314
|
+
* Defaults to `"createElement"`
|
|
315
|
+
*/
|
|
316
|
+
jsxFactory?: string
|
|
317
|
+
/**
|
|
318
|
+
* Defaults to `"Fragment"`
|
|
319
|
+
*/
|
|
320
|
+
jsxFragment?: string
|
|
321
|
+
/**
|
|
322
|
+
* Defaults to `"react"`
|
|
323
|
+
*/
|
|
324
|
+
jsxImportSource?: string
|
|
325
|
+
/**
|
|
326
|
+
* Build package with support for legacy exports (writes root `<export>.js` files)
|
|
327
|
+
*/
|
|
328
|
+
legacyExports?: boolean
|
|
329
|
+
minify?: boolean
|
|
330
|
+
/** @alpha */
|
|
331
|
+
rollup?: {
|
|
332
|
+
plugins?: PkgConfigProperty<RollupPlugin[]>
|
|
333
|
+
output?: Partial<NormalizedOutputOptions>
|
|
334
|
+
/**
|
|
335
|
+
* Default options are `preset: 'recommended'` and `propertyReadSideEffects: false`
|
|
336
|
+
* @alpha
|
|
337
|
+
*/
|
|
338
|
+
treeshake?: TreeshakingOptions
|
|
339
|
+
/** @alpha */
|
|
340
|
+
experimentalLogSideEffects?: boolean
|
|
341
|
+
/**
|
|
342
|
+
* Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
|
|
343
|
+
* It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
|
|
344
|
+
* @defaultValue false
|
|
345
|
+
*/
|
|
346
|
+
hashChunkFileNames?: boolean
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Default runtime of package exports
|
|
350
|
+
*/
|
|
351
|
+
runtime?: PkgRuntime
|
|
352
|
+
sourcemap?: boolean
|
|
353
|
+
/**
|
|
354
|
+
* Directory of source files.
|
|
355
|
+
*/
|
|
356
|
+
src?: string
|
|
357
|
+
tsconfig?: string
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** @public */
|
|
361
|
+
export declare type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T
|
|
362
|
+
|
|
363
|
+
/** @public */
|
|
364
|
+
export declare type PkgConfigPropertyResolver<T> = (prev: T) => T
|
|
365
|
+
|
|
366
|
+
/** @public */
|
|
367
|
+
export declare interface PkgExport {
|
|
368
|
+
/** @internal */
|
|
369
|
+
_exported?: boolean
|
|
370
|
+
browser?: {
|
|
371
|
+
source: string
|
|
372
|
+
import?: string
|
|
373
|
+
require?: string
|
|
374
|
+
}
|
|
375
|
+
node?: {
|
|
376
|
+
source?: string
|
|
377
|
+
import?: string
|
|
378
|
+
require?: string
|
|
379
|
+
}
|
|
380
|
+
types?: string
|
|
381
|
+
source: string
|
|
382
|
+
import?: string
|
|
383
|
+
require?: string
|
|
384
|
+
default: string
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** @public */
|
|
388
|
+
export declare interface PkgExports {
|
|
389
|
+
[path: string]: PkgExport
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** @internal */
|
|
393
|
+
export declare interface PkgExtMap {
|
|
394
|
+
commonjs: {
|
|
395
|
+
commonjs: string
|
|
396
|
+
esm: string
|
|
397
|
+
}
|
|
398
|
+
module: {
|
|
399
|
+
commonjs: string
|
|
400
|
+
esm: string
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** @public */
|
|
405
|
+
export declare type PkgFormat = 'commonjs' | 'esm'
|
|
406
|
+
|
|
407
|
+
/** @public */
|
|
408
|
+
export declare type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'
|
|
409
|
+
|
|
410
|
+
/** @public */
|
|
411
|
+
export declare type PkgRuntime = '*' | 'browser' | 'node'
|
|
412
|
+
|
|
413
|
+
/** @public */
|
|
414
|
+
export declare type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver
|
|
415
|
+
|
|
416
|
+
/** @public */
|
|
417
|
+
export declare interface PkgTemplateDefinition {
|
|
418
|
+
options: PkgTemplateStringOption<any>[]
|
|
419
|
+
features: {
|
|
420
|
+
name: string
|
|
421
|
+
optional: boolean
|
|
422
|
+
initial: boolean
|
|
423
|
+
}[]
|
|
424
|
+
getFiles: (
|
|
425
|
+
options: Record<string, any>,
|
|
426
|
+
features: Record<string, boolean>,
|
|
427
|
+
) => Promise<PkgTemplateFile[]>
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** @public */
|
|
431
|
+
export declare interface PkgTemplateFile {
|
|
432
|
+
name: string
|
|
433
|
+
contents: string
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** @public */
|
|
437
|
+
export declare type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
|
|
438
|
+
|
|
439
|
+
/** @public */
|
|
440
|
+
export declare type PkgTemplateResolver = (options: {
|
|
441
|
+
cwd: string
|
|
442
|
+
/** @internal */
|
|
443
|
+
logger: Logger
|
|
444
|
+
packagePath: string
|
|
445
|
+
}) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>
|
|
446
|
+
|
|
447
|
+
/** @public */
|
|
448
|
+
export declare interface PkgTemplateStringOption<T = string> {
|
|
449
|
+
name: string
|
|
450
|
+
type: 'string'
|
|
451
|
+
description: string
|
|
452
|
+
initial?: T | ((options: Record<string, any>) => T)
|
|
453
|
+
parse?: (v: string) => T | null
|
|
454
|
+
validate?: (v: string) => string | true
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** @internal */
|
|
458
|
+
export declare function resolveBuildTasks(ctx: BuildContext): BuildTask[]
|
|
459
|
+
|
|
460
|
+
/** @internal */
|
|
461
|
+
export declare function resolveConfigProperty<T>(
|
|
462
|
+
prop: PkgConfigProperty<T> | undefined,
|
|
463
|
+
initialValue: T,
|
|
464
|
+
): T
|
|
465
|
+
|
|
466
|
+
export {RollupPlugin}
|
|
467
|
+
|
|
468
|
+
/** @internal */
|
|
469
|
+
export declare interface RollupTask {
|
|
470
|
+
type: 'build:js'
|
|
471
|
+
buildId: string
|
|
472
|
+
entries: RollupTaskEntry[]
|
|
473
|
+
runtime: PkgRuntime
|
|
474
|
+
format: 'commonjs' | 'esm'
|
|
475
|
+
target: string[]
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** @internal */
|
|
479
|
+
export declare const rollupTask: TaskHandler<RollupTask>
|
|
480
|
+
|
|
481
|
+
/** @internal */
|
|
482
|
+
export declare interface RollupTaskEntry {
|
|
483
|
+
path: string
|
|
484
|
+
source: string
|
|
485
|
+
output: string
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** @internal */
|
|
489
|
+
export declare interface RollupWatchTask {
|
|
490
|
+
type: 'watch:js'
|
|
491
|
+
buildId: string
|
|
492
|
+
entries: RollupTaskEntry[]
|
|
493
|
+
runtime: PkgRuntime
|
|
494
|
+
format: 'commonjs' | 'esm'
|
|
495
|
+
target: string[]
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** @internal */
|
|
499
|
+
export declare const rollupWatchTask: TaskHandler<RollupWatchTask, RollupWatcherEvent>
|
|
500
|
+
|
|
501
|
+
/** @internal */
|
|
502
|
+
export declare type TaskHandler<Task, Result = void> = {
|
|
503
|
+
name: (ctx: BuildContext, task: Task) => string
|
|
504
|
+
exec: (ctx: BuildContext, task: Task) => Observable<Result>
|
|
505
|
+
complete: (ctx: BuildContext, task: Task, result: Result) => void
|
|
506
|
+
error: (ctx: BuildContext, task: Task, error: unknown) => void
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/** @public */
|
|
510
|
+
export declare interface TSDocCustomTag {
|
|
511
|
+
name: string
|
|
512
|
+
syntaxKind: 'block' | 'modifier'
|
|
513
|
+
allowMultiple?: boolean
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** @public */
|
|
517
|
+
export declare function watch(options: {
|
|
518
|
+
cwd: string
|
|
519
|
+
strict?: boolean
|
|
520
|
+
tsconfig?: string
|
|
521
|
+
}): Promise<void>
|
|
522
|
+
|
|
523
|
+
/** @internal */
|
|
524
|
+
export declare type WatchTask = DtsWatchTask | RollupWatchTask
|
|
525
|
+
|
|
526
|
+
/** @internal */
|
|
527
|
+
export declare interface WatchTaskHandlers {
|
|
528
|
+
'watch:dts': TaskHandler<DtsWatchTask, DtsResult>
|
|
529
|
+
'watch:js': TaskHandler<RollupWatchTask, RollupWatcherEvent>
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** @internal */
|
|
533
|
+
export declare const watchTaskHandlers: WatchTaskHandlers
|
|
534
|
+
|
|
535
|
+
export {}
|
package/dist/index.js
CHANGED
|
@@ -648,7 +648,16 @@ async function buildTypes(options2) {
|
|
|
648
648
|
declarationDir: outDir,
|
|
649
649
|
emitDeclarationOnly: !0,
|
|
650
650
|
noEmit: !1,
|
|
651
|
-
outDir
|
|
651
|
+
outDir,
|
|
652
|
+
// Support the new `module: 'preserve'` option in TypeScript 5.4
|
|
653
|
+
...tsconfig.options.module === ts.ModuleKind.Preserve ? {
|
|
654
|
+
// Set the equivalent options to `module: 'Preserve'`
|
|
655
|
+
// https://github.com/microsoft/TypeScript/pull/56785/files?file-filters%5B%5D=.js&file-filters%5B%5D=.json&file-filters%5B%5D=.symbols&file-filters%5B%5D=.ts&file-filters%5B%5D=.types&show-viewed-files=true#diff-31d3c12bafea26bc9e8c8a77920c41af0c593206442add70c45a06c063767445
|
|
656
|
+
module: ts.ModuleKind.ESNext,
|
|
657
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
658
|
+
esModuleInterop: !0,
|
|
659
|
+
resolveJsonModule: !0
|
|
660
|
+
} : {}
|
|
652
661
|
}, program = ts.createProgram(tsconfig.fileNames, compilerOptions), emitResult = program.emit(), allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
653
662
|
for (const diagnostic of allDiagnostics)
|
|
654
663
|
printDiagnostic({ cwd, logger, diagnostic });
|
|
@@ -669,6 +678,7 @@ function createApiExtractorConfig(options2) {
|
|
|
669
678
|
messages,
|
|
670
679
|
projectFolder,
|
|
671
680
|
mainEntryPointFilePath,
|
|
681
|
+
tsconfig,
|
|
672
682
|
tsconfigPath
|
|
673
683
|
} = options2;
|
|
674
684
|
return {
|
|
@@ -677,7 +687,21 @@ function createApiExtractorConfig(options2) {
|
|
|
677
687
|
reportFileName: "<unscopedPackageName>.api.md"
|
|
678
688
|
},
|
|
679
689
|
bundledPackages,
|
|
680
|
-
compiler: {
|
|
690
|
+
compiler: tsconfig.options.module === ts.ModuleKind.Preserve ? {
|
|
691
|
+
// When the module is 'preserve' it's necessary to override the tsconfig file as api-extractor doesn't handle it out of the box
|
|
692
|
+
overrideTsconfig: {
|
|
693
|
+
extends: tsconfigPath,
|
|
694
|
+
compilerOptions: {
|
|
695
|
+
// Set the equivalent options to `module: 'Preserve'`
|
|
696
|
+
// https://github.com/microsoft/TypeScript/pull/56785/files?file-filters%5B%5D=.js&file-filters%5B%5D=.json&file-filters%5B%5D=.symbols&file-filters%5B%5D=.ts&file-filters%5B%5D=.types&show-viewed-files=true#diff-31d3c12bafea26bc9e8c8a77920c41af0c593206442add70c45a06c063767445
|
|
697
|
+
module: "ESNext",
|
|
698
|
+
moduleResolution: "Bundler",
|
|
699
|
+
esModuleInterop: !0,
|
|
700
|
+
resolveJsonModule: !0
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
} : {
|
|
704
|
+
// If the module is not 'preserve', use the tsconfig file directly
|
|
681
705
|
tsconfigFilePath: tsconfigPath
|
|
682
706
|
},
|
|
683
707
|
docModel: {
|
|
@@ -20161,6 +20185,7 @@ async function extractTypes(options2) {
|
|
|
20161
20185
|
rules,
|
|
20162
20186
|
sourceTypesPath,
|
|
20163
20187
|
tmpPath,
|
|
20188
|
+
tsconfig,
|
|
20164
20189
|
tsconfigPath
|
|
20165
20190
|
} = options2, tsdocConfigFile = await createTSDocConfig({
|
|
20166
20191
|
customTags: customTags || []
|
|
@@ -20173,6 +20198,7 @@ async function extractTypes(options2) {
|
|
|
20173
20198
|
messages: getExtractMessagesConfig({ rules }),
|
|
20174
20199
|
projectFolder: projectPath,
|
|
20175
20200
|
mainEntryPointFilePath: sourceTypesPath,
|
|
20201
|
+
tsconfig,
|
|
20176
20202
|
tsconfigPath
|
|
20177
20203
|
}),
|
|
20178
20204
|
configObjectFullPath: void 0,
|
|
@@ -20231,6 +20257,7 @@ async function doExtract(ctx, task) {
|
|
|
20231
20257
|
projectPath: cwd,
|
|
20232
20258
|
rules: config2?.extract?.rules,
|
|
20233
20259
|
sourceTypesPath,
|
|
20260
|
+
tsconfig: ts2.config,
|
|
20234
20261
|
tmpPath,
|
|
20235
20262
|
tsconfigPath: path$1.resolve(cwd, ts2.configPath || "tsconfig.json")
|
|
20236
20263
|
});
|