@sanity/pkg-utils 7.4.1-canary.0 → 7.5.1-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.
Files changed (75) hide show
  1. package/dist/_chunks-cjs/index.cjs +2022 -260
  2. package/dist/_chunks-cjs/index.cjs.map +1 -1
  3. package/dist/_chunks-es/build.js +106 -17
  4. package/dist/_chunks-es/build.js.map +1 -1
  5. package/dist/_chunks-es/check.js +125 -37
  6. package/dist/_chunks-es/check.js.map +1 -1
  7. package/dist/_chunks-es/consoleSpy.js +541 -0
  8. package/dist/_chunks-es/consoleSpy.js.map +1 -0
  9. package/dist/_chunks-es/index.js +774 -180
  10. package/dist/_chunks-es/index.js.map +1 -1
  11. package/dist/_chunks-es/init.js +493 -9
  12. package/dist/_chunks-es/init.js.map +1 -1
  13. package/dist/_chunks-es/{logger.js → isRecord.js} +15 -2
  14. package/dist/_chunks-es/isRecord.js.map +1 -0
  15. package/dist/_chunks-es/resolveRolldownConfig.js +1 -1
  16. package/dist/_chunks-es/spinner.js +16 -0
  17. package/dist/_chunks-es/spinner.js.map +1 -0
  18. package/dist/_chunks-es/watch.js +115 -9
  19. package/dist/_chunks-es/watch.js.map +1 -1
  20. package/dist/cli.d.ts +1 -1
  21. package/dist/cli.js +1 -1
  22. package/dist/index.d.cts +421 -487
  23. package/dist/index.d.ts +421 -487
  24. package/dist/index.js +7 -4
  25. package/dist/index.js.map +1 -1
  26. package/package.json +3 -2
  27. package/dist/_chunks-cjs/findConfigFile.cjs +0 -24
  28. package/dist/_chunks-cjs/findConfigFile.cjs.map +0 -1
  29. package/dist/_chunks-cjs/index2.cjs +0 -781
  30. package/dist/_chunks-cjs/index2.cjs.map +0 -1
  31. package/dist/_chunks-cjs/index3.cjs +0 -50
  32. package/dist/_chunks-cjs/index3.cjs.map +0 -1
  33. package/dist/_chunks-cjs/printPackageTree.cjs +0 -42
  34. package/dist/_chunks-cjs/printPackageTree.cjs.map +0 -1
  35. package/dist/_chunks-cjs/resolveBuildContext.cjs +0 -176
  36. package/dist/_chunks-cjs/resolveBuildContext.cjs.map +0 -1
  37. package/dist/_chunks-cjs/resolveBuildTasks.cjs +0 -111
  38. package/dist/_chunks-cjs/resolveBuildTasks.cjs.map +0 -1
  39. package/dist/_chunks-cjs/resolveConfigProperty.cjs +0 -6
  40. package/dist/_chunks-cjs/resolveConfigProperty.cjs.map +0 -1
  41. package/dist/_chunks-cjs/resolveWatchTasks.cjs +0 -79
  42. package/dist/_chunks-cjs/resolveWatchTasks.cjs.map +0 -1
  43. package/dist/_chunks-cjs/template.cjs +0 -446
  44. package/dist/_chunks-cjs/template.cjs.map +0 -1
  45. package/dist/_chunks-cjs/validatePkg.cjs +0 -71
  46. package/dist/_chunks-cjs/validatePkg.cjs.map +0 -1
  47. package/dist/_chunks-cjs/watchConfigFiles.cjs +0 -59
  48. package/dist/_chunks-cjs/watchConfigFiles.cjs.map +0 -1
  49. package/dist/_chunks-es/fileExists.js +0 -12
  50. package/dist/_chunks-es/fileExists.js.map +0 -1
  51. package/dist/_chunks-es/findConfigFile.js +0 -23
  52. package/dist/_chunks-es/findConfigFile.js.map +0 -1
  53. package/dist/_chunks-es/index2.js +0 -769
  54. package/dist/_chunks-es/index2.js.map +0 -1
  55. package/dist/_chunks-es/index3.js +0 -51
  56. package/dist/_chunks-es/index3.js.map +0 -1
  57. package/dist/_chunks-es/loadPkgWithReporting.js +0 -100
  58. package/dist/_chunks-es/loadPkgWithReporting.js.map +0 -1
  59. package/dist/_chunks-es/logger.js.map +0 -1
  60. package/dist/_chunks-es/printPackageTree.js +0 -44
  61. package/dist/_chunks-es/printPackageTree.js.map +0 -1
  62. package/dist/_chunks-es/resolveBuildContext.js +0 -177
  63. package/dist/_chunks-es/resolveBuildContext.js.map +0 -1
  64. package/dist/_chunks-es/resolveBuildTasks.js +0 -109
  65. package/dist/_chunks-es/resolveBuildTasks.js.map +0 -1
  66. package/dist/_chunks-es/resolveConfigProperty.js +0 -7
  67. package/dist/_chunks-es/resolveConfigProperty.js.map +0 -1
  68. package/dist/_chunks-es/resolveWatchTasks.js +0 -77
  69. package/dist/_chunks-es/resolveWatchTasks.js.map +0 -1
  70. package/dist/_chunks-es/template.js +0 -449
  71. package/dist/_chunks-es/template.js.map +0 -1
  72. package/dist/_chunks-es/validatePkg.js +0 -72
  73. package/dist/_chunks-es/validatePkg.js.map +0 -1
  74. package/dist/_chunks-es/watchConfigFiles.js +0 -45
  75. package/dist/_chunks-es/watchConfigFiles.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,10 +1,8 @@
