@sanity/pkg-utils 6.6.4-canary.0 → 6.6.4-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "6.6.4-canary.0",
3
+ "version": "6.6.4-canary.1",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -136,7 +136,7 @@
136
136
  "typescript": "5.4.5",
137
137
  "vitest": "^1.5.0",
138
138
  "vitest-github-actions-reporter": "^0.11.1",
139
- "@sanity/pkg-utils": "6.6.4-canary.0"
139
+ "@sanity/pkg-utils": "6.6.4-canary.1"
140
140
  },
141
141
  "peerDependencies": {
142
142
  "typescript": "5.4.x"
@@ -19,6 +19,7 @@ export async function buildTypes(options: {
19
19
  declarationDir: outDir,
20
20
  emitDeclarationOnly: true,
21
21
  noEmit: false,
22
+ noEmitOnError: strict ? true : tsconfig.options.noEmitOnError ?? true,
22
23
  outDir,
23
24
  }
24
25
 
@@ -26,6 +26,34 @@ export function createApiExtractorConfig(options: {
26
26
  tsconfigPath,
27
27
  } = options
28
28
 
29
+ // When the module is 'preserve' it's necessary to override the tsconfig file as api-extractor doesn't handle it out of the box
30
+ const workaroundModulePreserve = tsconfig.options.module === ts.ModuleKind.Preserve
31
+ // 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`),
32
+ const workaroundPaths = !!tsconfig.options.paths
33
+
34
+ const overrideTsconfig = {
35
+ extends: tsconfigPath,
36
+ compilerOptions: {},
37
+ }
38
+
39
+ if (workaroundModulePreserve) {
40
+ Object.assign(overrideTsconfig.compilerOptions, {
41
+ // Set the equivalent options to `module: 'Preserve'`
42
+ // 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
43
+ module: 'ESNext',
44
+ moduleResolution: 'Bundler',
45
+ esModuleInterop: true,
46
+ resolveJsonModule: true,
47
+ })
48
+ }
49
+
50
+ if (workaroundPaths) {
51
+ Object.assign(overrideTsconfig.compilerOptions, {
52
+ // An empty object replaces whatever is in the original tsconfig file
53
+ paths: {},
54
+ })
55
+ }
56
+
29
57
  return {
30
58
  apiReport: {
31
59
  enabled: false,
@@ -33,25 +61,10 @@ export function createApiExtractorConfig(options: {
33
61
  },
34
62
  bundledPackages,
35
63
  compiler:
36
- tsconfig.options.module === ts.ModuleKind.Preserve
37
- ? {
38
- // When the module is 'preserve' it's necessary to override the tsconfig file as api-extractor doesn't handle it out of the box
39
- overrideTsconfig: {
40
- extends: tsconfigPath,
41
- compilerOptions: {
42
- // Set the equivalent options to `module: 'Preserve'`
43
- // 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
44
- module: 'ESNext',
45
- moduleResolution: 'Bundler',
46
- esModuleInterop: true,
47
- resolveJsonModule: true,
48
- },
49
- },
50
- }
51
- : {
52
- // If the module is not 'preserve', use the tsconfig file directly
53
- tsconfigFilePath: tsconfigPath,
54
- },
64
+ workaroundModulePreserve || workaroundPaths
65
+ ? {overrideTsconfig}
66
+ : {tsconfigFilePath: tsconfigPath},
67
+
55
68
  docModel: {
56
69
  enabled: false,
57
70
  apiJsonFilePath: path.resolve(distPath, `${exportPath}.api.json`),