@sanity/pkg-utils 7.2.10-canary.1 → 7.2.10-canary.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.
Files changed (95) hide show
  1. package/dist/_chunks-cjs/index.cjs +10 -106
  2. package/dist/_chunks-cjs/index.cjs.map +1 -1
  3. package/dist/_chunks-cjs/resolveRolldownConfig.cjs +79 -0
  4. package/dist/_chunks-cjs/resolveRolldownConfig.cjs.map +1 -0
  5. package/dist/_chunks-es/index.js +2311 -0
  6. package/dist/_chunks-es/index.js.map +1 -0
  7. package/dist/_chunks-es/resolveRolldownConfig.js +78 -0
  8. package/dist/_chunks-es/resolveRolldownConfig.js.map +1 -0
  9. package/dist/cli.cjs +1 -1
  10. package/dist/cli.d.cts +1 -1
  11. package/dist/index.d.cts +487 -408
  12. package/dist/index.d.ts +487 -408
  13. package/dist/index.js +1 -2390
  14. package/dist/index.js.map +1 -1
  15. package/package.json +7 -8
  16. package/src/cli/buildAction.ts +0 -21
  17. package/src/cli/checkAction.ts +0 -14
  18. package/src/cli/handleError.ts +0 -11
  19. package/src/cli/index.ts +0 -65
  20. package/src/cli/initAction.ts +0 -13
  21. package/src/cli/watchAction.ts +0 -14
  22. package/src/global.ts +0 -5
  23. package/src/node/__snapshots__/strict.test.ts.snap +0 -154
  24. package/src/node/build.ts +0 -100
  25. package/src/node/check.ts +0 -188
  26. package/src/node/consoleSpy.ts +0 -39
  27. package/src/node/core/config/defineConfig.ts +0 -6
  28. package/src/node/core/config/findConfigFile.ts +0 -31
  29. package/src/node/core/config/index.ts +0 -4
  30. package/src/node/core/config/loadConfig.ts +0 -37
  31. package/src/node/core/config/resolveConfigProperty.ts +0 -15
  32. package/src/node/core/config/types.ts +0 -315
  33. package/src/node/core/contexts/buildContext.ts +0 -32
  34. package/src/node/core/contexts/index.ts +0 -1
  35. package/src/node/core/defaults.ts +0 -4
  36. package/src/node/core/findCommonPath.ts +0 -35
  37. package/src/node/core/isRecord.ts +0 -4
  38. package/src/node/core/pkg/helpers.ts +0 -36
  39. package/src/node/core/pkg/index.ts +0 -5
  40. package/src/node/core/pkg/loadPkg.ts +0 -21
  41. package/src/node/core/pkg/loadPkgWithReporting.ts +0 -154
  42. package/src/node/core/pkg/parseExports.ts +0 -233
  43. package/src/node/core/pkg/pkgExt.ts +0 -22
  44. package/src/node/core/pkg/types.ts +0 -60
  45. package/src/node/core/pkg/validateExports.ts +0 -30
  46. package/src/node/core/pkg/validatePkg.ts +0 -82
  47. package/src/node/core/template/createFromTemplate.ts +0 -84
  48. package/src/node/core/template/define.ts +0 -6
  49. package/src/node/core/template/index.ts +0 -3
  50. package/src/node/core/template/types.ts +0 -45
  51. package/src/node/core/ts/index.ts +0 -1
  52. package/src/node/core/ts/loadTSConfig.ts +0 -19
  53. package/src/node/fileExists.ts +0 -12
  54. package/src/node/getFilesize.ts +0 -8
  55. package/src/node/globFiles.ts +0 -6
  56. package/src/node/index.ts +0 -48
  57. package/src/node/init.ts +0 -54
  58. package/src/node/isEmptyDirectory.ts +0 -5
  59. package/src/node/logger.ts +0 -32
  60. package/src/node/printExtractMessages.ts +0 -59
  61. package/src/node/printPackageTree.ts +0 -95
  62. package/src/node/resolveBrowserTarget.ts +0 -17
  63. package/src/node/resolveBuildContext.ts +0 -202
  64. package/src/node/resolveBuildTasks.ts +0 -199
  65. package/src/node/resolveNodeTarget.ts +0 -9
  66. package/src/node/resolveWatchTasks.ts +0 -132
  67. package/src/node/spinner.ts +0 -17
  68. package/src/node/strict.test-d.ts +0 -6
  69. package/src/node/strict.ts +0 -84
  70. package/src/node/tasks/dts/DtsError.ts +0 -11
  71. package/src/node/tasks/dts/buildTypes.ts +0 -42
  72. package/src/node/tasks/dts/createApiExtractorConfig.ts +0 -67
  73. package/src/node/tasks/dts/createTSDocConfig.ts +0 -53
  74. package/src/node/tasks/dts/doExtract.ts +0 -80
  75. package/src/node/tasks/dts/dtsTask.ts +0 -50
  76. package/src/node/tasks/dts/dtsWatchTask.ts +0 -165
  77. package/src/node/tasks/dts/extractModuleBlocks.ts +0 -45
  78. package/src/node/tasks/dts/extractTypes.ts +0 -128
  79. package/src/node/tasks/dts/getExtractMessagesConfig.ts +0 -109
  80. package/src/node/tasks/dts/getTargetPaths.ts +0 -72
  81. package/src/node/tasks/dts/printDiagnostic.ts +0 -42
  82. package/src/node/tasks/dts/types.ts +0 -30
  83. package/src/node/tasks/index.ts +0 -19
  84. package/src/node/tasks/rolldown/resolveRolldownConfig.ts +0 -208
  85. package/src/node/tasks/rolldown/rolldownDtsTask.ts +0 -155
  86. package/src/node/tasks/rollup/resolveRollupConfig.ts +0 -264
  87. package/src/node/tasks/rollup/rollupTask.ts +0 -154
  88. package/src/node/tasks/rollup/rollupWatchTask.ts +0 -77
  89. package/src/node/tasks/types.ts +0 -69
  90. package/src/node/templates/default/index.ts +0 -1
  91. package/src/node/templates/default/template.ts +0 -547
  92. package/src/node/templates/index.ts +0 -1
  93. package/src/node/watch.ts +0 -66
  94. package/src/node/watchConfigFiles.ts +0 -53
  95. package/src/node/watchFiles.ts +0 -31
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
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";
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
+
6
8
  /**
7
9
  * Build the distribution files of a npm package.
8
10
  *
@@ -22,261 +24,218 @@ import { IExtractorMessagesConfig } from "@microsoft/api-extractor";
22
24
  *
23
25
  * @public
24
26
  */
