@sanity/pkg-utils 5.0.7 → 5.0.8-canary.0

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.
@@ -85,7 +85,16 @@ async function buildTypes(options2) {
85
85
  declarationDir: outDir,
86
86
  emitDeclarationOnly: !0,
87
87
  noEmit: !1,
88
- outDir
88
+ outDir,
89
+ // Support the new `module: 'preserve'` option in TypeScript 5.4
90
+ ...tsconfig.options.module === ts__default.default.ModuleKind.Preserve ? {
91
+ // Set the equivalent options to `module: 'Preserve'`
92
+ // 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
93
+ module: ts__default.default.ModuleKind.ESNext,
94
+ moduleResolution: ts__default.default.ModuleResolutionKind.Bundler,
95
+ esModuleInterop: !0,
96
+ resolveJsonModule: !0
97
+ } : {}
89
98
  }, program = ts__default.default.createProgram(tsconfig.fileNames, compilerOptions), emitResult = program.emit(), allDiagnostics = ts__default.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
90
99
  for (const diagnostic of allDiagnostics)
91
100
  printDiagnostic({ cwd, logger, diagnostic });
@@ -106,6 +115,7 @@ function createApiExtractorConfig(options2) {
106
115
  messages,
107
116
  projectFolder,
108
117
  mainEntryPointFilePath,
118
+ tsconfig,
109
119
  tsconfigPath
110
120
  } = options2;
111
121
  return {
@@ -114,7 +124,21 @@ function createApiExtractorConfig(options2) {
114
124
  reportFileName: "<unscopedPackageName>.api.md"
115
125
  },
116
126
  bundledPackages,
117
- compiler: {
127
+ compiler: tsconfig.options.module === ts__default.default.ModuleKind.Preserve ? {
128
+ // When the module is 'preserve' it's necessary to override the tsconfig file as api-extractor doesn't handle it out of the box
129
+ overrideTsconfig: {
130
+ extends: tsconfigPath,
131
+ compilerOptions: {
132
+ // Set the equivalent options to `module: 'Preserve'`
133
+ // 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
134
+ module: "ESNext",
135
+ moduleResolution: "Bundler",
136
+ esModuleInterop: !0,
137
+ resolveJsonModule: !0
138
+ }
139
+ }
140
+ } : {
141
+ // If the module is not 'preserve', use the tsconfig file directly
118
142
  tsconfigFilePath: tsconfigPath
119
143
  },
120
144
  docModel: {
@@ -19598,6 +19622,7 @@ async function extractTypes(options2) {
19598
19622
  rules,
19599
19623
  sourceTypesPath,
19600
19624
  tmpPath,
19625
+ tsconfig,
19601
19626
  tsconfigPath
19602
19627
  } = options2, tsdocConfigFile = await createTSDocConfig({
19603
19628
  customTags: customTags || []
@@ -19610,6 +19635,7 @@ async function extractTypes(options2) {
19610
19635
  messages: getExtractMessagesConfig({ rules }),
19611
19636
  projectFolder: projectPath,
19612
19637
  mainEntryPointFilePath: sourceTypesPath,
19638
+ tsconfig,
19613
19639
  tsconfigPath
19614
19640
  }),
19615
19641
  configObjectFullPath: void 0,
@@ -19668,6 +19694,7 @@ async function doExtract(ctx, task) {
19668
19694
  projectPath: cwd,
19669
19695
  rules: config?.extract?.rules,
19670
19696
  sourceTypesPath,
19697
+ tsconfig: ts2.config,
19671
19698
  tmpPath,
19672
19699
  tsconfigPath: path__default.default.resolve(cwd, ts2.configPath || "tsconfig.json")
19673
19700
  });