1
- import type {PluginItem} from '@babel/core'
2
- import type {IExtractorMessagesConfig} from '@microsoft/api-extractor'
3
- import type {OptimizeLodashOptions} from '@optimize-lodash/rollup-plugin'
4
- import type {NormalizedOutputOptions, TreeshakingOptions} from 'rollup'
5
- import {Plugin as RollupPlugin} from 'rollup'
6
- import {z} from 'zod'
7
-
1
+ import { PluginItem } from "@babel/core";
2
+ import { OptimizeLodashOptions } from "@optimize-lodash/rollup-plugin";
3
+ import { NormalizedOutputOptions, Plugin, Plugin as RollupPlugin, TreeshakingOptions } from "rollup";
4
+ import { z } from "zod";
5
+ import { IExtractorMessagesConfig } from "@microsoft/api-extractor";
8
6
  /**
9
7
  * Build the distribution files of a npm package.
10
8
  *
@@ -24,218 +22,274 @@ import {z} from 'zod'
24
22
  *
25
23
  * @public
26
24
  */
27
- export declare function build(options: {
28
- cwd: string
29
- emitDeclarationOnly?: boolean
30
- strict?: boolean
31
- tsconfig?: string
32
- clean?: boolean
33
- }): Promise<void>
34
-
25
+ declare function build(options: {
26
+ cwd: string;
27
+ emitDeclarationOnly?: boolean;
28
+ strict?: boolean;
29
+ tsconfig?: string;
30
+ clean?: boolean;
31
+ }): Promise<void>;
35
32
  /** @public */
36
- export declare function check(options: {
37
- cwd: string
38
- strict?: boolean
39
- tsconfig?: string
40
- }): Promise<void>
41
-
33
+ declare function check(options: {
34
+ cwd: string;
35
+ strict?: boolean;
36
+ tsconfig?: string;
37
+ }): Promise<void>;
38
+ /**
39
+ * @public
40
+ */
41
+ declare const toggle: z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>;
42
+ /**
43
+ * @public
44
+ */
45
+ type ToggleType = z.infer<typeof toggle>;
46
+ /**
47
+ * @public
48
+ */
49
+ declare const strictOptions: z.ZodObject<{
50
+ noPackageJsonTypings: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
51
+ noImplicitSideEffects: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
52
+ noImplicitBrowsersList: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
53
+ alwaysPackageJsonTypes: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
54
+ alwaysPackageJsonMain: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
55
+ alwaysPackageJsonFiles: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
56
+ }, "strict", z.ZodTypeAny, {
57
+ noPackageJsonTypings: "error" | "off" | "warn";
58
+ noImplicitSideEffects: "error" | "off" | "warn";
59
+ noImplicitBrowsersList: "error" | "off" | "warn";
60
+ alwaysPackageJsonTypes: "error" | "off" | "warn";
61
+ alwaysPackageJsonMain: "error" | "off" | "warn";
62
+ alwaysPackageJsonFiles: "error" | "off" | "warn";
63
+ }, {
64
+ noPackageJsonTypings?: "error" | "off" | "warn" | undefined;
65
+ noImplicitSideEffects?: "error" | "off" | "warn" | undefined;
66
+ noImplicitBrowsersList?: "error" | "off" | "warn" | undefined;
67
+ alwaysPackageJsonTypes?: "error" | "off" | "warn" | undefined;
68
+ alwaysPackageJsonMain?: "error" | "off" | "warn" | undefined;
69
+ alwaysPackageJsonFiles?: "error" | "off" | "warn" | undefined;
70
+ }>;
71
+ /**
72
+ * @public
73
+ */
74
+ type InferredStrictOptions = z.infer<typeof strictOptions>;
75
+ /**
76
+ * @public
77
+ */
78
+ interface StrictOptions {
79
+ /**
80
+ * Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.
81
+ * @defaultValue 'error'
82
+ */
83
+ noPackageJsonTypings?: ToggleType;
84
+ /**
85
+ * Requires specifying `sideEffects` in `package.json`.
86
+ * @defaultValue 'warn'
87
+ */
88
+ noImplicitSideEffects?: ToggleType;
89
+ /**
90
+ * Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:
91
+ * @example
92
+ * ```
93
+ * "browserslist": "extends @sanity/browserslist-config"
94
+ * ```
95
+ * @defaultValue 'warn'
96
+ */
97
+ noImplicitBrowsersList?: ToggleType;
98
+ /**
99
+ * If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon.
100
+ * @defaultValue 'error'
101
+ */
102
+ alwaysPackageJsonTypes?: ToggleType;
103
+ /**
104
+ * A lot of analysis tooling requiers the `main` field to work (like bundlephobia) and so it's best practice to always include it
105
+ * @defaultValue 'error'
106
+ */
107
+ alwaysPackageJsonMain?: ToggleType;
108
+ /**
109
+ * Using `.npmignore` is error prone, it's best practice to always declare `files` instead
110
+ * @defaultValue 'error'
111
+ */
112
+ alwaysPackageJsonFiles?: ToggleType;
113
+ }
42
114
  /** @alpha */