25
- declare function build(options: {
26
- cwd: string;
27
- emitDeclarationOnly?: boolean;
28
- strict?: boolean;
29
- tsconfig?: string;
30
- clean?: boolean;
31
- }): Promise<void>;
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
+
32
35
  /** @public */
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
- }
36
+ export declare function check(options: {
37
+ cwd: string
38
+ strict?: boolean
39
+ tsconfig?: string
40
+ }): Promise<void>
41
+
114
42
  /** @alpha */
115
- declare function parseStrictOptions(input: unknown): InferredStrictOptions;
43
+ export declare function createLogger(): Logger
44
+
116
45
  /** @public */
117
- type PkgFormat = 'commonjs' | 'esm';
46
+ export declare const DEFAULT_BROWSERSLIST_QUERY: string[]
47
+
118
48
  /** @public */
119
- type PkgRuntime = '*' | 'browser' | 'node';
49
+ export declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T
50
+
120
51
  /** @public */
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
- }
140
- /** @public */
141
- type PkgConfigPropertyResolver<T> = (prev: T) => T;
142
- /** @public */
143
- type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T;
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
+
144
67
  /** @public */
145
- interface PkgBundle {
146
- source: string;
147
- import?: string;
148
- require?: string;
149
- runtime?: PkgRuntime;
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
150
90
  }
151
- /** @public */
152
- interface PkgExports {
153
- [path: string]: PkgExport;
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
154
167
  }
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
+
155
183
  /** @public */
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';
184
+ export declare interface PkgBundle {
185
+ source: string
186
+ import?: string
187
+ require?: string
188
+ runtime?: PkgRuntime
190
189
  }
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';
190
+
234
191
  /** @public */
