@sanity/pkg-utils 7.4.1-canary.0 → 7.5.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 +408 -487
  23. package/dist/index.d.ts +408 -487
  24. package/dist/index.js +7 -4
  25. package/dist/index.js.map +1 -1
  26. package/package.json +2 -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.ts 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,261 @@ 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" | "warn" | "off";
58
+ noImplicitSideEffects: "error" | "warn" | "off";
59
+ noImplicitBrowsersList: "error" | "warn" | "off";
60
+ alwaysPackageJsonTypes: "error" | "warn" | "off";
61
+ alwaysPackageJsonMain: "error" | "warn" | "off";
62
+ alwaysPackageJsonFiles: "error" | "warn" | "off";
63
+ }, {
64
+ noPackageJsonTypings?: "error" | "warn" | "off" | undefined;
65
+ noImplicitSideEffects?: "error" | "warn" | "off" | undefined;
66
+ noImplicitBrowsersList?: "error" | "warn" | "off" | undefined;
67
+ alwaysPackageJsonTypes?: "error" | "warn" | "off" | undefined;
68
+ alwaysPackageJsonMain?: "error" | "warn" | "off" | undefined;
69
+ alwaysPackageJsonFiles?: "error" | "warn" | "off" | 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
+ node?: {
130
+ source?: string;
131
+ import?: string;
132
+ require?: string;
133
+ };
134
+ types?: string;
135
+ source: string;
136
+ import?: string;
137
+ require?: string;
138
+ default: string;
139
+ }
67
140
  /** @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
141
+ type PkgConfigPropertyResolver<T> = (prev: T) => T;
142
+ /** @public */
143
+ type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T;
144
+ /** @public */
145
+ interface PkgBundle {
146
+ source: string;
147
+ import?: string;
148
+ require?: string;
149
+ runtime?: PkgRuntime;
90
150
  }
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
151
+ /** @public */
152
+ interface PkgExports {
153
+ [path: string]: PkgExport;
167
154
  }
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
155
  /** @public */