43
- export declare function createLogger(): Logger
44
-
115
+ declare function parseStrictOptions(input: unknown): InferredStrictOptions;
45
116
  /** @public */
46
- export declare const DEFAULT_BROWSERSLIST_QUERY: string[]
47
-
117
+ type PkgFormat = 'commonjs' | 'esm';
48
118
  /** @public */
49
- export declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T
50
-
119
+ type PkgRuntime = '*' | 'browser' | 'node';
51
120
  /** @public */
52
- export declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>
53
-
54
- declare type DtsType = 'api-extractor' | 'rolldown'
55
-
56
- /** @alpha */
57
- export declare function getExtractMessagesConfig(options: {
58
- rules: NonNullable<PkgConfigOptions['extract']>['rules']
59
- disabled?: boolean
60
- }): IExtractorMessagesConfig
61
-
62
- /**
63
- * @public
64
- */
65
- export declare type InferredStrictOptions = z.infer<typeof strictOptions>
66
-
121
+ interface PkgExport {
122
+ /** @internal */
123
+ _exported?: boolean;
124
+ browser?: {
125
+ source: string;
126
+ import?: string;
127
+ require?: string;
128
+ };
129
+ // electron?: {
130
+ // node?: string
131
+ // default?: string
132
+ // }
133
+ node?: {
134
+ source?: string;
135
+ import?: string;
136
+ require?: string;
137
+ };
138
+ types?: string;
139
+ source: string;
140
+ import?: string;
141
+ require?: string;
142
+ default: string;
143
+ }
67
144
  /** @public */