235
- interface PkgConfigOptions {
192
+ export declare interface PkgConfigOptions {
236
193
  /** @alpha */
237
194
  babel?: {
238
- plugins?: PluginItem[] | null | undefined;
195
+ plugins?: PluginItem[] | null | undefined
239
196
  /** @alpha */
240
- reactCompiler?: boolean;
197
+ reactCompiler?: boolean
241
198
  /** @alpha */
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
- };
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
+ }
265
224
  /**
266
225
  * Configure the React Compiler.
267
226
  * To enable it, either:
268
227
  * - set `babel.reactCompiler` to `true`
269
228
  * - add a `react-compiler` export condition, before any `browser`, `require` or `import` conditions. After any `react-server` and `node` conditions
270
229
  * @alpha */
271
- reactCompilerOptions?: ReactCompilerOptions;
272
- bundles?: PkgBundle[];
230
+ reactCompilerOptions?: ReactCompilerOptions
231
+ bundles?: PkgBundle[]
273
232
  /** @alpha */
274
- define?: Record<string, string | number | boolean | undefined | null>;
233
+ define?: Record<string, string | number | boolean | undefined | null>
275
234
  /**
276
235
  * Directory of distributed & bundled files.
277
236
  */
278
- dist?: string;
279
- exports?: PkgConfigProperty<PkgExports>;
237
+ dist?: string
238
+ exports?: PkgConfigProperty<PkgExports>
280
239
  /**
281
240
  * Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.
282
241
  * This is useful for packages that need to be consumed by TSDoc-based tooling.
@@ -286,7 +245,7 @@ interface PkgConfigOptions {
286
245
  /**
287
246
  * @defaultValue true
288
247
  */
289
- enabled?: boolean;
248
+ enabled?: boolean
290
249
  /**
291
250
  * Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.
292
251
  * You can exclude a package from being bundled by using a callback:
@@ -294,21 +253,21 @@ interface PkgConfigOptions {
294
253
  * bundledPackages: (prev) => prev.filter(package => package !== 'sanity')
295
254
  * ```
296
255
  */
297
- bundledPackages?: PkgConfigProperty<string[]>;
298
- customTags?: TSDocCustomTag[];
256
+ bundledPackages?: PkgConfigProperty<string[]>
257
+ customTags?: TSDocCustomTag[]
299
258
  rules?: {
300
259
  /**
301
260
  * @deprecated as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873
302
261
  */
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
- };
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
+ }
312
271
  /**
313
272
  * Packages to exclude from bundles.
314
273
  * Provide an array to merge with default exclusions, use a function to replace them:
@@ -316,45 +275,45 @@ interface PkgConfigOptions {
316
275
  * exclude: (prev) => prev.filter(package => package !== 'foo')
317
276
  * ```
318
277
  */
319
- external?: PkgConfigProperty<string[]>;
278
+ external?: PkgConfigProperty<string[]>
320
279
  /**
321
280
  * Defaults to `"automatic"`
322
281
  */
323
- jsx?: 'transform' | 'preserve' | 'automatic';
282
+ jsx?: 'transform' | 'preserve' | 'automatic'
324
283
  /**
325
284
  * Defaults to `"createElement"`
326
285
  */
327
- jsxFactory?: string;
286
+ jsxFactory?: string
328
287
  /**
329
288
  * Defaults to `"Fragment"`
330
289
  */
331
- jsxFragment?: string;
290
+ jsxFragment?: string
332
291
  /**
333
292
  * Defaults to `"react"`
334
293
  */
335
- jsxImportSource?: string;
294
+ jsxImportSource?: string
336
295
  /**
337
296
  * @deprecated no longer supported
338
297
  */
339
- legacyExports?: never;
340
- minify?: boolean;
298
+ legacyExports?: never
299
+ minify?: boolean
341
300
  /** @alpha */