184
- export declare interface PkgBundle {
185
- source: string
186
- import?: string
187
- require?: string
188
- runtime?: PkgRuntime
156
+ type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off';
157
+ /** @public */
158
+ interface TSDocCustomTag {
159
+ name: string;
160
+ syntaxKind: 'block' | 'modifier';
161
+ allowMultiple?: boolean;
162
+ }
163
+ /**
164
+ * 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
165
+ * @alpha
166
+ */
167
+ interface ReactCompilerOptions {
168
+ logger?: ReactCompilerLogger | null;
169
+ panicThreshold?: 'ALL_ERRORS' | 'CRITICAL_ERRORS' | 'NONE';
170
+ compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all';
171
+ runtimeModule?: string | null | undefined;
172
+ /**
173
+ * By default React Compiler will skip compilation of code that suppresses the default
174
+ * React ESLint rules, since this is a strong indication that the code may be breaking React rules
175
+ * in some way.
176
+ *
177
+ * Use eslintSuppressionRules to pass a custom set of rule names: any code which suppresses the
178
+ * provided rules will skip compilation. To disable this feature (never bailout of compilation
179
+ * even if the default ESLint is suppressed), pass an empty array.
180
+ */
181
+ eslintSuppressionRules?: Array<string> | null | undefined;
182
+ sources?: Array<string> | ((filename: string) => boolean) | null;
183
+ /**
184
+ * The minimum major version of React that the compiler should emit code for. If the target is 19
185
+ * or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
186
+ * versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
187
+ * a userspace approximation of runtime APIs.
188
+ */
189
+ target: '17' | '18' | '19';
189
190
  }
190
-
191
+ /**
192
+ * @alpha
193
+ * Represents 'events' that may occur during compilation. Events are only
194
+ * recorded when a logger is set (through the config).
195
+ * These are the different types of events:
196
+ * CompileError:
197
+ * Forget skipped compilation of a function / file due to a known todo,
198
+ * invalid input, or compiler invariant being broken.
199
+ * CompileSuccess:
200
+ * Forget successfully compiled a function.
201
+ * PipelineError:
202
+ * Unexpected errors that occurred during compilation (e.g. failures in
203
+ * babel or other unhandled exceptions).
204
+ */
205
+ type ReactCompilerLoggerEvent = {
206
+ kind: 'CompileError';
207
+ fnLoc: unknown;
208
+ detail: unknown;
209
+ } | {
210
+ kind: 'CompileDiagnostic';
211
+ fnLoc: unknown;
212
+ detail: unknown;
213
+ } | {
214
+ kind: 'CompileSuccess';
215
+ fnLoc: unknown;
216
+ fnName: string | null;
217
+ memoSlots: number;
218
+ memoBlocks: number;
219
+ memoValues: number;
220
+ prunedMemoBlocks: number;
221
+ prunedMemoValues: number;
222
+ } | {
223
+ kind: 'PipelineError';
224
+ fnLoc: unknown;
225
+ data: string;
226
+ };
227
+ /**
228
+ * @alpha
229
+ */
230
+ type ReactCompilerLogger = {
231
+ logEvent: (filename: string | null, event: ReactCompilerLoggerEvent) => void;
232
+ };
233
+ type DtsType = 'api-extractor' | 'rolldown';
191
234
  /** @public */
192
- export declare interface PkgConfigOptions {
235
+ interface PkgConfigOptions {
193
236
  /** @alpha */
194
237
  babel?: {
195
- plugins?: PluginItem[] | null | undefined
238
+ plugins?: PluginItem[] | null | undefined;
196
239
  /** @alpha */
197
- reactCompiler?: boolean
240
+ reactCompiler?: boolean;
198
241
  /** @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
- }
242
+ styledComponents?: boolean | {
243
+ /** @defaultValue true */
244
+ displayName?: boolean;
245
+ /**
246
+ * @defaultValue []
247
+ * @example ["\@xstyled/styled-components", "\@xstyled/styled-components/*"]
248
+ */
249
+ topLevelImportPaths?: string[];
250
+ /** @defaultValue true */
251
+ ssr?: boolean;
252
+ /** @defaultValue fale */
253
+ fileName?: boolean;
254
+ /** @defaultValue ["index"] */
255
+ meaninglessFileNames?: string[];
256
+ /** @defaultValue true */
257
+ minify?: boolean;
258
+ /** @defaultValue false */
259
+ transpileTemplateLiterals?: boolean;
260
+ namespace?: string;
261
+ /** @defaultValue true */
262
+ pure?: boolean;
263
+ };
264
+ };
224
265
  /**
225
266
  * Configure the React Compiler.
226
267
  * To enable it, either:
227
268
  * - set `babel.reactCompiler` to `true`
228
269
  * - add a `react-compiler` export condition, before any `browser`, `require` or `import` conditions. After any `react-server` and `node` conditions
229
270
  * @alpha */
230
- reactCompilerOptions?: ReactCompilerOptions
231
- bundles?: PkgBundle[]
271
+ reactCompilerOptions?: ReactCompilerOptions;
272
+ bundles?: PkgBundle[];
232
273
  /** @alpha */
233
- define?: Record<string, string | number | boolean | undefined | null>
274
+ define?: Record<string, string | number | boolean | undefined | null>;
234
275
  /**
235
276
  * Directory of distributed & bundled files.
236
277
  */
237
- dist?: string
238
- exports?: PkgConfigProperty<PkgExports>
278
+ dist?: string;
279
+ exports?: PkgConfigProperty<PkgExports>;
239
280
  /**
240
281
  * Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.
241
282
  * This is useful for packages that need to be consumed by TSDoc-based tooling.
@@ -245,7 +286,7 @@ export declare interface PkgConfigOptions {
245
286
  /**
246
287
  * @defaultValue true
247
288
  */
248
- enabled?: boolean
289
+ enabled?: boolean;
249
290
  /**
250
291
  * Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.
251
292
  * You can exclude a package from being bundled by using a callback:
@@ -253,21 +294,21 @@ export declare interface PkgConfigOptions {
253
294
  * bundledPackages: (prev) => prev.filter(package => package !== 'sanity')
254
295
  * ```
255
296
  */
256
- bundledPackages?: PkgConfigProperty<string[]>
257
- customTags?: TSDocCustomTag[]
297
+ bundledPackages?: PkgConfigProperty<string[]>;
298
+ customTags?: TSDocCustomTag[];
258
299
  rules?: {
259
300
  /**
260
301
  * @deprecated as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873
261
302
  */
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
- }
303
+ 'ae-forgotten-export'?: never;
304
+ 'ae-incompatible-release-tags'?: PkgRuleLevel;
305
+ 'ae-internal-missing-underscore'?: PkgRuleLevel;
306
+ 'ae-missing-release-tag'?: PkgRuleLevel;
307
+ 'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel;
308
+ 'tsdoc-undefined-tag'?: PkgRuleLevel;
309
+ 'tsdoc-unsupported-tag'?: PkgRuleLevel;
310
+ };
311
+ };
271
312
  /**
272
313
  * Packages to exclude from bundles.
273
314
  * Provide an array to merge with default exclusions, use a function to replace them:
@@ -275,45 +316,45 @@ export declare interface PkgConfigOptions {
275
316
  * exclude: (prev) => prev.filter(package => package !== 'foo')
276
317
  * ```
277
318
  */
278
- external?: PkgConfigProperty<string[]>
319
+ external?: PkgConfigProperty<string[]>;
279
320
  /**
280
321
  * Defaults to `"automatic"`
281
322
  */
