@sanity/pkg-utils 11.0.17 → 12.0.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 (71) hide show
  1. package/MIGRATE.md +152 -0
  2. package/README.md +110 -55
  3. package/dist/buildAction-DFrmHzYY.js +146 -0
  4. package/dist/buildAction-DFrmHzYY.js.map +1 -0
  5. package/dist/checkAction-BMxszLZS.js +140 -0
  6. package/dist/checkAction-BMxszLZS.js.map +1 -0
  7. package/dist/cli.js +22 -28
  8. package/dist/cli.js.map +1 -1
  9. package/dist/createApiExtractorConfig-CJoZqw8e.js +30 -0
  10. package/dist/createApiExtractorConfig-CJoZqw8e.js.map +1 -0
  11. package/dist/createTSDocConfig-CwaWneTR.js +25 -0
  12. package/dist/createTSDocConfig-CwaWneTR.js.map +1 -0
  13. package/dist/getExtractMessagesConfig-CXljwFbQ.js +75 -0
  14. package/dist/getExtractMessagesConfig-CXljwFbQ.js.map +1 -0
  15. package/dist/handleError-83GwKIFM.js +40 -0
  16. package/dist/handleError-83GwKIFM.js.map +1 -0
  17. package/dist/index.d.ts +141 -195
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +203 -11
  20. package/dist/index.js.map +1 -1
  21. package/dist/initAction-Cv0oRwWP.js +618 -0
  22. package/dist/initAction-Cv0oRwWP.js.map +1 -0
  23. package/dist/printExtractMessages-DyaYtByp.js +33 -0
  24. package/dist/printExtractMessages-DyaYtByp.js.map +1 -0
  25. package/dist/resolveBuildContext-CwqbTV6p.js +713 -0
  26. package/dist/resolveBuildContext-CwqbTV6p.js.map +1 -0
  27. package/dist/resolveTsdownConfig-2OdGF-dM.js +258 -0
  28. package/dist/resolveTsdownConfig-2OdGF-dM.js.map +1 -0
  29. package/dist/spinner-DAHe7SuT.js +15 -0
  30. package/dist/spinner-DAHe7SuT.js.map +1 -0
  31. package/dist/watchAction-uRPAvgLE.js +179 -0
  32. package/dist/watchAction-uRPAvgLE.js.map +1 -0
  33. package/dist/watchConfigFiles-AGBDblwf.js +43 -0
  34. package/dist/watchConfigFiles-AGBDblwf.js.map +1 -0
  35. package/package.json +10 -24
  36. package/dist/_chunks-es/buildAction.js +0 -195
  37. package/dist/_chunks-es/buildAction.js.map +0 -1
  38. package/dist/_chunks-es/checkAction.js +0 -198
  39. package/dist/_chunks-es/checkAction.js.map +0 -1
  40. package/dist/_chunks-es/createApiExtractorConfig.js +0 -52
  41. package/dist/_chunks-es/createApiExtractorConfig.js.map +0 -1
  42. package/dist/_chunks-es/createTSDocConfig.js +0 -31
  43. package/dist/_chunks-es/createTSDocConfig.js.map +0 -1
  44. package/dist/_chunks-es/defaults.js +0 -36
  45. package/dist/_chunks-es/defaults.js.map +0 -1
  46. package/dist/_chunks-es/define.js +0 -7
  47. package/dist/_chunks-es/define.js.map +0 -1
  48. package/dist/_chunks-es/extractModuleBlocks.js +0 -48
  49. package/dist/_chunks-es/extractModuleBlocks.js.map +0 -1
  50. package/dist/_chunks-es/fileExists.js +0 -12
  51. package/dist/_chunks-es/fileExists.js.map +0 -1
  52. package/dist/_chunks-es/getExtractMessagesConfig.js +0 -83
  53. package/dist/_chunks-es/getExtractMessagesConfig.js.map +0 -1
  54. package/dist/_chunks-es/handleError.js +0 -32
  55. package/dist/_chunks-es/handleError.js.map +0 -1
  56. package/dist/_chunks-es/index.js +0 -825
  57. package/dist/_chunks-es/index.js.map +0 -1
  58. package/dist/_chunks-es/initAction.js +0 -654
  59. package/dist/_chunks-es/initAction.js.map +0 -1
  60. package/dist/_chunks-es/printExtractMessages.js +0 -44
  61. package/dist/_chunks-es/printExtractMessages.js.map +0 -1
  62. package/dist/_chunks-es/resolveBuildContext.js +0 -717
  63. package/dist/_chunks-es/resolveBuildContext.js.map +0 -1
  64. package/dist/_chunks-es/resolveRolldownConfig.js +0 -117
  65. package/dist/_chunks-es/resolveRolldownConfig.js.map +0 -1
  66. package/dist/_chunks-es/spinner.js +0 -16
  67. package/dist/_chunks-es/spinner.js.map +0 -1
  68. package/dist/_chunks-es/watchAction.js +0 -160
  69. package/dist/_chunks-es/watchAction.js.map +0 -1
  70. package/dist/_chunks-es/watchConfigFiles.js +0 -49
  71. package/dist/_chunks-es/watchConfigFiles.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- import { PluginItem } from "@babel/core";
2
- import { OptimizeLodashOptions } from "@optimize-lodash/rollup-plugin";
3
1
  import { PkgExport, PkgExports, PkgExports as PkgExports$1 } from "@sanity/parse-package-json";
4
- import { Options } from "@vanilla-extract/rollup-plugin";
5
- import { PluginOptions } from "babel-plugin-react-compiler";
6
- import { NormalizedOutputOptions, Plugin, Plugin as RollupPlugin, TreeshakingOptions } from "rollup";
2
+ import { PackageVanillaExtractOptions, PackageVanillaExtractOptions as PackageVanillaExtractOptions$1, ReactCompilerOptions, ReactCompilerOptions as ReactCompilerOptions$1, StyledComponentsOptions, StyledComponentsOptions as StyledComponentsOptions$1 } from "@sanity/tsdown-config";
3
+ import { UserConfig } from "tsdown";
7
4
  type ToggleType = "error" | "warn" | "off";
8
5
  /**
9
6
  * @public
@@ -126,60 +123,6 @@ interface StrictOptions {
126
123
  }
127
124
  /** @public */
128
125
  type PkgFormat = "commonjs" | "esm";