342
301
  rollup?: {
343
- plugins?: PkgConfigProperty<Plugin[]>;
344
- output?: Partial<NormalizedOutputOptions>;
302
+ plugins?: PkgConfigProperty<RollupPlugin[]>
303
+ output?: Partial<NormalizedOutputOptions>
345
304
  /**
346
305
  * Default options are `preset: 'recommended'` and `propertyReadSideEffects: false`
347
306
  * @alpha
348
307
  */
349
- treeshake?: TreeshakingOptions;
308
+ treeshake?: TreeshakingOptions
350
309
  /** @alpha */
351
- experimentalLogSideEffects?: boolean;
310
+ experimentalLogSideEffects?: boolean
352
311
  /**
353
312
  * Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
354
313
  * It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
355
314
  * @defaultValue false
356
315
  */
357
- hashChunkFileNames?: boolean;
316
+ hashChunkFileNames?: boolean
358
317
  /**
359
318
  * Optimizes lodash imports using `@optimize-lodash/rollup-plugin` when set to `true`.
360
319
  * It's enabled if `lodash` is found in `dependencies` or `peerDependencies`.
@@ -362,182 +321,302 @@ interface PkgConfigOptions {
362
321
  * @defaultValue true
363
322
  * @alpha
364
323
  */
365
- optimizeLodash?: boolean | OptimizeLodashOptions;
366
- };
324
+ optimizeLodash?: boolean | OptimizeLodashOptions
325
+ }
367
326
  /**
368
327
  * Default runtime of package exports
369
328
  */
370
- runtime?: PkgRuntime;
371
- sourcemap?: boolean;
329
+ runtime?: PkgRuntime
330
+ sourcemap?: boolean
372
331
  /**
373
332
  * Directory of source files.
374
333
  */
375
- src?: string;
376
- tsconfig?: string;
334
+ src?: string
335
+ tsconfig?: string
377
336
  /**
378
337
  * Configure what checks are made when running `--strict` builds and checks
379
338
  */
380
- strictOptions?: StrictOptions;
339
+ strictOptions?: StrictOptions
381
340
  /**
382
341
  * .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`.
383
342
  * `rolldown` is the faster option, but is not yet stable.
384
343
  * @defaultValue 'api-extractor'
385
344
  */
386
- dts?: DtsType;
345
+ dts?: DtsType
387
346
  }
347
+
388
348
  /** @public */
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>;
349
+ export declare type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T
350
+
394
351
  /** @public */
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;
459
- }
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;
471
- }
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
- })[];
352
+ export declare type PkgConfigPropertyResolver<T> = (prev: T) => T
353
+
490
354
  /** @public */
491
- interface PkgTemplateFile {
492
- name: string;
493
- contents: string;
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
494
373
  }
374
+
495
375
  /** @public */
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;
376
+ export declare interface PkgExports {
377
+ [path: string]: PkgExport
503
378
  }
379
+
380
+ /** @public */
381
+ export declare type PkgFormat = 'commonjs' | 'esm'
382
+
383
+ /** @public */
384
+ export declare type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'
385
+
386
+ /** @public */
387
+ export declare type PkgRuntime = '*' | 'browser' | 'node'
388
+
504
389
  /** @public */
505
- type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;
390
+ export declare type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver
391
+
506
392
  /** @public */
507
- interface PkgTemplateDefinition {
508
- options: PkgTemplateStringOption<any>[];
393
+ export declare interface PkgTemplateDefinition {
394
+ options: PkgTemplateStringOption<any>[]
509
395
  features: {
510
- name: string;
511
- optional: boolean;
512
- initial: boolean;
513
- }[];
514
- getFiles: (options: Record<string, any>, features: Record<string, boolean>) => Promise<PkgTemplateFile[]>;
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[]>
515
404
  }
405
+
516
406
  /** @public */
517
- type PkgTemplateResolver = (options: {
518
- cwd: string;
519
- /** @internal */
520
- logger: Logger;
521
- packagePath: string;
522
- }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;
407
+ export declare interface PkgTemplateFile {
408
+ name: string
409
+ contents: string
410
+ }
411
+
523
412
  /** @public */
524
- type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;
413
+ export declare type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
414
+
525
415
  /** @public */
526
- declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
416
+ export declare type PkgTemplateResolver = (options: {
417
+ cwd: string
418
+ /** @internal */
419
+ logger: Logger
420
+ packagePath: string
421
+ }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>
422
+
527
423
  /** @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;
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
+
608
+ /** @public */
609
+ export declare interface TSDocCustomTag {
610
+ name: string
611
+ syntaxKind: 'block' | 'modifier'
612
+ allowMultiple?: boolean
613
+ }
614
+
537
615
  /** @public */
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 };
616
+ export declare function watch(options: {
617
+ cwd: string
618
+ strict?: boolean
619
+ tsconfig?: string
620
+ }): Promise<void>
621
+
622
+ export {}