282
- jsx?: 'transform' | 'preserve' | 'automatic'
323
+ jsx?: 'transform' | 'preserve' | 'automatic';
283
324
  /**
284
325
  * Defaults to `"createElement"`
285
326
  */
286
- jsxFactory?: string
327
+ jsxFactory?: string;
287
328
  /**
288
329
  * Defaults to `"Fragment"`
289
330
  */
290
- jsxFragment?: string
331
+ jsxFragment?: string;
291
332
  /**
292
333
  * Defaults to `"react"`
293
334
  */
294
- jsxImportSource?: string
335
+ jsxImportSource?: string;
295
336
  /**
296
337
  * @deprecated no longer supported
297
338
  */
298
- legacyExports?: never
299
- minify?: boolean
339
+ legacyExports?: never;
340
+ minify?: boolean;
300
341
  /** @alpha */
301
342
  rollup?: {
302
- plugins?: PkgConfigProperty<RollupPlugin[]>
303
- output?: Partial<NormalizedOutputOptions>
343
+ plugins?: PkgConfigProperty<Plugin[]>;
344
+ output?: Partial<NormalizedOutputOptions>;
304
345
  /**
305
346
  * Default options are `preset: 'recommended'` and `propertyReadSideEffects: false`
306
347
  * @alpha
307
348
  */
308
- treeshake?: TreeshakingOptions
349
+ treeshake?: TreeshakingOptions;
309
350
  /** @alpha */
310
- experimentalLogSideEffects?: boolean
351
+ experimentalLogSideEffects?: boolean;
311
352
  /**
312
353
  * Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
313
354
  * It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
314
355
  * @defaultValue false
315
356
  */
316
- hashChunkFileNames?: boolean
357
+ hashChunkFileNames?: boolean;
317
358
  /**
318
359
  * Optimizes lodash imports using `@optimize-lodash/rollup-plugin` when set to `true`.
319
360
  * It's enabled if `lodash` is found in `dependencies` or `peerDependencies`.
@@ -321,302 +362,182 @@ export declare interface PkgConfigOptions {
321
362
  * @defaultValue true
322
363
  * @alpha
323
364
  */
324
- optimizeLodash?: boolean | OptimizeLodashOptions
325
- }
365
+ optimizeLodash?: boolean | OptimizeLodashOptions;
366
+ };
326
367
  /**
327
368
  * Default runtime of package exports
328
369
  */
329
- runtime?: PkgRuntime
330
- sourcemap?: boolean
370
+ runtime?: PkgRuntime;
371
+ sourcemap?: boolean;
331
372
  /**
332
373
  * Directory of source files.
333
374
  */
334
- src?: string
335
- tsconfig?: string
375
+ src?: string;
376
+ tsconfig?: string;
336
377
  /**
337
378
  * Configure what checks are made when running `--strict` builds and checks
338
379
  */
339
- strictOptions?: StrictOptions
380
+ strictOptions?: StrictOptions;
340
381
  /**
341
382
  * .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`.
342
383
  * `rolldown` is the faster option, but is not yet stable.
343
384
  * @defaultValue 'api-extractor'
344
385
  */
345
- dts?: DtsType
386
+ dts?: DtsType;
346
387
  }
347
-
348
388
  /** @public */
349
- export declare type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T
350
-
351
- /** @public */
352
- export declare type PkgConfigPropertyResolver<T> = (prev: T) => T
353
-
389
+ declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
390
+ /** @alpha */
391
+ declare function loadConfig(options: {
392
+ cwd: string;
393
+ }): Promise<PkgConfigOptions | undefined>;
354
394
  /** @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
395
+ declare const DEFAULT_BROWSERSLIST_QUERY: string[];
396
+ /** @alpha */
397
+ interface PackageJSON {
398
+ type?: 'commonjs' | 'module';
399
+ version: string;
400
+ private?: boolean;
401
+ author?: string | {
402
+ name: string;
403
+ email?: string;
404
+ url?: string;
405
+ };
406
+ name: string;
407
+ description?: string;
408
+ keywords?: string[];
409
+ bin?: Record<string, string>;
410
+ dependencies?: Record<string, string | undefined>;
411
+ devDependencies?: Record<string, string | undefined>;
412
+ peerDependencies?: Record<string, string | undefined>;
413
+ exports?: Record<string, `./${string}.json` | `./${string}.css` | {
414
+ source?: string;
415
+ types?: string;
416
+ browser?: {
417
+ source: string;
418
+ import?: string;
419
+ require?: string;
420
+ };
421
+ node?: {
422
+ source?: string;
423
+ module?: string;
424
+ import?: string;
425
+ require?: string;
426
+ };
427
+ module?: string;
428
+ import?: string;
429
+ require?: string;
430
+ default: string;
431
+ } | {
432
+ types?: string;
433
+ svelte: string;
434
+ default?: string;
435
+ }>;
436
+ main?: string;
437
+ browser?: Record<string, string>;
438
+ source?: string;
439
+ module?: string;
440
+ types?: string;
441
+ files?: string[];
442
+ scripts?: Record<string, string | undefined>;
443
+ browserslist?: string | string[];
444
+ sideEffects?: boolean | string[];
445
+ engines?: {
446
+ node?: string;
447
+ npm?: string;
448
+ };
449
+ repository?: string | {
450
+ type: 'git';
451
+ url: string;
452
+ };
453
+ bugs?: string | {
454
+ url: string;
455
+ email?: string;
456
+ };
457
+ homepage?: string;
458
+ license?: string;
373
459
  }
