@sanity/pkg-utils 7.2.9 → 7.2.10-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/build.cjs +82 -75
- package/dist/_chunks-cjs/build.cjs.map +1 -1
- package/dist/_chunks-cjs/consoleSpy.cjs +2 -1
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/_chunks-cjs/index.cjs +205 -17
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.d.cts +1 -1
- package/dist/index.d.cts +421 -482
- package/dist/index.d.ts +421 -482
- package/dist/index.js +294 -96
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/node/core/config/types.ts +18 -1
- package/src/node/core/contexts/buildContext.ts +2 -1
- package/src/node/resolveBuildContext.ts +1 -0
- package/src/node/resolveBuildTasks.ts +139 -116
- package/src/node/tasks/dts/createApiExtractorConfig.ts +3 -1
- package/src/node/tasks/dts/doExtract.ts +1 -0
- package/src/node/tasks/dts/dtsTask.ts +2 -2
- package/src/node/tasks/dts/dtsWatchTask.ts +1 -0
- package/src/node/tasks/dts/extractTypes.ts +7 -1
- package/src/node/tasks/dts/getExtractMessagesConfig.ts +68 -50
- package/src/node/tasks/index.ts +2 -0
- package/src/node/tasks/rolldown/resolveRolldownConfig.ts +208 -0
- package/src/node/tasks/rolldown/rolldownDtsTask.ts +155 -0
- package/src/node/tasks/types.ts +12 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.10-canary.1",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -102,6 +102,8 @@
|
|
|
102
102
|
"prompts": "^2.4.2",
|
|
103
103
|
"recast": "0.23.11",
|
|
104
104
|
"rimraf": "^4.4.1",
|
|
105
|
+
"rolldown": "1.0.0-beta.17",
|
|
106
|
+
"rolldown-plugin-dts": "^0.13.11",
|
|
105
107
|
"rollup": "^4.43.0",
|
|
106
108
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
107
109
|
"rxjs": "^7.8.2",
|
|
@@ -119,7 +121,7 @@
|
|
|
119
121
|
"@types/cpx": "^1.5.5",
|
|
120
122
|
"@types/find-config": "^1.0.4",
|
|
121
123
|
"@types/git-url-parse": "^16.0.2",
|
|
122
|
-
"@types/node": "^
|
|
124
|
+
"@types/node": "^24.0.3",
|
|
123
125
|
"@types/prompts": "^2.4.9",
|
|
124
126
|
"@types/rimraf": "^3.0.2",
|
|
125
127
|
"@types/semver": "^7.5.8",
|
|
@@ -139,7 +141,7 @@
|
|
|
139
141
|
"ts-node": "^10.9.2",
|
|
140
142
|
"typescript": "5.8.3",
|
|
141
143
|
"vitest": "^3.2.4",
|
|
142
|
-
"@sanity/pkg-utils": "7.2.
|
|
144
|
+
"@sanity/pkg-utils": "7.2.10-canary.1"
|
|
143
145
|
},
|
|
144
146
|
"peerDependencies": {
|
|
145
147
|
"babel-plugin-react-compiler": "*",
|
|
@@ -155,6 +155,8 @@ export type ReactCompilerLogger = {
|
|
|
155
155
|
logEvent: (filename: string | null, event: ReactCompilerLoggerEvent) => void
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
export type DtsType = 'api-extractor' | 'rolldown'
|
|
159
|
+
|
|
158
160
|
/** @public */
|
|
159
161
|
export interface PkgConfigOptions {
|
|
160
162
|
/** @alpha */
|
|
@@ -170,7 +172,7 @@ export interface PkgConfigOptions {
|
|
|
170
172
|
displayName?: boolean
|
|
171
173
|
/**
|
|
172
174
|
* @defaultValue []
|
|
173
|
-
* @example ["
|
|
175
|
+
* @example ["\@xstyled/styled-components", "\@xstyled/styled-components/*"]
|
|
174
176
|
*/
|
|
175
177
|
topLevelImportPaths?: string[]
|
|
176
178
|
/** @defaultValue true */
|
|
@@ -203,7 +205,16 @@ export interface PkgConfigOptions {
|
|
|
203
205
|
*/
|
|
204
206
|
dist?: string
|
|
205
207
|
exports?: PkgConfigProperty<PkgExports>
|
|
208
|
+
/**
|
|
209
|
+
* Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.
|
|
210
|
+
* This is useful for packages that need to be consumed by TSDoc-based tooling.
|
|
211
|
+
* It's enabled by default, it can be disabled by setting `extract: {enabled: false}`
|
|
212
|
+
*/
|
|
206
213
|
extract?: {
|
|
214
|
+
/**
|
|
215
|
+
* @defaultValue true
|
|
216
|
+
*/
|
|
217
|
+
enabled?: boolean
|
|
207
218
|
/**
|
|
208
219
|
* Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.
|
|
209
220
|
* You can exclude a package from being bundled by using a callback:
|
|
@@ -295,4 +306,10 @@ export interface PkgConfigOptions {
|
|
|
295
306
|
* Configure what checks are made when running `--strict` builds and checks
|
|
296
307
|
*/
|
|
297
308
|
strictOptions?: StrictOptions
|
|
309
|
+
/**
|
|
310
|
+
* .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`.
|
|
311
|
+
* `rolldown` is the faster option, but is not yet stable.
|
|
312
|
+
* @defaultValue 'api-extractor'
|
|
313
|
+
*/
|
|
314
|
+
dts?: DtsType
|
|
298
315
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ts from 'typescript'
|
|
2
2
|
import type {Logger} from '../../logger'
|
|
3
|
-
import type {PkgConfigOptions, PkgExports, PkgRuntime} from '../config/types'
|
|
3
|
+
import type {DtsType, PkgConfigOptions, PkgExports, PkgRuntime} from '../config/types'
|
|
4
4
|
import type {PackageJSON} from '../pkg/types'
|
|
5
5
|
|
|
6
6
|
/** @internal */
|
|
@@ -28,4 +28,5 @@ export interface BuildContext {
|
|
|
28
28
|
config?: ts.ParsedCommandLine
|
|
29
29
|
configPath?: string
|
|
30
30
|
}
|
|
31
|
+
dts: DtsType
|
|
31
32
|
}
|
|
@@ -3,7 +3,7 @@ import type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types'
|
|
|
3
3
|
import type {BuildContext} from './core/contexts/buildContext'
|
|
4
4
|
import {getTargetPaths} from './tasks/dts/getTargetPaths'
|
|
5
5
|
import type {DtsTask} from './tasks/dts/types'
|
|
6
|
-
import type {BuildTask, RollupTask, RollupTaskEntry} from './tasks/types'
|
|
6
|
+
import type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types'
|
|
7
7
|
|
|
8
8
|
/** @internal */
|
|
9
9
|
export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
|
|
@@ -22,155 +22,178 @@ export function resolveBuildTasks(ctx: BuildContext): BuildTask[] {
|
|
|
22
22
|
entries: [],
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
const rolldownDtsTask: Record<string, RolldownDtsTask> = {}
|
|
25
26
|
const rollupTasks: Record<string, RollupTask> = {}
|
|
26
27
|
|
|
27
28
|
function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {
|
|
28
29
|
const buildId = `${format}:${runtime}`
|
|
29
30
|
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
if (ctx.dts === 'rolldown') {
|
|
32
|
+
if (rolldownDtsTask[buildId]) {
|
|
33
|
+
rolldownDtsTask[buildId].entries.push(entry)
|
|
34
|
+
} else {
|
|
35
|
+
rolldownDtsTask[buildId] = {
|
|
36
|
+
type: 'rolldown:dts',
|
|
37
|
+
buildId,
|
|
38
|
+
entries: [entry],
|
|
39
|
+
runtime,
|
|
40
|
+
format,
|
|
41
|
+
target: target[runtime],
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
|
-
}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
if (!ctx.emitDeclarationOnly) {
|
|
47
|
+
if (rollupTasks[buildId]) {
|
|
48
|
+
rollupTasks[buildId].entries.push(entry)
|
|
49
|
+
} else {
|
|
50
|
+
rollupTasks[buildId] = {
|
|
51
|
+
type: 'build:js',
|
|
52
|
+
buildId,
|
|
53
|
+
entries: [entry],
|
|
54
|
+
runtime,
|
|
55
|
+
format,
|
|
56
|
+
target: target[runtime],
|
|
57
|
+
}
|
|
58
|
+
}
|
|
55
59
|
}
|
|
60
|
+
}
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
if (ctx.dts === 'api-extractor') {
|
|
63
|
+
// Parse `dts` tasks
|
|
64
|
+
for (const exp of exports) {
|
|
65
|
+
const importId = path.join(pkg.name, exp._path)
|
|
66
|
+
|
|
67
|
+
if (exp.source?.endsWith('.ts')) {
|
|
68
|
+
dtsTask.entries.push({
|
|
69
|
+
importId,
|
|
70
|
+
exportPath: exp._path,
|
|
71
|
+
sourcePath: exp.source,
|
|
72
|
+
targetPaths: getTargetPaths(pkg.type, exp),
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (exp.browser?.source?.endsWith('.ts')) {
|
|
77
|
+
dtsTask.entries.push({
|
|
78
|
+
importId,
|
|
79
|
+
exportPath: exp._path,
|
|
80
|
+
sourcePath: exp.browser.source,
|
|
81
|
+
targetPaths: getTargetPaths(pkg.type, exp.browser),
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (exp.node?.source?.endsWith('.ts')) {
|
|
86
|
+
dtsTask.entries.push({
|
|
87
|
+
importId,
|
|
88
|
+
exportPath: exp._path,
|
|
89
|
+
sourcePath: exp.node.source,
|
|
90
|
+
targetPaths: getTargetPaths(pkg.type, exp.node),
|
|
91
|
+
})
|
|
92
|
+
}
|
|
64
93
|
}
|
|
65
94
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
targetPaths:
|
|
72
|
-
|
|
95
|
+
// Handle dts tasks for bundles
|
|
96
|
+
for (const bundle of bundles) {
|
|
97
|
+
if (bundle.source?.endsWith('.ts')) {
|
|
98
|
+
// importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`
|
|
99
|
+
// exportPath needs to be the path to the bundle, like `./dist/cli`
|
|
100
|
+
// targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]
|
|
101
|
+
const exportPath = (bundle.import || bundle.require)!.replace(/\.[mc]?js$/, '')
|
|
102
|
+
const importId = path.join(pkg.name, exportPath)
|
|
103
|
+
|
|
104
|
+
dtsTask.entries.push({
|
|
105
|
+
importId,
|
|
106
|
+
exportPath,
|
|
107
|
+
sourcePath: bundle.source,
|
|
108
|
+
targetPaths: getTargetPaths(pkg.type, bundle),
|
|
109
|
+
})
|
|
110
|
+
}
|
|
73
111
|
}
|
|
74
|
-
}
|
|
75
112
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`
|
|
80
|
-
// exportPath needs to be the path to the bundle, like `./dist/cli`
|
|
81
|
-
// targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]
|
|
82
|
-
const exportPath = (bundle.import || bundle.require)!.replace(/\.[mc]?js$/, '')
|
|
83
|
-
const importId = path.join(pkg.name, exportPath)
|
|
84
|
-
|
|
85
|
-
dtsTask.entries.push({
|
|
86
|
-
importId,
|
|
87
|
-
exportPath,
|
|
88
|
-
sourcePath: bundle.source,
|
|
89
|
-
targetPaths: getTargetPaths(pkg.type, bundle),
|
|
90
|
-
})
|
|
113
|
+
// Add dts task
|
|
114
|
+
if (dtsTask.entries.length) {
|
|
115
|
+
tasks.push(dtsTask)
|
|
91
116
|
}
|
|
92
117
|
}
|
|
93
118
|
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
119
|
+
// Parse rollup:commonjs:* tasks
|
|
120
|
+
for (const exp of exports) {
|
|
121
|
+
const output = exp.require
|
|
98
122
|
|
|
99
|
-
|
|
100
|
-
// Parse rollup:commonjs:* tasks
|
|
101
|
-
for (const exp of exports) {
|
|
102
|
-
const output = exp.require
|
|
123
|
+
if (!output) continue
|
|
103
124
|
|
|
104
|
-
|
|
125
|
+
addRollupTaskEntry('commonjs', ctx.runtime, {
|
|
126
|
+
path: exp._path,
|
|
127
|
+
source: exp.source,
|
|
128
|
+
output,
|
|
129
|
+
})
|
|
130
|
+
}
|
|
105
131
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
output,
|
|
110
|
-
})
|
|
111
|
-
}
|
|
132
|
+
// Parse rollup:esm:* tasks
|
|
133
|
+
for (const exp of exports) {
|
|
134
|
+
const output = exp.import
|
|
112
135
|
|
|
113
|
-
|
|
114
|
-
for (const exp of exports) {
|
|
115
|
-
const output = exp.import
|
|
136
|
+
if (!output) continue
|
|
116
137
|
|
|
117
|
-
|
|
138
|
+
addRollupTaskEntry('esm', ctx.runtime, {
|
|
139
|
+
path: exp._path,
|
|
140
|
+
source: exp.source,
|
|
141
|
+
output,
|
|
142
|
+
})
|
|
143
|
+
}
|
|
118
144
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
output,
|
|
123
|
-
})
|
|
124
|
-
}
|
|
145
|
+
// Parse rollup:commonjs:browser tasks
|
|
146
|
+
for (const exp of exports) {
|
|
147
|
+
const output = exp.browser?.require
|
|
125
148
|
|
|
126
|
-
|
|
127
|
-
for (const exp of exports) {
|
|
128
|
-
const output = exp.browser?.require
|
|
149
|
+
if (!output) continue
|
|
129
150
|
|
|
130
|
-
|
|
151
|
+
addRollupTaskEntry('commonjs', 'browser', {
|
|
152
|
+
path: exp._path,
|
|
153
|
+
source: exp.browser?.source || exp.source,
|
|
154
|
+
output,
|
|
155
|
+
})
|
|
156
|
+
}
|
|
131
157
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
output,
|
|
136
|
-
})
|
|
137
|
-
}
|
|
158
|
+
// Parse rollup:esm:browser tasks
|
|
159
|
+
for (const exp of exports) {
|
|
160
|
+
const output = exp.browser?.import
|
|
138
161
|
|
|
139
|
-
|
|
140
|
-
for (const exp of exports) {
|
|
141
|
-
const output = exp.browser?.import
|
|
162
|
+
if (!output) continue
|
|
142
163
|
|
|
143
|
-
|
|
164
|
+
addRollupTaskEntry('esm', 'browser', {
|
|
165
|
+
path: exp._path,
|
|
166
|
+
source: exp.browser?.source || exp.source,
|
|
167
|
+
output,
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
for (const bundle of bundles) {
|
|
172
|
+
const idx = bundles.indexOf(bundle)
|
|
144
173
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
174
|
+
if (bundle.require) {
|
|
175
|
+
addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {
|
|
176
|
+
path: `__$$bundle_cjs_${idx}$$__`,
|
|
177
|
+
source: bundle.source,
|
|
178
|
+
output: bundle.require,
|
|
149
179
|
})
|
|
150
180
|
}
|
|
151
181
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
source: bundle.source,
|
|
159
|
-
output: bundle.require,
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (bundle.import) {
|
|
164
|
-
addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {
|
|
165
|
-
path: `__$$bundle_esm_${idx}$$__`,
|
|
166
|
-
source: bundle.source,
|
|
167
|
-
output: bundle.import,
|
|
168
|
-
})
|
|
169
|
-
}
|
|
182
|
+
if (bundle.import) {
|
|
183
|
+
addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {
|
|
184
|
+
path: `__$$bundle_esm_${idx}$$__`,
|
|
185
|
+
source: bundle.source,
|
|
186
|
+
output: bundle.import,
|
|
187
|
+
})
|
|
170
188
|
}
|
|
171
|
-
|
|
172
|
-
tasks.push(...Object.values(rollupTasks))
|
|
173
189
|
}
|
|
174
190
|
|
|
191
|
+
// Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks
|
|
192
|
+
tasks.push(...Object.values(rolldownDtsTask))
|
|
193
|
+
// Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)
|
|
194
|
+
// @TODO
|
|
195
|
+
// Then run rollup tasks
|
|
196
|
+
tasks.push(...Object.values(rollupTasks))
|
|
197
|
+
|
|
175
198
|
return tasks
|
|
176
199
|
}
|
|
@@ -12,6 +12,7 @@ export function createApiExtractorConfig(options: {
|
|
|
12
12
|
mainEntryPointFilePath: string
|
|
13
13
|
tsconfig: ts.ParsedCommandLine
|
|
14
14
|
tsconfigPath: string
|
|
15
|
+
dtsRollupEnabled: boolean
|
|
15
16
|
}): IConfigFile {
|
|
16
17
|
const {
|
|
17
18
|
bundledPackages,
|
|
@@ -23,6 +24,7 @@ export function createApiExtractorConfig(options: {
|
|
|
23
24
|
mainEntryPointFilePath,
|
|
24
25
|
tsconfig,
|
|
25
26
|
tsconfigPath,
|
|
27
|
+
dtsRollupEnabled,
|
|
26
28
|
} = options
|
|
27
29
|
|
|
28
30
|
return {
|
|
@@ -50,7 +52,7 @@ export function createApiExtractorConfig(options: {
|
|
|
50
52
|
apiJsonFilePath: path.resolve(distPath, `${exportPath}.api.json`),
|
|
51
53
|
},
|
|
52
54
|
dtsRollup: {
|
|
53
|
-
enabled:
|
|
55
|
+
enabled: dtsRollupEnabled,
|
|
54
56
|
untrimmedFilePath: path.resolve(distPath, filePath),
|
|
55
57
|
// betaTrimmedFilePath: path.resolve(distPath, filePath.replace('.d.ts', '-beta.d.ts')),
|
|
56
58
|
// publicTrimmedFilePath: path.resolve(distPath, filePath.replace('.d.ts', '-public.d.ts')),
|
|
@@ -8,9 +8,9 @@ import type {DtsResult, DtsTask} from './types'
|
|
|
8
8
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
export const dtsTask: TaskHandler<DtsTask, DtsResult> = {
|
|
11
|
-
name: (
|
|
11
|
+
name: (ctx, task) =>
|
|
12
12
|
[
|
|
13
|
-
|
|
13
|
+
`Build type definitions with ${chalk.bold(ctx.dts)}...`,
|
|
14
14
|
' entries:',
|
|
15
15
|
...task.entries.map((entry) => {
|
|
16
16
|
return entry.targetPaths
|
|
@@ -111,6 +111,7 @@ export const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult> = {
|
|
|
111
111
|
tsconfig: tsContext.config!,
|
|
112
112
|
tmpPath,
|
|
113
113
|
tsconfigPath: path.resolve(cwd, tsContext.configPath || 'tsconfig.json'),
|
|
114
|
+
extractorDisabled: config?.extract?.enabled === false,
|
|
114
115
|
})
|
|
115
116
|
|
|
116
117
|
messages.push(...result.messages)
|
|
@@ -30,6 +30,10 @@ export async function extractTypes(options: {
|
|
|
30
30
|
tmpPath: string
|
|
31
31
|
tsconfig: ts.ParsedCommandLine
|
|
32
32
|
tsconfigPath: string
|
|
33
|
+
/**
|
|
34
|
+
* If the extractor is disabled then it means API Extractor is only used to bundle dts, and not check tsdoc release tags.
|
|
35
|
+
*/
|
|
36
|
+
extractorDisabled: boolean
|
|
33
37
|
}): Promise<{extractorResult: ExtractorResult; messages: ExtractorMessage[]}> {
|
|
34
38
|
const {
|
|
35
39
|
bundledPackages,
|
|
@@ -44,6 +48,7 @@ export async function extractTypes(options: {
|
|
|
44
48
|
tmpPath,
|
|
45
49
|
tsconfig,
|
|
46
50
|
tsconfigPath,
|
|
51
|
+
extractorDisabled,
|
|
47
52
|
} = options
|
|
48
53
|
|
|
49
54
|
const tsdocConfigFile = await createTSDocConfig({
|
|
@@ -59,11 +64,12 @@ export async function extractTypes(options: {
|
|
|
59
64
|
distPath,
|
|
60
65
|
exportPath,
|
|
61
66
|
filePath,
|
|
62
|
-
messages: getExtractMessagesConfig({rules}),
|
|
67
|
+
messages: getExtractMessagesConfig({rules, disabled: extractorDisabled}),
|
|
63
68
|
projectFolder: projectPath,
|
|
64
69
|
mainEntryPointFilePath: sourceTypesPath,
|
|
65
70
|
tsconfig,
|
|
66
71
|
tsconfigPath,
|
|
72
|
+
dtsRollupEnabled: true,
|
|
67
73
|
}),
|
|
68
74
|
configObjectFullPath: undefined,
|
|
69
75
|
tsdocConfigFile,
|
|
@@ -11,8 +11,9 @@ const LOG_LEVELS: Record<PkgRuleLevel, ExtractorLogLevel> = {
|
|
|
11
11
|
/** @alpha */
|
|
12
12
|
export function getExtractMessagesConfig(options: {
|
|
13
13
|
rules: NonNullable<PkgConfigOptions['extract']>['rules']
|
|
14
|
+
disabled?: boolean
|
|
14
15
|
}): IExtractorMessagesConfig {
|
|
15
|
-
const {rules} = options
|
|
16
|
+
const {rules, disabled = false} = options
|
|
16
17
|
|
|
17
18
|
function ruleToLogLevel(
|
|
18
19
|
key: keyof NonNullable<NonNullable<PkgConfigOptions['extract']>['rules']>,
|
|
@@ -26,66 +27,83 @@ export function getExtractMessagesConfig(options: {
|
|
|
26
27
|
return {
|
|
27
28
|
compilerMessageReporting: {
|
|
28
29
|
default: {
|
|
29
|
-
logLevel: 'warning' as ExtractorLogLevel,
|
|
30
|
+
logLevel: (disabled ? 'none' : 'warning') as ExtractorLogLevel,
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
33
|
|
|
33
|
-
extractorMessageReporting:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
extractorMessageReporting: disabled
|
|
35
|
+
? {
|
|
36
|
+
default: {
|
|
37
|
+
logLevel: 'none' as ExtractorLogLevel,
|
|
38
|
+
addToApiReportFile: false,
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
'default': {
|
|
43
|
+
logLevel: 'warning' as ExtractorLogLevel,
|
|
44
|
+
addToApiReportFile: false,
|
|
45
|
+
},
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
'ae-forgotten-export': {
|
|
48
|
+
/**
|
|
49
|
+
* This is hardcoded to `none` as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873
|
|
50
|
+
* It's hardcoded to `none` since supported by API Extractor when using `module: 'Preserve'` doesn't support it well since `@microsoft/api-extractor` v7.49.0, which upgraded from TS 5.4 to 5.7 internally
|
|
51
|
+
*/
|
|
52
|
+
logLevel: 'none' as ExtractorLogLevel,
|
|
53
|
+
addToApiReportFile: false,
|
|
54
|
+
},
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
'ae-incompatible-release-tags': {
|
|
57
|
+
logLevel: ruleToLogLevel('ae-incompatible-release-tags', 'error' as ExtractorLogLevel),
|
|
58
|
+
addToApiReportFile: false,
|
|
59
|
+
},
|
|
52
60
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
'ae-internal-missing-underscore': {
|
|
62
|
+
logLevel: ruleToLogLevel('ae-internal-missing-underscore'),
|
|
63
|
+
addToApiReportFile: false,
|
|
64
|
+
},
|
|
57
65
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
'ae-missing-release-tag': {
|
|
67
|
+
logLevel: ruleToLogLevel('ae-missing-release-tag', 'error' as ExtractorLogLevel),
|
|
68
|
+
addToApiReportFile: false,
|
|
69
|
+
},
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
'ae-wrong-input-file-type': {
|
|
72
|
+
logLevel: 'none' as ExtractorLogLevel,
|
|
73
|
+
addToApiReportFile: false,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
68
76
|
|
|
69
|
-
tsdocMessageReporting:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
tsdocMessageReporting: disabled
|
|
78
|
+
? {
|
|
79
|
+
default: {
|
|
80
|
+
logLevel: 'none' as ExtractorLogLevel,
|
|
81
|
+
addToApiReportFile: false,
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
: {
|
|
85
|
+
'default': {
|
|
86
|
+
logLevel: 'warning' as ExtractorLogLevel,
|
|
87
|
+
addToApiReportFile: false,
|
|
88
|
+
},
|
|
74
89
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
'tsdoc-link-tag-unescaped-text': {
|
|
91
|
+
logLevel: ruleToLogLevel(
|
|
92
|
+
'tsdoc-link-tag-unescaped-text',
|
|
93
|
+
'warning' as ExtractorLogLevel,
|
|
94
|
+
),
|
|
95
|
+
addToApiReportFile: false,
|
|
96
|
+
},
|
|
79
97
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
98
|
+
'tsdoc-undefined-tag': {
|
|
99
|
+
logLevel: ruleToLogLevel('tsdoc-undefined-tag', 'error' as ExtractorLogLevel),
|
|
100
|
+
addToApiReportFile: false,
|
|
101
|
+
},
|
|
84
102
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
'tsdoc-unsupported-tag': {
|
|
104
|
+
logLevel: ruleToLogLevel('tsdoc-unsupported-tag', 'none' as ExtractorLogLevel),
|
|
105
|
+
addToApiReportFile: false,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
90
108
|
}
|
|
91
109
|
}
|
package/src/node/tasks/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {dtsTask} from './dts/dtsTask'
|
|
2
2
|
import {dtsWatchTask} from './dts/dtsWatchTask'
|
|
3
|
+
import {rolldownDtsTask} from './rolldown/rolldownDtsTask'
|
|
3
4
|
import {rollupTask} from './rollup/rollupTask'
|
|
4
5
|
import {rollupWatchTask} from './rollup/rollupWatchTask'
|
|
5
6
|
import type {BuildTaskHandlers, WatchTaskHandlers} from './types'
|
|
@@ -8,6 +9,7 @@ import type {BuildTaskHandlers, WatchTaskHandlers} from './types'
|
|
|
8
9
|
export const buildTaskHandlers: BuildTaskHandlers = {
|
|
9
10
|
'build:dts': dtsTask,
|
|
10
11
|
'build:js': rollupTask,
|
|
12
|
+
'rolldown:dts': rolldownDtsTask,
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/** @internal */
|