@sanity/pkg-utils 12.3.4 → 13.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 (26) hide show
  1. package/MIGRATE.md +1 -1
  2. package/README.md +2 -2
  3. package/dist/{buildAction-BPF82HZg.js → buildAction-kavz9FnJ.js} +5 -5
  4. package/dist/buildAction-kavz9FnJ.js.map +1 -0
  5. package/dist/{checkAction-DWSqzrZd.js → checkAction-BSYijAy1.js} +4 -4
  6. package/dist/{checkAction-DWSqzrZd.js.map → checkAction-BSYijAy1.js.map} +1 -1
  7. package/dist/cli.js +5 -5
  8. package/dist/index.d.ts +9 -9
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +3 -3
  11. package/dist/index.js.map +1 -1
  12. package/dist/{resolveBuildContext-vVTRkIDl.js → resolveBuildContext-i4HOnPda.js} +4 -4
  13. package/dist/resolveBuildContext-i4HOnPda.js.map +1 -0
  14. package/dist/{resolveTsdownConfig-C6jUZqvp.js → resolveTsdownConfig-orfQXkE6.js} +14 -22
  15. package/dist/{resolveTsdownConfig-C6jUZqvp.js.map → resolveTsdownConfig-orfQXkE6.js.map} +1 -1
  16. package/dist/{watchAction-IMdjLKl4.js → watchAction-CIMqTWfx.js} +23 -18
  17. package/dist/watchAction-CIMqTWfx.js.map +1 -0
  18. package/dist/{watchConfigFiles-AGBDblwf.js → watchConfigFiles-Bt03CSXT.js} +5 -11
  19. package/dist/watchConfigFiles-Bt03CSXT.js.map +1 -0
  20. package/dist/{writeBundleCssExports-BO8zfc4U.js → writeBundleCssExports-CW1Lc_p6.js} +2 -2
  21. package/dist/{writeBundleCssExports-BO8zfc4U.js.map → writeBundleCssExports-CW1Lc_p6.js.map} +1 -1
  22. package/package.json +10 -9
  23. package/dist/buildAction-BPF82HZg.js.map +0 -1
  24. package/dist/resolveBuildContext-vVTRkIDl.js.map +0 -1
  25. package/dist/watchAction-IMdjLKl4.js.map +0 -1
  26. package/dist/watchConfigFiles-AGBDblwf.js.map +0 -1
package/MIGRATE.md CHANGED
@@ -13,7 +13,7 @@ stops with an error that contains these same migration instructions (skipped whe
13
13
  | ---------------------------------------------- | --------------------------------------------------------------------------------------- |
14
14
  | `dts: 'rolldown'` | delete it (it's the default now) |
15
15
  | `dts: 'api-extractor'` | delete it (types come from tsdown) |
16
- | `tsgo: true` | `dts: {tsgo: true}` |
16
+ | `tsgo: true` | `dts: {generator: 'tsgo'}` |
17
17
  | `babel: {reactCompiler: true}` | `reactCompiler: true` |
18
18
  | `reactCompilerOptions: {...}` | `reactCompiler: {...}` |
19
19
  | `babel: {styledComponents: true}` | `styledComponents: true` |
package/README.md CHANGED
@@ -147,8 +147,8 @@ The path to the directory to which bundle and chunk files should be written.
147
147
  - Default: `undefined`
148
148
 
149
149
  tsdown's [`dts` options](https://tsdown.dev/options/dts), passed through as-is (an object, or
150
- `false` to skip generating `.d.ts` files entirely). For example `dts: {tsgo: true}` selects the
151
- Go-native TypeScript compiler for type generation.
150
+ `false` to skip generating `.d.ts` files entirely). For example `dts: {generator: 'tsgo'}`
151
+ selects the Go-native TypeScript compiler for type generation.
152
152
 
153
153
  #### `exports`
154
154
 
@@ -1,7 +1,7 @@
1
1
  import { n as createLogger, r as isRecord, t as handleError } from "./handleError-83GwKIFM.js";
2
- import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-vVTRkIDl.js";
2
+ import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-i4HOnPda.js";
3
3
  import { t as createSpinner } from "./spinner-DAHe7SuT.js";