374
-
375
- /** @public */
376
- export declare interface PkgExports {
377
- [path: string]: PkgExport
460
+ /** @internal */
461
+ declare function loadPkg(options: {
462
+ cwd: string;
463
+ }): Promise<PackageJSON>;
464
+ /** @alpha */
465
+ interface Logger {
466
+ log: (...args: unknown[]) => void;
467
+ info: (...args: unknown[]) => void;
468
+ warn: (...args: unknown[]) => void;
469
+ error: (...args: unknown[]) => void;
470
+ success: (...args: unknown[]) => void;
378
471
  }
379
-
380
- /** @public */
381
- export declare type PkgFormat = 'commonjs' | 'esm'
382
-
472
+ /** @alpha */
473
+ declare function createLogger(): Logger;
474
+ /** @alpha */
475
+ declare function loadPkgWithReporting(options: {
476
+ cwd: string;
477
+ logger: Logger;
478
+ strict: boolean;
479
+ }): Promise<PackageJSON>;
480
+ /** @alpha */
481
+ declare function parseExports(options: {
482
+ cwd: string;
483
+ pkg: PackageJSON;
484
+ strict: boolean;
485
+ strictOptions: InferredStrictOptions;
486
+ logger: Logger;
487
+ }): (PkgExport & {
488
+ _path: string;
489
+ })[];
383
490
  /** @public */
384
- export declare type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'
385
-
491
+ interface PkgTemplateFile {
492
+ name: string;
493
+ contents: string;
494
+ }
386
495
  /** @public */
387
- export declare type PkgRuntime = '*' | 'browser' | 'node'
388
-
496
+ interface PkgTemplateStringOption<T = string> {
497
+ name: string;
498
+ type: 'string';
499
+ description: string;
500
+ initial?: T | ((options: Record<string, any>) => T);
501
+ parse?: (v: string) => T | null;
502
+ validate?: (v: string) => string | true;
503
+ }
389
504
  /** @public */
390
- export declare type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver
391
-
505
+ type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;
392
506
  /** @public */
393
- export declare interface PkgTemplateDefinition {
394
- options: PkgTemplateStringOption<any>[]
507
+ interface PkgTemplateDefinition {
508
+ options: PkgTemplateStringOption<any>[];
395
509
  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[]>
510
+ name: string;
511
+ optional: boolean;
512
+ initial: boolean;
513
+ }[];
514
+ getFiles: (options: Record<string, any>, features: Record<string, boolean>) => Promise<PkgTemplateFile[]>;
404
515
  }
405
-
406
- /** @public */
407
- export declare interface PkgTemplateFile {
408
- name: string
409
- contents: string
410
- }
411
-
412
- /** @public */
413
- export declare type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
414
-
415
516
  /** @public */
416
- export declare type PkgTemplateResolver = (options: {
417
- cwd: string
517
+ type PkgTemplateResolver = (options: {
518
+ cwd: string;
418
519
  /** @internal */
419
- logger: Logger
420
- packagePath: string
421
- }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>
422
-
520
+ logger: Logger;
521
+ packagePath: string;
522
+ }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;
423
523
  /** @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
-
524
+ type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;
608
525
  /** @public */
609
- export declare interface TSDocCustomTag {
610
- name: string
611
- syntaxKind: 'block' | 'modifier'
612
- allowMultiple?: boolean
613
- }
614
-
526
+ declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
527
+ /** @public */
528
+ declare function init(options: {
529
+ cwd: string;
530
+ path: string;
531
+ }): Promise<void>;
532
+ /** @alpha */
533
+ declare function getExtractMessagesConfig(options: {
534
+ rules: NonNullable<PkgConfigOptions['extract']>['rules'];
535
+ disabled?: boolean;
536
+ }): IExtractorMessagesConfig;
615
537
  /** @public */
616
- export declare function watch(options: {
617
- cwd: string
618
- strict?: boolean
619
- tsconfig?: string
620
- }): Promise<void>
621
-
622
- export {}
538
+ declare function watch(options: {
539
+ cwd: string;
540
+ strict?: boolean;
541
+ tsconfig?: string;
542
+ }): Promise<void>;
543
+ 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 };