@sanity/pkg-utils 6.13.3-canary.3 → 6.13.3-canary.4
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 +17 -1
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/node/tasks/dts/createApiExtractorConfig.ts +15 -1
- package/src/node/tasks/dts/doExtract.ts +2 -0
- package/src/node/tasks/dts/dtsWatchTask.ts +2 -0
- package/src/node/tasks/dts/extractTypes.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "6.13.3-canary.
|
|
3
|
+
"version": "6.13.3-canary.4",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"ts-node": "^10.9.2",
|
|
146
146
|
"typescript": "5.7.2",
|
|
147
147
|
"vitest": "^2.1.8",
|
|
148
|
-
"@sanity/pkg-utils": "6.13.3-canary.
|
|
148
|
+
"@sanity/pkg-utils": "6.13.3-canary.4"
|
|
149
149
|
},
|
|
150
150
|
"peerDependencies": {
|
|
151
151
|
"babel-plugin-react-compiler": "*",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
|
|
3
3
|
import type {IConfigFile, IExtractorMessagesConfig} from '@microsoft/api-extractor'
|
|
4
|
+
import ts from 'typescript'
|
|
4
5
|
|
|
5
6
|
export function createApiExtractorConfig(options: {
|
|
6
7
|
bundledPackages?: string[]
|
|
@@ -10,6 +11,7 @@ export function createApiExtractorConfig(options: {
|
|
|
10
11
|
messages: IExtractorMessagesConfig
|
|
11
12
|
projectFolder: string
|
|
12
13
|
mainEntryPointFilePath: string
|
|
14
|
+
tsconfig: ts.ParsedCommandLine
|
|
13
15
|
tsconfigPath: string
|
|
14
16
|
}): IConfigFile {
|
|
15
17
|
const {
|
|
@@ -20,6 +22,7 @@ export function createApiExtractorConfig(options: {
|
|
|
20
22
|
messages,
|
|
21
23
|
projectFolder,
|
|
22
24
|
mainEntryPointFilePath,
|
|
25
|
+
tsconfig,
|
|
23
26
|
tsconfigPath,
|
|
24
27
|
} = options
|
|
25
28
|
|
|
@@ -29,7 +32,18 @@ export function createApiExtractorConfig(options: {
|
|
|
29
32
|
reportFileName: '<unscopedPackageName>.api.md',
|
|
30
33
|
},
|
|
31
34
|
bundledPackages,
|
|
32
|
-
|
|
35
|
+
// If `paths` are used for self-referencing imports (e.g. the module is named `sanity`, and the `sanity/structure` export is also importing from `sanity/router`),
|
|
36
|
+
compiler: tsconfig.options.paths
|
|
37
|
+
? {
|
|
38
|
+
overrideTsconfig: {
|
|
39
|
+
extends: tsconfigPath,
|
|
40
|
+
compilerOptions: {
|
|
41
|
+
// An empty object replaces whatever is in the original tsconfig file
|
|
42
|
+
paths: {},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
: {tsconfigFilePath: tsconfigPath},
|
|
33
47
|
|
|
34
48
|
docModel: {
|
|
35
49
|
enabled: false,
|
|
@@ -50,6 +50,7 @@ export async function doExtract(
|
|
|
50
50
|
const result = await extractTypes({
|
|
51
51
|
bundledPackages: bundledPackages || [],
|
|
52
52
|
customTags: config?.extract?.customTags,
|
|
53
|
+
cwd,
|
|
53
54
|
distPath: outDir,
|
|
54
55
|
exportPath,
|
|
55
56
|
files,
|
|
@@ -57,6 +58,7 @@ export async function doExtract(
|
|
|
57
58
|
projectPath: cwd,
|
|
58
59
|
rules: config?.extract?.rules,
|
|
59
60
|
sourceTypesPath: sourceTypesPath,
|
|
61
|
+
tsconfig: ts.config,
|
|
60
62
|
tmpPath,
|
|
61
63
|
tsconfigPath: path.resolve(cwd, ts.configPath || 'tsconfig.json'),
|
|
62
64
|
})
|
|
@@ -102,6 +102,7 @@ export const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult> = {
|
|
|
102
102
|
const result = await extractTypes({
|
|
103
103
|
bundledPackages: bundledPackages || [],
|
|
104
104
|
customTags: config?.extract?.customTags,
|
|
105
|
+
cwd,
|
|
105
106
|
distPath: outDir,
|
|
106
107
|
exportPath,
|
|
107
108
|
files,
|
|
@@ -109,6 +110,7 @@ export const dtsWatchTask: TaskHandler<DtsWatchTask, DtsResult> = {
|
|
|
109
110
|
projectPath: cwd,
|
|
110
111
|
rules: config?.extract?.rules,
|
|
111
112
|
sourceTypesPath: sourceTypesPath,
|
|
113
|
+
tsconfig: tsContext.config!,
|
|
112
114
|
tmpPath,
|
|
113
115
|
tsconfigPath: path.resolve(cwd, tsContext.configPath || 'tsconfig.json'),
|
|
114
116
|
})
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from '@microsoft/api-extractor'
|
|
10
10
|
import {mkdirp} from 'mkdirp'
|
|
11
11
|
import prettier from 'prettier'
|
|
12
|
+
import type ts from 'typescript'
|
|
12
13
|
|
|
13
14
|
import type {BuildFile, PkgConfigOptions} from '../../core'
|
|
14
15
|
import {createApiExtractorConfig} from './createApiExtractorConfig'
|
|
@@ -19,6 +20,7 @@ import {getExtractMessagesConfig} from './getExtractMessagesConfig'
|
|
|
19
20
|
export async function extractTypes(options: {
|
|
20
21
|
bundledPackages?: string[]
|
|
21
22
|
customTags: NonNullable<PkgConfigOptions['extract']>['customTags']
|
|
23
|
+
cwd: string
|
|
22
24
|
distPath: string
|
|
23
25
|
exportPath: string
|
|
24
26
|
filePaths: string[]
|
|
@@ -27,6 +29,7 @@ export async function extractTypes(options: {
|
|
|
27
29
|
rules?: NonNullable<PkgConfigOptions['extract']>['rules']
|
|
28
30
|
sourceTypesPath: string
|
|
29
31
|
tmpPath: string
|
|
32
|
+
tsconfig: ts.ParsedCommandLine
|
|
30
33
|
tsconfigPath: string
|
|
31
34
|
}): Promise<{extractorResult: ExtractorResult; messages: ExtractorMessage[]}> {
|
|
32
35
|
const {
|
|
@@ -40,6 +43,7 @@ export async function extractTypes(options: {
|
|
|
40
43
|
rules,
|
|
41
44
|
sourceTypesPath,
|
|
42
45
|
tmpPath,
|
|
46
|
+
tsconfig,
|
|
43
47
|
tsconfigPath,
|
|
44
48
|
} = options
|
|
45
49
|
|
|
@@ -59,6 +63,7 @@ export async function extractTypes(options: {
|
|
|
59
63
|
messages: getExtractMessagesConfig({rules}),
|
|
60
64
|
projectFolder: projectPath,
|
|
61
65
|
mainEntryPointFilePath: sourceTypesPath,
|
|
66
|
+
tsconfig,
|
|
62
67
|
tsconfigPath,
|
|
63
68
|
}),
|
|
64
69
|
configObjectFullPath: undefined,
|