129
- /**
130
- * Options for the `@vanilla-extract/rollup-plugin` integration, including pkg-utils-specific
131
- * extensions (`minify`, `browserslist`, and `extract.compatMode`).
132
- * @alpha
133
- */
134
- interface PkgVanillaExtractOptions extends Omit<Options, "extract"> {
135
- /**
136
- * Minify the extracted CSS with `lightningcss`.
137
- * @defaultValue true
138
- */
139
- minify?: boolean;
140
- /**
141
- * Browserslist query passed to `lightningcss` when optimizing the extracted CSS.
142
- * @defaultValue the project's browserslist config, falling back to pkg-utils' default query
143
- */
144
- browserslist?: string | string[];
145
- /**
146
- * Different formatting of identifiers (e.g. class names, keyframes, CSS Vars, etc).
147
- * @defaultValue "short"
148
- */
149
- identifiers?: Options["identifiers"];
150
- /**
151
- * Extract the CSS into a separate file. pkg-utils always extracts, so this configures _how_.
152
- */
153
- extract?: {
154
- /**
155
- * Name of the emitted `.css` file (and, with `compatMode`, the `exports` subpath + shim base).
156
- * @defaultValue "bundle.css"
157
- */
158
- name?: string;
159
- /**
160
- * Generate a `.css.map` sourcemap file.
161
- * @defaultValue true
162
- */
163
- sourcemap?: boolean;
164
- /**
165
- * Compatibility mode automatically wires up the conditional CSS export pattern so userland does
166
- * not have to. When enabled, pkg-utils:
167
- *
168
- * - injects `import "<pkg-name>/<name>"` into each entry chunk (no manual `rollup.output.intro`),
169
- * - emits a no-op shim (e.g. `bundle-css.js` for `name: "bundle.css"`) for runtimes that cannot
170
- * import `.css` files — named with a hyphen rather than a `.css.js` suffix so it does not
171
- * match vanilla-extract's `cssFileFilter`, and
172
- * - writes the conditional `"./<name>"` export to `package.json`
173
- * (`types` → the shim's `.d.ts`, `browser`/`style` → the real CSS, `node`/`default` → the
174
- * shim).
175
- *
176
- * The result is that `import "<pkg>/<name>"` resolves to the real CSS in bundlers/browsers and
177
- * to the no-op shim in Node and similar runtimes. Disable it to wire these up yourself.
178
- * @defaultValue true
179
- */
180
- compatMode?: boolean;
181
- };
182
- }
183
126
  /** @public */
184
127
  type PkgRuntime = "*" | "browser" | "node";
185
128
  /** @public */
@@ -201,154 +144,97 @@ interface TSDocCustomTag {
201
144
  syntaxKind: "block" | "modifier";
202
145
  allowMultiple?: boolean;
203
146
  }
204
- type DtsType = "api-extractor" | "rolldown";
147
+ /**
148
+ * Options for the `tsdoc` option: the `@microsoft/api-extractor` powered TSDoc and release-tag
149
+ * checking that runs during `pkg check` (and `pkg build --check`).
150
+ * @public
151
+ */
152
+ interface PkgTsdocOptions {
153
+ customTags?: TSDocCustomTag[];
154
+ rules?: {
155
+ "ae-incompatible-release-tags"?: PkgRuleLevel;
156
+ "ae-internal-missing-underscore"?: PkgRuleLevel;
157
+ "ae-missing-release-tag"?: PkgRuleLevel;
158
+ "tsdoc-link-tag-unescaped-text"?: PkgRuleLevel;
159
+ "tsdoc-undefined-tag"?: PkgRuleLevel;
160
+ "tsdoc-unsupported-tag"?: PkgRuleLevel;
161
+ };
162
+ }
205
163
  /** @public */
206
164
  interface PkgConfigOptions {
207
- /** @alpha */
208
- babel?: {
209
- plugins?: PluginItem[] | null | undefined;
210
- /** @alpha */
211
- reactCompiler?: boolean;
212
- /** @alpha */
213
- styledComponents?: boolean | {
214
- /** @defaultValue true */
215
- displayName?: boolean;
216
- /**
217
- * @defaultValue []
218
- * @example ["\@xstyled/styled-components", "\@xstyled/styled-components/*"]
219
- */
220
- topLevelImportPaths?: string[];
221
- /** @defaultValue true */
222
- ssr?: boolean;
223
- /** @defaultValue false */
224
- fileName?: boolean;
225
- /** @defaultValue ["index"] */
226
- meaninglessFileNames?: string[];
227
- /** @defaultValue true */
228
- minify?: boolean;
229
- /**
230
- * Transpiles `styled.button`...`` to `styled.button(["..."])` so that the `pure` option can
231
- * annotate a plain call expression, as pure annotations on tagged template expressions aren't
232
- * supported by bundlers (https://github.com/rollup/rollup/issues/4035). Without it unused
233
- * styled components can't be tree-shaken.
234
- * @defaultValue true
235
- */
236
- transpileTemplateLiterals?: boolean;
237
- namespace?: string;
238
- /** @defaultValue true */
239
- pure?: boolean;
240
- };
241
- };
242
- /**
243
- * Configure the React Compiler.
244
- * To enable it set `babel.reactCompiler` to `true`
245
- * @beta */
246
- reactCompilerOptions?: Partial<PluginOptions>;
247
165
  bundles?: PkgBundle[];
166
+ /**
167
+ * tsdown's `clean` option, passed through as-is. Cleaning is on by default: `true` (the
168
+ * default) cleans the `dist` folder before the build, `false` skips cleaning, and a
169
+ * `string[]` replaces the default with the listed paths/globs — include `dist` when you
170
+ * still want it cleaned alongside other folders (e.g. `clean: ['dist', 'coverage']`
171
+ * replaces a `"clean": "rimraf dist coverage"` script).
172
+ * @defaultValue true
173
+ */
174
+ clean?: UserConfig["clean"];
248
175
  /** @alpha */
249
176
  define?: Record<string, string | number | boolean | undefined | null>;
177
+ /**
178
+ * tsdown's `deps` option, passed through as-is: `neverBundle` marks dependencies as external
179
+ * (the successor of the deprecated `external` array), `alwaysBundle` forces a dependency to
180
+ * be inlined (the successor of the `external` callback pattern that filtered a dependency
181
+ * out of the externals).
182
+ * @see https://tsdown.dev/options/dependencies
183
+ */
184
+ deps?: UserConfig["deps"];
250
185
  /**
251
186
  * Directory of distributed & bundled files.
252
187
  */
253
188
  dist?: string;
254
- exports?: PkgConfigProperty<PkgExports$1>;
255
189
  /**
256
- * Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.
257
- * This is useful for packages that need to be consumed by TSDoc-based tooling.
258
- * It's enabled by default, it can be disabled by setting `extract: {enabled: false}`
259
- */
260
- extract?: {
261
- /**
262
- * @defaultValue true
263
- */
264
- enabled?: boolean;
265
- /**
266
- * When set to false, disables type checking during type definition generation.
267
- * This is equivalent to setting `"noCheck": true` in tsconfig.json but can be
268
- * controlled from package.config.ts without needing multiple tsconfig files.
269
- * @defaultValue undefined (uses tsconfig.json settings)
270
- */
271
- checkTypes?: boolean;
272
- /**
273
- * Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.
274
- * You can exclude a package from being bundled by using a callback:
275
- * ```
276
- * bundledPackages: (prev) => prev.filter(package => package !== 'sanity')
277
- * ```
278
- */
279
- bundledPackages?: PkgConfigProperty<string[]>;
280
- customTags?: TSDocCustomTag[];
281
- rules?: {
282
- "ae-incompatible-release-tags"?: PkgRuleLevel;
283
- "ae-internal-missing-underscore"?: PkgRuleLevel;
284
- "ae-missing-release-tag"?: PkgRuleLevel;
285
- "tsdoc-link-tag-unescaped-text"?: PkgRuleLevel;
286
- "tsdoc-undefined-tag"?: PkgRuleLevel;
287
- "tsdoc-unsupported-tag"?: PkgRuleLevel;
288
- };
289
- };
190
+ * tsdown's `dts` options, passed through as-is (an object, or `false` to skip generating
191
+ * `.d.ts` files entirely). For example `dts: {tsgo: true}` selects the Go-native TypeScript
192
+ * compiler for type generation.
193
+ * @see https://tsdown.dev/options/dts
194
+ */
195
+ dts?: false | Extract<NonNullable<UserConfig["dts"]>, object>;
196
+ exports?: PkgConfigProperty<PkgExports$1>;
290
197
  /**
291
198
  * Packages to exclude from bundles.
292
199
  * Provide an array to merge with default exclusions, use a function to replace them:
293
200
  * ```
294
- * exclude: (prev) => prev.filter(package => package !== 'foo')
201
+ * external: (prev) => prev.filter(package => package !== 'foo')
295
202
  * ```
203
+ * @deprecated Use `deps: {neverBundle: [...]}` to mark dependencies as external, and
204
+ * `deps: {alwaysBundle: [...]}` to bundle a dependency (the callback pattern that filtered
205
+ * entries out of the defaults). `external` still works but logs a warning on every build.
296
206
  */
