@sanity/pkg-utils 6.13.3-canary.3 → 6.13.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "6.13.3-canary.3",
3
+ "version": "6.13.3",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -81,7 +81,7 @@
81
81
  "@rollup/plugin-replace": "^6.0.2",
82
82
  "@rollup/plugin-terser": "^0.4.4",
83
83
  "@sanity/browserslist-config": "^1.0.5",
84
- "browserslist": "^4.24.3",
84
+ "browserslist": "^4.24.4",
85
85
  "cac": "^6.7.14",
86
86
  "chalk": "^4.1.2",
87
87
  "chokidar": "^4.0.3",
@@ -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.3"
148
+ "@sanity/pkg-utils": "6.13.3"
149
149
  },
150
150
  "peerDependencies": {
151
151
  "babel-plugin-react-compiler": "*",
@@ -223,7 +223,7 @@ export interface PkgConfigOptions {
223
223
  customTags?: TSDocCustomTag[]
224
224
  rules?: {
225
225
  /**
226
- * @deprecated no longer needed since TypeScript 5.5 https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#consulting-package.json-dependencies-for-declaration-file-generation
226
+ * @deprecated as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873
227
227
  */
228
228
  'ae-forgotten-export'?: PkgRuleLevel
229
229
  'ae-incompatible-release-tags'?: PkgRuleLevel
@@ -260,6 +260,7 @@ export interface PkgConfigOptions {
260
260
  jsxImportSource?: string
261
261
  /**
262
262
  * Build package with support for legacy exports (writes root `<export>.js` files)
263
+ * @deprecated - will be removed in the next major version
263
264
  */
264
265
  legacyExports?: boolean
265
266
  minify?: boolean
@@ -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
- compiler: {tsconfigFilePath: tsconfigPath},
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,