68
- export declare function init(options: {cwd: string; path: string}): Promise<void>
69
-
70
- /** @alpha */
71
- export declare function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined>
72
-
73
- /** @internal */
74
- export declare function loadPkg(options: {cwd: string}): Promise<PackageJSON>
75
-
76
- /** @alpha */
77
- export declare function loadPkgWithReporting(options: {
78
- cwd: string
79
- logger: Logger
80
- strict: boolean
81
- }): Promise<PackageJSON>
82
-
83
- /** @alpha */
84
- declare interface Logger {
85
- log: (...args: unknown[]) => void
86
- info: (...args: unknown[]) => void
87
- warn: (...args: unknown[]) => void
88
- error: (...args: unknown[]) => void
89
- success: (...args: unknown[]) => void
145
+ type PkgConfigPropertyResolver<T> = (prev: T) => T;
146
+ /** @public */
147
+ type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T;
148
+ /** @public */
149
+ interface PkgBundle {
150
+ source: string;
151
+ import?: string;
152
+ require?: string;
153
+ runtime?: PkgRuntime;
90
154
  }
91
-
92
- /** @alpha */
93
- export declare interface PackageJSON {
94
- type?: 'commonjs' | 'module'
95
- version: string
96
- private?: boolean
97
- author?:
98
- | string
99
- | {
100
- name: string
101
- email?: string
102
- url?: string
103
- }
104
- name: string
105
- description?: string
106
- keywords?: string[]
107
- bin?: Record<string, string>
108
- dependencies?: Record<string, string | undefined>
109
- devDependencies?: Record<string, string | undefined>
110
- peerDependencies?: Record<string, string | undefined>
111
- exports?: Record<
112
- string,
113
- | `./${string}.json`
114
- | `./${string}.css`
115
- | {
116
- source?: string
117
- types?: string
118
- browser?: {
119
- source: string
120
- import?: string
121
- require?: string
122
- }
123
- node?: {
124
- source?: string
125
- module?: string
126
- import?: string
127
- require?: string
128
- }
129
- module?: string
130
- import?: string
131
- require?: string
132
- default: string
133
- }
134
- | {
135
- types?: string
136
- svelte: string
137
- default?: string
138
- }
139
- >
140
- main?: string
141
- browser?: Record<string, string>
142
- source?: string
143
- module?: string
144
- types?: string
145
- files?: string[]
146
- scripts?: Record<string, string | undefined>
147
- browserslist?: string | string[]
148
- sideEffects?: boolean | string[]
149
- engines?: {
150
- node?: string
151
- npm?: string
152
- }
153
- repository?:
154
- | string
155
- | {
156
- type: 'git'
157
- url: string
158
- }
159
- bugs?:
160
- | string
161
- | {
162
- url: string
163
- email?: string
164
- }
165
- homepage?: string
166
- license?: string
155
+ /** @public */
156
+ interface PkgExports {
157
+ [path: string]: PkgExport;
167
158
  }
168
-
169
- /** @alpha */
170
- export declare function parseExports(options: {
171
- cwd: string
172
- pkg: PackageJSON
173
- strict: boolean
174
- strictOptions: InferredStrictOptions
175
- logger: Logger
176
- }): (PkgExport & {
177
- _path: string
178
- })[]
179
-
180
- /** @alpha */
181
- export declare function parseStrictOptions(input: unknown): InferredStrictOptions
182
-
183
159
  /** @public */
184
- export declare interface PkgBundle {
185
- source: string
186
- import?: string
187
- require?: string
188
- runtime?: PkgRuntime
160
+ type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off';
161
+ /** @public */
162
+ interface TSDocCustomTag {
163
+ name: string;
164
+ syntaxKind: 'block' | 'modifier';
165
+ allowMultiple?: boolean;
189
166
  }
190
-
167
+ /**
168
+ * Until these types are on npm: https://github.com/facebook/react/blob/0bc30748730063e561d87a24a4617526fdd38349/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts#L39-L122
169
+ * @alpha
170
+ */
171
+ interface ReactCompilerOptions {
172
+ logger?: ReactCompilerLogger | null;
173
+ panicThreshold?: 'ALL_ERRORS' | 'CRITICAL_ERRORS' | 'NONE';
174
+ compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all';
175
+ /*
176
+ * If enabled, Forget will import `useMemoCache` from the given module
177
+ * instead of `react/compiler-runtime`.
178
+ *
179
+ * ```
180
+ * // If set to "react-compiler-runtime"
181
+ * import {c as useMemoCache} from 'react-compiler-runtime';
182
+ * ```
183
+ */
184
+ runtimeModule?: string | null | undefined;
185
+ /**
186
+ * By default React Compiler will skip compilation of code that suppresses the default
187
+ * React ESLint rules, since this is a strong indication that the code may be breaking React rules
188
+ * in some way.
189
+ *
190
+ * Use eslintSuppressionRules to pass a custom set of rule names: any code which suppresses the
191
+ * provided rules will skip compilation. To disable this feature (never bailout of compilation
192
+ * even if the default ESLint is suppressed), pass an empty array.
193
+ */
194
+ eslintSuppressionRules?: Array<string> | null | undefined;
195
+ sources?: Array<string> | ((filename: string) => boolean) | null;
196
+ /**
197
+ * The minimum major version of React that the compiler should emit code for. If the target is 19
198
+ * or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
199
+ * versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
200
+ * a userspace approximation of runtime APIs.
201
+ */
202
+ target: '17' | '18' | '19';
203
+ }
204
+ /**
205
+ * @alpha
206
+ * Represents 'events' that may occur during compilation. Events are only
207
+ * recorded when a logger is set (through the config).
208
+ * These are the different types of events:
209
+ * CompileError:
210
+ * Forget skipped compilation of a function / file due to a known todo,
211
+ * invalid input, or compiler invariant being broken.
212
+ * CompileSuccess:
213
+ * Forget successfully compiled a function.
214
+ * PipelineError:
215
+ * Unexpected errors that occurred during compilation (e.g. failures in
216
+ * babel or other unhandled exceptions).
217
+ */
218
+ type ReactCompilerLoggerEvent = {
219
+ kind: 'CompileError';
220
+ fnLoc: unknown;
221
+ detail: unknown;
222
+ } | {
223
+ kind: 'CompileDiagnostic';
224
+ fnLoc: unknown;
225
+ detail: unknown;
226
+ } | {
227
+ kind: 'CompileSuccess';
228
+ fnLoc: unknown;
229
+ fnName: string | null;
230
+ memoSlots: number;
231
+ memoBlocks: number;
232
+ memoValues: number;
233
+ prunedMemoBlocks: number;
234
+ prunedMemoValues: number;
235
+ } | {
236
+ kind: 'PipelineError';
237
+ fnLoc: unknown;
238
+ data: string;
239
+ };
240
+ /**
241
+ * @alpha
242
+ */
243
+ type ReactCompilerLogger = {
244
+ logEvent: (filename: string | null, event: ReactCompilerLoggerEvent) => void;
245
+ };
246
+ type DtsType = 'api-extractor' | 'rolldown';
191
247
  /** @public */
192
- export declare interface PkgConfigOptions {
248
+ interface PkgConfigOptions {
193
249
  /** @alpha */
194
250
  babel?: {
195
- plugins?: PluginItem[] | null | undefined
251
+ plugins?: PluginItem[] | null | undefined;
196
252
  /** @alpha */
197
- reactCompiler?: boolean
253
+ reactCompiler?: boolean;
198
254
  /** @alpha */
199
- styledComponents?:
200
- | boolean
201
- | {
202
- /** @defaultValue true */
203
- displayName?: boolean
204
- /**
205
- * @defaultValue []
206
- * @example ["\@xstyled/styled-components", "\@xstyled/styled-components/*"]
207
- */
208
- topLevelImportPaths?: string[]
209
- /** @defaultValue true */
210
- ssr?: boolean
211
- /** @defaultValue fale */
212
- fileName?: boolean
213
- /** @defaultValue ["index"] */
214
- meaninglessFileNames?: string[]
215
- /** @defaultValue true */
216
- minify?: boolean
217
- /** @defaultValue false */
218
- transpileTemplateLiterals?: boolean
219
- namespace?: string
220
- /** @defaultValue true */
221
- pure?: boolean
222
- }
223
- }
255
+ styledComponents?: boolean | {
256
+ /** @defaultValue true */
257
+ displayName?: boolean;
258
+ /**
259
+ * @defaultValue []
260
+ * @example ["\@xstyled/styled-components", "\@xstyled/styled-components/*"]
261
+ */
262
+ topLevelImportPaths?: string[];
263
+ /** @defaultValue true */
264
+ ssr?: boolean;
265
+ /** @defaultValue fale */
266
+ fileName?: boolean;
267
+ /** @defaultValue ["index"] */
268
+ meaninglessFileNames?: string[];
269
+ /** @defaultValue true */
270
+ minify?: boolean;
271
+ /** @defaultValue false */
272
+ transpileTemplateLiterals?: boolean;
273
+ namespace?: string;
274
+ /** @defaultValue true */
275
+ pure?: boolean;
276
+ };
277
+ };
224
278
  /**
225
279
  * Configure the React Compiler.
226
280
  * To enable it, either:
227
281
  * - set `babel.reactCompiler` to `true`
228
282
  * - add a `react-compiler` export condition, before any `browser`, `require` or `import` conditions. After any `react-server` and `node` conditions
229
283
  * @alpha */
230
- reactCompilerOptions?: ReactCompilerOptions
231
- bundles?: PkgBundle[]
284
+ reactCompilerOptions?: ReactCompilerOptions;
285
+ bundles?: PkgBundle[];
232
286
  /** @alpha */
233
- define?: Record<string, string | number | boolean | undefined | null>
287
+ define?: Record<string, string | number | boolean | undefined | null>;
234
288
  /**
235
289
  * Directory of distributed & bundled files.
236
290
  */
237
- dist?: string
238
- exports?: PkgConfigProperty<PkgExports>
291
+ dist?: string;
292
+ exports?: PkgConfigProperty<PkgExports>;
239
293
  /**
240
294
  * Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.
241
295
  * This is useful for packages that need to be consumed by TSDoc-based tooling.
@@ -245,7 +299,7 @@ export declare interface PkgConfigOptions {
245
299
  /**
246
300
  * @defaultValue true
247
301
  */
248
- enabled?: boolean
302
+ enabled?: boolean;
249
303
  /**
250
304
  * Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.
251
305
  * You can exclude a package from being bundled by using a callback:
@@ -253,21 +307,21 @@ export declare interface PkgConfigOptions {
253
307
  * bundledPackages: (prev) => prev.filter(package => package !== 'sanity')
254
308
  * ```
255
309
  */
256
- bundledPackages?: PkgConfigProperty<string[]>
257
- customTags?: TSDocCustomTag[]
310
+ bundledPackages?: PkgConfigProperty<string[]>;
311
+ customTags?: TSDocCustomTag[];
258
312
  rules?: {
259
313
  /**
260
314
  * @deprecated as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873
261
315
  */
262
- 'ae-forgotten-export'?: never
263
- 'ae-incompatible-release-tags'?: PkgRuleLevel
264
- 'ae-internal-missing-underscore'?: PkgRuleLevel
265
- 'ae-missing-release-tag'?: PkgRuleLevel
266
- 'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel
267
- 'tsdoc-undefined-tag'?: PkgRuleLevel
268
- 'tsdoc-unsupported-tag'?: PkgRuleLevel
269
- }
270
- }
316
+ 'ae-forgotten-export'?: never;
317
+ 'ae-incompatible-release-tags'?: PkgRuleLevel;
318
+ 'ae-internal-missing-underscore'?: PkgRuleLevel;
319
+ 'ae-missing-release-tag'?: PkgRuleLevel;
320
+ 'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel;
321
+ 'tsdoc-undefined-tag'?: PkgRuleLevel;
322
+ 'tsdoc-unsupported-tag'?: PkgRuleLevel;
323
+ };
324
+ };
271
325
  /**
272
326
  * Packages to exclude from bundles.
273
327
  * Provide an array to merge with default exclusions, use a function to replace them:
@@ -275,45 +329,45 @@ export declare interface PkgConfigOptions {
275
329
  * exclude: (prev) => prev.filter(package => package !== 'foo')
276
330
  * ```
277
331
  */
278
- external?: PkgConfigProperty<string[]>
332
+ external?: PkgConfigProperty<string[]>;
279
333
  /**
280
334
  * Defaults to `"automatic"`
281
335
  */
282
- jsx?: 'transform' | 'preserve' | 'automatic'
336
+ jsx?: 'transform' | 'preserve' | 'automatic';
283
337
  /**
284
338
  * Defaults to `"createElement"`
285
339
  */
286
- jsxFactory?: string
340
+ jsxFactory?: string;
287
341
  /**
288
342
  * Defaults to `"Fragment"`
289
343
  */
290
- jsxFragment?: string
344
+ jsxFragment?: string;
291
345
  /**
292
346
  * Defaults to `"react"`
293
347
  */
294
- jsxImportSource?: string
348
+ jsxImportSource?: string;
295
349
  /**
296
350
  * @deprecated no longer supported
297
351
  */
298
- legacyExports?: never
299
- minify?: boolean
352
+ legacyExports?: never;
353
+ minify?: boolean;
300
354
  /** @alpha */
301
355
  rollup?: {
302
- plugins?: PkgConfigProperty<RollupPlugin[]>
303
- output?: Partial<NormalizedOutputOptions>
356
+ plugins?: PkgConfigProperty<Plugin[]>;
357
+ output?: Partial<NormalizedOutputOptions>;
304
358
  /**
305
359
  * Default options are `preset: 'recommended'` and `propertyReadSideEffects: false`
306
360
  * @alpha
307
361
  */
308
- treeshake?: TreeshakingOptions
362
+ treeshake?: TreeshakingOptions;
309
363
  /** @alpha */
310
- experimentalLogSideEffects?: boolean
364
+ experimentalLogSideEffects?: boolean;
311
365
  /**
312
366
  * Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
313
367
  * It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
314
368
  * @defaultValue false
315
369
  */
316
- hashChunkFileNames?: boolean
370
+ hashChunkFileNames?: boolean;
317
371
  /**
318
372
  * Optimizes lodash imports using `@optimize-lodash/rollup-plugin` when set to `true`.
319
373
  * It's enabled if `lodash` is found in `dependencies` or `peerDependencies`.
@@ -321,302 +375,182 @@ export declare interface PkgConfigOptions {
321
375
  * @defaultValue true
322
376
  * @alpha
323
377
  */
324
- optimizeLodash?: boolean | OptimizeLodashOptions
325
- }
378
+ optimizeLodash?: boolean | OptimizeLodashOptions;
379
+ };
326
380
  /**
327
381
  * Default runtime of package exports
328
382
  */