4
- import { r as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-C6jUZqvp.js";
4
+ import { r as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-orfQXkE6.js";
5
5
  import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
6
  import path from "node:path";
7
7
  import { up } from "empathic/package";
@@ -32,7 +32,7 @@ async function build$1(options) {
32
32
  let config = await loadConfig({
33
33
  cwd,
34
34
  pkgPath
35
- }), { parseStrictOptions } = await import("./resolveBuildContext-vVTRkIDl.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
35
+ }), { parseStrictOptions } = await import("./resolveBuildContext-i4HOnPda.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
36
36
  pkgPath,
37
37
  logger,
38
38
  strict,
@@ -54,7 +54,7 @@ async function build$1(options) {
54
54
  try {
55
55
  let inlineConfig = await resolveTsdownConfig(ctx, buildDef, { clean: first && clean });
56
56
  first = !1;
57
- let bundles = await build(inlineConfig);
57
+ let { bundles } = await build(inlineConfig);
58
58
  ctx.emitDeclarationOnly && removeNonDeclarationOutputs(bundles), buildDef.canonical && restoreAuthoredTypes(ctx), spinner.complete(), ctx.logger.log(), printBuildOutputs(ctx, bundles, buildDef), ctx.logger.log();
59
59
  } catch (err) {
60
60
  if (spinner.error(), err instanceof Error) {
@@ -147,4 +147,4 @@ async function buildAction(options) {
147
147
  }
148
148
  export { buildAction };
149
149
 
150
- //# sourceMappingURL=buildAction-BPF82HZg.js.map
150
+ //# sourceMappingURL=buildAction-kavz9FnJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAction-kavz9FnJ.js","names":["build","findPkgPath","tsdownBuild","build"],"sources":["../src/node/build.ts","../src/cli/buildAction.ts"],"sourcesContent":["import {existsSync, readFileSync, rmSync, writeFileSync} from 'node:fs'\nimport path from 'node:path'\nimport {up as findPkgPath} from 'empathic/package'\nimport {build as tsdownBuild, type TsdownBundle} from 'tsdown'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {isRecord} from './core/isRecord.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger, type Logger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\nimport {\n resolveTsdownBuilds,\n type TsdownBuild as TsdownBuildDef,\n} from './tasks/tsdown/resolveTsdownBuilds.ts'\nimport {resolveTsdownConfig} from './tasks/tsdown/resolveTsdownConfig.ts'\n\nconst RE_TS_SOURCE = /\\.[cm]?tsx?$/\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n // `--no-clean` skips cleaning for this run; `true` (the CLI default — `--clean` still\n // parses as a no-op for v11 compatibility) defers to the `clean` config option\n clean = true,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n warnAboutTsdownConfigFiles(cwd, logger)\n\n const builds = resolveTsdownBuilds(ctx)\n\n let first = true\n for (const buildDef of builds) {\n // A types-only run skips builds without TypeScript sources entirely\n if (\n ctx.emitDeclarationOnly &&\n !buildDef.entries.some((entry) => RE_TS_SOURCE.test(entry.source))\n ) {\n continue\n }\n\n const taskName = buildTaskName(buildDef)\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const inlineConfig = await resolveTsdownConfig(ctx, buildDef, {clean: first && clean})\n first = false\n\n const {bundles} = await tsdownBuild(inlineConfig)\n\n if (ctx.emitDeclarationOnly) {\n // `dts.emitDtsOnly` suppresses the JS chunks of the ES pass, but the CJS pass emits\n // its JS regardless (only its extra dts pass runs the dts plugin) — a types-only\n // build removes everything that is not a declaration file\n removeNonDeclarationOutputs(bundles)\n }\n\n if (buildDef.canonical) {\n restoreAuthoredTypes(ctx)\n }\n\n spinner.complete()\n ctx.logger.log()\n\n printBuildOutputs(ctx, bundles, buildDef)\n ctx.logger.log()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(escapeRegExp(cwd), 'g')\n\n ctx.logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n process.exit(1)\n }\n }\n}\n\nfunction buildTaskName(buildDef: TsdownBuildDef): string {\n const formats = Array.from(new Set(buildDef.entries.flatMap((entry) => entry.formats)))\n return `build ${buildDef.key} (${formats.join(', ') || 'types'})`\n}\n\nconst RE_DTS_OUTPUT = /\\.d\\.[mc]?ts(\\.map)?$/\n\n/** Removes every emitted file that is not a declaration file (or its sourcemap). */\nfunction removeNonDeclarationOutputs(bundles: TsdownBundle[]): void {\n for (const bundle of bundles) {\n for (const chunk of bundle.chunks) {\n if (RE_DTS_OUTPUT.test(chunk.fileName)) continue\n rmSync(path.join(chunk.outDir, chunk.fileName), {force: true})\n rmSync(path.join(chunk.outDir, `${chunk.fileName}.map`), {force: true})\n }\n }\n}\n\n/**\n * Prints `<pkg>: <source> → <output>` for every entry chunk (JS and `.d.ts`) that tsdown\n * emitted, mirroring the per-file output of previous majors.\n */\nfunction printBuildOutputs(\n ctx: {\n cwd: string\n distPath: string\n emitDeclarationOnly: boolean\n logger: Logger\n pkg: {name: string}\n },\n bundles: TsdownBundle[],\n buildDef: TsdownBuildDef,\n): void {\n const {cwd, logger, pkg} = ctx\n const lines = new Set<string>()\n\n // Stylesheets are emitted as assets, which carry no `facadeModuleId` back to their source,\n // so the stylesheet build's lines come from its entry map instead.\n if (buildDef.css) {\n for (const entry of buildDef.entries) {\n const output = `./${path\n .relative(cwd, path.join(ctx.distPath, `${entry.alias}.css`))\n .replaceAll('\\\\', '/')}`\n lines.add(\n `${pkg.name}: ./${path.relative(cwd, path.resolve(cwd, entry.source)).replaceAll('\\\\', '/')} \\u2192 ${output}`,\n )\n }\n }\n\n for (const bundle of bundles) {\n for (const chunk of bundle.chunks) {\n if (chunk.type !== 'chunk' || !chunk.isEntry || !chunk.facadeModuleId) continue\n if (ctx.emitDeclarationOnly && !RE_DTS_OUTPUT.test(chunk.fileName)) continue\n const source = `./${path\n .relative(cwd, chunk.facadeModuleId)\n .replaceAll('\\\\', '/')\n // the dts chunks facade the fake `.d.ts` module ids of rolldown-plugin-dts; print the\n // actual `.ts` source instead\n .replace(/\\.d\\.([mc]?)ts$/, '.$1ts')}`\n const output = `./${path\n .relative(cwd, path.join(chunk.outDir, chunk.fileName))\n .replaceAll('\\\\', '/')}`\n lines.add(`${pkg.name}: ${source} \\u2192 ${output}`)\n }\n }\n\n for (const line of Array.from(lines).toSorted()) {\n logger.log(line)\n }\n}\n\n/**\n * tsdown's exports generation rewrites the top-level `types` field alongside `main`/`module`\n * when the `legacy` fields are maintained, preferring the CJS declarations (`.d.cts`) for\n * dual-format packages. The hand-written value is authoritative here (the Sanity convention\n * points `types` at the ESM `.d.ts`), so it is restored after the canonical build.\n */\nfunction restoreAuthoredTypes(ctx: {cwd: string; pkg: {types?: string | undefined}}): void {\n const authoredTypes = ctx.pkg.types\n if (!authoredTypes) return\n\n const pkgPath = path.resolve(ctx.cwd, 'package.json')\n let text: string\n try {\n text = readFileSync(pkgPath, 'utf8')\n } catch {\n return\n }\n const json: unknown = JSON.parse(text)\n if (!isRecord(json) || json['types'] === authoredTypes) return\n json['types'] = authoredTypes\n\n const indent = /^([ \\t]+)\\S/m.exec(text)?.[1] ?? 2\n let output = JSON.stringify(json, null, indent)\n if (text.endsWith('\\n')) output += '\\n'\n writeFileSync(pkgPath, output, 'utf8')\n}\n\n/**\n * pkg-utils owns its own experience: `tsdown.config.*` files are never loaded in pkg-utils\n * mode (`package.config.ts` is the sole config source), so their presence is worth a warning.\n */\nfunction warnAboutTsdownConfigFiles(cwd: string, logger: Logger): void {\n const candidates = [\n 'tsdown.config.ts',\n 'tsdown.config.mts',\n 'tsdown.config.cts',\n 'tsdown.config.js',\n 'tsdown.config.mjs',\n 'tsdown.config.cjs',\n 'tsdown.config.json',\n ]\n const found = candidates.find((candidate) => existsSync(path.resolve(cwd, candidate)))\n if (found) {\n logger.warn(\n `found \\`${found}\\`, which @sanity/pkg-utils does not load — \\`package.config.ts\\` is the only config source of \\`pkg build\\`. Either migrate the package fully to tsdown (and drop @sanity/pkg-utils), or move the configuration into \\`package.config.ts\\`.`,\n )\n }\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n","import {build} from '../node/build.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function buildAction(options: {\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n try {\n await build({\n cwd: process.cwd(),\n emitDeclarationOnly: options.emitDeclarationOnly,\n strict: options.strict,\n tsconfig: options.tsconfig,\n clean: options.clean,\n quiet: options.quiet,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;AAqBrB,eAAsBA,QAAM,SAOV;CAChB,IAAM,EACJ,KACA,qBACA,SAAS,IACT,UAAU,gBAGV,QAAQ,IACR,QAAQ,OACN,SACE,SAAS,aAAa,KAAK,GAE3B,UAAUC,GAAY,EAAC,IAAG,CAAC;CACjC,IAAI,CAAC,SACH,MAAU,MAAM,yBAAyB,EAAC,OAAO,EAAC,IA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AAO,QAAQ;EACjB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { i as fileExists, n as createLogger, t as handleError } from "./handleError-83GwKIFM.js";
2
- import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-vVTRkIDl.js";
2
+ import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-i4HOnPda.js";
3
3
  import { t as createSpinner } from "./spinner-DAHe7SuT.js";
4
4
  import { statSync } from "node:fs";
5
5
  import path from "node:path";
@@ -50,7 +50,7 @@ async function check(options) {
50
50
  let config = await loadConfig({
51
51
  cwd,
52
52
  pkgPath
53
- }), { parseStrictOptions } = await import("./resolveBuildContext-vVTRkIDl.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
53
+ }), { parseStrictOptions } = await import("./resolveBuildContext-i4HOnPda.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
54
54
  pkgPath,
55
55
  logger,
56
56
  strict,
@@ -105,7 +105,7 @@ async function checkApiExtractorReleaseTags(ctx) {
105
105
  }
106
106
  for (let dtsPath of candidates) {
107
107
  let exportPath = path.resolve(ctx.cwd, dtsPath);
108
- !fileExists(exportPath) || seen.has(exportPath) || (seen.add(exportPath), entryDtsFiles.push(exportPath));
108
+ fileExists(exportPath) && !seen.has(exportPath) && (seen.add(exportPath), entryDtsFiles.push(exportPath));
109
109
  }
110
110
  }
111
111
  entryDtsFiles.length !== 0 && await checkTsdoc({
@@ -143,4 +143,4 @@ async function checkAction(options) {
143
143
  }
144
144
  export { checkAction };
145
145
 
146
- //# sourceMappingURL=checkAction-DWSqzrZd.js.map
146
+ //# sourceMappingURL=checkAction-BSYijAy1.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkAction-DWSqzrZd.js","names":["findPkgPath"],"sources":["../src/node/getFilesize.ts","../src/node/printPackageTree.ts","../src/node/check.ts","../src/cli/checkAction.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {fileExists} from './fileExists.ts'\nimport {getFilesize} from './getFilesize.ts'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n if (entry.browser.default) exp.browser.default = fileInfo(entry.browser.default)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n if (entry.node.default) exp.node.default = fileInfo(entry.node.default)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport {checkTsdoc} from '@sanity/tsdown-config/tsdoc'\nimport {up as findPkgPath} from 'empathic/package'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {fileExists} from './fileExists.ts'\nimport {createLogger} from './logger.ts'\nimport {printPackageTree} from './printPackageTree.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n const spinner = createSpinner('')\n try {\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n }\n\n // publint validates that the built package resolves in every runtime/bundler — it packs\n // the package (which applies `publishConfig`, so the source-condition convention checks\n // out the way consumers see it) and lints the result. This replaced the bespoke\n // esbuild-based resolution checks of previous majors.\n await runPublint(ctx)\n\n if (ctx.config?.tsdoc !== false) {\n await checkApiExtractorReleaseTags(ctx)\n }\n\n spinner.complete()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g')\n\n logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nasync function runPublint(ctx: BuildContext): Promise<void> {\n const {cwd, logger, strict} = ctx\n const [{publint}, {formatMessage}] = await Promise.all([\n import('publint'),\n import('publint/utils'),\n ])\n\n const {messages, pkg} = await publint({pkgDir: cwd, strict})\n\n let hasErrors = false\n\n for (const message of messages) {\n const formatted = formatMessage(message, pkg)\n if (message.type === 'error') {\n hasErrors = true\n logger.error(`publint: ${formatted}`)\n } else if (message.type === 'warning') {\n logger.warn(`publint: ${formatted}`)\n } else {\n logger.log(`publint: ${formatted}`)\n }\n }\n\n if (hasErrors) {\n process.exit(1)\n }\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const tsdoc =\n ctx.config?.tsdoc === false || ctx.config?.tsdoc === true ? undefined : ctx.config?.tsdoc\n const entryDtsFiles: string[] = []\n const seen = new Set<string>()\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n // Prefer an explicit `types` condition; otherwise derive declarations from every runtime\n // file (`.js` → `.d.ts`, `.mjs` → `.d.mts`, `.cjs` → `.d.cts`) so dual-format / fixed-\n // extension packages are checked the same way as the build-time `tsdoc` hook.\n const candidates = new Set<string>()\n if (exp.types) candidates.add(exp.types)\n for (const js of [exp.default, exp.import, exp.require]) {\n if (!js) continue\n const dts = jsFileToDts(js)\n if (dts) candidates.add(dts)\n }\n for (const dtsPath of candidates) {\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n // JS-only entries emit no declarations; there is nothing to check\n if (!fileExists(exportPath) || seen.has(exportPath)) continue\n seen.add(exportPath)\n entryDtsFiles.push(exportPath)\n }\n }\n\n if (entryDtsFiles.length === 0) return\n\n await checkTsdoc({\n cwd: ctx.cwd,\n entryDtsFiles,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n outDir: ctx.ts.config?.options.outDir ?? ctx.distPath,\n bundledPackages: ctx.bundledPackages,\n customTags: tsdoc?.customTags,\n rules: tsdoc?.rules,\n logger: {\n log: (...args) => ctx.logger.log(...args),\n warn: (...args) => ctx.logger.warn(...args),\n error: (...args) => ctx.logger.error(...args),\n },\n })\n}\n\n/** `./dist/index.js` → `./dist/index.d.ts` (`.mjs` → `.d.mts`, `.cjs` → `.d.cts`). */\nfunction jsFileToDts(file: string): string | undefined {\n if (/\\.d\\.[mc]?ts$/.test(file)) return file\n if (file.endsWith('.mjs')) return file.replace(/\\.mjs$/, '.d.mts')\n if (file.endsWith('.cjs')) return file.replace(/\\.cjs$/, '.d.cts')\n if (file.endsWith('.js')) return file.replace(/\\.js$/, '.d.ts')\n return undefined\n}\n","import {check} from '../node/check.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function checkAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await check({\n cwd: process.cw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GAChC,IAAM,aAAa,KAAK,QAAQ,IAAI,KAAK,OAAO;GAE5C,CAAC,WAAW,UAAU,KAAK,KAAK,IAAI,UAAU,MAClD,KAAK,IAAI,UAAU,GACnB,cAAc,KAAK,UAAU;EAC/B;CACF;CAEI,cAAc,WAAW,KAE7B,MAAM,WAAW;EACf,KAAK,IAAI;EACT;EACA,UAAU,IAAI,GAAG,cAAc;EAC/B,QAAQ,IAAI,GAAG,QAAQ,QAAQ,UAAU,IAAI;EAC7C,iBAAiB,IAAI;EACrB,YAAY,OAAO;EACnB,OAAO,OAAO;EACd,QAAQ;GACN,MAAM,GAAG,SAAS,IAAI,OAAO,IAAI,GAAG,IAAI;GACxC,OAAO,GAAG,SAAS,IAAI,OAAO,KAAK,GAAG,IAAI;GAC1C,QAAQ,GAAG,SAAS,IAAI,OAAO,MAAM,GAAG,IAAI;EAC9C;CACF,CAAC;AACH;;AAGA,SAAS,YAAY,MAAkC;CACrD,IAAI,gBAAgB,KAAK,IAAI,GAAG,OAAO;CACvC,IAAI,KAAK,SAAS,MAAM,GAAG,OAAO,KAAK,QAAQ,UAAU,QAAQ;CACjE,IAAI,KAAK,SAAS,MAAM,GAAG,OAAO,KAAK,QAAQ,UAAU,QAAQ;CACjE,IAAI,KAAK,SAAS,KAAK,GAAG,OAAO,KAAK,QAAQ,SAAS,OAAO;AAEhE;ACrKA,eAAsB,YAAY,SAA+D;CAC/F,IAAI;EACF,MAAM,MAAM;GACV,KAAK,QAAQ,IAAI;GACjB,QAAQ,QAAQ;GAChB,UAAU,QAAQ;EACpB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
1
+ {"version":3,"file":"checkAction-BSYijAy1.js","names":["findPkgPath"],"sources":["../src/node/getFilesize.ts","../src/node/printPackageTree.ts","../src/node/check.ts","../src/cli/checkAction.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {fileExists} from './fileExists.ts'\nimport {getFilesize} from './getFilesize.ts'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n if (entry.browser.default) exp.browser.default = fileInfo(entry.browser.default)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n if (entry.node.default) exp.node.default = fileInfo(entry.node.default)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport {checkTsdoc} from '@sanity/tsdown-config/tsdoc'\nimport {up as findPkgPath} from 'empathic/package'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {fileExists} from './fileExists.ts'\nimport {createLogger} from './logger.ts'\nimport {printPackageTree} from './printPackageTree.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n const spinner = createSpinner('')\n try {\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n }\n\n // publint validates that the built package resolves in every runtime/bundler — it packs\n // the package (which applies `publishConfig`, so the source-condition convention checks\n // out the way consumers see it) and lints the result. This replaced the bespoke\n // esbuild-based resolution checks of previous majors.\n await runPublint(ctx)\n\n if (ctx.config?.tsdoc !== false) {\n await checkApiExtractorReleaseTags(ctx)\n }\n\n spinner.complete()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g')\n\n logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nasync function runPublint(ctx: BuildContext): Promise<void> {\n const {cwd, logger, strict} = ctx\n const [{publint}, {formatMessage}] = await Promise.all([\n import('publint'),\n import('publint/utils'),\n ])\n\n const {messages, pkg} = await publint({pkgDir: cwd, strict})\n\n let hasErrors = false\n\n for (const message of messages) {\n const formatted = formatMessage(message, pkg)\n if (message.type === 'error') {\n hasErrors = true\n logger.error(`publint: ${formatted}`)\n } else if (message.type === 'warning') {\n logger.warn(`publint: ${formatted}`)\n } else {\n logger.log(`publint: ${formatted}`)\n }\n }\n\n if (hasErrors) {\n process.exit(1)\n }\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const tsdoc =\n ctx.config?.tsdoc === false || ctx.config?.tsdoc === true ? undefined : ctx.config?.tsdoc\n const entryDtsFiles: string[] = []\n const seen = new Set<string>()\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n // Prefer an explicit `types` condition; otherwise derive declarations from every runtime\n // file (`.js` → `.d.ts`, `.mjs` → `.d.mts`, `.cjs` → `.d.cts`) so dual-format / fixed-\n // extension packages are checked the same way as the build-time `tsdoc` hook.\n const candidates = new Set<string>()\n if (exp.types) candidates.add(exp.types)\n for (const js of [exp.default, exp.import, exp.require]) {\n if (!js) continue\n const dts = jsFileToDts(js)\n if (dts) candidates.add(dts)\n }\n for (const dtsPath of candidates) {\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n // JS-only entries emit no declarations; there is nothing to check\n if (!fileExists(exportPath) || seen.has(exportPath)) continue\n seen.add(exportPath)\n entryDtsFiles.push(exportPath)\n }\n }\n\n if (entryDtsFiles.length === 0) return\n\n await checkTsdoc({\n cwd: ctx.cwd,\n entryDtsFiles,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n outDir: ctx.ts.config?.options.outDir ?? ctx.distPath,\n bundledPackages: ctx.bundledPackages,\n customTags: tsdoc?.customTags,\n rules: tsdoc?.rules,\n logger: {\n log: (...args) => ctx.logger.log(...args),\n warn: (...args) => ctx.logger.warn(...args),\n error: (...args) => ctx.logger.error(...args),\n },\n })\n}\n\n/** `./dist/index.js` → `./dist/index.d.ts` (`.mjs` → `.d.mts`, `.cjs` → `.d.cts`). */\nfunction jsFileToDts(file: string): string | undefined {\n if (/\\.d\\.[mc]?ts$/.test(file)) return file\n if (file.endsWith('.mjs')) return file.replace(/\\.mjs$/, '.d.mts')\n if (file.endsWith('.cjs')) return file.replace(/\\.cjs$/, '.d.cts')\n if (file.endsWith('.js')) return file.replace(/\\.js$/, '.d.ts')\n return undefined\n}\n","import {check} from '../node/check.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function checkAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await check({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,YAAY,MAAsB;CAChD,IAAM,QAAQ,SAAS,IAAI;CA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C/B;CACF;CAEI,cAAc,WAAW,KAE7B,MAAM,WAAW;EACf,KAAK,IAAI;EACT;EACA,UAAU,IAAI,GAAG,cAAc;EAC/B,QAAQ,IAAI,GAAG,QAAQ,QAAQ,UAAU,IAAI;EAC7C,iBAAiB,IAAI;EACrB,YAAY,OAAO;EACnB,OAAO,OAAO;EACd,QAAQ;GACN,MAAM,GAAG,SAAS,IAAI,OAAO,IAAI,GAAG,IAAI;GACxC,OAAO,GAAG,SAAS,IAAI,OAAO,KAAK,GAAG,IAAI;GAC1C,QAAQ,GAAG,SAAS,IAAI,OAAO,MAAM,GAAG,IAAI;EAC9C;CACF,CAAC;AACH;;AAGA,SAAS,YAAY,MAAkC;CACrD,IAAI,gBAAgB,KAAK,IAAI,GAAG,OAAO;CACvC,IAAI,KAAK,SAAS,MAAM,GAAG,OAAO,KAAK,QAAQ,UAAU,QAAQ;CACjE,IAAI,KAAK,SAAS,MAAM,GAAG,OAAO,KAAK,QAAQ,UAAU,QAAQ;CACjE,IAAI,KAAK,SAAS,KAAK,GAAG,OAAO,KAAK,QAAQ,SAAS,OAAO;AAEhE;ACrKA,eAAsB,YAAY,SAA+D;CAC/F,IAAI;EACF,MAAM,MAAM;GACV,KAAK,QAAQ,IAAI;GACjB,QAAQ,QAAQ;GAChB,UAAU,QAAQ;EACpB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { cac } from "cac";
2
- var version = "12.3.4";
2
+ var version = "13.0.0";
3
3
  const cli = cac();
4
4
  cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
5
- let { checkAction } = await import("./checkAction-DWSqzrZd.js");
5
+ let { checkAction } = await import("./checkAction-BSYijAy1.js");
6
6
  return checkAction(options);
7
7
  }), cli.command("build", "Build package").option("--emitDeclarationOnly", "Emit d.ts only").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").option("--check", "Run the check command after build (same as running `pkg build && pkg check`)").option("--no-clean", "Skip cleaning the `dist` folder before the build").option("--quiet", "Suppress all output except errors, warnings, and checks").action(async (options) => {
8
- let { check = !1, ...buildOptions } = options, { buildAction } = await import("./buildAction-BPF82HZg.js");
8
+ let { check = !1, ...buildOptions } = options, { buildAction } = await import("./buildAction-kavz9FnJ.js");
9
9
  if (await buildAction(buildOptions), check) {
10
- let { checkAction } = await import("./checkAction-DWSqzrZd.js");
10
+ let { checkAction } = await import("./checkAction-BSYijAy1.js");
11
11
  await checkAction({
12
12
  strict: options.strict,
13
13
  tsconfig: options.tsconfig
@@ -17,7 +17,7 @@ cli.command("", "Check").alias("check").option("--strict", "Strict mode").option
17
17
  let { initAction } = await import("./initAction-CmOO8eod.js");
18
18
  return initAction({ path: p });
19
19
  }), cli.command("watch", "Watch package").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
20
- let { watchAction } = await import("./watchAction-IMdjLKl4.js");
20
+ let { watchAction } = await import("./watchAction-CIMqTWfx.js");
21
21
  return watchAction(options);
22
22
  }), cli.help(), cli.version(version), cli.parse();
23
23
  export {};
package/dist/index.d.ts CHANGED
@@ -248,8 +248,8 @@ interface PkgConfigOptions {
248
248
  dist?: string;
249
249
  /**
250
250
  * tsdown's `dts` options, passed through as-is (an object, or `false` to skip generating
251
- * `.d.ts` files entirely). For example `dts: {tsgo: true}` selects the Go-native TypeScript
252
- * compiler for type generation.
251
+ * `.d.ts` files entirely). For example `dts: {generator: 'tsgo'}` selects the Go-native
252
+ * TypeScript compiler for type generation.
253
253
  * @see https://tsdown.dev/options/dts
254
254
  */
255
255
  dts?: false | Extract<NonNullable<UserConfig["dts"]>, object>;
@@ -383,20 +383,20 @@ interface PkgConfigOptions {
383
383
  */
384
384
  rollup?: never;
385
385
  /**
386
- * @deprecated Removed in v12. Set `dts: {tsgo: true}` instead — the `dts` option is passed
387
- * through to tsdown as-is.
386
+ * @deprecated Removed in v12. Set `dts: {generator: 'tsgo'}` instead — the `dts` option is
387
+ * passed through to tsdown as-is.
388
388
  */
389
389
  tsgo?: never;
390
390
  }
391
391
  /** @public */
392
- declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
392
+ export declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
393
393
  /** @alpha */
394
- declare function loadConfig(options: {
394
+ export declare function loadConfig(options: {
395
395
  cwd: string;
396
396
  pkgPath: string;
397
397
  }): Promise<PkgConfigOptions | undefined>;
398
398
  /** @public */
399
- declare const DEFAULT_BROWSERSLIST_QUERY: string[];
399
+ export declare const DEFAULT_BROWSERSLIST_QUERY: string[];
400
400
  /** @public */
401
401
  interface PkgTemplateStringOption<T = string> {
402
402
  name: string;
@@ -409,6 +409,6 @@ interface PkgTemplateStringOption<T = string> {
409
409
  /** @public */
410
410
  type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;
411
411
  /** @public */
412
- declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
413
- export { DEFAULT_BROWSERSLIST_QUERY, type PackageBundleAnalyzerOptions, type PackageTsdocCustomTag, type PackageTsdocOptions, type PackageTsdocRuleLevel, type PackageVanillaExtractOptions, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type PkgTsdocOptions, type ReactCompilerBabelOptions, type ReactCompilerConfigOptions, type ReactCompilerOptions, type ReactCompilerOxcOptions, type StyledComponentsOptions, type TSDocCustomTag, defineConfig, defineTemplateOption, loadConfig };
412
+ export declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
413
+ export type { PackageBundleAnalyzerOptions, PackageTsdocCustomTag, PackageTsdocOptions, PackageTsdocRuleLevel, PackageVanillaExtractOptions, PkgBundle, PkgConfigOptions, PkgConfigProperty, PkgConfigPropertyResolver, PkgExport, PkgExports, PkgFormat, PkgRuleLevel, PkgRuntime, PkgTsdocOptions, ReactCompilerBabelOptions, ReactCompilerConfigOptions, ReactCompilerOptions, ReactCompilerOxcOptions, StyledComponentsOptions, TSDocCustomTag };
414
414
  //# 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;;;;;;;UCzHf,kCACP,QAAQ,gBAAkC;;;;;EAKlD;;;;;;;UAQe,gCACP,wBAAyB;;EAEjC;;;;;;KAOU,uBAAuB,4BAA4B;;KAGnD;;KAGA;;KAGA,0BAA0B,MAAM,MAAM,MAAM;;KAG5C,kBAAkB,KAAK,0BAA0B,KAAK;;UAGjD;EACf;EACA;EACA;EACA,UAAU;;;;;;KAOA,eAAe;;;;;KAMf,iBAAiB;;;;;;;KAQjB,kBAAkB;;UAGb;EACf,UAAU;;;;;;;;;;;;;;;;;;;EAmBV,2BAA2B;;;;;;;;;EAS3B,QAAQ;;;;;;;;;;;;;;;;;;;;EAoBR,MAAM;;EAEN,SAAS;;;;;;;;EAQT,OAAO;;;;EAIP;;;;;;;EAOA,cAAc,QAAQ,YAAY;EAClC,UAAU,kBAAkB;;;;;;;;;;;EAW5B,WAAW;;;;;;;;EAQX;;;;;;;;EAQA;;;;;;;EAOA,UAAU;;;;;;;;EAQV,0BAA0B;;;;EAI1B,UAAU;EACV;;;;EAIA;;;;EAIA,gBAAgB,QAAQ;;;;;;;EAOxB,6BAA6B;EAC7B;;;;;;;EAOA,kBAAkB;;;;;;;;;;EAUlB,2BAA2B;;;;;;;EAa3B;;;;;;;;EAQA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;;;;EAQA;;;;;EAKA;;;iBCxTc,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"}
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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/dist/index.js CHANGED
@@ -56,7 +56,7 @@ const MIGRATION_GUIDE_URL = "https://github.com/sanity-io/pkg-utils/blob/main/pa
56
56
  "",
57
57
  " // package.config.ts",
58
58
  " export default defineConfig({",
59
- " dts: {tsgo: true},",
59
+ " dts: {generator: 'tsgo'},",
60
60
  " })"
61
61
  ]
62
62
  },
@@ -170,7 +170,7 @@ function runLegacyConfigChecks(config) {
170
170
  `package.config.ts: \`dts: '${dts}'\` was removed in @sanity/pkg-utils v12 — the \`dts\``,
171
171
  "option is now passed through to tsdown as-is (an options object, or `false`).",
172
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}`."] : [
173
+ ...dts === "rolldown" ? ["`dts: 'rolldown'` is the default behavior now: delete the option. Options that", "accompanied it move into the object, e.g. `dts: {generator: 'tsgo'}`."] : [
174
174
  "`dts: 'api-extractor'` type generation was removed. Types are generated with",
175
175
  "tsdown (rolldown-plugin-dts); api-extractor remains as the TSDoc/release-tag",
176
176
  "checking that runs during `pkg build`/`pkg check` — configure it with the",
@@ -185,7 +185,7 @@ function runLegacyConfigChecks(config) {
185
185
  let value = config[option];
186
186
  if (typeof value != "object" || !value) continue;
187
187
  let inject = value.inject;
188
- typeof inject != "object" || !inject || inject.nodeCompat !== void 0 && console.warn([
188
+ typeof inject == "object" && inject && inject.nodeCompat !== void 0 && console.warn([
189
189
  `package.config.ts: \`${option}.inject.nodeCompat\` is deprecated. Use`,
190
190
  `\`${option}: {inject: true, exports: {nodeCompat: true}}\` instead — \`nodeCompat\``,
191
191
  "configures the package exports, not the injected import."
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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 build`/`pkg check` — configure it with the',\n '`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: `inject: {nodeCompat: true}` still works (it means\n // `{inject: true, exports: {nodeCompat: true}}`), with a nudge toward its successor. The\n // option configures how the CSS file is published, not how the import is injected.\n for (const option of ['vanillaExtract', 'css'] as const) {\n const value = config[option]\n if (typeof value !== 'object' || value === null) continue\n // oxlint-disable-next-line no-unsafe-type-assertion\n const inject = (value as {inject?: unknown}).inject\n if (typeof inject !== 'object' || inject === null) continue\n // oxlint-disable-next-line no-unsafe-type-assertion\n if ((inject as {nodeCompat?: unknown}).nodeCompat === undefined) continue\n // eslint-disable-next-line no-console -- config-load-time deprecation warning\n console.warn(\n [\n `package.config.ts: \\`${option}.inject.nodeCompat\\` is deprecated. Use`,\n `\\`${option}: {inject: true, exports: {nodeCompat: true}}\\` instead — \\`nodeCompat\\``,\n 'configures the package exports, not the injected import.',\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;GACA;EACF;EACJ;EACA,yBAAyB;EACzB;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;CAMF,KAAK,IAAM,UAAU,CAAC,kBAAkB,KAAK,GAAY;EACvD,IAAM,QAAQ,OAAO;EACrB,IAAI,OAAO,SAAU,aAAY,OAAgB;EAEjD,IAAM,SAAU,MAA6B;EACzC,OAAO,UAAW,aAAY,UAE7B,OAAkC,eAAe,KAAA,KAEtD,QAAQ,KACN;GACE,wBAAwB,OAAO;GAC/B,KAAK,OAAO;GACZ;EACF,CAAC,CAAC,KAAK,IAAI,CACb;CACF;CAIA,AAAI,OAAO,aAAgB,KAAA,KAEzB,QAAQ,KACN;EACE;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;AAEJ;;AChNA,eAAsB,WAAW,SAGS;CACxC,IAAM,EAAC,KAAK,YAAW,SAIjB,aAAa,eAFN,KAAK,QAAQ,OAEQ,CAAI;CAOtC,IALI,CAAC,cAKD,CAAC,WAAW,WAAW,GAAG,GAC5B;CAGF,IAAM,MAAM,MAAM,SAAS,cAAc,UAAU,CAAC,CAAC,SAAS,GAAG,YAAY,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"}
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: {generator: 'tsgo'},\",\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. `dts: {generator: 'tsgo'}`.\",\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 build`/`pkg check` — configure it with the',\n '`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: `inject: {nodeCompat: true}` still works (it means\n // `{inject: true, exports: {nodeCompat: true}}`), with a nudge toward its successor. The\n // option configures how the CSS file is published, not how the import is injected.\n for (const option of ['vanillaExtract', 'css'] as const) {\n const value = config[option]\n if (typeof value !== 'object' || value === null) continue\n // oxlint-disable-next-line no-unsafe-type-assertion\n const inject = (value as {inject?: unknown}).inject\n if (typeof inject !== 'object' || inject === null) continue\n // oxlint-disable-next-line no-unsafe-type-assertion\n if ((inject as {nodeCompat?: unknown}).nodeCompat === undefined) continue\n // eslint-disable-next-line no-console -- config-load-time deprecation warning\n console.warn(\n [\n `package.config.ts: \\`${option}.inject.nodeCompat\\` is deprecated. Use`,\n `\\`${option}: {inject: true, exports: {nodeCompat: true}}\\` instead — \\`nodeCompat\\``,\n 'configures the package exports, not the injected import.',\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;G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ChNA,eAAsB,WAAW,SAGS;CACxC,IAAM,EAAC,KAAK,YAAW,SAIjB,aAAa,eAFN,KAAK,QAAQ,OAEQ,CAAI;CAOtC,IALI,CAAC,cAKD,CAAC,WAAW,WAAW,GAAG,GAC5B;CAGF,IAAM,MAAM,MAAM,SAAS,cAAc,UAAU,CAAC,CAAC,SAAS,GAAG,YAAY,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"}
@@ -53,7 +53,7 @@ const MIGRATION_GUIDE_URL = "https://github.com/sanity-io/pkg-utils/blob/main/pa
53
53
  "",
54
54
  " // package.config.ts",
55
55
  " export default defineConfig({",
56
- " dts: {tsgo: true},",
56
+ " dts: {generator: 'tsgo'},",
57
57
  " })"
58
58
  ]
59
59
  },
@@ -167,7 +167,7 @@ function runLegacyConfigChecks(config) {
167
167
  `package.config.ts: \`dts: '${dts}'\` was removed in @sanity/pkg-utils v12 — the \`dts\``,
168
168
  "option is now passed through to tsdown as-is (an options object, or `false`).",
169
169
  "",
170
- ...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}`."] : [
170
+ ...dts === "rolldown" ? ["`dts: 'rolldown'` is the default behavior now: delete the option. Options that", "accompanied it move into the object, e.g. `dts: {generator: 'tsgo'}`."] : [
171
171
  "`dts: 'api-extractor'` type generation was removed. Types are generated with",
172
172
  "tsdown (rolldown-plugin-dts); api-extractor remains as the TSDoc/release-tag",
173
173
  "checking that runs during `pkg build`/`pkg check` — configure it with the",
@@ -182,7 +182,7 @@ function runLegacyConfigChecks(config) {
182
182
  let value = config[option];
183
183
  if (typeof value != "object" || !value) continue;
184
184
  let inject = value.inject;
185
- typeof inject != "object" || !inject || inject.nodeCompat !== void 0 && console.warn([
185
+ typeof inject == "object" && inject && inject.nodeCompat !== void 0 && console.warn([
186
186
  `package.config.ts: \`${option}.inject.nodeCompat\` is deprecated. Use`,
187
187
  `\`${option}: {inject: true, exports: {nodeCompat: true}}\` instead — \`nodeCompat\``,
188
188
  "configures the package exports, not the injected import."
@@ -759,4 +759,4 @@ function transformPackageName(packageName) {
759
759
  }
760
760
  export { loadPkgWithReporting as a, pkgExtMap as i, strict_exports as n, loadConfig as o, fileEnding as r, resolveBuildContext as t };
761
761
 
762
- //# sourceMappingURL=resolveBuildContext-vVTRkIDl.js.map
762
+ //# sourceMappingURL=resolveBuildContext-i4HOnPda.js.map