297
207
  external?: PkgConfigProperty<string[]>;
298
208
  /**
299
- * Defaults to `"automatic"`
209
+ * Gates the legacy-config migration checks (the runtime errors and warnings for options that
210
+ * were removed or deprecated in v12). Defaults to on outside production builds, where
211
+ * migration mistakes surface during development, and off when `NODE_ENV=production` so the
212
+ * validation adds no overhead to production builds.
213
+ * @defaultValue `process.env.NODE_ENV !== 'production'`
300
214
  */
301
- jsx?: "transform" | "preserve" | "automatic";
215
+ legacyChecks?: boolean;
302
216
  /**
303
- * Defaults to `"createElement"`
217
+ * Fully minify the output (identifier mangling and whitespace removal included). Off by
218
+ * default: the output is always compressed (constant folding, dead code elimination) with
219
+ * function/class names preserved, and consumers' production builds minify `node_modules`
220
+ * again anyway.
221
+ * @defaultValue false
304
222
  */
305
- jsxFactory?: string;
223
+ minify?: boolean;
306
224
  /**
307
- * Defaults to `"Fragment"`
225
+ * Extra rolldown plugins, appended after the plugins pkg-utils sets up (React Compiler,
226
+ * vanilla-extract). Most Rollup plugins are also compatible.
227
+ * @see https://tsdown.dev/advanced/plugins
228
+ * @alpha
308
229
  */
309
- jsxFragment?: string;
230
+ plugins?: UserConfig["plugins"];
310
231
  /**
311
- * Defaults to `"react"`
232
+ * Runs `babel-plugin-react-compiler` on the source files before they are bundled, so
233
+ * published components are memoized automatically. Pass `true` to use the defaults, or an
234
+ * options object to configure the compiler (e.g. `{target: '18'}`). Requires
235
+ * `babel-plugin-react-compiler` to be installed.
312
236
  */
313
- jsxImportSource?: string;
314
- minify?: boolean;
315
- /** @alpha */
316
- rollup?: {
317
- plugins?: PkgConfigProperty<Plugin[]>;
318
- output?: Partial<NormalizedOutputOptions>;
319
- /**
320
- * Defaults to Rollup's `preset: 'recommended'` tree-shaking options. Anything provided here
321
- * is merged on top of that preset.
322
- * @alpha
323
- */
324
- treeshake?: TreeshakingOptions;
325
- /** @alpha */
326
- experimentalLogSideEffects?: boolean;
327
- /**
328
- * Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
329
- * It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
330
- * @defaultValue false
331
- */
332
- hashChunkFileNames?: boolean;
333
- /**
334
- * Optimizes lodash imports using `@optimize-lodash/rollup-plugin` when set to `true`.
335
- * It's enabled if `lodash` is found in `dependencies` or `peerDependencies`.
336
- * It will use `lodash-es` for ESM targets if found in `dependencies` or `peerDependencies`.
337
- * @defaultValue true
338
- * @alpha
339
- */
340
- optimizeLodash?: boolean | OptimizeLodashOptions;
341
- /**
342
- * Enables \@vanilla-extract/rollup-plugin to extract CSS into a separate file, with support for
343
- * minifying the extracted CSS. Pass `true` to use the defaults, or an object to customize.
344
- *
345
- * By default (`extract.compatMode: true`) pkg-utils also injects the self-referential
346
- * `import "<pkg>/bundle.css"`, emits a `bundle-css.js` shim, and writes the conditional
347
- * `"./bundle.css"` export to `package.json` - see {@link PkgVanillaExtractOptions}.
348
- * @alpha
349
- */
350
- vanillaExtract?: boolean | PkgVanillaExtractOptions;
351
- };
237
+ reactCompiler?: boolean | ReactCompilerOptions$1;
352
238
  /**
353
239
  * Default runtime of package exports
354
240
  */