329
- runtime?: PkgRuntime
330
- sourcemap?: boolean
383
+ runtime?: PkgRuntime;
384
+ sourcemap?: boolean;
331
385
  /**
332
386
  * Directory of source files.
333
387
  */
334
- src?: string
335
- tsconfig?: string
388
+ src?: string;
389
+ tsconfig?: string;
336
390
  /**
337
391
  * Configure what checks are made when running `--strict` builds and checks
338
392
  */
339
- strictOptions?: StrictOptions
393
+ strictOptions?: StrictOptions;
340
394
  /**
341
395
  * .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`.
342
396
  * `rolldown` is the faster option, but is not yet stable.
343
397
  * @defaultValue 'api-extractor'
344
398
  */
345
- dts?: DtsType
399
+ dts?: DtsType;
346
400
  }
347
-
348
401
  /** @public */
349
- export declare type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T
350
-
351
- /** @public */
352
- export declare type PkgConfigPropertyResolver<T> = (prev: T) => T
353
-
402
+ declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
403
+ /** @alpha */
404
+ declare function loadConfig(options: {
405
+ cwd: string;
406
+ }): Promise<PkgConfigOptions | undefined>;
354
407
  /** @public */
355
- export declare interface PkgExport {
356
- /** @internal */
357
- _exported?: boolean
358
- browser?: {
359
- source: string
360
- import?: string
361
- require?: string
362
- }
363
- node?: {
364
- source?: string
365
- import?: string
366
- require?: string
367
- }
368
- types?: string
369
- source: string
370
- import?: string
371
- require?: string
372
- default: string
408
+ declare const DEFAULT_BROWSERSLIST_QUERY: string[];
409
+ /** @alpha */
410
+ interface PackageJSON {
411
+ type?: 'commonjs' | 'module';
412
+ version: string;
413
+ private?: boolean;
414
+ author?: string | {
415
+ name: string;
416
+ email?: string;
417
+ url?: string;
418
+ };
419
+ name: string;
420
+ description?: string;
421
+ keywords?: string[];
422
+ bin?: Record<string, string>;
423
+ dependencies?: Record<string, string | undefined>;
424
+ devDependencies?: Record<string, string | undefined>;
425
+ peerDependencies?: Record<string, string | undefined>;
426
+ exports?: Record<string, `./${string}.json` | `./${string}.css` | {
427
+ source?: string;
428
+ types?: string;
429
+ browser?: {
430
+ source: string;
431
+ import?: string;
432
+ require?: string;
433
+ };
434
+ node?: {
435
+ source?: string;
436
+ module?: string;
437
+ import?: string;
438
+ require?: string;
439
+ };
440
+ module?: string;
441
+ import?: string;
442
+ require?: string;
443
+ default: string;
444
+ } | {
445
+ types?: string;
446
+ svelte: string;
447
+ default?: string;
448
+ }>;
449
+ main?: string;
450
+ browser?: Record<string, string>;
451
+ source?: string;
452
+ module?: string;
453
+ types?: string;
454
+ files?: string[];
455
+ scripts?: Record<string, string | undefined>;
456
+ browserslist?: string | string[];
457
+ sideEffects?: boolean | string[];
458
+ engines?: {
459
+ node?: string;
460
+ npm?: string;
461
+ };
462
+ repository?: string | {
463
+ type: 'git';
464
+ url: string;
465
+ };
466
+ bugs?: string | {
467
+ url: string;
468
+ email?: string;
469
+ };
470
+ homepage?: string;
471
+ license?: string;
373
472
  }
374
-
375
- /** @public */
376
- export declare interface PkgExports {
377
- [path: string]: PkgExport
473
+ /** @internal */
474
+ declare function loadPkg(options: {
475
+ cwd: string;
476
+ }): Promise<PackageJSON>;
477
+ /** @alpha */
478
+ interface Logger {
479
+ log: (...args: unknown[]) => void;
480
+ info: (...args: unknown[]) => void;
481
+ warn: (...args: unknown[]) => void;
482
+ error: (...args: unknown[]) => void;
483
+ success: (...args: unknown[]) => void;
378
484
  }
379
-
380
- /** @public */
381
- export declare type PkgFormat = 'commonjs' | 'esm'
382
-
485
+ /** @alpha */
486
+ declare function createLogger(): Logger;
487
+ /** @alpha */
488
+ declare function loadPkgWithReporting(options: {
489
+ cwd: string;
490
+ logger: Logger;
491
+ strict: boolean;
492
+ }): Promise<PackageJSON>;
493
+ /** @alpha */
494
+ declare function parseExports(options: {
495
+ cwd: string;
496
+ pkg: PackageJSON;
497
+ strict: boolean;
498
+ strictOptions: InferredStrictOptions;
499
+ logger: Logger;
500
+ }): (PkgExport & {
501
+ _path: string;
502
+ })[];
383
503
  /** @public */
384
- export declare type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'
385
-
504
+ interface PkgTemplateFile {
505
+ name: string;
506
+ contents: string;
507
+ }
386
508
  /** @public */
387
- export declare type PkgRuntime = '*' | 'browser' | 'node'
388
-
509
+ interface PkgTemplateStringOption<T = string> {
510
+ name: string;
511
+ type: 'string';
512
+ description: string;
513
+ initial?: T | ((options: Record<string, any>) => T);
514
+ parse?: (v: string) => T | null;
515
+ validate?: (v: string) => string | true;
516
+ }
389
517
  /** @public */
390
- export declare type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver
391
-
518
+ type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;
392
519
  /** @public */
393
- export declare interface PkgTemplateDefinition {
394
- options: PkgTemplateStringOption<any>[]
520
+ interface PkgTemplateDefinition {
521
+ options: PkgTemplateStringOption<any>[];
395
522
  features: {
396
- name: string
397
- optional: boolean
398
- initial: boolean
399
- }[]
400
- getFiles: (
401
- options: Record<string, any>,
402
- features: Record<string, boolean>,
403
- ) => Promise<PkgTemplateFile[]>
404
- }
405
-
406
- /** @public */
407
- export declare interface PkgTemplateFile {
408
- name: string
409
- contents: string
523
+ name: string;
524
+ optional: boolean;
525
+ initial: boolean;
526
+ }[];
527
+ getFiles: (options: Record<string, any>, features: Record<string, boolean>) => Promise<PkgTemplateFile[]>;
410
528
  }
411
-
412
529
  /** @public */
413
- export declare type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
414
-
415
- /** @public */
416
- export declare type PkgTemplateResolver = (options: {
417
- cwd: string
530
+ type PkgTemplateResolver = (options: {
531
+ cwd: string;
418
532
  /** @internal */
419
- logger: Logger
420
- packagePath: string
421
- }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>
422
-
533
+ logger: Logger;
534
+ packagePath: string;
535
+ }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;
423
536
  /** @public */
424
- export declare interface PkgTemplateStringOption<T = string> {
425
- name: string
426
- type: 'string'
427
- description: string
428
- initial?: T | ((options: Record<string, any>) => T)
429
- parse?: (v: string) => T | null
430
- validate?: (v: string) => string | true
431
- }
432
-
433
- /**
434
- * @alpha
435
- */
436
- export declare type ReactCompilerLogger = {
437
- logEvent: (filename: string | null, event: ReactCompilerLoggerEvent) => void
438
- }
439
-
440
- /**
441
- * @alpha
442
- * Represents 'events' that may occur during compilation. Events are only
443
- * recorded when a logger is set (through the config).
444
- * These are the different types of events:
445
- * CompileError:
446
- * Forget skipped compilation of a function / file due to a known todo,
447
- * invalid input, or compiler invariant being broken.
448
- * CompileSuccess:
449
- * Forget successfully compiled a function.
450
- * PipelineError:
451
- * Unexpected errors that occurred during compilation (e.g. failures in
452
- * babel or other unhandled exceptions).
453
- */
454
- export declare type ReactCompilerLoggerEvent =
455
- | {
456
- kind: 'CompileError'
457
- fnLoc: unknown
458
- detail: unknown
459
- }
460
- | {
461
- kind: 'CompileDiagnostic'
462
- fnLoc: unknown
463
- detail: unknown
464
- }
465
- | {
466
- kind: 'CompileSuccess'
467
- fnLoc: unknown
468
- fnName: string | null
469
- memoSlots: number
470
- memoBlocks: number
471
- memoValues: number
472
- prunedMemoBlocks: number
473
- prunedMemoValues: number
474
- }
475
- | {
476
- kind: 'PipelineError'
477
- fnLoc: unknown
478
- data: string
479
- }
480
-
481
- /**
482
- * Until these types are on npm: https://github.com/facebook/react/blob/0bc30748730063e561d87a24a4617526fdd38349/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts#L39-L122
483
- * @alpha
484
- */
485
- export declare interface ReactCompilerOptions {
486
- logger?: ReactCompilerLogger | null
487
- panicThreshold?: 'ALL_ERRORS' | 'CRITICAL_ERRORS' | 'NONE'
488
- compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all'
489
- runtimeModule?: string | null | undefined
490
- /**
491
- * By default React Compiler will skip compilation of code that suppresses the default
492
- * React ESLint rules, since this is a strong indication that the code may be breaking React rules
493
- * in some way.
494
- *
495
- * Use eslintSuppressionRules to pass a custom set of rule names: any code which suppresses the
496
- * provided rules will skip compilation. To disable this feature (never bailout of compilation
497
- * even if the default ESLint is suppressed), pass an empty array.
498
- */
499
- eslintSuppressionRules?: Array<string> | null | undefined
500
- sources?: Array<string> | ((filename: string) => boolean) | null
501
- /**
502
- * The minimum major version of React that the compiler should emit code for. If the target is 19
503
- * or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
504
- * versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
505
- * a userspace approximation of runtime APIs.
506
- */
507
- target: '17' | '18' | '19'
508
- }
509
-
510
- export {RollupPlugin}
511
-
512
- /**
513
- * @public
514
- */
515
- export declare interface StrictOptions {
516
- /**
517
- * Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.
518
- * @defaultValue 'error'
519
- */
520
- noPackageJsonTypings?: ToggleType
521
- /**
522
- * Requires specifying `sideEffects` in `package.json`.
523
- * @defaultValue 'warn'
524
- */
525
- noImplicitSideEffects?: ToggleType
526
- /**
527
- * Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:
528
- * @example
529
- * ```
530
- * "browserslist": "extends @sanity/browserslist-config"
531
- * ```
532
- * @defaultValue 'warn'
533
- */
534
- noImplicitBrowsersList?: ToggleType
535
- /**
536
- * If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon.
537
- * @defaultValue 'error'
538
- */
539
- alwaysPackageJsonTypes?: ToggleType
540
- /**
541
- * A lot of analysis tooling requiers the `main` field to work (like bundlephobia) and so it's best practice to always include it
542
- * @defaultValue 'error'
543
- */
544
- alwaysPackageJsonMain?: ToggleType
545
- /**
546
- * Using `.npmignore` is error prone, it's best practice to always declare `files` instead
547
- * @defaultValue 'error'
548
- */
549
- alwaysPackageJsonFiles?: ToggleType
550
- }
551
-
552
- /**
553
- * @public
554
- */
555
- export declare const strictOptions: z.ZodObject<
556
- {
557
- noPackageJsonTypings: z.ZodDefault<
558
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
559
- >
560
- noImplicitSideEffects: z.ZodDefault<
561
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
562
- >
563
- noImplicitBrowsersList: z.ZodDefault<
564
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
565
- >
566
- alwaysPackageJsonTypes: z.ZodDefault<
567
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
568
- >
569
- alwaysPackageJsonMain: z.ZodDefault<
570
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
571
- >
572
- alwaysPackageJsonFiles: z.ZodDefault<
573
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
574
- >
575
- },
576
- 'strict',
577
- z.ZodTypeAny,
578
- {
579
- noPackageJsonTypings: 'error' | 'warn' | 'off'
580
- noImplicitSideEffects: 'error' | 'warn' | 'off'
581
- noImplicitBrowsersList: 'error' | 'warn' | 'off'
582
- alwaysPackageJsonTypes: 'error' | 'warn' | 'off'
583
- alwaysPackageJsonMain: 'error' | 'warn' | 'off'
584
- alwaysPackageJsonFiles: 'error' | 'warn' | 'off'
585
- },
586
- {
587
- noPackageJsonTypings?: 'error' | 'warn' | 'off' | undefined
588
- noImplicitSideEffects?: 'error' | 'warn' | 'off' | undefined
589
- noImplicitBrowsersList?: 'error' | 'warn' | 'off' | undefined
590
- alwaysPackageJsonTypes?: 'error' | 'warn' | 'off' | undefined
591
- alwaysPackageJsonMain?: 'error' | 'warn' | 'off' | undefined
592
- alwaysPackageJsonFiles?: 'error' | 'warn' | 'off' | undefined
593
- }
594
- >
595
-
596
- /**
597
- * @public
598
- */
599
- export declare const toggle: z.ZodUnion<
600
- [z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]
601
- >
602
-
603
- /**
604
- * @public
605
- */
606
- export declare type ToggleType = z.infer<typeof toggle>
607
-
537
+ type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;
608
538
  /** @public */
609
- export declare interface TSDocCustomTag {
610
- name: string
611
- syntaxKind: 'block' | 'modifier'
612
- allowMultiple?: boolean
613
- }
614
-
539
+ declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
540
+ /** @public */
541
+ declare function init(options: {
542
+ cwd: string;
543
+ path: string;
544
+ }): Promise<void>;
545
+ /** @alpha */
546
+ declare function getExtractMessagesConfig(options: {
547
+ rules: NonNullable<PkgConfigOptions['extract']>['rules'];
548
+ disabled?: boolean;
549
+ }): IExtractorMessagesConfig;
615
550
  /** @public */
616
- export declare function watch(options: {
617
- cwd: string
618
- strict?: boolean
619
- tsconfig?: string
620
- }): Promise<void>
621
-
622
- export {}
551
+ declare function watch(options: {
552
+ cwd: string;
553
+ strict?: boolean;
554
+ tsconfig?: string;
555
+ }): Promise<void>;
556
+ export { DEFAULT_BROWSERSLIST_QUERY, InferredStrictOptions, PackageJSON, PkgBundle, PkgConfigOptions, PkgConfigProperty, PkgConfigPropertyResolver, PkgExport, PkgExports, PkgFormat, PkgRuleLevel, PkgRuntime, PkgTemplate, PkgTemplateDefinition, PkgTemplateFile, PkgTemplateOption, PkgTemplateResolver, PkgTemplateStringOption, ReactCompilerLogger, ReactCompilerLoggerEvent, ReactCompilerOptions, RollupPlugin, StrictOptions, TSDocCustomTag, ToggleType, build, check, createLogger, defineConfig, defineTemplateOption, getExtractMessagesConfig, init, loadConfig, loadPkg, loadPkgWithReporting, parseExports, parseStrictOptions, strictOptions, toggle, watch };