@sanity/pkg-utils 12.0.0 → 12.0.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveTsdownConfig-CGE_7cMM.js","names":[],"sources":["../src/node/tasks/tsdown/resolveTsdownBuilds.ts","../src/node/tasks/tsdown/composeExports.ts","../src/node/tasks/tsdown/resolveTsdownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgFormat, PkgRuntime} from '../../core/config/types.ts'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {fileEnding} from '../../core/pkg/pkgExt.ts'\n\n/**\n * One entry of a tsdown build.\n * @internal\n */\nexport interface TsdownBuildEntry {\n /**\n * The entry alias handed to tsdown: the output path relative to `dist` without the\n * extension (e.g. `index`, `index.browser`, `sub/feature`), so the emitted filenames match\n * the hand-written `exports` targets exactly.\n */\n alias: string\n source: string\n /** The hand-written export subpath this entry backs (`undefined` for `bundles`). */\n exportPath?: string\n /** The formats the hand-written exports declare for this entry. */\n formats: PkgFormat[]\n}\n\n/**\n * One tsdown `build()` call of the waterfall. Builds run serially — variants and bundles\n * first, the canonical build last, so its exports generation and publint see every emitted\n * file on disk.\n * @internal\n */\nexport interface TsdownBuild {\n /** Stable identifier, e.g. `neutral`, `browser`, `node`, `bundles`. */\n key: string\n runtime: PkgRuntime\n /** The canonical build owns `dist` conventions: exports generation runs here. */\n canonical: boolean\n entries: TsdownBuildEntry[]\n}\n\n/**\n * Collapses the hand-written `exports` map (+ `bundles`) into the per-platform tsdown build\n * waterfall: one canonical build for the package's default runtime, plus a variant build per\n * `browser`/`node` exports condition, plus builds for `bundles` (which must not participate\n * in exports generation).\n * @internal\n */\nexport function resolveTsdownBuilds(ctx: BuildContext): TsdownBuild[] {\n const {config, cwd, distPath, logger} = ctx\n\n const entryAlias = (output: string): string => {\n const alias = path\n .relative(distPath, path.resolve(cwd, output))\n .replaceAll('\\\\', '/')\n .replace(fileEnding, '')\n if (alias.startsWith('..')) {\n throw new Error(`output file is outside the \\`dist\\` folder: ${output}`)\n }\n return alias\n }\n\n interface EntryDraft {\n alias: string\n source: string\n exportPath?: string | undefined\n formats: Set<PkgFormat>\n }\n\n const draftsByBuild = new Map<string, Map<string, EntryDraft>>()\n const runtimeByBuild = new Map<string, PkgRuntime>()\n\n const addEntry = (\n buildKey: string,\n runtime: PkgRuntime,\n entry: {\n source: string\n exportPath?: string | undefined\n import?: string | undefined\n require?: string | undefined\n },\n ) => {\n runtimeByBuild.set(buildKey, runtime)\n const {source, exportPath} = entry\n const aliases = new Set<string>()\n const formats = new Set<PkgFormat>()\n if (entry.import) {\n aliases.add(entryAlias(entry.import))\n formats.add('esm')\n }\n if (entry.require) {\n aliases.add(entryAlias(entry.require))\n formats.add('commonjs')\n }\n if (aliases.size === 0) return\n if (aliases.size > 1) {\n throw new Error(\n `the \\`import\\` and \\`require\\` targets of ${\n exportPath ? `exports[\"${exportPath}\"]` : `the bundle for ${source}`\n } must share a basename (e.g. \\`./dist/index.js\\` + \\`./dist/index.cjs\\`), ` +\n `got: ${entry.import} and ${entry.require}`,\n )\n }\n const [alias] = aliases\n let drafts = draftsByBuild.get(buildKey)\n if (!drafts) {\n drafts = new Map()\n draftsByBuild.set(buildKey, drafts)\n }\n const existing = drafts.get(alias!)\n if (existing) {\n if (existing.source !== source) {\n throw new Error(\n `conflicting sources for the output alias \"${alias}\": ${existing.source} and ${source}`,\n )\n }\n for (const format of formats) existing.formats.add(format)\n return\n }\n drafts.set(alias!, {alias: alias!, source, exportPath, formats})\n }\n\n const exports = Object.entries(ctx.exports || {})\n\n let hasRuntimeConditions = false\n\n for (const [exportPath, exp] of exports) {\n addEntry('canonical', ctx.runtime, {\n source: exp.source,\n exportPath,\n import: exp.import,\n require: exp.require,\n })\n\n if (exp.browser?.import || exp.browser?.require) {\n hasRuntimeConditions = true\n addEntry('browser', 'browser', {\n source: exp.browser.source || exp.source,\n exportPath,\n import: exp.browser.import,\n require: exp.browser.require,\n })\n }\n\n if (exp.node?.import || exp.node?.require) {\n hasRuntimeConditions = true\n addEntry('node', 'node', {\n source: exp.node.source || exp.source,\n exportPath,\n import: exp.node.import,\n require: exp.node.require,\n })\n }\n }\n\n // `bundles` are extra entrypoints that are deliberately not in the exports map (CLI workers\n // and similar), so they build separately from the canonical build — exports generation\n // derives subpaths from every entry of its build, and bundles must never become export\n // subpaths of their own.\n for (const bundle of config?.bundles || []) {\n const runtime = bundle.runtime || ctx.runtime\n addEntry(runtime === ctx.runtime ? 'bundles' : `bundles:${runtime}`, runtime, {\n source: bundle.source,\n import: bundle.import,\n require: bundle.require,\n })\n }\n\n if (hasRuntimeConditions) {\n logger.warn(\n [\n 'The `exports[].browser.source` / `exports[].node.source` pattern is not recommended: every',\n 'runtime condition adds a full extra build (complexity and build time). Consider instead:',\n ' 1. separate npm packages per platform/runtime, selected through export conditions that',\n ' pick the right package per environment,',\n ' 2. when possible, a single neutral build using JS that works in both runtimes without',\n ' special-casing (e.g. `new URL` over `require(\"url\")`, WebCrypto over',\n ' `require(\"crypto\")`), or',\n ' 3. using `tsdown` + `@sanity/tsdown-config` directly, exporting an array from',\n ' `tsdown.config.ts` with one config per `platform` — the fully supported path for',\n ' this level of customization.',\n ].join('\\n'),\n )\n }\n\n const builds: TsdownBuild[] = []\n\n const toBuild = (key: string, runtime: PkgRuntime, canonical: boolean): TsdownBuild | null => {\n const drafts = draftsByBuild.get(key)\n if (!drafts || drafts.size === 0) return null\n return {\n key,\n runtime,\n canonical,\n entries: Array.from(drafts.values(), (draft) => ({\n alias: draft.alias,\n source: draft.source,\n ...(draft.exportPath === undefined ? {} : {exportPath: draft.exportPath}),\n formats: Array.from(draft.formats),\n })),\n }\n }\n\n // Variants and bundles run first; the canonical build runs last so its exports generation\n // and publint see the other builds' files on disk. Each build's runtime was recorded when\n // its entries were added, so nothing is re-derived from the build key (a bundle with\n // `runtime: '*'` in a `runtime: 'node'` package must build for `'*'`/neutral).\n for (const key of draftsByBuild.keys()) {\n if (key === 'canonical') continue\n const build = toBuild(key, runtimeByBuild.get(key) ?? ctx.runtime, false)\n if (build) builds.push(build)\n }\n\n const canonical = toBuild('canonical', ctx.runtime, true)\n if (canonical) builds.push(canonical)\n\n return builds\n}\n","import type {PkgExport} from '../../core/config/types.ts'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {isRecord} from '../../core/isRecord.ts'\nimport type {TsdownBuild} from './resolveTsdownBuilds.ts'\n\ntype ExportsMap = Record<string, unknown>\ninterface ComposeContext {\n isPublish: boolean\n}\n\n/**\n * The pkg-utils opinion layer over tsdown's generated `exports` map, composed into\n * `exports.customExports` of the canonical build (the same composition hook\n * `@sanity/vanilla-extract-tsdown-plugin` uses for its conditional CSS export).\n *\n * tsdown generates subpaths from the entry aliases with `source`/`import`/`require` conditions\n * (`devExports: 'source'`) and a `source`-less `publishConfig.exports` — already the Sanity\n * convention. This composer reconciles the generated map with the hand-written one, which\n * remains the input:\n *\n * - generated keys are remapped to the hand-written subpaths (entry aliases are derived from\n * the output paths, which don't have to match the subpath names),\n * - the hand-written `types`, `browser`, `node`, `development` and `monorepo` conditions are\n * re-inserted (tsdown's generator cannot express them; the `browser`/`node` files are built\n * by the variant builds of the waterfall) — with `source`-like conditions stripped from the\n * publish variant,\n * - all hand-written conditions (`react-server`, `worker`, … included) retain their authored\n * order in each map independently, because earlier matching conditions take precedence,\n * - generated conditions for conditional entries are materialized in both `exports` and\n * `publishConfig.exports`, so they can be reordered directly in `package.json` and keep that\n * position on later builds (plain-string entries stay compact),\n * - a trailing `default` condition is kept on dual-format entries (tsdown emits bare\n * `import`/`require` pairs; the Sanity convention always ends with `default`),\n * - hand-written subpaths that aren't build entries (`.css`/`.json` exports, `svelte`\n * entries) are carried over untouched, and\n * - the hand-written subpath and condition key order of each map is preserved.\n * @internal\n */\nexport function createExportsComposer(\n ctx: BuildContext,\n build: TsdownBuild,\n): (exportsMap: ExportsMap, context: ComposeContext) => ExportsMap {\n const {pkg} = ctx\n const type = pkg.type === 'module' ? 'module' : 'commonjs'\n\n // alias -> hand-written subpath, e.g. `index` -> `.`, `sub/feature` -> `./feature`\n const aliasToExportPath = new Map<string, string>()\n for (const entry of build.entries) {\n if (entry.exportPath !== undefined) {\n aliasToExportPath.set(entry.alias, entry.exportPath)\n }\n }\n\n return (exportsMap, context) => {\n const {isPublish} = context\n\n // 1. Remap the generated keys (`.` for the `index` alias, `./<alias>` otherwise) back to\n // the hand-written subpaths.\n const remapped: ExportsMap = {}\n for (const [key, value] of Object.entries(exportsMap)) {\n const alias = key === '.' ? 'index' : key.startsWith('./') ? key.slice(2) : key\n const exportPath = aliasToExportPath.get(alias) ?? key\n remapped[exportPath] = value\n }\n\n // 2. Reconcile each generated entry with its hand-written counterpart.\n const result: ExportsMap = {}\n const handwritten = ctx.exports || {}\n const sourceRaw: ExportsMap = pkg.exports || {}\n const publishRaw: ExportsMap | undefined = pkg.publishConfig?.exports\n const authoredRaw = isPublish && publishRaw ? publishRaw : sourceRaw\n\n const reconcile = (exportPath: string, value: unknown): unknown => {\n const exp = handwritten[exportPath]\n if (!exp) return value\n const raw = authoredRaw[exportPath]\n const source = sourceRaw[exportPath]\n // A configured exports map is itself authoritative. Otherwise use the raw package entry\n // for the map being generated. Fall back to `exports` when a new publish map/entry is\n // being generated, so inferred conditions don't masquerade as ordering choices.\n const authored =\n ctx.config?.exports === undefined\n ? isRecord(raw)\n ? raw\n : isRecord(source)\n ? source\n : exp\n : exp\n return reconcileEntry(exp, value, {authored, isPublish, type})\n }\n\n // 3. Follow the hand-written key order of the map being generated. Source-only passthrough\n // subpaths missing from an existing publish map are appended, followed by generated extras.\n const authoredPaths = Object.keys(authoredRaw)\n for (const exportPath of Object.keys(sourceRaw)) {\n if (!Object.prototype.hasOwnProperty.call(authoredRaw, exportPath)) {\n authoredPaths.push(exportPath)\n }\n }\n for (const exportPath of authoredPaths) {\n if (exportPath in remapped) {\n result[exportPath] = reconcile(exportPath, remapped[exportPath])\n } else {\n // Hand-written subpaths that aren't build entries (`.css`/`.json` exports, `svelte`\n // entries) pass through untouched.\n result[exportPath] = Object.prototype.hasOwnProperty.call(authoredRaw, exportPath)\n ? authoredRaw[exportPath]\n : sourceRaw[exportPath]\n }\n }\n for (const [exportPath, value] of Object.entries(remapped)) {\n if (exportPath in result) continue\n result[exportPath] = reconcile(exportPath, value)\n }\n\n return result\n }\n}\n\n/**\n * Rebuilds a generated subpath entry in its authored condition order, re-inserting the\n * hand-written conditions tsdown's generator cannot express.\n */\nfunction reconcileEntry(\n exp: PkgExport,\n generated: unknown,\n options: {authored: object; isPublish: boolean; type: 'commonjs' | 'module'},\n): unknown {\n const {authored, isPublish, type} = options\n const authoredRecord = isRecord(authored) ? authored : {}\n\n // tsdown's publish variant of a single-format entry is a plain string\n const gen: Record<string, unknown> | undefined =\n typeof generated === 'string'\n ? {default: generated}\n : isRecord(generated)\n ? generated\n : undefined\n if (!gen) return generated\n\n const browserOrder = isRecord(authoredRecord['browser']) ? authoredRecord['browser'] : exp.browser\n const browser =\n exp.browser && (exp.browser.import || exp.browser.require)\n ? pickConditions(exp.browser, isPublish, browserOrder ?? exp.browser)\n : undefined\n const nodeOrder = isRecord(authoredRecord['node']) ? authoredRecord['node'] : exp.node\n const node =\n exp.node && (exp.node.import || exp.node.require)\n ? pickConditions(exp.node, isPublish, nodeOrder ?? exp.node)\n : undefined\n const custom = pickCustomConditions(exp)\n\n // Preserve tsdown's compact single-format publish shape unless hand-written conditions need\n // to be re-inserted. There is no condition ordering to preserve in a plain string entry.\n if (typeof generated === 'string' && !exp.types && !browser && !node && custom.length === 0) {\n return generated\n }\n\n const next: Record<string, unknown> = {}\n\n // `source`-like conditions resolve at development time and are stripped from the publish\n // variant (tsdown already does this for `source`; `development`/`monorepo` follow)\n if (!isPublish) {\n if (typeof gen['source'] === 'string') next['source'] = gen['source']\n else if (exp.source) next['source'] = exp.source\n if (exp.development) next['development'] = exp.development\n if (exp.monorepo) next['monorepo'] = exp.monorepo\n }\n\n if (exp.types) next['types'] = exp.types\n if (browser) next['browser'] = browser\n if (node) next['node'] = node\n\n // Hand-written custom conditions (`react-server`, `worker`, …) aren't built, but they are\n // the author's: carry their targets over, then restore every condition's authored position.\n for (const [condition, target] of custom) {\n const authoredTarget = authoredRecord[condition]\n next[condition] =\n isRecord(target) && isRecord(authoredTarget)\n ? preserveConditionOrder(target, authoredTarget)\n : target\n }\n\n if (typeof gen['import'] === 'string' && typeof gen['require'] === 'string') {\n next['import'] = gen['import']\n next['require'] = gen['require']\n // tsdown emits bare `import`/`require` pairs; the Sanity convention ends with `default`\n next['default'] = type === 'module' ? gen['import'] : gen['require']\n } else {\n // Single-format entries keep the generated shape (`{source, default}` in development)\n for (const [condition, target] of Object.entries(gen)) {\n if (condition in next || condition === 'source') continue\n next[condition] = target\n }\n }\n\n return preserveConditionOrder(next, authored)\n}\n\n/** The hand-written `browser`/`node` condition object, minus `source` for the publish map. */\nfunction pickConditions(\n conditions: {source?: string; import?: string; require?: string},\n isPublish: boolean,\n authored: object = conditions,\n): Record<string, string> {\n const next: Record<string, string> = {}\n if (!isPublish && conditions.source) next['source'] = conditions.source\n if (conditions.import) next['import'] = conditions.import\n if (conditions.require) next['require'] = conditions.require\n return preserveConditionOrder(next, authored)\n}\n\n/**\n * Reorders reconciled conditions to match their hand-written order. Conditions generated by\n * tsdown but absent from the hand-written entry are inserted before its `default` fallback.\n */\nfunction preserveConditionOrder<T>(\n conditions: Record<string, T>,\n authored: object,\n): Record<string, T> {\n const entries: [string, T][] = []\n const added = new Set<string>()\n const conditionEntries = Object.entries(conditions)\n const entriesByCondition = new Map(conditionEntries.map((entry) => [entry[0], entry]))\n const authoredOrder = Object.keys(authored).filter((condition) => !condition.startsWith('_'))\n const authoredConditions = new Set(authoredOrder)\n\n const addGeneratedConditions = () => {\n for (const entry of conditionEntries) {\n if (!authoredConditions.has(entry[0]) && !added.has(entry[0])) {\n entries.push(entry)\n added.add(entry[0])\n }\n }\n }\n\n for (const condition of authoredOrder) {\n // A generated condition has no authored position. Keep the explicit `default` as the final\n // fallback by placing generated conditions immediately before it.\n if (condition === 'default') addGeneratedConditions()\n const entry = entriesByCondition.get(condition)\n if (!entry) continue\n entries.push(entry)\n added.add(condition)\n }\n\n addGeneratedConditions()\n\n return Object.fromEntries(entries)\n}\n\n/** The conditions the pipeline owns (or re-inserts itself) on a build entry. */\nconst managedConditions = new Set([\n 'source',\n 'development',\n 'monorepo',\n 'types',\n 'browser',\n 'node',\n 'import',\n 'require',\n 'default',\n])\n\n/**\n * Hand-written conditions the pipeline knows nothing about (`react-server`, `worker`,\n * `edge-light`, …), in authored order. `parseExports` spreads the raw entry, so they survive\n * on the parsed `PkgExport` beyond its typed fields.\n */\nfunction pickCustomConditions(exp: PkgExport): [string, unknown][] {\n return Object.entries(exp).filter(\n ([condition, target]) =>\n !managedConditions.has(condition) && !condition.startsWith('_') && target !== undefined,\n )\n}\n","import path from 'node:path'\nimport {defineConfig} from '@sanity/tsdown-config'\nimport {mergeConfig, type InlineConfig, type UserConfig} from 'tsdown'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {pkgExtMap} from '../../core/pkg/pkgExt.ts'\nimport {createExportsComposer} from './composeExports.ts'\nimport type {TsdownBuild} from './resolveTsdownBuilds.ts'\n\nconst RE_TS_SOURCE = /\\.[cm]?tsx?$/\n\n/**\n * Composes the tsdown config for one build of the waterfall: `@sanity/tsdown-config`'s\n * `defineConfig()` provides the shared Sanity base, and the pkg-utils opinions (browserslist\n * targets, `PKG_*` defines, exports reconciliation, dts selection) layer over it with\n * tsdown's `mergeConfig`.\n *\n * pkg-utils owns its own experience: the returned config carries `config: false`, so tsdown\n * never loads `tsdown.config.*` files — `package.config.ts` is the sole config source — and\n * `logLevel: 'warn'` keeps tsdown's info chatter out of pkg-utils' own output.\n * @internal\n */\nexport async function resolveTsdownConfig(\n ctx: BuildContext,\n build: TsdownBuild,\n options: {\n /**\n * Whether this build may clean: only the first build of the waterfall cleans (so later\n * builds can't wipe earlier output), and `--no-clean` turns it off for the whole run.\n */\n clean: boolean\n watch?: boolean\n },\n): Promise<InlineConfig> {\n const {config, cwd, distPath, pkg} = ctx\n\n const reactCompiler = config?.reactCompiler\n if (typeof reactCompiler === 'object' && reactCompiler.reactServer === true) {\n throw new Error(\n [\n 'package.config.ts: `reactCompiler.reactServer` is not supported by `pkg build` — the',\n 'dual React Server Components build needs one tsdown run driving multiple configs.',\n 'Use `tsdown` + `@sanity/tsdown-config` directly instead: export the config from',\n '`tsdown.config.ts` and build with `tsdown`.',\n ].join('\\n'),\n )\n }\n\n const entry: Record<string, string> = {}\n for (const buildEntry of build.entries) {\n entry[buildEntry.alias] = buildEntry.source\n }\n\n // tsdown's `format` applies to the whole build (and its exports generation composes the\n // dual `import`/`require` map from both formats' chunks of one build), so the entries'\n // formats union: every entry is emitted in every format of the build. Mixed per-entry\n // coverage gets a heads-up — the extra files are emitted, and local exports generation\n // will declare them.\n const formats = new Set(build.entries.flatMap((buildEntry) => buildEntry.formats))\n if (formats.size > 1) {\n const partial = build.entries.filter((buildEntry) => buildEntry.formats.length < formats.size)\n if (partial.length) {\n const names = partial\n .map((buildEntry) =>\n buildEntry.exportPath ? `exports[\"${buildEntry.exportPath}\"]` : buildEntry.source,\n )\n .join(', ')\n ctx.logger.warn(\n `${names} declare${partial.length === 1 ? 's' : ''} fewer formats than the rest of the package. tsdown emits every format of a build for every entry, so the missing format is built anyway (and local exports generation will declare it). Declare both \\`import\\` and \\`require\\` targets for every subpath — or for none — to keep the exports map unambiguous.`,\n )\n }\n }\n const format = [\n ...(formats.has('esm') ? ['esm' as const] : []),\n ...(formats.has('commonjs') ? ['cjs' as const] : []),\n ]\n\n const platform =\n build.runtime === 'node' ? 'node' : build.runtime === 'browser' ? 'browser' : 'neutral'\n\n // Build-time constants: `PKG_VERSION` reads the environment override first, like v11.\n // pkg-utils' own build skips it so the replacement logic in this very file survives its own\n // bundling. (`PKG_FORMAT`, `PKG_RUNTIME` and `PKG_FILE_PATH` were removed in v12 — see\n // MIGRATE.md for the `package.json#imports` / `import.meta.url` replacements.)\n const define: Record<string, string> = {}\n if (pkg.name !== '@sanity/pkg-utils') {\n define['process.env.PKG_VERSION'] = JSON.stringify(process.env['PKG_VERSION'] || pkg.version)\n }\n for (const [key, value] of Object.entries(config?.define || {})) {\n define[key] = JSON.stringify(value)\n }\n\n // Types are generated with tsdown (rolldown-plugin-dts). `@typescript/native-preview` in\n // devDependencies auto-enables tsgo, like v11; an explicit `dts.tsgo` wins. Only the object\n // form spreads: when the `legacyChecks` migration errors are skipped\n // (`NODE_ENV=production` / `legacyChecks: false`), a leftover v11 string like\n // `dts: 'rolldown'` must degrade to the default behavior (which is what it meant) instead\n // of spreading into numeric character keys.\n const hasTsSources = build.entries.some((buildEntry) => RE_TS_SOURCE.test(buildEntry.source))\n const dtsPassthrough = typeof config?.dts === 'object' ? config.dts : undefined\n const dts =\n hasTsSources && config?.dts !== false\n ? {\n ...(typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies\n ? {tsgo: true}\n : {}),\n // Always create dts from scratch, don't reuse contexts from previous builds\n newContext: true,\n ...dtsPassthrough,\n ...(ctx.emitDeclarationOnly ? {emitDtsOnly: true} : {}),\n }\n : false\n\n // Exports generation runs on the canonical build only, with `devExports: 'source'` — the\n // hand-written Sanity convention (`source` conditions in `exports`, a `source`-less\n // `publishConfig.exports`) — and the pkg-utils composer reconciling the generated map with\n // the hand-written one. `@sanity/tsdown-config`'s always-on exports default applies: the map\n // is rewritten on every build (CI included), so environments that set `CI=true` without\n // meaning \"skip package.json\" (Cursor Cloud, …) still keep exports in sync. A types-only\n // build never rewrites `package.json`, and neither do watch builds (a rewrite would\n // re-trigger the `package.json` watcher).\n const exports: UserConfig['exports'] =\n build.canonical && !ctx.emitDeclarationOnly && !options.watch\n ? {\n devExports: 'source',\n customExports: createExportsComposer(ctx, build),\n // Keep the hand-written legacy fields (`main`/`module`) in sync instead of deleting\n // them; packages without them don't gain them\n ...(pkg.main || pkg.module ? {legacy: true} : {}),\n }\n : false\n\n const base = await defineConfig({\n cwd,\n tsconfig: ctx.ts.configPath,\n platform,\n format,\n entry,\n // POSIX separators: on Windows `path.relative` yields backslashes, which would leak into\n // generated `package.json` export targets (e.g. the conditional vanilla-extract export)\n outDir: path.relative(cwd, distPath).replaceAll('\\\\', '/') || '.',\n target: ctx.target[build.runtime],\n define,\n sourcemap: config?.sourcemap,\n // tsdown owns cleaning: the first build of the waterfall carries the effective `clean`\n // (the config passthrough, or tsdown's default `true`), every later build gets `false`.\n // A types-only build never cleans, so it can't delete JS output.\n clean: options.clean && !ctx.emitDeclarationOnly ? config?.clean : false,\n dts,\n deps: ctx.deps,\n exports,\n reactCompiler: config?.reactCompiler,\n styledComponents: config?.styledComponents,\n vanillaExtract: config?.vanillaExtract,\n })\n\n // The hand-written exports define the emitted extensions (`.js`/`.mjs`/`.cjs` per\n // `package.json#type`, enforced by `validateExports`), so the extensions are pinned\n // explicitly instead of relying on tsdown's defaults (whose `fixedExtension` kicks in for\n // `platform: 'node'` and would emit `.mjs` for `type: module` packages).\n const extMap = pkgExtMap[pkg.type === 'module' ? 'module' : 'commonjs']\n const outExtensions: UserConfig['outExtensions'] = ({format: outputFormat}) => ({\n js: outputFormat === 'cjs' ? extMap.commonjs : extMap.esm,\n })\n\n const merged = mergeConfig(base, {\n outExtensions,\n // publint runs during `pkg check` (via its node API), not inside the build\n publint: false,\n // the per-file size report logs through tsdown's info channel; pkg-utils prints its own\n report: false,\n ...(config?.minify === true ? {minify: true} : {}),\n ...(config?.plugins === undefined ? {} : {plugins: config.plugins}),\n })\n\n return {\n ...merged,\n config: false,\n logLevel: 'warn',\n ...(options.watch ? {watch: true} : {}),\n }\n}\n"],"mappings":";;;;;;;;;;;;AA6CA,SAAgB,oBAAoB,KAAkC;CACpE,IAAM,EAAC,QAAQ,KAAK,UAAU,WAAU,KAElC,cAAc,WAA2B;EAC7C,IAAM,QAAQ,KACX,SAA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;EACA,WAAW,QAAQ;EAInB,OAAO,QAAQ,SAAS,CAAC,IAAI,sBAAsB,QAAQ,QAAQ;EACnE;EACA,MAAM,IAAI;EACV;EACA,eAAe,QAAQ;EACvB,kBAAkB,QAAQ;EAC1B,gBAAgB,QAAQ;CAC1B,CAAC,GAMK,SAAS,UAAU,IAAI,SAAS,WAAW,WAAW,aACtD,iBAA8C,EAAC,QAAQ,oBAAmB,EAC9E,IAAI,iBAAiB,QAAQ,OAAO,WAAW,OAAO,IACxD;CAYA,OAAO;EACL,GAXa,YAAY,MAAM;GAC/B;GAEA,SAAS;GAET,QAAQ;GACR,GAAI,QAAQ,WAAW,KAAO,EAAC,QAAQ,GAAI,IAAI,CAAC;GAChD,GAAI,QAAQ,YAAY,KAAA,IAAY,CAAC,IAAI,EAAC,SAAS,OAAO,QAAO;EACnE,CAGU;EACR,QAAQ;EACR,UAAU;EACV,GAAI,QAAQ,QAAQ,EAAC,OAAO,GAAI,IAAI,CAAC;CACvC;AACF"}
@@ -1,6 +1,6 @@
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-CwqbTV6p.js";
3
- import { n as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-2OdGF-dM.js";
2
+ import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-CbwvYKj1.js";
3
+ import { n as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-CGE_7cMM.js";
4
4
  import path from "node:path";
5
5
  import { up } from "empathic/package";
6
6
  import { build } from "tsdown";
@@ -113,7 +113,7 @@ async function watch(options) {
113
113
  let config = await loadConfig({
114
114
  cwd,
115
115
  pkgPath
116
- }), { parseStrictOptions } = await import("./resolveBuildContext-CwqbTV6p.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
116
+ }), { parseStrictOptions } = await import("./resolveBuildContext-CbwvYKj1.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
117
117
  pkgPath,
118
118
  logger,
119
119
  strict,
@@ -176,4 +176,4 @@ async function watchAction(options) {
176
176
  }
177
177
  export { watchAction };
178
178
 
179
- //# sourceMappingURL=watchAction-uRPAvgLE.js.map
179
+ //# sourceMappingURL=watchAction-BQG5_hhl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"watchAction-uRPAvgLE.js","names":["findPkgPath","tsdownBuild"],"sources":["../src/node/core/pkg/cssShimFileName.ts","../src/node/core/pkg/writeBundleCssExports.ts","../src/node/watch.ts","../src/cli/watchAction.ts"],"sourcesContent":["/**\n * The no-op JS shim file name for a CSS file under vanilla-extract compat mode.\n *\n * `bundle.css` → `bundle-css.js` — deliberately not `${cssFileName}.js` (`bundle.css.js`),\n * which vanilla-extract's `cssFileFilter` (`/\\.css\\.(js|cjs|mjs|jsx|ts|tsx)$/`) would treat as\n * a stylesheet module. Kept in sync with `cssShimFileName` in\n * `@sanity/vanilla-extract-rolldown-plugin`.\n *\n * @internal\n */\nexport function cssShimFileName(cssFileName: string): string {\n return `${cssFileName.replace(/\\.css$/, '-css')}.js`\n}\n\n/**\n * The `.d.ts` companion for {@link cssShimFileName}. `bundle.css` → `bundle-css.d.ts`.\n *\n * @internal\n */\nexport function cssShimDtsFileName(cssFileName: string): string {\n return `${cssFileName.replace(/\\.css$/, '-css')}.d.ts`\n}\n","import {readFile, writeFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport type {Logger} from '../../logger.ts'\nimport {isRecord} from '../isRecord.ts'\nimport {cssShimDtsFileName, cssShimFileName} from './cssShimFileName.ts'\n\n/**\n * Build the conditional CSS export object that vanilla-extract compat mode expects, e.g.\n * ```json\n * {\n * \"types\": \"./dist/bundle-css.d.ts\",\n * \"browser\": \"./dist/bundle.css\",\n * \"style\": \"./dist/bundle.css\",\n * \"node\": \"./dist/bundle-css.js\",\n * \"default\": \"./dist/bundle-css.js\"\n * }\n * ```\n * The shim is named `bundle-css.js` (not `bundle.css.js`) so it does not match\n * vanilla-extract's `cssFileFilter`. An explicit `types` condition (rather than relying on\n * TypeScript's extension-substitution fallback, which only works when the shim shares the CSS\n * file's basename, and which TypeScript is deprecating anyway - microsoft/TypeScript#50762)\n * points resolvers straight at the shim's declaration file.\n *\n * Kept in sync with `createConditionalCssExport` in `@sanity/vanilla-extract-tsdown-plugin`,\n * which writes the same entry through tsdown's `exports.customExports` during full builds.\n */\nfunction createConditionalCssExport(cssFile: string, shimFile: string, shimDtsFile: string) {\n return {types: shimDtsFile, browser: cssFile, style: cssFile, node: shimFile, default: shimFile}\n}\n\nfunction hasMatchingExport(value: unknown, expected: Record<string, string>): boolean {\n if (typeof value !== 'object' || value === null) return false\n const actual = Object.fromEntries(Object.entries(value))\n const keys = Object.keys(expected)\n return (\n keys.length === Object.keys(actual).length && keys.every((key) => actual[key] === expected[key])\n )\n}\n\n/**\n * Insert (or replace) the `\"./<cssName>\"` export in an `exports`-shaped map, preserving the existing\n * order and placing it before `./package.json` when present.\n */\nfunction insertCssExport(\n exports: Record<string, unknown>,\n exportKey: string,\n conditionalExport: Record<string, string>,\n): Record<string, unknown> {\n const nextExports: Record<string, unknown> = {}\n let inserted = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === exportKey) continue\n if (key === './package.json' && !inserted) {\n nextExports[exportKey] = conditionalExport\n inserted = true\n }\n nextExports[key] = value\n }\n if (!inserted) {\n nextExports[exportKey] = conditionalExport\n }\n return nextExports\n}\n\nfunction detectIndent(source: string): string | number {\n const match = source.match(/\\n([ \\t]+)\\S/)\n if (!match) return 2\n const indent = match[1]!\n return indent.includes('\\t') ? '\\t' : indent.length\n}\n\n/**\n * Write the conditional `\"./<cssName>\"` export to `package.json` (used by vanilla-extract compat\n * mode), so userland does not have to maintain it by hand. The write is idempotent: if the export\n * already matches, the file is left untouched.\n *\n * Full builds write this entry through tsdown's `exports.customExports` (the\n * `@sanity/vanilla-extract-tsdown-plugin` composition), but watch mode disables tsdown's\n * `exports` feature (a `package.json` write per rebuild would loop the watcher) — `pkg watch`\n * calls this once per context instead, like v11 did.\n *\n * When `publishConfig.exports` is present, the same conditional CSS export is mirrored into it. The\n * conditional CSS export has no `source`/`development`/`monorepo` conditions to strip, so the entry\n * is identical in both places. Keeping them in sync prevents the `publishConfig.exports` validation\n * from failing with a \"missing export path\" error for the auto-added `./<cssName>` export.\n *\n * @internal\n */\nexport async function writeBundleCssExports(options: {\n cwd: string\n distPath: string\n cssName: string\n logger: Logger\n}): Promise<void> {\n const {cwd, distPath, cssName, logger} = options\n\n const pkgPath = path.resolve(cwd, 'package.json')\n const source = await readFile(pkgPath, 'utf8')\n // oxlint-disable-next-line no-unsafe-type-assertion\n const pkg = JSON.parse(source) as {\n exports?: Record<string, unknown>\n publishConfig?: {exports?: Record<string, unknown>}\n }\n\n // Normalize to POSIX separators - `path.relative` uses `\\\\` on Windows, but `exports` paths in\n // package.json must always use `/`.\n const distRel = (path.relative(cwd, distPath) || 'dist').split(path.sep).join('/')\n const exportKey = `./${cssName}`\n const cssFile = `./${path.posix.join(distRel, cssName)}`\n const shimFile = `./${path.posix.join(distRel, cssShimFileName(cssName))}`\n const shimDtsFile = `./${path.posix.join(distRel, cssShimDtsFileName(cssName))}`\n const conditionalExport = createConditionalCssExport(cssFile, shimFile, shimDtsFile)\n\n // Only mirror into `publishConfig.exports` when it already exists; never create it here.\n const publishConfig = pkg.publishConfig\n const publishConfigExports = isRecord(publishConfig?.exports) ? publishConfig.exports : undefined\n\n const exportsMatch = hasMatchingExport(pkg.exports?.[exportKey], conditionalExport)\n const publishConfigExportsMatch =\n !publishConfigExports || hasMatchingExport(publishConfigExports[exportKey], conditionalExport)\n\n if (exportsMatch && publishConfigExportsMatch) {\n return\n }\n\n pkg.exports = insertCssExport(pkg.exports ?? {}, exportKey, conditionalExport)\n\n if (publishConfig && publishConfigExports) {\n publishConfig.exports = insertCssExport(publishConfigExports, exportKey, conditionalExport)\n }\n\n await writeFile(pkgPath, `${JSON.stringify(pkg, null, detectIndent(source))}\\n`)\n logger.log(\n `Updated package.json: added \\`exports[\"${exportKey}\"]\\`${\n publishConfigExports ? ` and \\`publishConfig.exports[\"${exportKey}\"]\\`` : ''\n } for vanilla-extract compat mode`,\n )\n}\n","import {up as findPkgPath} from 'empathic/package'\nimport type {Subscription} from 'rxjs'\nimport {switchMap} from 'rxjs'\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 {writeBundleCssExports} from './core/pkg/writeBundleCssExports.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveTsdownBuilds} from './tasks/tsdown/resolveTsdownBuilds.ts'\nimport {resolveTsdownConfig} from './tasks/tsdown/resolveTsdownConfig.ts'\n\nconst asyncDispose: typeof Symbol.asyncDispose =\n Symbol.asyncDispose || Symbol.for('Symbol.asyncDispose')\n\n/** @public */\nexport async function watch(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n signal?: AbortSignal\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption, signal} = options\n\n const logger = createLogger()\n\n const {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n // Every rebuild of the waterfall holds tsdown watchers (one per platform build); they are\n // disposed when the config files change (the waterfall restarts) or the signal aborts.\n // RxJS does not await async subscriber callbacks, so a monotonically increasing run id\n // guards the rebuilds: only the latest run may publish into `bundles`, and a run that turns\n // stale mid-flight (a newer config-file event, or the abort signal) disposes the watchers\n // it created instead of leaking them.\n let bundles: TsdownBundle[] = []\n let runId = 0\n const disposeBundles = async () => {\n const disposing = bundles\n bundles = []\n for (const bundle of disposing) {\n await bundle[asyncDispose]()\n }\n }\n\n const ctx$ = configFiles$.pipe(\n switchMap(async () => {\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('missing package.json', {cause: {cwd}})\n }\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\n return resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n }),\n )\n\n const ctxSubscription: Subscription = ctx$.subscribe(async (ctx) => {\n const id = ++runId\n const runBundles: TsdownBundle[] = []\n try {\n await disposeBundles()\n\n // Full builds write the conditional `./<css>` export through tsdown's\n // `exports.customExports` composition, but watch mode disables tsdown's `exports` feature\n // (a package.json write per rebuild would loop the watcher). Keep the export in sync here\n // instead, once per context, like v11 — the write is idempotent, so it won't loop.\n const vanillaExtract = ctx.config?.vanillaExtract\n if (vanillaExtract) {\n const veOptions = vanillaExtract === true ? {} : vanillaExtract\n // `@sanity/tsdown-config` defaults `inject` to `{nodeCompat: true}` (the conditional\n // CSS export pattern); an explicit user `inject` replaces that default\n const inject = veOptions.inject ?? {nodeCompat: true}\n if (isRecord(inject) && inject['nodeCompat']) {\n await writeBundleCssExports({\n cwd,\n distPath: ctx.distPath,\n cssName: veOptions.fileName || 'bundle.css',\n logger,\n })\n }\n }\n\n const builds = resolveTsdownBuilds(ctx)\n\n let first = true\n for (const buildDef of builds) {\n if (id !== runId) break\n\n const inlineConfig = await resolveTsdownConfig(ctx, buildDef, {\n clean: first,\n watch: true,\n })\n first = false\n\n runBundles.push(...(await tsdownBuild(inlineConfig)))\n }\n\n if (id !== runId) {\n // A newer run (or the abort signal) took over while this rebuild was in flight —\n // dispose everything this run created instead of publishing it\n for (const bundle of runBundles) {\n await bundle[asyncDispose]()\n }\n return\n }\n\n bundles = runBundles\n\n logger.success(`${ctx.pkg.name}: watching for file changes\\u2026`)\n logger.log()\n } catch (err) {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n }\n })\n\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n runId++\n ctxSubscription.unsubscribe()\n void disposeBundles()\n },\n {once: true},\n )\n }\n}\n","import {watch} from '../node/watch.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function watchAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await watch({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,SAAgB,gBAAgB,aAA6B;CAC3D,OAAO,GAAG,YAAY,QAAQ,UAAU,MAAM,EAAE;AAClD;;;;;;AAOA,SAAgB,mBAAmB,aAA6B;CAC9D,OAAO,GAAG,YAAY,QAAQ,UAAU,MAAM,EAAE;AAClD;;;;;;;;;;;;;;;;;;;;;ACKA,SAAS,2BAA2B,SAAiB,UAAkB,aAAqB;CAC1F,OAAO;EAAC,OAAO;EAAa,SAAS;EAAS,OAAO;EAAS,MAAM;EAAU,SAAS;CAAQ;AACjG;AAEA,SAAS,kBAAkB,OAAgB,UAA2C;CACpF,IAAI,OAAO,SAAU,aAAY,OAAgB,OAAO;CACxD,IAAM,SAAS,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,GACjD,OAAO,OAAO,KAAK,QAAQ;CACjC,OACE,KAAK,WAAW,OAAO,KAAK,MAAM,CAAC,CAAC,UAAU,KAAK,OAAO,QAAQ,OAAO,SAAS,SAAS,IAAI;AAEnG;;;;;AAMA,SAAS,gBACP,SACA,WACA,mBACyB;CACzB,IAAM,cAAuC,CAAC,GAC1C,WAAW;CACf,KAAK,IAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAC3C,QAAQ,cACR,QAAQ,oBAAoB,CAAC,aAC/B,YAAY,aAAa,mBACzB,WAAW,KAEb,YAAY,OAAO;CA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AU,IAAI;KACd,SAAS,UAAU,YAAY;KAC/B;IACF,CAAC;GAEL;GAEA,IAAM,SAAS,oBAAoB,GAAG,GAElC,QAAQ;GACZ,KAAK,IAAM,YAAY,QAAQ;IAC7B,IAAI,OAAO,OAAO;IAElB,IAAM,eAAe,MAAM,oBAAoB,KAAK,UAAU;KAC5D,OAAO;KACP,OAAO;IACT,CAAC;IAGD,AAFA,QAAQ,IAER,WAAW,KAAK,GAAI,MAAMC,MAAY,YAAY,CAAE;GACtD;GAEA,IAAI,OAAO,OAAO;IAGhB,KAAK,IAAM,UAAU,YACnB,MAAM,OAAO,aAAa,CAAC;IAE7B;GACF;GAKA,AAHA,UAAU,YAEV,OAAO,QAAQ,GAAG,IAAI,IAAI,KAAK,kCAAkC,GACjE,OAAO,IAAI;EACb,SAAS,KAAK;GAIZ,AAHA,IAAI,OAAO,MAAM,GAAG,GACpB,IAAI,OAAO,IAAI,GAEf,QAAQ,KAAK,CAAC;EAChB;CACF,CAAC;CAED,AAAI,UACF,OAAO,iBACL,eACM;EAGJ,AAFA,SACA,gBAAgB,YAAY,GAC5B,eAAoB;CACtB,GACA,EAAC,MAAM,GAAI,CACb;AAEJ;ACrIA,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":"watchAction-BQG5_hhl.js","names":["findPkgPath","tsdownBuild"],"sources":["../src/node/core/pkg/cssShimFileName.ts","../src/node/core/pkg/writeBundleCssExports.ts","../src/node/watch.ts","../src/cli/watchAction.ts"],"sourcesContent":["/**\n * The no-op JS shim file name for a CSS file under vanilla-extract compat mode.\n *\n * `bundle.css` → `bundle-css.js` — deliberately not `${cssFileName}.js` (`bundle.css.js`),\n * which vanilla-extract's `cssFileFilter` (`/\\.css\\.(js|cjs|mjs|jsx|ts|tsx)$/`) would treat as\n * a stylesheet module. Kept in sync with `cssShimFileName` in\n * `@sanity/vanilla-extract-rolldown-plugin`.\n *\n * @internal\n */\nexport function cssShimFileName(cssFileName: string): string {\n return `${cssFileName.replace(/\\.css$/, '-css')}.js`\n}\n\n/**\n * The `.d.ts` companion for {@link cssShimFileName}. `bundle.css` → `bundle-css.d.ts`.\n *\n * @internal\n */\nexport function cssShimDtsFileName(cssFileName: string): string {\n return `${cssFileName.replace(/\\.css$/, '-css')}.d.ts`\n}\n","import {readFile, writeFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport type {Logger} from '../../logger.ts'\nimport {isRecord} from '../isRecord.ts'\nimport {cssShimDtsFileName, cssShimFileName} from './cssShimFileName.ts'\n\n/**\n * Build the conditional CSS export object that vanilla-extract compat mode expects, e.g.\n * ```json\n * {\n * \"types\": \"./dist/bundle-css.d.ts\",\n * \"browser\": \"./dist/bundle.css\",\n * \"style\": \"./dist/bundle.css\",\n * \"node\": \"./dist/bundle-css.js\",\n * \"default\": \"./dist/bundle-css.js\"\n * }\n * ```\n * The shim is named `bundle-css.js` (not `bundle.css.js`) so it does not match\n * vanilla-extract's `cssFileFilter`. An explicit `types` condition (rather than relying on\n * TypeScript's extension-substitution fallback, which only works when the shim shares the CSS\n * file's basename, and which TypeScript is deprecating anyway - microsoft/TypeScript#50762)\n * points resolvers straight at the shim's declaration file.\n *\n * Kept in sync with `createConditionalCssExport` in `@sanity/vanilla-extract-tsdown-plugin`,\n * which writes the same entry through tsdown's `exports.customExports` during full builds.\n */\nfunction createConditionalCssExport(cssFile: string, shimFile: string, shimDtsFile: string) {\n return {types: shimDtsFile, browser: cssFile, style: cssFile, node: shimFile, default: shimFile}\n}\n\nfunction hasMatchingExport(value: unknown, expected: Record<string, string>): boolean {\n if (typeof value !== 'object' || value === null) return false\n const actual = Object.fromEntries(Object.entries(value))\n const keys = Object.keys(expected)\n return (\n keys.length === Object.keys(actual).length && keys.every((key) => actual[key] === expected[key])\n )\n}\n\n/**\n * Insert (or replace) the `\"./<cssName>\"` export in an `exports`-shaped map, preserving the existing\n * order and placing it before `./package.json` when present.\n */\nfunction insertCssExport(\n exports: Record<string, unknown>,\n exportKey: string,\n conditionalExport: Record<string, string>,\n): Record<string, unknown> {\n const nextExports: Record<string, unknown> = {}\n let inserted = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === exportKey) continue\n if (key === './package.json' && !inserted) {\n nextExports[exportKey] = conditionalExport\n inserted = true\n }\n nextExports[key] = value\n }\n if (!inserted) {\n nextExports[exportKey] = conditionalExport\n }\n return nextExports\n}\n\nfunction detectIndent(source: string): string | number {\n const match = source.match(/\\n([ \\t]+)\\S/)\n if (!match) return 2\n const indent = match[1]!\n return indent.includes('\\t') ? '\\t' : indent.length\n}\n\n/**\n * Write the conditional `\"./<cssName>\"` export to `package.json` (used by vanilla-extract compat\n * mode), so userland does not have to maintain it by hand. The write is idempotent: if the export\n * already matches, the file is left untouched.\n *\n * Full builds write this entry through tsdown's `exports.customExports` (the\n * `@sanity/vanilla-extract-tsdown-plugin` composition), but watch mode disables tsdown's\n * `exports` feature (a `package.json` write per rebuild would loop the watcher) — `pkg watch`\n * calls this once per context instead, like v11 did.\n *\n * When `publishConfig.exports` is present, the same conditional CSS export is mirrored into it. The\n * conditional CSS export has no `source`/`development`/`monorepo` conditions to strip, so the entry\n * is identical in both places. Keeping them in sync prevents the `publishConfig.exports` validation\n * from failing with a \"missing export path\" error for the auto-added `./<cssName>` export.\n *\n * @internal\n */\nexport async function writeBundleCssExports(options: {\n cwd: string\n distPath: string\n cssName: string\n logger: Logger\n}): Promise<void> {\n const {cwd, distPath, cssName, logger} = options\n\n const pkgPath = path.resolve(cwd, 'package.json')\n const source = await readFile(pkgPath, 'utf8')\n // oxlint-disable-next-line no-unsafe-type-assertion\n const pkg = JSON.parse(source) as {\n exports?: Record<string, unknown>\n publishConfig?: {exports?: Record<string, unknown>}\n }\n\n // Normalize to POSIX separators - `path.relative` uses `\\\\` on Windows, but `exports` paths in\n // package.json must always use `/`.\n const distRel = (path.relative(cwd, distPath) || 'dist').split(path.sep).join('/')\n const exportKey = `./${cssName}`\n const cssFile = `./${path.posix.join(distRel, cssName)}`\n const shimFile = `./${path.posix.join(distRel, cssShimFileName(cssName))}`\n const shimDtsFile = `./${path.posix.join(distRel, cssShimDtsFileName(cssName))}`\n const conditionalExport = createConditionalCssExport(cssFile, shimFile, shimDtsFile)\n\n // Only mirror into `publishConfig.exports` when it already exists; never create it here.\n const publishConfig = pkg.publishConfig\n const publishConfigExports = isRecord(publishConfig?.exports) ? publishConfig.exports : undefined\n\n const exportsMatch = hasMatchingExport(pkg.exports?.[exportKey], conditionalExport)\n const publishConfigExportsMatch =\n !publishConfigExports || hasMatchingExport(publishConfigExports[exportKey], conditionalExport)\n\n if (exportsMatch && publishConfigExportsMatch) {\n return\n }\n\n pkg.exports = insertCssExport(pkg.exports ?? {}, exportKey, conditionalExport)\n\n if (publishConfig && publishConfigExports) {\n publishConfig.exports = insertCssExport(publishConfigExports, exportKey, conditionalExport)\n }\n\n await writeFile(pkgPath, `${JSON.stringify(pkg, null, detectIndent(source))}\\n`)\n logger.log(\n `Updated package.json: added \\`exports[\"${exportKey}\"]\\`${\n publishConfigExports ? ` and \\`publishConfig.exports[\"${exportKey}\"]\\`` : ''\n } for vanilla-extract compat mode`,\n )\n}\n","import {up as findPkgPath} from 'empathic/package'\nimport type {Subscription} from 'rxjs'\nimport {switchMap} from 'rxjs'\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 {writeBundleCssExports} from './core/pkg/writeBundleCssExports.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveTsdownBuilds} from './tasks/tsdown/resolveTsdownBuilds.ts'\nimport {resolveTsdownConfig} from './tasks/tsdown/resolveTsdownConfig.ts'\n\nconst asyncDispose: typeof Symbol.asyncDispose =\n Symbol.asyncDispose || Symbol.for('Symbol.asyncDispose')\n\n/** @public */\nexport async function watch(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n signal?: AbortSignal\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption, signal} = options\n\n const logger = createLogger()\n\n const {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n // Every rebuild of the waterfall holds tsdown watchers (one per platform build); they are\n // disposed when the config files change (the waterfall restarts) or the signal aborts.\n // RxJS does not await async subscriber callbacks, so a monotonically increasing run id\n // guards the rebuilds: only the latest run may publish into `bundles`, and a run that turns\n // stale mid-flight (a newer config-file event, or the abort signal) disposes the watchers\n // it created instead of leaking them.\n let bundles: TsdownBundle[] = []\n let runId = 0\n const disposeBundles = async () => {\n const disposing = bundles\n bundles = []\n for (const bundle of disposing) {\n await bundle[asyncDispose]()\n }\n }\n\n const ctx$ = configFiles$.pipe(\n switchMap(async () => {\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('missing package.json', {cause: {cwd}})\n }\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\n return resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n }),\n )\n\n const ctxSubscription: Subscription = ctx$.subscribe(async (ctx) => {\n const id = ++runId\n const runBundles: TsdownBundle[] = []\n try {\n await disposeBundles()\n\n // Full builds write the conditional `./<css>` export through tsdown's\n // `exports.customExports` composition, but watch mode disables tsdown's `exports` feature\n // (a package.json write per rebuild would loop the watcher). Keep the export in sync here\n // instead, once per context, like v11 — the write is idempotent, so it won't loop.\n const vanillaExtract = ctx.config?.vanillaExtract\n if (vanillaExtract) {\n const veOptions = vanillaExtract === true ? {} : vanillaExtract\n // `@sanity/tsdown-config` defaults `inject` to `{nodeCompat: true}` (the conditional\n // CSS export pattern); an explicit user `inject` replaces that default\n const inject = veOptions.inject ?? {nodeCompat: true}\n if (isRecord(inject) && inject['nodeCompat']) {\n await writeBundleCssExports({\n cwd,\n distPath: ctx.distPath,\n cssName: veOptions.fileName || 'bundle.css',\n logger,\n })\n }\n }\n\n const builds = resolveTsdownBuilds(ctx)\n\n let first = true\n for (const buildDef of builds) {\n if (id !== runId) break\n\n const inlineConfig = await resolveTsdownConfig(ctx, buildDef, {\n clean: first,\n watch: true,\n })\n first = false\n\n runBundles.push(...(await tsdownBuild(inlineConfig)))\n }\n\n if (id !== runId) {\n // A newer run (or the abort signal) took over while this rebuild was in flight —\n // dispose everything this run created instead of publishing it\n for (const bundle of runBundles) {\n await bundle[asyncDispose]()\n }\n return\n }\n\n bundles = runBundles\n\n logger.success(`${ctx.pkg.name}: watching for file changes\\u2026`)\n logger.log()\n } catch (err) {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n }\n })\n\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n runId++\n ctxSubscription.unsubscribe()\n void disposeBundles()\n },\n {once: true},\n )\n }\n}\n","import {watch} from '../node/watch.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function watchAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await watch({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,SAAgB,gBAAgB,aAA6B;CAC3D,OAAO,GAAG,YAAY,QAAQ,UAAU,MAAM,EAAE;AAClD;;;;;;AAOA,SAAgB,mBAAmB,aAA6B;CAC9D,OAAO,GAAG,YAAY,QAAQ,UAAU,MAAM,EAAE;AAClD;;;;;;;;;;;;;;;;;;;;;ACKA,SAAS,2BAA2B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UACF,OAAO,iBACL,eACM;EAGJ,AAFA,SACA,gBAAgB,YAAY,GAC5B,eAAoB;CACtB,GACA,EAAC,MAAM,GAAI,CACb;AAEJ;ACrIA,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "12.0.0",
3
+ "version": "12.0.1",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -67,11 +67,11 @@
67
67
  "rxjs": "^7.8.2",
68
68
  "treeify": "^1.1.0",
69
69
  "tsdown": "^0.22.14",
70
- "tsx": "^4.23.1",
70
+ "tsx": "^4.23.4",
71
71
  "zod": "^4.4.3",
72
72
  "zod-validation-error": "^5.0.0",
73
- "@sanity/tsdown-config": "^0.22.0",
74
- "@sanity/parse-package-json": "^2.2.11"
73
+ "@sanity/parse-package-json": "^2.2.11",
74
+ "@sanity/tsdown-config": "^0.23.0"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/find-config": "^1.0.4",
@@ -1 +0,0 @@
1
- {"version":3,"file":"initAction-Cv0oRwWP.js","names":["prettierConfig"],"sources":["../src/node/core/template/createFromTemplate.ts","../src/node/core/template/define.ts","../src/node/isEmptyDirectory.ts","../../../../node_modules/.pnpm/@sanity+prettier-config@3.0.0_prettier@3.9.6/node_modules/@sanity/prettier-config/dist/index.js","../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/parse-url.js","../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/index.js","../src/node/templates/default/template.ts","../src/node/init.ts","../src/cli/initAction.ts"],"sourcesContent":["import {writeFile} from 'node:fs/promises'\nimport {dirname, relative, resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport prompts from 'prompts'\nimport type {Logger} from '../../logger.ts'\nimport type {PkgTemplate} from './types.ts'\n\nconst promptsTypes = {\n string: 'text' as const,\n}\n\n/** @internal */\nexport async function createFromTemplate(options: {\n cwd: string\n logger: Logger\n packagePath: string\n template: PkgTemplate\n}): Promise<void> {\n const {cwd, logger, packagePath, template: templateOrResolver} = options\n\n const template =\n typeof templateOrResolver === 'function'\n ? await templateOrResolver({cwd, logger, packagePath})\n : templateOrResolver\n\n logger.log('create new package at', relative(cwd, packagePath))\n\n const templateOptions: Record<string, string> = {}\n\n for (const templateOption of template.options) {\n const templateValidate = templateOption.validate\n\n const res = await prompts(\n {\n type: promptsTypes[templateOption.type],\n name: templateOption.name,\n message: templateOption.description,\n validate: templateValidate ? (prev) => templateValidate(prev) : undefined,\n initial:\n typeof templateOption.initial === 'function'\n ? templateOption.initial(templateOptions)\n : templateOption.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n\n templateOptions[templateOption.name] = templateOption.parse\n ? templateOption.parse(res[templateOption.name])\n : res[templateOption.name]\n }\n\n const features: Record<string, boolean> = {}\n\n for (const templateFeature of template.features) {\n const res = templateFeature.optional\n ? await prompts(\n {\n type: 'confirm',\n name: 'confirm',\n message: `use ${templateFeature.name}?`,\n initial: templateFeature.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n : undefined\n\n features[templateFeature.name] = res?.confirm || !templateFeature.optional\n }\n\n const files = await template.getFiles(templateOptions, features)\n\n files.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n for (const file of files) {\n const filePath = resolve(packagePath, file.name)\n\n await mkdirp(dirname(filePath))\n await writeFile(filePath, file.contents.trim() + '\\n')\n\n logger.success(`wrote ${relative(cwd, filePath)}`)\n }\n}\n","import type {PkgTemplateOption} from './types.ts'\n\n/** @public */\nexport function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T> {\n return option\n}\n","import {readdir} from 'node:fs/promises'\n\nexport async function isEmptyDirectory(dirPath: string): Promise<boolean> {\n return (await readdir(dirPath)).length === 0\n}\n","const overridableDefaults = {\n endOfLine: \"lf\",\n tabWidth: 2,\n useTabs: !1\n}, json5 = {\n files: [\"*.json5\"],\n options: {\n quoteProps: \"preserve\",\n singleQuote: !1\n }\n}, yaml = {\n files: [\"*.yml\"],\n options: {\n singleQuote: !1\n }\n}, config = {\n ...overridableDefaults,\n printWidth: 100,\n semi: !1,\n singleQuote: !0,\n quoteProps: \"consistent\",\n bracketSpacing: !1,\n plugins: [\"prettier-plugin-packagejson\"],\n overrides: [json5, yaml]\n};\nexport {\n config as default\n};\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nvar urlModule = require('url');\nvar URLCtor = typeof URL === 'undefined' ? urlModule.URL || null : URL;\nvar legacyURLParse = URLCtor ? null : urlModule.parse;\n\nfunction parseWHATWG(str) {\n\ttry {\n\t\tvar u = new URLCtor(str);\n\t\tvar auth = null;\n\t\tif (u.username) {\n\t\t\tauth = u.password ? u.username + ':' + u.password : u.username;\n\t\t}\n\t\tvar host = u.host || null;\n\t\tvar hostname = u.hostname || null;\n\t\tvar pathname = u.pathname || null;\n\t\tvar path = u.pathname + (u.search || '') || null;\n\n\t\t// For non-special schemes without '//' (e.g. 'github:user/repo', 'foo:bar'),\n\t\t// the WHATWG URL API produces an opaque path (host is empty). Replicate the\n\t\t// legacy url.parse() behavior: treat the first path segment as the host.\n\t\tif (!host && pathname && str.indexOf('//') === -1) {\n\t\t\tvar slashIdx = pathname.indexOf('/');\n\t\t\tif (slashIdx === -1) {\n\t\t\t\t// e.g. 'foo:bar' — no path segment, only a host-like token → null path\n\t\t\t\thost = pathname;\n\t\t\t\thostname = pathname;\n\t\t\t\tpathname = null;\n\t\t\t\tpath = null;\n\t\t\t} else {\n\t\t\t\t// e.g. 'github:user/repo' — first segment is host, rest is path\n\t\t\t\thost = pathname.slice(0, slashIdx);\n\t\t\t\thostname = host;\n\t\t\t\tpathname = pathname.slice(slashIdx);\n\t\t\t\tpath = pathname + (u.search || '');\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tauth: auth,\n\t\t\thash: u.hash || null,\n\t\t\thost: host,\n\t\t\thostname: hostname,\n\t\t\thref: u.href,\n\t\t\tpath: path,\n\t\t\tpathname: pathname,\n\t\t\tport: u.port || null,\n\t\t\tprotocol: u.protocol || null,\n\t\t\tquery: u.search ? u.search.slice(1) : null,\n\t\t\tsearch: u.search || null,\n\t\t\tslashes: str.indexOf('//') === -1 ? null : true\n\t\t};\n\t} catch (_) {\n\t\t// Fall back for non-standard strings (bare paths, git@ URLs, etc.)\n\t\tvar hashIdx = str.indexOf('#');\n\t\tvar hash = hashIdx === -1 ? null : str.slice(hashIdx);\n\t\tvar pathPart = hashIdx === -1 ? str : str.slice(0, hashIdx);\n\t\tvar queryIdx = pathPart.indexOf('?');\n\t\tvar search = queryIdx === -1 ? null : pathPart.slice(queryIdx);\n\t\tvar pathnamePart = queryIdx === -1 ? pathPart : pathPart.slice(0, queryIdx);\n\t\treturn {\n\t\t\tauth: null,\n\t\t\thash: hash,\n\t\t\thost: null,\n\t\t\thostname: null,\n\t\t\thref: str,\n\t\t\tpath: pathPart || null,\n\t\t\tpathname: pathnamePart || null,\n\t\t\tport: null,\n\t\t\tprotocol: null,\n\t\t\tquery: search ? search.slice(1) : null,\n\t\t\tsearch: search,\n\t\t\tslashes: null\n\t\t};\n\t}\n}\n\nmodule.exports = URLCtor ? parseWHATWG : legacyURLParse;\n","/*!\n * parse-github-url <https://github.com/jonschlinkert/parse-github-url>\n *\n * Copyright (c) 2015-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\n'use strict';\n\nvar parseURL = require('./parse-url');\nvar cache = { __proto__: null };\n\nfunction isChecksum(str) {\n\treturn (/^[a-f0-9]{40}$/i).test(str);\n}\n\nfunction getBranch(str, obj) {\n\tvar segs = str.split('#');\n\tvar branch;\n\tif (segs.length > 1) {\n\t\tbranch = segs[segs.length - 1];\n\t}\n\tif (!branch && obj.hash && obj.hash.charAt(0) === '#') {\n\t\tbranch = obj.hash.slice(1);\n\t}\n\treturn branch || 'master';\n}\n\nfunction trimSlash(path) {\n\treturn path.charAt(0) === '/' ? path.slice(1) : path;\n}\n\nfunction name(str) {\n\treturn str ? str.replace(/\\.git$/, '') : null;\n}\n\nfunction owner(str) {\n\tif (!str) {\n\t\treturn null;\n\t}\n\tvar idx = str.indexOf(':');\n\tif (idx > -1) {\n\t\treturn str.slice(idx + 1);\n\t}\n\treturn str;\n}\n\n/**\n * Extract the host from a git@ URL using the WHATWG URL API.\n */\nfunction getGitAtHost(str) {\n\tvar transformed = 'http://' + str.replace(/git@([^:]+):/, '$1/');\n\treturn parseURL(transformed).host || null;\n}\n\nfunction parse(str) {\n\tif (typeof str !== 'string' || !str.length) {\n\t\treturn null;\n\t}\n\n\tif (str.indexOf('git@gist') !== -1 || str.indexOf('//gist') !== -1) {\n\t\treturn null;\n\t}\n\n\t// parse the URL\n\tvar obj = parseURL(str);\n\tif (typeof obj.path !== 'string' || !obj.path.length || typeof obj.pathname !== 'string' || !obj.pathname.length) {\n\t\treturn null;\n\t}\n\n\tif (!obj.host && (/^git@/).test(str) === true) {\n\t\t// return the correct host for git@ URLs\n\t\tobj.host = getGitAtHost(str);\n\t}\n\n\tobj.path = trimSlash(obj.path);\n\tobj.pathname = trimSlash(obj.pathname);\n\tobj.filepath = null;\n\n\tif (obj.path.indexOf('repos') === 0) {\n\t\tobj.path = obj.path.slice(6);\n\t}\n\n\tvar seg = obj.path.split('/').filter(Boolean);\n\tvar hasBlob = seg[2] === 'blob';\n\tif (hasBlob && !isChecksum(seg[3])) {\n\t\tobj.branch = seg[3];\n\t\tif (seg.length > 4) {\n\t\t\tobj.filepath = seg.slice(4).join('/');\n\t\t}\n\t}\n\n\tvar blob = str.indexOf('blob');\n\tif (hasBlob && blob !== -1) {\n\t\tobj.blob = str.slice(blob + 5);\n\t}\n\n\tvar hasTree = seg[2] === 'tree';\n\tvar tree = str.indexOf('tree');\n\tif (hasTree && tree !== -1) {\n\t\tvar idx = tree + 5;\n\t\tvar branch = str.slice(idx);\n\t\tvar slash = branch.indexOf('/');\n\t\tif (slash !== -1) {\n\t\t\tbranch = branch.slice(0, slash);\n\t\t}\n\t\tobj.branch = branch;\n\t}\n\n\tobj.owner = owner(seg[0]);\n\tobj.name = name(seg[1]);\n\n\tif (seg.length > 1 && obj.owner && obj.name) {\n\t\tobj.repo = obj.owner + '/' + obj.name;\n\t} else {\n\t\tvar href = obj.href.split(':');\n\t\tif (href.length === 2 && obj.href.indexOf('//') === -1) {\n\t\t\tobj.repo = obj.repo || href[href.length - 1];\n\t\t\tvar repoSegments = obj.repo.split('/');\n\t\t\tobj.owner = repoSegments[0];\n\t\t\tobj.name = repoSegments[1];\n\n\t\t} else {\n\t\t\tvar match = obj.href.match(/\\/([^/]*)$/);\n\t\t\tobj.owner = match ? match[1] : null;\n\t\t\tobj.repo = null;\n\t\t}\n\n\t\tif (obj.repo && (!obj.owner || !obj.name)) {\n\t\t\tvar segs = obj.repo.split('/');\n\t\t\tif (segs.length === 2) {\n\t\t\t\tobj.owner = segs[0];\n\t\t\t\tobj.name = segs[1];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!obj.branch) {\n\t\tobj.branch = seg[2] || getBranch(obj.path, obj);\n\t\tif (seg.length > 3) {\n\t\t\tobj.filepath = seg.slice(3).join('/');\n\t\t}\n\t}\n\n\tobj.host = obj.host || 'github.com';\n\tobj.owner = obj.owner || null;\n\tobj.name = obj.name || null;\n\tobj.repository = obj.repo;\n\treturn obj;\n}\n\nmodule.exports = function parseGithubUrl(str) {\n\tif (!cache[str]) {\n\t\tcache[str] = parse(str);\n\t}\n\treturn cache[str];\n};\n","import {execSync} from 'node:child_process'\nimport {resolve} from 'node:path'\nimport type {PackageJSON} from '@sanity/parse-package-json'\nimport prettierConfig from '@sanity/prettier-config'\nimport {getLatestVersion} from 'get-latest-version'\nimport {outdent} from 'outdent'\nimport parseGithubUrl from 'parse-github-url'\nimport {format, type Config as PrettierConfig} from 'prettier'\nimport {isRecord} from '../../core/isRecord.ts'\nimport {defineTemplateOption} from '../../core/template/define.ts'\nimport {type PkgTemplate, type PkgTemplateFile} from '../../core/template/types.ts'\n\nconst RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\\/)?[a-z0-9-~][a-z0-9-._~]*$/i\n\nexport const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) => {\n const gitConfig = getGitUserConfig(cwd)\n\n return {\n options: [\n defineTemplateOption<{owner: string; name: string}>({\n name: 'repo',\n type: 'string',\n description: 'git url',\n validate: (v) => {\n if (!v) return true\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n return 'invalid git url'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) return null\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n throw new Error('invalid git url')\n }\n\n return {source: result.host, owner: result.owner, name: result.name}\n },\n }),\n defineTemplateOption({\n name: 'pkgName',\n type: 'string',\n description: 'package name',\n initial: (options) => options['repo']?.name || undefined,\n validate: (v) => {\n if (!v) return 'package name is required'\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n return 'invalid package name'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) {\n throw new Error('package name is required')\n }\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n throw new Error('invalid package name')\n }\n\n const [scope, name] = v.split('/')\n\n return {scope, name, fullName: v}\n },\n }),\n defineTemplateOption({\n name: 'description',\n type: 'string',\n description: 'package description',\n }),\n defineTemplateOption({\n name: 'authorName',\n type: 'string',\n description: 'package author name',\n initial: gitConfig.user,\n }),\n defineTemplateOption({\n name: 'authorEmail',\n type: 'string',\n description: 'package author email',\n initial: gitConfig.email,\n }),\n defineTemplateOption({\n name: 'license',\n type: 'string',\n description: 'package license',\n initial: 'MIT',\n validate: (v) => {\n if (!v) return 'license is required'\n\n return true\n },\n }),\n ],\n\n features: [\n {\n name: 'eslint',\n optional: true,\n initial: true,\n },\n {\n name: 'prettier',\n optional: true,\n initial: true,\n },\n {\n name: 'typescript',\n optional: true,\n initial: true,\n },\n ],\n\n async getFiles(options, features) {\n const {pkgName, repo} = options\n const {fullName: name} = pkgName\n\n const author =\n [options['authorName'], options['authorEmail'] && `<${options['authorEmail']}>`]\n .filter(Boolean)\n .join(' ') ?? undefined\n\n const pkgJson: PackageJSON & {\n prettier?: '@sanity/prettier-config'\n ['lint-staged']?: Record<string, string[]>\n } = {\n name,\n 'version': '0.0.0',\n 'description': options['description'] ?? undefined,\n 'keywords': [],\n 'homepage': undefined,\n 'bugs': undefined,\n 'repository': undefined,\n 'license': options['license'],\n author,\n 'sideEffects': false,\n 'type': 'module',\n 'exports': {\n '.': {\n source: features['typescript'] ? './src/index.ts' : './src/index.js',\n require: './dist/index.cjs',\n default: './dist/index.js',\n },\n './package.json': './package.json',\n },\n 'main': './dist/index.cjs',\n 'module': './dist/index.js',\n 'types': undefined,\n 'files': ['dist', 'src'],\n 'scripts': {\n build: 'pkg build --strict --clean --check',\n format: features['prettier'] ? 'prettier --write --cache --ignore-unknown .' : undefined,\n },\n 'lint-staged': features['prettier']\n ? {\n '*': ['prettier --write --cache --ignore-unknown'],\n }\n : undefined,\n 'browserslist': 'extends @sanity/browserslist-config',\n 'prettier': features['prettier'] ? '@sanity/prettier-config' : undefined,\n 'dependencies': {},\n 'devDependencies': {\n '@sanity/tsconfig': features['typescript'] ? '^1' : undefined,\n '@sanity/pkg-utils': '^9',\n '@sanity/prettier-config': features['prettier'] ? '^1' : undefined,\n '@typescript-eslint/eslint-plugin': undefined,\n '@typescript-eslint/parser': undefined,\n 'eslint': undefined,\n 'eslint-config-prettier': undefined,\n 'eslint-plugin-import': undefined,\n 'eslint-plugin-prettier': undefined,\n 'eslint-plugin-simple-import-sort': undefined,\n 'lint-staged': '^15',\n 'prettier': features['prettier'] ? '^3' : undefined,\n 'typescript': undefined,\n },\n 'engines': {\n node: '>=20.19 <22 || >=22.12',\n },\n }\n\n const files: PkgTemplateFile[] = []\n\n // .editorconfig\n files.push({\n name: '.editorconfig',\n contents: outdent`\n root = true\n\n [*]\n charset = utf-8\n indent_style = space\n indent_size = 2\n end_of_line = lf\n insert_final_newline = true\n trim_trailing_whitespace = true\n `,\n })\n\n // .gitignore\n files.push({\n name: '.gitignore',\n contents: outdent`\n *.local\n *.log\n *.tgz\n\n .DS_Store\n dist\n etc\n node_modules\n `,\n })\n\n if (features['prettier']) {\n files.push({\n name: '.prettierignore',\n contents: outdent`\n dist\n pnpm-lock.yaml\n `,\n })\n }\n\n if (repo) {\n pkgJson.repository = {\n type: 'git',\n url: `git+ssh://git@${repo.source}/${repo.owner}/${repo.name}.git`,\n }\n pkgJson.bugs = {\n url: `https://${repo.source}/${repo.owner}/${repo.name}/issues`,\n }\n pkgJson.homepage = `https://${repo.source}/${repo.owner}/${repo.name}#readme`\n }\n\n if (features['typescript']) {\n pkgJson.types = './dist/index.d.ts'\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n ['ts:check']: 'tsc --noEmit',\n }\n\n const devDependencies = pkgJson.devDependencies\n\n if (isRecord(devDependencies)) {\n devDependencies['typescript'] = '^5.9'\n }\n }\n\n if (features['eslint']) {\n const eslintConfig: any = {\n root: true,\n env: {\n browser: true,\n es6: true,\n node: true,\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n ].filter(Boolean),\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n },\n plugins: [\n 'import',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n 'no-console': 'error',\n 'no-shadow': 'error',\n 'no-warning-comments': ['warn', {location: 'start', terms: ['todo', 'fixme']}],\n 'quote-props': ['warn', 'consistent-as-needed'],\n 'simple-import-sort/exports': 'warn',\n 'simple-import-sort/imports': 'warn',\n 'strict': ['warn', 'global'],\n },\n }\n\n files.push({\n name: '.eslintignore',\n contents: outdent`\n dist\n `,\n })\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n lint: features['typescript']\n ? 'eslint . --ext .cjs,.js,.ts,.tsx'\n : 'eslint . --ext .cjs,.js',\n }\n\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n 'eslint': '^8',\n 'eslint-config-prettier': features['prettier'] ? '^9' : undefined,\n 'eslint-plugin-import': '^2',\n 'eslint-plugin-prettier': features['prettier'] ? '^5' : undefined,\n 'eslint-plugin-simple-import-sort': '^12',\n }\n\n if (features['typescript']) {\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n '@typescript-eslint/eslint-plugin': '^7',\n '@typescript-eslint/parser': '^7',\n }\n\n const eslintConfigOverride: any = {\n files: ['**/*.ts', '**/*.tsx'],\n parser: '@typescript-eslint/parser',\n parserOptions: {\n project: ['./tsconfig.json'],\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n 'plugin:@typescript-eslint/eslint-recommended',\n 'plugin:@typescript-eslint/recommended',\n ].filter(Boolean),\n plugins: [\n 'import',\n '@typescript-eslint',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n '@typescript-eslint/explicit-module-boundary-types': 'error',\n '@typescript-eslint/interface-name-prefix': 'off',\n '@typescript-eslint/member-delimiter-style': 'off',\n '@typescript-eslint/no-empty-interface': 'off',\n },\n }\n\n eslintConfig.overrides = [eslintConfigOverride]\n }\n\n files.push({\n name: '.eslintrc.cjs',\n contents: await prettierFormat(\n resolve(packagePath, '.eslintrc.cjs'),\n outdent`\n 'use strict'\n\n /** @type import('eslint').Linter.Config */\n module.exports = ${JSON.stringify(eslintConfig, null, 2)}\n `,\n prettierConfig,\n ),\n })\n }\n\n if (features['typescript']) {\n files.push({\n name: 'tsconfig.settings.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.settings.json'),\n outdent`\n {\n \"extends\": \"@sanity/tsconfig/strictest\",\n \"compilerOptions\": {\n \"rootDir\": \".\",\n \"outDir\": \"./dist\"\n }\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.dist.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.dist.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./src\"],\n \"exclude\": [\"./src/**/*.test.ts\"]\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./**/*.cjs\", \"./**/*.ts\", \"./**/*.tsx\"],\n \"exclude\": [\"./node_modules\"]\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // source file\n if (features['typescript']) {\n files.push({\n name: 'package.config.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.ts'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n // https://github.com/sanity-io/pkg-utils#configuration\n export default defineConfig({\n // the path to the tsconfig file for distributed builds\n tsconfig: 'tsconfig.dist.json',\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.ts'),\n outdent`\n /** @public */\n export function main(): void {\n //\n }\n `,\n prettierConfig,\n ),\n })\n } else {\n files.push({\n name: 'package.config.js',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.js'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n export default defineConfig({\n extract: {\n rules: {\n // do not require internal members to be prefixed with \\`_\\`\n 'ae-internal-missing-underscore': 'off',\n },\n },\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.js',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.js'),\n outdent`\n /** @public */\n export function main() {\n //\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // Resolve latest dependencies\n try {\n pkgJson.dependencies = await resolveLatestDeps(pkgJson.dependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n // Resolve latest devDependencies\n try {\n pkgJson.devDependencies = await resolveLatestDeps(pkgJson.devDependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n files.push({\n name: 'package.json',\n contents: await prettierFormat(\n resolve(packagePath, 'package.json'),\n JSON.stringify(pkgJson, null, 2),\n prettierConfig,\n ),\n })\n\n return files\n },\n }\n}\n\nfunction prettierFormat(\n filepath: string,\n input: string,\n prettierOptions: PrettierConfig | undefined,\n) {\n return format(input, {...prettierOptions, plugins: [], filepath})\n}\n\nasync function resolveLatestDeps(deps: Record<string, string | undefined>) {\n const depsEntries = Object.entries(deps)\n const latestDeps: Record<string, string> = {}\n\n for (const entry of depsEntries) {\n const [name, version] = entry\n\n if (version) {\n const latestVersion = await getLatestVersion(name, {range: version})\n\n latestDeps[name] = latestVersion ? `^${latestVersion}` : version\n }\n }\n\n return latestDeps\n}\n\nfunction getGitUserConfig(cwd: string): {user: string | undefined; email: string | undefined} {\n let user: string | undefined\n let email: string | undefined\n\n try {\n user = execSync('git config user.name', {encoding: 'utf8', cwd}).trim() || undefined\n email = execSync('git config user.email', {encoding: 'utf8', cwd}).trim() || undefined\n } catch {\n /* ignore */\n }\n\n return {user, email}\n}\n","import {lstat} from 'node:fs/promises'\nimport {resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport {createFromTemplate} from './core/template/index.ts'\nimport {fileExists} from './fileExists.ts'\nimport {isEmptyDirectory} from './isEmptyDirectory.ts'\nimport {createLogger} from './logger.ts'\nimport {defaultTemplate} from './templates/default/template.ts'\n\n/** @public */\nexport async function init(options: {cwd: string; path: string}): Promise<void> {\n if (!options.cwd) {\n throw new Error('Missing required option: cwd')\n }\n\n if (!options.path) {\n throw new Error('Missing required option: path')\n }\n\n const logger = createLogger()\n\n const packagePath = resolve(options.cwd, options.path)\n\n await ensurePackagePath(packagePath)\n\n await createFromTemplate({\n cwd: options.cwd,\n logger,\n template: defaultTemplate,\n packagePath,\n })\n}\n\nasync function ensurePackagePath(packagePath: string): Promise<void> {\n const exists = fileExists(packagePath)\n\n if (!exists) {\n await mkdirp(packagePath)\n\n return\n }\n\n const dir = (await lstat(packagePath)).isDirectory()\n\n if (!dir) {\n throw new Error('the package path is a file, not a directory')\n }\n\n const empty = await isEmptyDirectory(packagePath)\n\n if (!empty) {\n throw new Error('the package directory is not empty')\n }\n}\n","import {init} from '../node/init.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function initAction(options: {path: string}): Promise<void> {\n try {\n await init({\n cwd: process.cwd(),\n path: options.path,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"x_google_ignoreList":[3,4,5],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,eAAe,EACnB,QAAQ,OACV;;AAGA,eAAsB,mBAAmB,SAKvB;CAChB,IAAM,EAAC,KAAK,QAAQ,aAAa,UAAU,uBAAsB,SAE3D,WACJ,OAAO,sBAAuB,aAC1B,MAAM,mBAAmB;EAAC;EAAK;EAAQ;CAAW,CAAC,IACnD;CAEN,OAAO,IAAI,yBAAyB,SAAS,KAAK,WAAW,CAAC;CAE9D,IAAM,kBAA0C,CAAC;CAEjD,KAAK,IAAM,kBAAkB,SAAS,SAAS;EAC7C,IAAM,mBAAmB,eAAe,UAElC,MAAM,MAAM,QAChB;GACE,MAAM,aAAa,eAAe;GAClC,MAAM,eAAe;GACrB,SAAS,eAAe;GACxB,UAAU,oBAAoB,SAAS,iBAAiB,IAAI,IAAI,KAAA;GAChE,SACE,OAAO,eAAe,WAAY,aAC9B,eAAe,QAAQ,eAAe,IACtC,eAAe;EACvB,GACA,EAAC,gBAAgB,QAAQ,KAAK,CAAC,EAAC,CAClC;EAEA,gBAAgB,eAAe,QAAQ,eAAe,QAClD,eAAe,MAAM,IAAI,eAAe,KAAK,IAC7C,IAAI,eAAe;CACzB;CAEA,IAAM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AAQ,SAAS,yBAAyB;GAAC,UAAU;GAAQ;EAAG,CAAC,CAAC,CAAC,KAAK,KAAK,KAAA;CAC/E,QAAQ,CAER;CAEA,OAAO;EAAC;EAAM;CAAK;AACrB;;AC7hBA,eAAsB,KAAK,SAAqD;CAC9E,IAAI,CAAC,QAAQ,KACX,MAAU,MAAM,8BAA8B;CAGhD,IAAI,CAAC,QAAQ,MACX,MAAU,MAAM,+BAA+B;CAGjD,IAAM,SAAS,aAAa,GAEtB,cAAc,QAAQ,QAAQ,KAAK,QAAQ,IAAI;CAIrD,AAFA,MAAM,kBAAkB,WAAW,GAEnC,MAAM,mBAAmB;EACvB,KAAK,QAAQ;EACb;EACA,UAAU;EACV;CACF,CAAC;AACH;AAEA,eAAe,kBAAkB,aAAoC;CAGnE,IAAI,CAFW,WAAW,WAEhB,GAAG;EACX,MAAM,OAAO,WAAW;EAExB;CACF;CAIA,IAAI,EAFS,MAAM,MAAM,WAAW,EAAA,CAAG,YAEhC,GACL,MAAU,MAAM,6CAA6C;CAK/D,IAAI,CAAC,MAFe,iBAAiB,WAAW,GAG9C,MAAU,MAAM,oCAAoC;AAExD;AClDA,eAAsB,WAAW,SAAwC;CACvE,IAAI;EACF,MAAM,KAAK;GACT,KAAK,QAAQ,IAAI;GACjB,MAAM,QAAQ;EAChB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveTsdownConfig-2OdGF-dM.js","names":[],"sources":["../src/node/tasks/tsdown/resolveTsdownBuilds.ts","../src/node/tasks/tsdown/composeExports.ts","../src/node/tasks/tsdown/resolveTsdownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgFormat, PkgRuntime} from '../../core/config/types.ts'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {fileEnding} from '../../core/pkg/pkgExt.ts'\n\n/**\n * One entry of a tsdown build.\n * @internal\n */\nexport interface TsdownBuildEntry {\n /**\n * The entry alias handed to tsdown: the output path relative to `dist` without the\n * extension (e.g. `index`, `index.browser`, `sub/feature`), so the emitted filenames match\n * the hand-written `exports` targets exactly.\n */\n alias: string\n source: string\n /** The hand-written export subpath this entry backs (`undefined` for `bundles`). */\n exportPath?: string\n /** The formats the hand-written exports declare for this entry. */\n formats: PkgFormat[]\n}\n\n/**\n * One tsdown `build()` call of the waterfall. Builds run serially — variants and bundles\n * first, the canonical build last, so its exports generation and publint see every emitted\n * file on disk.\n * @internal\n */\nexport interface TsdownBuild {\n /** Stable identifier, e.g. `neutral`, `browser`, `node`, `bundles`. */\n key: string\n runtime: PkgRuntime\n /** The canonical build owns `dist` conventions: exports generation runs here. */\n canonical: boolean\n entries: TsdownBuildEntry[]\n}\n\n/**\n * Collapses the hand-written `exports` map (+ `bundles`) into the per-platform tsdown build\n * waterfall: one canonical build for the package's default runtime, plus a variant build per\n * `browser`/`node` exports condition, plus builds for `bundles` (which must not participate\n * in exports generation).\n * @internal\n */\nexport function resolveTsdownBuilds(ctx: BuildContext): TsdownBuild[] {\n const {config, cwd, distPath, logger} = ctx\n\n const entryAlias = (output: string): string => {\n const alias = path\n .relative(distPath, path.resolve(cwd, output))\n .replaceAll('\\\\', '/')\n .replace(fileEnding, '')\n if (alias.startsWith('..')) {\n throw new Error(`output file is outside the \\`dist\\` folder: ${output}`)\n }\n return alias\n }\n\n interface EntryDraft {\n alias: string\n source: string\n exportPath?: string | undefined\n formats: Set<PkgFormat>\n }\n\n const draftsByBuild = new Map<string, Map<string, EntryDraft>>()\n const runtimeByBuild = new Map<string, PkgRuntime>()\n\n const addEntry = (\n buildKey: string,\n runtime: PkgRuntime,\n entry: {\n source: string\n exportPath?: string | undefined\n import?: string | undefined\n require?: string | undefined\n },\n ) => {\n runtimeByBuild.set(buildKey, runtime)\n const {source, exportPath} = entry\n const aliases = new Set<string>()\n const formats = new Set<PkgFormat>()\n if (entry.import) {\n aliases.add(entryAlias(entry.import))\n formats.add('esm')\n }\n if (entry.require) {\n aliases.add(entryAlias(entry.require))\n formats.add('commonjs')\n }\n if (aliases.size === 0) return\n if (aliases.size > 1) {\n throw new Error(\n `the \\`import\\` and \\`require\\` targets of ${\n exportPath ? `exports[\"${exportPath}\"]` : `the bundle for ${source}`\n } must share a basename (e.g. \\`./dist/index.js\\` + \\`./dist/index.cjs\\`), ` +\n `got: ${entry.import} and ${entry.require}`,\n )\n }\n const [alias] = aliases\n let drafts = draftsByBuild.get(buildKey)\n if (!drafts) {\n drafts = new Map()\n draftsByBuild.set(buildKey, drafts)\n }\n const existing = drafts.get(alias!)\n if (existing) {\n if (existing.source !== source) {\n throw new Error(\n `conflicting sources for the output alias \"${alias}\": ${existing.source} and ${source}`,\n )\n }\n for (const format of formats) existing.formats.add(format)\n return\n }\n drafts.set(alias!, {alias: alias!, source, exportPath, formats})\n }\n\n const exports = Object.entries(ctx.exports || {})\n\n let hasRuntimeConditions = false\n\n for (const [exportPath, exp] of exports) {\n addEntry('canonical', ctx.runtime, {\n source: exp.source,\n exportPath,\n import: exp.import,\n require: exp.require,\n })\n\n if (exp.browser?.import || exp.browser?.require) {\n hasRuntimeConditions = true\n addEntry('browser', 'browser', {\n source: exp.browser.source || exp.source,\n exportPath,\n import: exp.browser.import,\n require: exp.browser.require,\n })\n }\n\n if (exp.node?.import || exp.node?.require) {\n hasRuntimeConditions = true\n addEntry('node', 'node', {\n source: exp.node.source || exp.source,\n exportPath,\n import: exp.node.import,\n require: exp.node.require,\n })\n }\n }\n\n // `bundles` are extra entrypoints that are deliberately not in the exports map (CLI workers\n // and similar), so they build separately from the canonical build — exports generation\n // derives subpaths from every entry of its build, and bundles must never become export\n // subpaths of their own.\n for (const bundle of config?.bundles || []) {\n const runtime = bundle.runtime || ctx.runtime\n addEntry(runtime === ctx.runtime ? 'bundles' : `bundles:${runtime}`, runtime, {\n source: bundle.source,\n import: bundle.import,\n require: bundle.require,\n })\n }\n\n if (hasRuntimeConditions) {\n logger.warn(\n [\n 'The `exports[].browser.source` / `exports[].node.source` pattern is not recommended: every',\n 'runtime condition adds a full extra build (complexity and build time). Consider instead:',\n ' 1. separate npm packages per platform/runtime, selected through export conditions that',\n ' pick the right package per environment,',\n ' 2. when possible, a single neutral build using JS that works in both runtimes without',\n ' special-casing (e.g. `new URL` over `require(\"url\")`, WebCrypto over',\n ' `require(\"crypto\")`), or',\n ' 3. using `tsdown` + `@sanity/tsdown-config` directly, exporting an array from',\n ' `tsdown.config.ts` with one config per `platform` — the fully supported path for',\n ' this level of customization.',\n ].join('\\n'),\n )\n }\n\n const builds: TsdownBuild[] = []\n\n const toBuild = (key: string, runtime: PkgRuntime, canonical: boolean): TsdownBuild | null => {\n const drafts = draftsByBuild.get(key)\n if (!drafts || drafts.size === 0) return null\n return {\n key,\n runtime,\n canonical,\n entries: Array.from(drafts.values(), (draft) => ({\n alias: draft.alias,\n source: draft.source,\n ...(draft.exportPath === undefined ? {} : {exportPath: draft.exportPath}),\n formats: Array.from(draft.formats),\n })),\n }\n }\n\n // Variants and bundles run first; the canonical build runs last so its exports generation\n // and publint see the other builds' files on disk. Each build's runtime was recorded when\n // its entries were added, so nothing is re-derived from the build key (a bundle with\n // `runtime: '*'` in a `runtime: 'node'` package must build for `'*'`/neutral).\n for (const key of draftsByBuild.keys()) {\n if (key === 'canonical') continue\n const build = toBuild(key, runtimeByBuild.get(key) ?? ctx.runtime, false)\n if (build) builds.push(build)\n }\n\n const canonical = toBuild('canonical', ctx.runtime, true)\n if (canonical) builds.push(canonical)\n\n return builds\n}\n","import type {PkgExport} from '../../core/config/types.ts'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {isRecord} from '../../core/isRecord.ts'\nimport type {TsdownBuild} from './resolveTsdownBuilds.ts'\n\ntype ExportsMap = Record<string, unknown>\ninterface ComposeContext {\n isPublish: boolean\n}\n\n/**\n * The pkg-utils opinion layer over tsdown's generated `exports` map, composed into\n * `exports.customExports` of the canonical build (the same composition hook\n * `@sanity/vanilla-extract-tsdown-plugin` uses for its conditional CSS export).\n *\n * tsdown generates subpaths from the entry aliases with `source`/`import`/`require` conditions\n * (`devExports: 'source'`) and a `source`-less `publishConfig.exports` — already the Sanity\n * convention. This composer reconciles the generated map with the hand-written one, which\n * remains the input:\n *\n * - generated keys are remapped to the hand-written subpaths (entry aliases are derived from\n * the output paths, which don't have to match the subpath names),\n * - the hand-written `types`, `browser`, `node`, `development` and `monorepo` conditions are\n * re-inserted (tsdown's generator cannot express them; the `browser`/`node` files are built\n * by the variant builds of the waterfall) — with `source`-like conditions stripped from the\n * publish variant,\n * - hand-written custom conditions (`react-server`, `worker`, …) are carried over as authored,\n * placed before the `import`/`require`/`default` fallbacks so they can match,\n * - a trailing `default` condition is kept on dual-format entries (tsdown emits bare\n * `import`/`require` pairs; the Sanity convention always ends with `default`),\n * - hand-written subpaths that aren't build entries (`.css`/`.json` exports, `svelte`\n * entries) are carried over untouched, and\n * - the hand-written key order is preserved.\n * @internal\n */\nexport function createExportsComposer(\n ctx: BuildContext,\n build: TsdownBuild,\n): (exportsMap: ExportsMap, context: ComposeContext) => ExportsMap {\n const {pkg} = ctx\n const type = pkg.type === 'module' ? 'module' : 'commonjs'\n\n // alias -> hand-written subpath, e.g. `index` -> `.`, `sub/feature` -> `./feature`\n const aliasToExportPath = new Map<string, string>()\n for (const entry of build.entries) {\n if (entry.exportPath !== undefined) {\n aliasToExportPath.set(entry.alias, entry.exportPath)\n }\n }\n\n return (exportsMap, context) => {\n const {isPublish} = context\n\n // 1. Remap the generated keys (`.` for the `index` alias, `./<alias>` otherwise) back to\n // the hand-written subpaths.\n const remapped: ExportsMap = {}\n for (const [key, value] of Object.entries(exportsMap)) {\n const alias = key === '.' ? 'index' : key.startsWith('./') ? key.slice(2) : key\n const exportPath = aliasToExportPath.get(alias) ?? key\n remapped[exportPath] = value\n }\n\n // 2. Reconcile each generated entry with its hand-written counterpart.\n const result: ExportsMap = {}\n const handwritten = ctx.exports || {}\n\n const reconcile = (exportPath: string, value: unknown): unknown => {\n const exp = handwritten[exportPath]\n if (!exp) return value\n return reconcileEntry(exp, value, {isPublish, type})\n }\n\n // 3. Follow the hand-written key order; append generated extras (e.g. `./package.json`\n // when it wasn't hand-written) at the end.\n const handwrittenRaw: Record<string, unknown> = pkg.exports || {}\n for (const exportPath of Object.keys(handwrittenRaw)) {\n if (exportPath in remapped) {\n result[exportPath] = reconcile(exportPath, remapped[exportPath])\n } else {\n // Hand-written subpaths that aren't build entries (`.css`/`.json` exports, `svelte`\n // entries) pass through untouched.\n result[exportPath] = handwrittenRaw[exportPath]\n }\n }\n for (const [exportPath, value] of Object.entries(remapped)) {\n if (exportPath in result) continue\n result[exportPath] = reconcile(exportPath, value)\n }\n\n return result\n }\n}\n\n/**\n * Rebuilds a generated subpath entry in the Sanity condition order, re-inserting the\n * hand-written conditions tsdown's generator cannot express.\n */\nfunction reconcileEntry(\n exp: PkgExport,\n generated: unknown,\n options: {isPublish: boolean; type: 'commonjs' | 'module'},\n): unknown {\n const {isPublish, type} = options\n\n // tsdown's publish variant of a single-format entry is a plain string\n const gen: Record<string, unknown> | undefined =\n typeof generated === 'string'\n ? {default: generated}\n : isRecord(generated)\n ? generated\n : undefined\n if (!gen) return generated\n\n const browser =\n exp.browser && (exp.browser.import || exp.browser.require)\n ? pickConditions(exp.browser, isPublish)\n : undefined\n const node =\n exp.node && (exp.node.import || exp.node.require)\n ? pickConditions(exp.node, isPublish)\n : undefined\n const custom = pickCustomConditions(exp)\n\n // A plain-string publish entry without hand-written conditions to re-insert stays a plain\n // string (e.g. `publishConfig.exports[\".\"] = \"./dist/index.js\"`)\n if (typeof generated === 'string' && !exp.types && !browser && !node && custom.length === 0) {\n return generated\n }\n\n const next: Record<string, unknown> = {}\n\n // `source`-like conditions resolve at development time and are stripped from the publish\n // variant (tsdown already does this for `source`; `development`/`monorepo` follow)\n if (!isPublish) {\n if (typeof gen['source'] === 'string') next['source'] = gen['source']\n else if (exp.source) next['source'] = exp.source\n if (exp.development) next['development'] = exp.development\n if (exp.monorepo) next['monorepo'] = exp.monorepo\n }\n\n if (exp.types) next['types'] = exp.types\n if (browser) next['browser'] = browser\n if (node) next['node'] = node\n\n // Hand-written custom conditions (`react-server`, `worker`, …) aren't built, but they are\n // the author's: carry them over as authored, before the format fallbacks so they can match.\n for (const [condition, target] of custom) {\n next[condition] = target\n }\n\n if (typeof gen['import'] === 'string' && typeof gen['require'] === 'string') {\n next['import'] = gen['import']\n next['require'] = gen['require']\n // tsdown emits bare `import`/`require` pairs; the Sanity convention ends with `default`\n next['default'] = type === 'module' ? gen['import'] : gen['require']\n } else {\n // Single-format entries keep the generated shape (`{source, default}` in development)\n for (const [condition, target] of Object.entries(gen)) {\n if (condition in next || condition === 'source') continue\n next[condition] = target\n }\n }\n\n return next\n}\n\n/** The hand-written `browser`/`node` condition object, minus `source` for the publish map. */\nfunction pickConditions(\n conditions: {source?: string; import?: string; require?: string},\n isPublish: boolean,\n): Record<string, string> {\n const next: Record<string, string> = {}\n if (!isPublish && conditions.source) next['source'] = conditions.source\n if (conditions.import) next['import'] = conditions.import\n if (conditions.require) next['require'] = conditions.require\n return next\n}\n\n/** The conditions the pipeline owns (or re-inserts itself) on a build entry. */\nconst managedConditions = new Set([\n 'source',\n 'development',\n 'monorepo',\n 'types',\n 'browser',\n 'node',\n 'import',\n 'require',\n 'default',\n])\n\n/**\n * Hand-written conditions the pipeline knows nothing about (`react-server`, `worker`,\n * `edge-light`, …), in authored order. `parseExports` spreads the raw entry, so they survive\n * on the parsed `PkgExport` beyond its typed fields.\n */\nfunction pickCustomConditions(exp: PkgExport): [string, unknown][] {\n return Object.entries(exp).filter(\n ([condition, target]) =>\n !managedConditions.has(condition) && !condition.startsWith('_') && target !== undefined,\n )\n}\n","import path from 'node:path'\nimport {defineConfig} from '@sanity/tsdown-config'\nimport {mergeConfig, type InlineConfig, type UserConfig} from 'tsdown'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {pkgExtMap} from '../../core/pkg/pkgExt.ts'\nimport {createExportsComposer} from './composeExports.ts'\nimport type {TsdownBuild} from './resolveTsdownBuilds.ts'\n\nconst RE_TS_SOURCE = /\\.[cm]?tsx?$/\n\n/**\n * Composes the tsdown config for one build of the waterfall: `@sanity/tsdown-config`'s\n * `defineConfig()` provides the shared Sanity base, and the pkg-utils opinions (browserslist\n * targets, `PKG_*` defines, exports reconciliation, dts selection) layer over it with\n * tsdown's `mergeConfig`.\n *\n * pkg-utils owns its own experience: the returned config carries `config: false`, so tsdown\n * never loads `tsdown.config.*` files — `package.config.ts` is the sole config source — and\n * `logLevel: 'warn'` keeps tsdown's info chatter out of pkg-utils' own output.\n * @internal\n */\nexport async function resolveTsdownConfig(\n ctx: BuildContext,\n build: TsdownBuild,\n options: {\n /**\n * Whether this build may clean: only the first build of the waterfall cleans (so later\n * builds can't wipe earlier output), and `--no-clean` turns it off for the whole run.\n */\n clean: boolean\n watch?: boolean\n },\n): Promise<InlineConfig> {\n const {config, cwd, distPath, pkg} = ctx\n\n const reactCompiler = config?.reactCompiler\n if (typeof reactCompiler === 'object' && reactCompiler.reactServer === true) {\n throw new Error(\n [\n 'package.config.ts: `reactCompiler.reactServer` is not supported by `pkg build` — the',\n 'dual React Server Components build needs one tsdown run driving multiple configs.',\n 'Use `tsdown` + `@sanity/tsdown-config` directly instead: export the config from',\n '`tsdown.config.ts` and build with `tsdown`.',\n ].join('\\n'),\n )\n }\n\n const entry: Record<string, string> = {}\n for (const buildEntry of build.entries) {\n entry[buildEntry.alias] = buildEntry.source\n }\n\n // tsdown's `format` applies to the whole build (and its exports generation composes the\n // dual `import`/`require` map from both formats' chunks of one build), so the entries'\n // formats union: every entry is emitted in every format of the build. Mixed per-entry\n // coverage gets a heads-up — the extra files are emitted, and local exports generation\n // will declare them.\n const formats = new Set(build.entries.flatMap((buildEntry) => buildEntry.formats))\n if (formats.size > 1) {\n const partial = build.entries.filter((buildEntry) => buildEntry.formats.length < formats.size)\n if (partial.length) {\n const names = partial\n .map((buildEntry) =>\n buildEntry.exportPath ? `exports[\"${buildEntry.exportPath}\"]` : buildEntry.source,\n )\n .join(', ')\n ctx.logger.warn(\n `${names} declare${partial.length === 1 ? 's' : ''} fewer formats than the rest of the package. tsdown emits every format of a build for every entry, so the missing format is built anyway (and local exports generation will declare it). Declare both \\`import\\` and \\`require\\` targets for every subpath — or for none — to keep the exports map unambiguous.`,\n )\n }\n }\n const format = [\n ...(formats.has('esm') ? ['esm' as const] : []),\n ...(formats.has('commonjs') ? ['cjs' as const] : []),\n ]\n\n const platform =\n build.runtime === 'node' ? 'node' : build.runtime === 'browser' ? 'browser' : 'neutral'\n\n // Build-time constants: `PKG_VERSION` reads the environment override first, like v11.\n // pkg-utils' own build skips it so the replacement logic in this very file survives its own\n // bundling. (`PKG_FORMAT`, `PKG_RUNTIME` and `PKG_FILE_PATH` were removed in v12 — see\n // MIGRATE.md for the `package.json#imports` / `import.meta.url` replacements.)\n const define: Record<string, string> = {}\n if (pkg.name !== '@sanity/pkg-utils') {\n define['process.env.PKG_VERSION'] = JSON.stringify(process.env['PKG_VERSION'] || pkg.version)\n }\n for (const [key, value] of Object.entries(config?.define || {})) {\n define[key] = JSON.stringify(value)\n }\n\n // Types are generated with tsdown (rolldown-plugin-dts). `@typescript/native-preview` in\n // devDependencies auto-enables tsgo, like v11; an explicit `dts.tsgo` wins. Only the object\n // form spreads: when the `legacyChecks` migration errors are skipped\n // (`NODE_ENV=production` / `legacyChecks: false`), a leftover v11 string like\n // `dts: 'rolldown'` must degrade to the default behavior (which is what it meant) instead\n // of spreading into numeric character keys.\n const hasTsSources = build.entries.some((buildEntry) => RE_TS_SOURCE.test(buildEntry.source))\n const dtsPassthrough = typeof config?.dts === 'object' ? config.dts : undefined\n const dts =\n hasTsSources && config?.dts !== false\n ? {\n ...(typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies\n ? {tsgo: true}\n : {}),\n // Always create dts from scratch, don't reuse contexts from previous builds\n newContext: true,\n ...dtsPassthrough,\n ...(ctx.emitDeclarationOnly ? {emitDtsOnly: true} : {}),\n }\n : false\n\n // Exports generation runs on the canonical build only, with `devExports: 'source'` — the\n // hand-written Sanity convention (`source` conditions in `exports`, a `source`-less\n // `publishConfig.exports`) — and the pkg-utils composer reconciling the generated map with\n // the hand-written one. tsdown's own `enabled: 'local-only'` default applies: the map is\n // written during local builds and left alone in CI. A types-only build never rewrites\n // `package.json`, and neither do watch builds (a rewrite would re-trigger the\n // `package.json` watcher).\n const exports: UserConfig['exports'] =\n build.canonical && !ctx.emitDeclarationOnly && !options.watch\n ? {\n devExports: 'source',\n customExports: createExportsComposer(ctx, build),\n // Keep the hand-written legacy fields (`main`/`module`) in sync instead of deleting\n // them; packages without them don't gain them\n ...(pkg.main || pkg.module ? {legacy: true} : {}),\n }\n : false\n\n const base = await defineConfig({\n cwd,\n tsconfig: ctx.ts.configPath,\n platform,\n format,\n entry,\n // POSIX separators: on Windows `path.relative` yields backslashes, which would leak into\n // generated `package.json` export targets (e.g. the conditional vanilla-extract export)\n outDir: path.relative(cwd, distPath).replaceAll('\\\\', '/') || '.',\n target: ctx.target[build.runtime],\n define,\n sourcemap: config?.sourcemap,\n // tsdown owns cleaning: the first build of the waterfall carries the effective `clean`\n // (the config passthrough, or tsdown's default `true`), every later build gets `false`.\n // A types-only build never cleans, so it can't delete JS output.\n clean: options.clean && !ctx.emitDeclarationOnly ? config?.clean : false,\n dts,\n deps: ctx.deps,\n exports,\n reactCompiler: config?.reactCompiler,\n styledComponents: config?.styledComponents,\n vanillaExtract: config?.vanillaExtract,\n })\n\n // The hand-written exports define the emitted extensions (`.js`/`.mjs`/`.cjs` per\n // `package.json#type`, enforced by `validateExports`), so the extensions are pinned\n // explicitly instead of relying on tsdown's defaults (whose `fixedExtension` kicks in for\n // `platform: 'node'` and would emit `.mjs` for `type: module` packages).\n const extMap = pkgExtMap[pkg.type === 'module' ? 'module' : 'commonjs']\n const outExtensions: UserConfig['outExtensions'] = ({format: outputFormat}) => ({\n js: outputFormat === 'cjs' ? extMap.commonjs : extMap.esm,\n })\n\n const merged = mergeConfig(base, {\n outExtensions,\n // publint runs during `pkg check` (via its node API), not inside the build\n publint: false,\n // the per-file size report logs through tsdown's info channel; pkg-utils prints its own\n report: false,\n ...(config?.minify === true ? {minify: true} : {}),\n ...(config?.plugins === undefined ? {} : {plugins: config.plugins}),\n })\n\n return {\n ...merged,\n config: false,\n logLevel: 'warn',\n ...(options.watch ? {watch: true} : {}),\n }\n}\n"],"mappings":";;;;;;;;;;;;AA6CA,SAAgB,oBAAoB,KAAkC;CACpE,IAAM,EAAC,QAAQ,KAAK,UAAU,WAAU,KAElC,cAAc,WAA2B;EAC7C,IAAM,QAAQ,KACX,SAAS,UAAU,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC,CAC7C,WAAW,MAAM,GAAG,CAAC,CACrB,QAAQ,YAAY,EAAE;EACzB,IAAI,MAAM,WAAW,IAAI,GACvB,MAAU,MAAM,+CAA+C,QAAQ;EAEzE,OAAO;CACT,GASM,gCAAgB,IAAI,IAAqC,GACzD,iCAAiB,IAAI,IAAwB,GAE7C,YACJ,UACA,SACA,UAMG;EACH,eAAe,IAAI,UAAU,OAAO;EACpC,IAAM,EAAC,QAAQ,eAAc,OACvB,0BAAU,IAAI,IAAY,GAC1B,0BAAU,IAAI,IAAe;EASnC,IARI,MAAM,WACR,QAAQ,IAAI,WAAW,MAAM,MAAM,CAAC,GACpC,QAAQ,IAAI,KAAK,IAEf,MAAM,YACR,QAAQ,IAAI,WAAW,MAAM,OAAO,CAAC,GACrC,QAAQ,IAAI,UAAU,IAEpB,QAAQ,SAAS,GAAG;EACxB,IAAI,QAAQ,OAAO,GACjB,MAAU,MACR,6CACE,aAAa,YAAY,WAAW,MAAM,kBAAkB,SAC7D,iFACS,MAAM,OAAO,OAAO,MAAM,SACtC;EAEF,IAAM,CAAC,SAAS,SACZ,SAAS,cAAc,IAAI,QAAQ;EACvC,AAAK,WACH,yBAAS,IAAI,IAAI,GACjB,cAAc,IAAI,UAAU,MAAM;EAEpC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