@@ -358,27 +244,87 @@ interface PkgConfigOptions {
358
244
  * Directory of source files.
359
245
  */
360
246
  src?: string;
361
- tsconfig?: string;
362
247
  /**
363
248
  * Configure what checks are made when running `--strict` builds and checks
364
249
  */
365
250
  strictOptions?: Partial<StrictOptions>;
366
251
  /**
367
- * .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`.
368
- * `rolldown` is the faster option, but is not yet stable.
369
- * @defaultValue 'api-extractor'
252
+ * Applies the `styled-components` transform (`displayName`, `componentId`, CSS minification,
253
+ * etc) using oxc's native port of `babel-plugin-styled-components` no Babel dependencies
254
+ * required. Pass `true` for the defaults, or an options object to customize.
255
+ * @defaultValue false
370
256
  */
371
- dts?: DtsType;
257
+ styledComponents?: boolean | StyledComponentsOptions$1;
258
+ tsconfig?: string;
372
259
  /**
373
- * When using `dts: 'rolldown'`, enables the use of the Go-native TypeScript compiler (`tsgo`) for type generation.
374
- * By default, `tsgo` is automatically enabled if `@typescript/native-preview` is found in `devDependencies`,
375
- * or if the installed `typescript` is v7 (which is the Go-native compiler).
376
- * Set to `true` to explicitly enable or `false` to explicitly disable.
377
- * Note that `tsgo` cannot be disabled when `typescript` v7 is installed, as v7 no longer ships
378
- * the JS compiler API that the non-tsgo code path depends on.
260
+ * Runs `@microsoft/api-extractor` during `pkg check` to check that TSDoc tags are valid and
261
+ * release tags are correct. This is useful for packages that are consumed by TSDoc-based
262
+ * tooling. It's enabled by default; set `tsdoc: false` to disable it.
263
+ */
264
+ tsdoc?: false | PkgTsdocOptions;
265
+ /**
266
+ * Enables `@sanity/vanilla-extract-tsdown-plugin` to extract CSS from `.css.ts` files into a
267
+ * separate file (`dist/bundle.css` by default), minified and lowered with `lightningcss`.
268
+ * By default the conditional CSS export pattern is wired up automatically: the
269
+ * self-referential `import "<pkg>/bundle.css"` is injected into the entry chunks, a no-op
270
+ * `bundle-css.js` shim is emitted, and the conditional `"./bundle.css"` export is written to
271
+ * `package.json`. Pass `true` for the defaults, or an options object to customize.
379
272
  * @alpha
380
273
  */
381
- tsgo?: boolean;
274
+ vanillaExtract?: boolean | PackageVanillaExtractOptions$1;
275
+ /**
276
+ * @deprecated Removed in v12. `babel.reactCompiler` is the top-level `reactCompiler` option,
277
+ * `babel.styledComponents` is the top-level `styledComponents` option (now an oxc native
278
+ * transform — `babel-plugin-styled-components` can be uninstalled), and custom Babel plugins
279
+ * run through the `plugins` option with a self-installed `@rolldown/plugin-babel`.
280
+ */
281
+ babel?: never;
282
+ /**
283
+ * @deprecated Removed in v12. TSDoc/release-tag checking is configured with the top-level
284
+ * `tsdoc` option (`extract: {enabled: false}` becomes `tsdoc: false`; `rules` and
285
+ * `customTags` carry over unchanged). Type inlining (`extract.bundledPackages`) is
286
+ * `dts: {resolve: [...]}`. `extract.checkTypes` has no successor — type generation no longer
287
+ * type-checks.
288
+ */
289
+ extract?: never;
290
+ /**
291
+ * @deprecated Removed in v12. Configure JSX through `tsconfig.json` (`compilerOptions.jsx`,
292
+ * `jsxFactory`, `jsxFragmentFactory`, `jsxImportSource`) — the bundler reads it from there.
293
+ */
294
+ jsx?: never;
295
+ /**
296
+ * @deprecated Removed in v12. Configure JSX through `tsconfig.json`
297
+ * (`compilerOptions.jsxFactory`).
298
+ */
299
+ jsxFactory?: never;
300
+ /**
301
+ * @deprecated Removed in v12. Configure JSX through `tsconfig.json`
302
+ * (`compilerOptions.jsxFragmentFactory`).
303
+ */
304
+ jsxFragment?: never;
305
+ /**
306
+ * @deprecated Removed in v12. Configure JSX through `tsconfig.json`
307
+ * (`compilerOptions.jsxImportSource`).
308
+ */
309
+ jsxImportSource?: never;
310
+ /**
311
+ * @deprecated Removed in v12. Pass the compiler options to `reactCompiler` instead:
312
+ * `reactCompiler: {target: '18'}`.
313
+ */
314
+ reactCompilerOptions?: never;
315
+ /**
316
+ * @deprecated Removed in v12. `rollup.vanillaExtract` is the top-level `vanillaExtract`
317
+ * option, and `rollup.plugins` is the top-level `plugins` option (rolldown plugins; most
318
+ * Rollup plugins are compatible). `rollup.output`, `rollup.treeshake`,
319
+ * `rollup.experimentalLogSideEffects`, `rollup.hashChunkFileNames` and
320
+ * `rollup.optimizeLodash` have no successor.
321
+ */
322
+ rollup?: never;
323
+ /**
324
+ * @deprecated Removed in v12. Set `dts: {tsgo: true}` instead — the `dts` option is passed
325
+ * through to tsdown as-is.
326
+ */
327
+ tsgo?: never;
382
328
  }
383
329
  /** @public */
384
330
  declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
@@ -402,5 +348,5 @@ interface PkgTemplateStringOption<T = string> {
402
348
  type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;
403
349
  /** @public */
404
350
  declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
405
- export { DEFAULT_BROWSERSLIST_QUERY, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type RollupPlugin, type TSDocCustomTag, defineConfig, defineTemplateOption, loadConfig };
351
+ export { DEFAULT_BROWSERSLIST_QUERY, type PackageVanillaExtractOptions, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type PkgTsdocOptions, type ReactCompilerOptions, type StyledComponentsOptions, type TSDocCustomTag, defineConfig, defineTemplateOption, loadConfig };
406
352
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/node/strict.ts","../src/node/core/config/types.ts","../src/node/core/config/defineConfig.ts","../src/node/core/config/loadConfig.ts","../src/node/core/defaults.ts","../src/node/core/template/types.ts","../src/node/core/template/define.ts"],"mappings":";;;;;;KAKK;;;;UAwCY;;;;;EAKf,sBAAsB;;;;;EAKtB,uBAAuB;;;;;;;;;EASvB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,cAAc;;;;;EAKd,sBAAsB;;;;;EAKtB,4BAA4B;;;;;EAK5B,kBAAkB;;;;;EAKlB,wBAAwB;;;;;EAKxB,yBAAyB;;;;;EAKzB,0BAA0B;;;;;EAK1B,6BAA6B;;;;;EAK7B,oBAAoB;;;;;EAKpB,8BAA8B;;;;;EAK9B,mBAAmB;;;;;EAKnB,sBAAsB;;;;;EAKtB,wBAAwB;;;;;EAKxB,2BAA2B;;;;;EAK3B,uBAAuB;;;;;EAKvB,sBAAsB;;;;;EAKtB,8BAA8B;;;KCpJpB;;;;;;UAOK,iCAAiC,KAAK;;;;;EAKrD;;;;;EAKA;;;;;EAKA,cAAc;;;;EAId;;;;;IAKE;;;;;IAKA;;;;;;;;;;;;;;;;;IAiBA;;;;KAKQ;;KAGA,0BAA0B,MAAM,MAAM,MAAM;;KAG5C,kBAAkB,KAAK,0BAA0B,KAAK;;UAGjD;EACf;EACA;EACA;EACA,UAAU;;;KAIA;;UAGK;EACf;EACA;EACA;;KAGU;;UAGK;;EAEf;IACE,UAAU;;IAEV;;IAEA;;MAIM;;;;;MAKA;;MAEA;;MAEA;;MAEA;;MAEA;;;;;;;;MAQA;MACA;;MAEA;;;;;;;EAOR,uBAAuB,QAAQ;EAC/B,UAAU;;EAEV,SAAS;;;;EAIT;EACA,UAAU,kBAAkB;;;;;;EAM5B;;;;IAIE;;;;;;;IAOA;;;;;;;;IAQA,kBAAkB;IAClB,aAAa;IACb;MACE,iCAAiC;MACjC,mCAAmC;MACnC,2BAA2B;MAC3B,kCAAkC;MAClC,wBAAwB;MACxB,0BAA0B;;;;;;;;;;EAU9B,WAAW;;;;EAIX;;;;EAIA;;;;EAIA;;;;EAIA;EACA;;EAEA;IACE,UAAU,kBAAkB;IAC5B,SAAS,QAAQ;;;;;;IAMjB,YAAY;;IAEZ;;;;;;IAMA;;;;;;;;IAQA,2BAA2B;;;;;;;;;;IAU3B,2BAA2B;;;;;EAK7B,UAAU;EACV;;;;EAIA;EACA;;;;EAIA,gBAAgB,QAAQ;;;;;;EAMxB,MAAM;;;;;;;;;;EAUN;;;iBChRc,mBAAmB,UAAU,kBAAkB,eAAe,IAAI;;iBCI5D,WAAW;EAC/B;EACA;IACE,QAAQ;;cCPC;;UCMI,wBAAwB;EACvC;EACA;EACA;EACA,UAAU,MAAM,SAAS,wBAAwB;EACjD,SAAS,cAAc;EACvB,YAAY;;;KAIF,kBAAkB,cAAc,wBAAwB;;iBChBpD,qBAAqB,GAAG,QAAQ,kBAAkB,KAAK,kBAAkB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/node/strict.ts","../src/node/core/config/types.ts","../src/node/core/config/defineConfig.ts","../src/node/core/config/loadConfig.ts","../src/node/core/defaults.ts","../src/node/core/template/types.ts","../src/node/core/template/define.ts"],"mappings":";;;KAKK;;;;UAwCY;;;;;EAKf,sBAAsB;;;;;EAKtB,uBAAuB;;;;;;;;;EASvB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,wBAAwB;;;;;EAKxB,cAAc;;;;;EAKd,sBAAsB;;;;;EAKtB,4BAA4B;;;;;EAK5B,kBAAkB;;;;;EAKlB,wBAAwB;;;;;EAKxB,yBAAyB;;;;;EAKzB,0BAA0B;;;;;EAK1B,6BAA6B;;;;;EAK7B,oBAAoB;;;;;EAKpB,8BAA8B;;;;;EAK9B,mBAAmB;;;;;EAKnB,sBAAsB;;;;;EAKtB,wBAAwB;;;;;EAKxB,2BAA2B;;;;;EAK3B,uBAAuB;;;;;EAKvB,sBAAsB;;;;;EAKtB,8BAA8B;;;KC9IpB;;KAGA;;KAGA,0BAA0B,MAAM,MAAM,MAAM;;KAG5C,kBAAkB,KAAK,0BAA0B,KAAK;;UAGjD;EACf;EACA;EACA;EACA,UAAU;;;KAIA;;UAGK;EACf;EACA;EACA;;;;;;;UAQe;EACf,aAAa;EACb;IACE,iCAAiC;IACjC,mCAAmC;IACnC,2BAA2B;IAC3B,kCAAkC;IAClC,wBAAwB;IACxB,0BAA0B;;;;UAKb;EACf,UAAU;;;;;;;;;EASV,QAAQ;;EAER,SAAS;;;;;;;;EAQT,OAAO;;;;EAIP;;;;;;;EAOA,cAAc,QAAQ,YAAY;EAClC,UAAU,kBAAkB;;;;;;;;;;;EAW5B,WAAW;;;;;;;;EAQX;;;;;;;;EAQA;;;;;;;EAOA,UAAU;;;;;;;EAOV,0BAA0B;;;;EAI1B,UAAU;EACV;;;;EAIA;;;;EAIA,gBAAgB,QAAQ;;;;;;;EAOxB,6BAA6B;EAC7B;;;;;;EAMA,gBAAgB;;;;;;;;;;EAUhB,2BAA2B;;;;;;;EAa3B;;;;;;;;EAQA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;;;;EAQA;;;;;EAKA;;;iBCtOc,mBAAmB,UAAU,kBAAkB,eAAe,IAAI;;iBCK5D,WAAW;EAC/B;EACA;IACE,QAAQ;;cCRC;;UCMI,wBAAwB;EACvC;EACA;EACA;EACA,UAAU,MAAM,SAAS,wBAAwB;EACjD,SAAS,cAAc;EACvB,YAAY;;;KAIF,kBAAkB,cAAc,wBAAwB;;iBChBpD,qBAAqB,GAAG,QAAQ,kBAAkB,KAAK,kBAAkB"}
package/dist/index.js CHANGED
@@ -1,12 +1,204 @@
1
- import { DEFAULT_BROWSERSLIST_QUERY, loadConfig } from "./_chunks-es/defaults.js";
2
- import { defineTemplateOption } from "./_chunks-es/define.js";
1
+ import path from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+ import { tsImport } from "tsx/esm/api";
4
+ import findConfig from "find-config";
5
+ import { statSync } from "node:fs";
6
+ import config from "@sanity/browserslist-config";
7
+ /** @public */
3
8
  function defineConfig(configOptions) {
4
- return configOptions;
5
- }
6
- export {
7
- DEFAULT_BROWSERSLIST_QUERY,
8
- defineConfig,
9
- defineTemplateOption,
10
- loadConfig
11
- };
12
- //# sourceMappingURL=index.js.map
9
+ return configOptions;
10
+ }
11
+ /** @internal */
12
+ function fileExists(filePath) {
13
+ try {
14
+ return statSync(filePath), !0;
15
+ } catch {
16
+ return !1;
17
+ }
18
+ }
19
+ const CONFIG_FILE_NAMES = [
20
+ "package.config.ts",
21
+ "package.config.js",
22
+ "package.config.cjs",
23
+ "package.config.mts",
24
+ "package.config.mjs"
25
+ ];
26
+ /** @internal */
27
+ function findConfigFile(cwd) {
28
+ let pkgJsonPath = findConfig("package.json", { cwd });
29
+ if (!pkgJsonPath) return;
30
+ let pkgPath = path.dirname(pkgJsonPath);
31
+ for (let fileName of CONFIG_FILE_NAMES) {
32
+ let configPath = path.resolve(pkgPath, fileName);
33
+ if (fileExists(configPath)) return configPath;
34
+ }
35
+ }
36
+ /**
37
+ * Migration checks for `package.config.ts` options that were removed or deprecated in v12,
38
+ * when `@sanity/pkg-utils` moved from its rollup/rolldown stack onto `tsdown` +
39
+ * `@sanity/tsdown-config`.
40
+ *
41
+ * Removed options are "tombstoned": they stay declared on `PkgConfigOptions` (typed `never`,
42
+ * tagged `@deprecated`) so editors surface the migration path, and the checks below throw a
43
+ * runtime error with copy-pasteable migration instructions when they are set anyway — JS
44
+ * configs bypass the types, and the error text is written to be actionable for humans and
45
+ * agents alike.
46
+ *
47
+ * The checks are gated by the `legacyChecks` option, defaulting to on outside production
48
+ * builds (`process.env.NODE_ENV !== 'production'`) so they add no overhead where migration
49
+ * mistakes can no longer surface.
50
+ */
51
+ const MIGRATION_GUIDE_URL = "https://github.com/sanity-io/pkg-utils/blob/main/packages/@sanity/pkg-utils/MIGRATE.md", tombstones = [
52
+ {
53
+ option: "tsgo",
54
+ migration: [
55
+ "The `dts` option is now passed through to tsdown as-is. Move the flag into it:",
56
+ "",
57
+ " // package.config.ts",
58
+ " export default defineConfig({",
59
+ " dts: {tsgo: true},",
60
+ " })"
61
+ ]
62
+ },
63
+ {
64
+ option: "extract",
65
+ migration: [
66
+ "TSDoc/release-tag checking is configured with the top-level `tsdoc` option:",
67
+ "",
68
+ " // extract: {enabled: false} -> tsdoc: false",
69
+ " // extract: {rules: {...}} -> tsdoc: {rules: {...}}",
70
+ " // extract: {customTags: [...]} -> tsdoc: {customTags: [...]}",
71
+ "",
72
+ "Type inlining (`extract.bundledPackages`) follows the bundling decisions now:",
73
+ "devDependencies that are imported are inlined automatically (types included), and",
74
+ "`deps: {alwaysBundle: [...]}` forces inlining a dependency/peerDependency.",
75
+ "",
76
+ "`extract.checkTypes` has no successor: type generation no longer type-checks",
77
+ "(run `tsc --noEmit` for type checking)."
78
+ ]
79
+ },
80
+ {
81
+ option: "babel",
82
+ migration: [
83
+ "The Babel options moved to the top level:",
84
+ "",
85
+ " // babel: {reactCompiler: true} -> reactCompiler: true",
86
+ " // babel: {styledComponents: true} -> styledComponents: true",
87
+ "",
88
+ "`styledComponents` now uses oxc’s native port of `babel-plugin-styled-components`,",
89
+ "so `babel-plugin-styled-components` can be uninstalled.",
90
+ "",
91
+ "Custom Babel plugins (`babel.plugins`) run through the `plugins` option instead,",
92
+ "with a self-installed `@rolldown/plugin-babel`:",
93
+ "",
94
+ " import pluginBabel from \"@rolldown/plugin-babel\"",
95
+ " export default defineConfig({",
96
+ " plugins: [await pluginBabel({plugins: [\"babel-plugin-example\"]})],",
97
+ " })"
98
+ ]
99
+ },
100
+ {
101
+ option: "rollup",
102
+ migration: [
103
+ "The rollup stack was replaced with tsdown:",
104
+ "",
105
+ " // rollup: {vanillaExtract: true} -> vanillaExtract: true",
106
+ " // rollup: {plugins: [...]} -> plugins: [...] (rolldown plugins; most",
107
+ " // Rollup plugins are compatible)",
108
+ "",
109
+ "`rollup.output`, `rollup.treeshake`, `rollup.experimentalLogSideEffects` and",
110
+ "`rollup.hashChunkFileNames` have no successor (chunk filenames are content-hashed now).",
111
+ "",
112
+ "`rollup.optimizeLodash` has no successor either — and neither does the implicit",
113
+ "lodash-import optimization that was applied whenever `lodash` was a dependency.",
114
+ "Preferably drop lodash altogether (see https://e18e.dev for module replacements like",
115
+ "`es-toolkit`), or import from `lodash-es`, which tree-shakes in consumers without",
116
+ "build-time rewriting."
117
+ ]
118
+ },
119
+ {
120
+ option: "reactCompilerOptions",
121
+ migration: [
122
+ "Pass the compiler options to `reactCompiler` instead:",
123
+ "",
124
+ " // babel: {reactCompiler: true}, reactCompilerOptions: {target: \"18\"}",
125
+ " // becomes:",
126
+ " reactCompiler: {target: \"18\"}"
127
+ ]
128
+ },
129
+ {
130
+ option: "jsx",
131
+ migration: [
132
+ "Configure JSX through `tsconfig.json` — the bundler reads it from there:",
133
+ "",
134
+ " // tsconfig.json",
135
+ " {\"compilerOptions\": {\"jsx\": \"react-jsx\"}}"
136
+ ]
137
+ },
138
+ {
139
+ option: "jsxFactory",
140
+ migration: ["Configure JSX through `tsconfig.json` (`compilerOptions.jsxFactory`)."]
141
+ },
142
+ {
143
+ option: "jsxFragment",
144
+ migration: ["Configure JSX through `tsconfig.json` (`compilerOptions.jsxFragmentFactory`)."]
145
+ },
146
+ {
147
+ option: "jsxImportSource",
148
+ migration: ["Configure JSX through `tsconfig.json` (`compilerOptions.jsxImportSource`)."]
149
+ }
150
+ ];
151
+ /**
152
+ * Throws for tombstoned options and warns for grandfathered ones. `config` is the raw loaded
153
+ * config object (before it is narrowed to `PkgConfigOptions`), so removed options are still
154
+ * observable.
155
+ * @internal
156
+ */
157
+ function runLegacyConfigChecks(config) {
158
+ if (!(typeof config.legacyChecks == "boolean" ? config.legacyChecks : process.env.NODE_ENV !== "production")) return;
159
+ for (let { option, migration } of tombstones) if (config[option] !== void 0) throw Error([
160
+ `package.config.ts: the \`${option}\` option was removed in @sanity/pkg-utils v12.`,
161
+ "",
162
+ ...migration,
163
+ "",
164
+ `Full migration guide: ${MIGRATION_GUIDE_URL}`,
165
+ "Set `legacyChecks: false` in package.config.ts to skip this validation (it is also",
166
+ "skipped when NODE_ENV=production)."
167
+ ].join("\n"));
168
+ let dts = config.dts;
169
+ if (typeof dts == "string") throw Error([
170
+ `package.config.ts: \`dts: '${dts}'\` was removed in @sanity/pkg-utils v12 — the \`dts\``,
171
+ "option is now passed through to tsdown as-is (an options object, or `false`).",
172
+ "",
173
+ ...dts === "rolldown" ? ["`dts: 'rolldown'` is the default behavior now: delete the option. Options that", "accompanied it move into the object, e.g. `tsgo: true` becomes `dts: {tsgo: true}`."] : [
174
+ "`dts: 'api-extractor'` type generation was removed. Types are generated with",
175
+ "tsdown (rolldown-plugin-dts); api-extractor remains as the TSDoc/release-tag",
176
+ "checking that runs during `pkg check` — configure it with the `tsdoc` option."
177
+ ],
178
+ "",
179
+ `Full migration guide: ${MIGRATION_GUIDE_URL}`,
180
+ "Set `legacyChecks: false` in package.config.ts to skip this validation (it is also",
181
+ "skipped when NODE_ENV=production)."
182
+ ].join("\n"));
183
+ config.external !== void 0 && console.warn([
184
+ "package.config.ts: `external` is deprecated. Use `deps: {neverBundle: [...]}` to mark",
185
+ "dependencies as external, and `deps: {alwaysBundle: [...]}` to bundle a dependency",
186
+ "(the callback pattern that filtered entries out of the defaults)."
187
+ ].join("\n"));
188
+ }
189
+ /** @alpha */
190
+ async function loadConfig(options) {
191
+ let { cwd, pkgPath } = options, configFile = findConfigFile(path.dirname(pkgPath));
192
+ if (!configFile || !configFile.startsWith(cwd)) return;
193
+ let mod = await tsImport(pathToFileURL(configFile).toString(), import.meta.url), config = mod?.default || mod || void 0;
194
+ return config && typeof config == "object" && runLegacyConfigChecks(config), config;
195
+ }
196
+ /** @public */
197
+ const DEFAULT_BROWSERSLIST_QUERY = config;
198
+ /** @public */
199
+ function defineTemplateOption(option) {
200
+ return option;
201
+ }
202
+ export { DEFAULT_BROWSERSLIST_QUERY, defineConfig, defineTemplateOption, loadConfig };
203
+
204
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/node/core/config/defineConfig.ts"],"sourcesContent":["import type {PkgConfigOptions} from './types.ts'\n\n/** @public */\nexport function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T {\n return configOptions\n}\n"],"names":[],"mappings":";;AAGO,SAAS,aAA+C,eAAqB;AAClF,SAAO;AACT;"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/node/core/config/defineConfig.ts","../src/node/fileExists.ts","../src/node/core/config/findConfigFile.ts","../src/node/core/config/legacyConfig.ts","../src/node/core/config/loadConfig.ts","../src/node/core/defaults.ts","../src/node/core/template/define.ts"],"sourcesContent":["import type {PkgConfigOptions} from './types.ts'\n\n/** @public */\nexport function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T {\n return configOptions\n}\n","import {statSync} from 'node:fs'\n\n/** @internal */\nexport function fileExists(filePath: string): boolean {\n try {\n statSync(filePath)\n\n return true\n } catch {\n return false\n }\n}\n","import path from 'node:path'\nimport findConfig from 'find-config'\nimport {fileExists} from '../../fileExists.ts'\n\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\n 'package.config.mts',\n 'package.config.mjs',\n]\n\n/** @internal */\nexport function findConfigFile(cwd: string): string | undefined {\n const pkgJsonPath = findConfig('package.json', {cwd})\n\n if (!pkgJsonPath) return undefined\n\n const pkgPath = path.dirname(pkgJsonPath)\n\n for (const fileName of CONFIG_FILE_NAMES) {\n const configPath = path.resolve(pkgPath, fileName)\n\n const exists = fileExists(configPath)\n\n if (exists) {\n return configPath\n }\n }\n\n return undefined\n}\n","/**\n * Migration checks for `package.config.ts` options that were removed or deprecated in v12,\n * when `@sanity/pkg-utils` moved from its rollup/rolldown stack onto `tsdown` +\n * `@sanity/tsdown-config`.\n *\n * Removed options are \"tombstoned\": they stay declared on `PkgConfigOptions` (typed `never`,\n * tagged `@deprecated`) so editors surface the migration path, and the checks below throw a\n * runtime error with copy-pasteable migration instructions when they are set anyway — JS\n * configs bypass the types, and the error text is written to be actionable for humans and\n * agents alike.\n *\n * The checks are gated by the `legacyChecks` option, defaulting to on outside production\n * builds (`process.env.NODE_ENV !== 'production'`) so they add no overhead where migration\n * mistakes can no longer surface.\n */\n\nconst MIGRATION_GUIDE_URL =\n 'https://github.com/sanity-io/pkg-utils/blob/main/packages/@sanity/pkg-utils/MIGRATE.md'\n\ninterface LegacyCheck {\n option: string\n migration: string[]\n}\n\nconst tombstones: LegacyCheck[] = [\n {\n option: 'tsgo',\n migration: [\n 'The `dts` option is now passed through to tsdown as-is. Move the flag into it:',\n '',\n ' // package.config.ts',\n ' export default defineConfig({',\n ' dts: {tsgo: true},',\n ' })',\n ],\n },\n {\n option: 'extract',\n migration: [\n 'TSDoc/release-tag checking is configured with the top-level `tsdoc` option:',\n '',\n ' // extract: {enabled: false} -> tsdoc: false',\n ' // extract: {rules: {...}} -> tsdoc: {rules: {...}}',\n ' // extract: {customTags: [...]} -> tsdoc: {customTags: [...]}',\n '',\n 'Type inlining (`extract.bundledPackages`) follows the bundling decisions now:',\n 'devDependencies that are imported are inlined automatically (types included), and',\n '`deps: {alwaysBundle: [...]}` forces inlining a dependency/peerDependency.',\n '',\n '`extract.checkTypes` has no successor: type generation no longer type-checks',\n '(run `tsc --noEmit` for type checking).',\n ],\n },\n {\n option: 'babel',\n migration: [\n 'The Babel options moved to the top level:',\n '',\n ' // babel: {reactCompiler: true} -> reactCompiler: true',\n ' // babel: {styledComponents: true} -> styledComponents: true',\n '',\n '`styledComponents` now uses oxc\\u2019s native port of `babel-plugin-styled-components`,',\n 'so `babel-plugin-styled-components` can be uninstalled.',\n '',\n 'Custom Babel plugins (`babel.plugins`) run through the `plugins` option instead,',\n 'with a self-installed `@rolldown/plugin-babel`:',\n '',\n ' import pluginBabel from \"@rolldown/plugin-babel\"',\n ' export default defineConfig({',\n ' plugins: [await pluginBabel({plugins: [\"babel-plugin-example\"]})],',\n ' })',\n ],\n },\n {\n option: 'rollup',\n migration: [\n 'The rollup stack was replaced with tsdown:',\n '',\n ' // rollup: {vanillaExtract: true} -> vanillaExtract: true',\n ' // rollup: {plugins: [...]} -> plugins: [...] (rolldown plugins; most',\n ' // Rollup plugins are compatible)',\n '',\n '`rollup.output`, `rollup.treeshake`, `rollup.experimentalLogSideEffects` and',\n '`rollup.hashChunkFileNames` have no successor (chunk filenames are content-hashed now).',\n '',\n '`rollup.optimizeLodash` has no successor either \\u2014 and neither does the implicit',\n 'lodash-import optimization that was applied whenever `lodash` was a dependency.',\n 'Preferably drop lodash altogether (see https://e18e.dev for module replacements like',\n '`es-toolkit`), or import from `lodash-es`, which tree-shakes in consumers without',\n 'build-time rewriting.',\n ],\n },\n {\n option: 'reactCompilerOptions',\n migration: [\n 'Pass the compiler options to `reactCompiler` instead:',\n '',\n ' // babel: {reactCompiler: true}, reactCompilerOptions: {target: \"18\"}',\n ' // becomes:',\n ' reactCompiler: {target: \"18\"}',\n ],\n },\n {\n option: 'jsx',\n migration: [\n 'Configure JSX through `tsconfig.json` \\u2014 the bundler reads it from there:',\n '',\n ' // tsconfig.json',\n ' {\"compilerOptions\": {\"jsx\": \"react-jsx\"}}',\n ],\n },\n {\n option: 'jsxFactory',\n migration: ['Configure JSX through `tsconfig.json` (`compilerOptions.jsxFactory`).'],\n },\n {\n option: 'jsxFragment',\n migration: ['Configure JSX through `tsconfig.json` (`compilerOptions.jsxFragmentFactory`).'],\n },\n {\n option: 'jsxImportSource',\n migration: ['Configure JSX through `tsconfig.json` (`compilerOptions.jsxImportSource`).'],\n },\n]\n\n/**\n * Throws for tombstoned options and warns for grandfathered ones. `config` is the raw loaded\n * config object (before it is narrowed to `PkgConfigOptions`), so removed options are still\n * observable.\n * @internal\n */\nexport function runLegacyConfigChecks(config: Record<string, unknown>): void {\n const legacyChecks =\n typeof config['legacyChecks'] === 'boolean'\n ? config['legacyChecks']\n : process.env['NODE_ENV'] !== 'production'\n\n if (!legacyChecks) return\n\n for (const {option, migration} of tombstones) {\n if (config[option] === undefined) continue\n\n throw new Error(\n [\n `package.config.ts: the \\`${option}\\` option was removed in @sanity/pkg-utils v12.`,\n '',\n ...migration,\n '',\n `Full migration guide: ${MIGRATION_GUIDE_URL}`,\n 'Set `legacyChecks: false` in package.config.ts to skip this validation (it is also',\n 'skipped when NODE_ENV=production).',\n ].join('\\n'),\n )\n }\n\n // `dts` survived, but as a tsdown passthrough object — the old mode strings are tombstoned\n // with value-specific migration instructions.\n const dts = config['dts']\n if (typeof dts === 'string') {\n throw new Error(\n [\n `package.config.ts: \\`dts: '${dts}'\\` was removed in @sanity/pkg-utils v12 — the \\`dts\\``,\n 'option is now passed through to tsdown as-is (an options object, or `false`).',\n '',\n ...(dts === 'rolldown'\n ? [\n \"`dts: 'rolldown'` is the default behavior now: delete the option. Options that\",\n 'accompanied it move into the object, e.g. `tsgo: true` becomes `dts: {tsgo: true}`.',\n ]\n : [\n \"`dts: 'api-extractor'` type generation was removed. Types are generated with\",\n 'tsdown (rolldown-plugin-dts); api-extractor remains as the TSDoc/release-tag',\n 'checking that runs during `pkg check` — configure it with the `tsdoc` option.',\n ]),\n '',\n `Full migration guide: ${MIGRATION_GUIDE_URL}`,\n 'Set `legacyChecks: false` in package.config.ts to skip this validation (it is also',\n 'skipped when NODE_ENV=production).',\n ].join('\\n'),\n )\n }\n\n // Grandfathered: `external` still works (mapped onto tsdown's `deps`), with a nudge toward\n // its successor.\n if (config['external'] !== undefined) {\n // eslint-disable-next-line no-console -- config-load-time deprecation warning\n console.warn(\n [\n 'package.config.ts: `external` is deprecated. Use `deps: {neverBundle: [...]}` to mark',\n 'dependencies as external, and `deps: {alwaysBundle: [...]}` to bundle a dependency',\n '(the callback pattern that filtered entries out of the defaults).',\n ].join('\\n'),\n )\n }\n}\n","import path from 'node:path'\nimport {pathToFileURL} from 'node:url'\nimport {tsImport} from 'tsx/esm/api'\nimport {findConfigFile} from './findConfigFile.ts'\nimport {runLegacyConfigChecks} from './legacyConfig.ts'\nimport type {PkgConfigOptions} from './types.ts'\n\n/** @alpha */\nexport async function loadConfig(options: {\n cwd: string\n pkgPath: string\n}): Promise<PkgConfigOptions | undefined> {\n const {cwd, pkgPath} = options\n\n const root = path.dirname(pkgPath)\n\n const configFile = findConfigFile(root)\n\n if (!configFile) {\n return undefined\n }\n\n // Do not accept config files outside of the root\n if (!configFile.startsWith(cwd)) {\n return undefined\n }\n\n const mod = await tsImport(pathToFileURL(configFile).toString(), import.meta.url)\n\n const config = mod?.default || mod || undefined\n\n if (config && typeof config === 'object') {\n runLegacyConfigChecks(config)\n }\n\n return config\n}\n","import config from '@sanity/browserslist-config'\n\n/** @public */\nexport const DEFAULT_BROWSERSLIST_QUERY: string[] = config\n","import type {PkgTemplateOption} from './types.ts'\n\n/** @public */\nexport function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T> {\n return option\n}\n"],"mappings":";;;;;;;AAGA,SAAgB,aAA+C,eAAqB;CAClF,OAAO;AACT;;ACFA,SAAgB,WAAW,UAA2B;CACpD,IAAI;EAGF,OAFA,SAAS,QAAQ,GAEV;CACT,QAAQ;EACN,OAAO;CACT;AACF;ACPA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAgB,eAAe,KAAiC;CAC9D,IAAM,cAAc,WAAW,gBAAgB,EAAC,IAAG,CAAC;CAEpD,IAAI,CAAC,aAAa;CAElB,IAAM,UAAU,KAAK,QAAQ,WAAW;CAExC,KAAK,IAAM,YAAY,mBAAmB;EACxC,IAAM,aAAa,KAAK,QAAQ,SAAS,QAAQ;EAIjD,IAFe,WAAW,UAEjB,GACP,OAAO;CAEX;AAGF;;;;;;;;;;;;;;;;ACfA,MAAM,sBACJ,0FAOI,aAA4B;CAChC;EACE,QAAQ;EACR,WAAW;GACT;GACA;GACA;GACA;GACA;GACA;EACF;CACF;CACA;EACE,QAAQ;EACR,WAAW;GACT;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;CACF;CACA;EACE,QAAQ;EACR,WAAW;GACT;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;CACF;CACA;EACE,QAAQ;EACR,WAAW;GACT;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;CACF;CACA;EACE,QAAQ;EACR,WAAW;GACT;GACA;GACA;GACA;GACA;EACF;CACF;CACA;EACE,QAAQ;EACR,WAAW;GACT;GACA;GACA;GACA;EACF;CACF;CACA;EACE,QAAQ;EACR,WAAW,CAAC,uEAAuE;CACrF;CACA;EACE,QAAQ;EACR,WAAW,CAAC,+EAA+E;CAC7F;CACA;EACE,QAAQ;EACR,WAAW,CAAC,4EAA4E;CAC1F;AACF;;;;;;;AAQA,SAAgB,sBAAsB,QAAuC;CAM3E,IAAI,EAJF,OAAO,OAAO,gBAAoB,YAC9B,OAAO,eACP,QAAQ,IAAI,aAAgB,eAEf;CAEnB,KAAK,IAAM,EAAC,QAAQ,eAAc,YAC5B,WAAO,YAAY,KAAA,GAEvB,MAAU,MACR;EACE,4BAA4B,OAAO;EACnC;EACA,GAAG;EACH;EACA,yBAAyB;EACzB;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;CAKF,IAAM,MAAM,OAAO;CACnB,IAAI,OAAO,OAAQ,UACjB,MAAU,MACR;EACE,8BAA8B,IAAI;EAClC;EACA;EACA,GAAI,QAAQ,aACR,CACE,kFACA,qFACF,IACA;GACE;GACA;GACA;EACF;EACJ;EACA,yBAAyB;EACzB;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;CAKF,AAAI,OAAO,aAAgB,KAAA,KAEzB,QAAQ,KACN;EACE;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;AAEJ;;AC1LA,eAAsB,WAAW,SAGS;CACxC,IAAM,EAAC,KAAK,YAAW,SAIjB,aAAa,eAFN,KAAK,QAAQ,OAEW,CAAC;CAOtC,IALI,CAAC,cAKD,CAAC,WAAW,WAAW,GAAG,GAC5B;CAGF,IAAM,MAAM,MAAM,SAAS,cAAc,UAAU,CAAC,CAAC,SAAS,GAAG,OAAO,KAAK,GAAG,GAE1E,SAAS,KAAK,WAAW,OAAO,KAAA;CAMtC,OAJI,UAAU,OAAO,UAAW,YAC9B,sBAAsB,MAAM,GAGvB;AACT;;ACjCA,MAAa,6BAAuC;;ACApD,SAAgB,qBAAwB,QAAoD;CAC1F,OAAO;AACT"}