@sanity/pkg-utils 12.3.4 → 13.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.
- package/MIGRATE.md +1 -1
- package/README.md +2 -2
- package/dist/{buildAction-BPF82HZg.js → buildAction-BbznO37s.js} +5 -5
- package/dist/buildAction-BbznO37s.js.map +1 -0
- package/dist/{checkAction-DWSqzrZd.js → checkAction-hzCSdRlj.js} +4 -4
- package/dist/{checkAction-DWSqzrZd.js.map → checkAction-hzCSdRlj.js.map} +1 -1
- package/dist/cli.js +5 -5
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/initAction-CmOO8eod.js.map +1 -1
- package/dist/{resolveBuildContext-vVTRkIDl.js → resolveBuildContext-Cp6bOuom.js} +16 -9
- package/dist/resolveBuildContext-Cp6bOuom.js.map +1 -0
- package/dist/{resolveTsdownConfig-C6jUZqvp.js → resolveTsdownConfig-QaIhKS-s.js} +14 -22
- package/dist/{resolveTsdownConfig-C6jUZqvp.js.map → resolveTsdownConfig-QaIhKS-s.js.map} +1 -1
- package/dist/{watchAction-IMdjLKl4.js → watchAction-fgVjJMTR.js} +23 -18
- package/dist/watchAction-fgVjJMTR.js.map +1 -0
- package/dist/{watchConfigFiles-AGBDblwf.js → watchConfigFiles-Bt03CSXT.js} +5 -11
- package/dist/watchConfigFiles-Bt03CSXT.js.map +1 -0
- package/dist/{writeBundleCssExports-BO8zfc4U.js → writeBundleCssExports-DXkUB_7e.js} +2 -2
- package/dist/{writeBundleCssExports-BO8zfc4U.js.map → writeBundleCssExports-DXkUB_7e.js.map} +1 -1
- package/package.json +15 -14
- package/dist/buildAction-BPF82HZg.js.map +0 -1
- package/dist/resolveBuildContext-vVTRkIDl.js.map +0 -1
- package/dist/watchAction-IMdjLKl4.js.map +0 -1
- package/dist/watchConfigFiles-AGBDblwf.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as isRecord } from "./handleError-83GwKIFM.js";
|
|
2
|
-
import { i as pkgExtMap, r as fileEnding } from "./resolveBuildContext-
|
|
2
|
+
import { i as pkgExtMap, r as fileEnding } from "./resolveBuildContext-Cp6bOuom.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { mergeConfig } from "tsdown";
|
|
5
5
|
import { defineConfig } from "@sanity/tsdown-config";
|
|
@@ -320,6 +320,9 @@ function pickCustomConditions(exp) {
|
|
|
320
320
|
return Object.entries(exp).filter(([condition, target]) => !managedConditions.has(condition) && !condition.startsWith("_") && target !== void 0);
|
|
321
321
|
}
|
|
322
322
|
const RE_TS_SOURCE = /\.[cm]?tsx?$/;
|
|
323
|
+
function hasNativePreview(pkg) {
|
|
324
|
+
return typeof pkg.devDependencies == "object" && pkg.devDependencies !== null && "@typescript/native-preview" in pkg.devDependencies;
|
|
325
|
+
}
|
|
323
326
|
/**
|
|
324
327
|
* Composes the tsdown config for one build of the waterfall: `@sanity/tsdown-config`'s
|
|
325
328
|
* `defineConfig()` provides the shared Sanity base, and the pkg-utils opinions (browserslist
|
|
@@ -358,10 +361,10 @@ async function resolveTsdownConfig(ctx, build, options) {
|
|
|
358
361
|
} : void 0, define = {};
|
|
359
362
|
pkg.name !== "@sanity/pkg-utils" && (define["process.env.PKG_VERSION"] = JSON.stringify(process.env.PKG_VERSION || pkg.version));
|
|
360
363
|
for (let [key, value] of Object.entries(config?.define || {})) define[key] = JSON.stringify(value);
|
|
361
|
-
let hasTsSources = !build.css && build.entries.some((buildEntry) => RE_TS_SOURCE.test(buildEntry.source)),
|
|
362
|
-
...
|
|
364
|
+
let hasTsSources = !build.css && build.entries.some((buildEntry) => RE_TS_SOURCE.test(buildEntry.source)), dtsObject = typeof config?.dts == "object" ? config.dts : void 0, nativePreviewGenerator = hasNativePreview(pkg) ? { generator: "tsgo" } : void 0, dts = hasTsSources && config?.dts !== !1 ? {
|
|
365
|
+
...nativePreviewGenerator,
|
|
363
366
|
newContext: !0,
|
|
364
|
-
...
|
|
367
|
+
...dtsObject,
|
|
365
368
|
...ctx.emitDeclarationOnly ? { emitDtsOnly: !0 } : {}
|
|
366
369
|
} : !1, exports = build.canonical && !ctx.emitDeclarationOnly && !options.watch && !build.css ? {
|
|
367
370
|
devExports: "source",
|
|
@@ -402,30 +405,19 @@ async function resolveTsdownConfig(ctx, build, options) {
|
|
|
402
405
|
}),
|
|
403
406
|
config: !1,
|
|
404
407
|
logLevel: "warn",
|
|
405
|
-
...options.watch ? {
|
|
408
|
+
...options.watch ? {
|
|
409
|
+
watch: !0,
|
|
410
|
+
ignoreWatch: [path.join(cwd, "package.json"), ctx.ts.configPath ?? "tsconfig.json"]
|
|
411
|
+
} : {}
|
|
406
412
|
};
|
|
407
413
|
}
|
|
408
|
-
/**
|
|
409
|
-
* Declares the conditional export of every CSS file a watch rebuild emitted.
|
|
410
|
-
*
|
|
411
|
-
* A full build leaves this to `cssNodeCompatPlugin`, which composes into tsdown's
|
|
412
|
-
* `exports.customExports`. Watch mode turns tsdown's `exports` feature off (a `package.json`
|
|
413
|
-
* write per rebuild would loop the watcher), so `pkg watch` maintains the exports itself. Most
|
|
414
|
-
* of them are known before the build and are written once per context in `watch.ts`, but the
|
|
415
|
-
* merged `style.css` of CSS imported from JS only exists when something actually imports CSS —
|
|
416
|
-
* declaring it from the config alone would point the export at files nobody produced.
|
|
417
|
-
*
|
|
418
|
-
* `build:done` is the only place that knows: in watch mode `build()` resolves before the first
|
|
419
|
-
* rebuild runs, so the returned bundle's chunks are still empty. The write is idempotent, so
|
|
420
|
-
* the `package.json` watcher settles after one extra rebuild rather than looping.
|
|
421
|
-
* @internal
|
|
422
|
-
*/
|
|
414
|
+
/** @internal */
|
|
423
415
|
function createWatchCssExportsHook(ctx, css) {
|
|
424
416
|
let mergedCssName = css.splitting ? void 0 : css.fileName || "style.css";
|
|
425
417
|
return (hooks) => {
|
|
426
418
|
hooks.hook("build:done", async ({ chunks }) => {
|
|
427
419
|
if (mergedCssName === void 0 || !chunks.some((chunk) => chunk.type === "asset" && chunk.fileName === mergedCssName)) return;
|
|
428
|
-
let { writeBundleCssExports } = await import("./writeBundleCssExports-
|
|
420
|
+
let { writeBundleCssExports } = await import("./writeBundleCssExports-DXkUB_7e.js").then((n) => n.n);
|
|
429
421
|
await writeBundleCssExports({
|
|
430
422
|
cwd: ctx.cwd,
|
|
431
423
|
distPath: ctx.distPath,
|
|
@@ -437,4 +429,4 @@ function createWatchCssExportsHook(ctx, css) {
|
|
|
437
429
|
}
|
|
438
430
|
export { createConditionalCssExport as n, resolveTsdownBuilds as r, resolveTsdownConfig as t };
|
|
439
431
|
|
|
440
|
-
//# sourceMappingURL=resolveTsdownConfig-
|
|
432
|
+
//# sourceMappingURL=resolveTsdownConfig-QaIhKS-s.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveTsdownConfig-C6jUZqvp.js","names":[],"sources":["../src/node/tasks/tsdown/resolveTsdownBuilds.ts","../src/node/core/pkg/cssShimFileName.ts","../src/node/core/pkg/cssExport.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`, `css`. */\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 * The stylesheet build: its entries are `.css` files rather than JS, so it emits CSS assets\n * (one per entry) and no JS at all. It runs on its own because a `.css` entry has nothing to\n * declare types for, and because its per-entry CSS output needs `css.splitting`.\n */\n css?: boolean\n}\n\n/** The build key of the stylesheet build. */\nconst CSS_BUILD_KEY = 'css'\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 const packageType = ctx.pkg.type === 'module' ? 'module' : 'commonjs'\n const resolveRuntimeTargets = (condition: {\n import?: string\n require?: string\n default?: string\n }) => ({\n import: condition.import ?? (packageType === 'module' ? condition.default : undefined),\n require: condition.require ?? (packageType === 'commonjs' ? condition.default : undefined),\n })\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 const browserTargets = exp.browser && resolveRuntimeTargets(exp.browser)\n if (exp.browser && browserTargets && (browserTargets.import || browserTargets.require)) {\n hasRuntimeConditions = true\n addEntry('browser', 'browser', {\n source: exp.browser.source || exp.source,\n exportPath,\n ...browserTargets,\n })\n }\n\n const nodeTargets = exp.node && resolveRuntimeTargets(exp.node)\n if (exp.node && nodeTargets && (nodeTargets.import || nodeTargets.require)) {\n hasRuntimeConditions = true\n addEntry('node', 'node', {\n source: exp.node.source || exp.source,\n exportPath,\n ...nodeTargets,\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 // `.css` export subpaths that declare a `source` build in their own pass: their entries are\n // stylesheets, so the emitted file name follows the export subpath (`./ui/styles.css` ->\n // `dist/ui/styles.css`) instead of an `import`/`require` target, and `dts` has nothing to do.\n const cssEntries: TsdownBuildEntry[] = ctx.cssExports.map((cssExport) => ({\n alias: cssEntryAlias(cssExport._path),\n source: cssExport.source,\n exportPath: cssExport._path,\n formats: ['esm'],\n }))\n if (cssEntries.length) {\n builds.push({\n key: CSS_BUILD_KEY,\n runtime: ctx.runtime,\n canonical: false,\n entries: cssEntries,\n css: true,\n })\n }\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\n/**\n * The tsdown entry alias of a `.css` export subpath: the subpath without its leading `./` and\n * `.css` ending, so `@tsdown/css` (with `splitting`) emits the stylesheet at exactly the path\n * the subpath promises — `\"./ui/styles.css\"` -> alias `ui/styles` -> `dist/ui/styles.css`.\n */\nfunction cssEntryAlias(exportPath: string): string {\n return exportPath.replace(/^\\.\\//, '').replace(/\\.css$/, '')\n}\n","/**\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 path from 'node:path'\nimport {cssShimDtsFileName, cssShimFileName} from './cssShimFileName.ts'\n\n/**\n * Build the conditional CSS export object that `exports.nodeCompat` 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 *\n * @internal\n */\nexport function createConditionalCssExport(\n cssName: string,\n distRel: string,\n): Record<string, string> {\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 return {types: shimDtsFile, browser: cssFile, style: cssFile, node: shimFile, default: shimFile}\n}\n","import path from 'node:path'\nimport type {PkgExport} from '../../core/config/types.ts'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {isRecord} from '../../core/isRecord.ts'\nimport {createConditionalCssExport} from '../../core/pkg/cssExport.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 and nested runtime variants\n * (tsdown emits bare `import`/`require` pairs; the Sanity convention always ends with\n * `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 // POSIX separators: on Windows `path.relative` yields backslashes, which must never leak\n // into generated `package.json` export targets.\n const distRel = (path.relative(ctx.cwd, ctx.distPath) || 'dist').split(path.sep).join('/')\n const cssExportPaths = new Set(ctx.cssExports.map((cssExport) => cssExport._path))\n const cssSources: Record<string, string> = {}\n for (const cssExport of ctx.cssExports) {\n cssSources[cssExport._path] = cssExport.source\n }\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 if (cssExportPaths.has(exportPath)) {\n // A `.css` subpath with a `source` is built by the stylesheet build, which does not\n // participate in exports generation (its entries are stylesheets, not JS). Its\n // conditions are materialized here instead, from the export subpath: `./ui/styles.css`\n // is built to `<dist>/ui/styles.css` with the shim next to it.\n result[exportPath] = reconcileCssEntry(exportPath, {\n distRel,\n source: cssSources[exportPath],\n isPublish,\n })\n } else {\n // Hand-written subpaths that aren't build entries (plain `.css`/`.json` exports,\n // `svelte` 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 * The conditional CSS export of a `.css` subpath built by the stylesheet build. `source`\n * resolves at development time, so it is kept in `exports` and stripped from the publish\n * variant — the same split the build entries get.\n */\nfunction reconcileCssEntry(\n exportPath: string,\n options: {distRel: string; source: string | undefined; isPublish: boolean},\n): Record<string, string> {\n const {distRel, source, isPublish} = options\n const cssName = exportPath.replace(/^\\.\\//, '')\n const conditions = createConditionalCssExport(cssName, distRel)\n return isPublish || source === undefined ? conditions : {source, ...conditions}\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 || exp.browser.default)\n ? pickConditions(exp.browser, {\n authored: browserOrder ?? exp.browser,\n isPublish,\n type,\n })\n : undefined\n const nodeOrder = isRecord(authoredRecord['node']) ? authoredRecord['node'] : exp.node\n const node =\n exp.node && (exp.node.import || exp.node.require || exp.node.default)\n ? pickConditions(exp.node, {\n authored: nodeOrder ?? exp.node,\n isPublish,\n type,\n })\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/**\n * The hand-written `browser`/`node` condition object, minus `source` for the publish map.\n * A nested runtime condition must have its own fallback: once a resolver matches `node` or\n * `browser`, an unmatched module-format condition otherwise backtracks to the outer entry.\n */\nfunction pickConditions(\n conditions: {source?: string; import?: string; require?: string; default?: string},\n options: {\n authored?: object\n isPublish: boolean\n type: 'commonjs' | 'module'\n },\n): Record<string, string> {\n const {authored = conditions, isPublish, type} = options\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 const fallback =\n conditions.default ?? (type === 'module' ? conditions.import : conditions.require)\n if (fallback) next['default'] = fallback\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 {\n defineConfig,\n type ReactCompilerOptions as TsdownConfigReactCompilerOptions,\n} from '@sanity/tsdown-config'\nimport {mergeConfig, type InlineConfig, type UserConfig} from 'tsdown'\nimport type {PkgConfigOptions} from '../../core/config/types.ts'\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 // `?? false` up front (like tsdown-config's own normalization): JS configs bypass the\n // types, and a `reactCompiler: null` would pass the `typeof … === 'object'` checks below\n const reactCompiler = config?.reactCompiler ?? false\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 // Pin the `'babel'` default before forwarding: `@sanity/tsdown-config` defaults to `'oxc'`\n // since 0.27, and inheriting the flip would break published configs.\n const reactCompilerOption: TsdownConfigReactCompilerOptions | boolean =\n typeof reactCompiler === 'object'\n ? reactCompiler.transform === 'oxc'\n ? reactCompiler\n : {...reactCompiler, transform: 'babel'}\n : reactCompiler\n ? {transform: 'babel'}\n : false\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 // The `@tsdown/css` pipeline turns on when it's configured, and automatically for a package\n // that declares a `.css` export subpath with a `source`. The stylesheet build needs\n // `splitting` so each entry emits its own file at the path its subpath promises; the JS\n // builds keep `@tsdown/css`'s merged default, so CSS imported from JS lands in a single\n // `style.css` with one export and one injected import - the `bundle.css` shape of\n // `vanillaExtract`.\n const css: PkgConfigOptions['css'] | undefined =\n config?.css || ctx.cssExports.length\n ? {...config?.css, ...(build.css ? {splitting: true} : {})}\n : undefined\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 =\n !build.css && 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 && !build.css\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 // `@sanity/tsdown-config` defaults `tsdoc` to `false`; pkg-utils keeps the historical\n // default of enabled (`true`), and forwards an options object (with `bundledPackages` for\n // API Extractor's type resolution of inlined deps) when the user customized rules/tags.\n const tsdocOption =\n config?.tsdoc === false\n ? false\n : {\n ...(typeof config?.tsdoc === 'object' ? config.tsdoc : {}),\n bundledPackages: ctx.bundledPackages,\n }\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 css,\n reactCompiler: reactCompilerOption,\n styledComponents: config?.styledComponents,\n vanillaExtract: config?.vanillaExtract,\n bundleAnalyzer: config?.bundleAnalyzer,\n // Types-only builds still emit `.d.ts` files that deserve the check; watch mode skips it\n // so a failing TSDoc rule doesn't tear down the watcher on every save.\n tsdoc: options.watch ? false : tsdocOption,\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 ...(options.watch && css ? {hooks: createWatchCssExportsHook(ctx, css)} : {}),\n })\n\n return {\n ...merged,\n config: false,\n logLevel: 'warn',\n ...(options.watch ? {watch: true} : {}),\n }\n}\n\n/**\n * Declares the conditional export of every CSS file a watch rebuild emitted.\n *\n * A full build leaves this to `cssNodeCompatPlugin`, which composes into tsdown's\n * `exports.customExports`. Watch mode turns tsdown's `exports` feature off (a `package.json`\n * write per rebuild would loop the watcher), so `pkg watch` maintains the exports itself. Most\n * of them are known before the build and are written once per context in `watch.ts`, but the\n * merged `style.css` of CSS imported from JS only exists when something actually imports CSS —\n * declaring it from the config alone would point the export at files nobody produced.\n *\n * `build:done` is the only place that knows: in watch mode `build()` resolves before the first\n * rebuild runs, so the returned bundle's chunks are still empty. The write is idempotent, so\n * the `package.json` watcher settles after one extra rebuild rather than looping.\n * @internal\n */\nfunction createWatchCssExportsHook(\n ctx: BuildContext,\n css: NonNullable<PkgConfigOptions['css']>,\n): NonNullable<UserConfig['hooks']> {\n // Only the merged mode has a CSS file name to declare up front. With `splitting` the names\n // follow the chunk names and the export is the host's to wire up, so a full build declares\n // nothing either.\n const mergedCssName = css.splitting ? undefined : css.fileName || 'style.css'\n\n return (hooks) => {\n hooks.hook('build:done', async ({chunks}) => {\n if (mergedCssName === undefined) return\n const emitted = chunks.some(\n (chunk) => chunk.type === 'asset' && chunk.fileName === mergedCssName,\n )\n if (!emitted) return\n\n const {writeBundleCssExports} = await import('../../core/pkg/writeBundleCssExports.ts')\n await writeBundleCssExports({\n cwd: ctx.cwd,\n distPath: ctx.distPath,\n cssNames: [mergedCssName],\n logger: ctx.logger,\n })\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsDA,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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,KAAO,EAAC,QAAQ,GAAI,IAAI,CAAC;GAChD,GAAI,QAAQ,YAAY,KAAA,IAAY,CAAC,IAAI,EAAC,SAAS,OAAO,QAAO;GACjE,GAAI,QAAQ,SAAS,MAAM,EAAC,OAAO,0BAA0B,KAAK,GAAG,EAAC,IAAI,CAAC;EAC7E,CAGU;EACR,QAAQ;EACR,UAAU;EACV,GAAI,QAAQ,QAAQ,EAAC,OAAO,GAAI,IAAI,CAAC;CACvC;AACF;;;;;;;;;;;;;;;;AAiBA,SAAS,0BACP,KACA,KACkC;CAIlC,IAAM,gBAAgB,IAAI,YAAY,KAAA,IAAY,IAAI,YAAY;CAElE,QAAQ,UAAU;EAChB,MAAM,KAAK,cAAc,OAAO,EAAC,aAAY;GAK3C,IAJI,kBAAkB,KAAA,KAIlB,CAHY,OAAO,MACpB,UAAU,MAAM,SAAS,WAAW,MAAM,aAAa,aAE/C,GAAG;GAEd,IAAM,EAAC,0BAAyB,MAAM,OAAO,sCAA0C,CAAA,MAAA,MAAA,EAAA,CAAA;GACvF,MAAM,sBAAsB;IAC1B,KAAK,IAAI;IACT,UAAU,IAAI;IACd,UAAU,CAAC,aAAa;IACxB,QAAQ,IAAI;GACd,CAAC;EACH,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"resolveTsdownConfig-QaIhKS-s.js","names":[],"sources":["../src/node/tasks/tsdown/resolveTsdownBuilds.ts","../src/node/core/pkg/cssShimFileName.ts","../src/node/core/pkg/cssExport.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`, `css`. */\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 * The stylesheet build: its entries are `.css` files rather than JS, so it emits CSS assets\n * (one per entry) and no JS at all. It runs on its own because a `.css` entry has nothing to\n * declare types for, and because its per-entry CSS output needs `css.splitting`.\n */\n css?: boolean\n}\n\n/** The build key of the stylesheet build. */\nconst CSS_BUILD_KEY = 'css'\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 const packageType = ctx.pkg.type === 'module' ? 'module' : 'commonjs'\n const resolveRuntimeTargets = (condition: {\n import?: string\n require?: string\n default?: string\n }) => ({\n import: condition.import ?? (packageType === 'module' ? condition.default : undefined),\n require: condition.require ?? (packageType === 'commonjs' ? condition.default : undefined),\n })\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 const browserTargets = exp.browser && resolveRuntimeTargets(exp.browser)\n if (exp.browser && browserTargets && (browserTargets.import || browserTargets.require)) {\n hasRuntimeConditions = true\n addEntry('browser', 'browser', {\n source: exp.browser.source || exp.source,\n exportPath,\n ...browserTargets,\n })\n }\n\n const nodeTargets = exp.node && resolveRuntimeTargets(exp.node)\n if (exp.node && nodeTargets && (nodeTargets.import || nodeTargets.require)) {\n hasRuntimeConditions = true\n addEntry('node', 'node', {\n source: exp.node.source || exp.source,\n exportPath,\n ...nodeTargets,\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 // `.css` export subpaths that declare a `source` build in their own pass: their entries are\n // stylesheets, so the emitted file name follows the export subpath (`./ui/styles.css` ->\n // `dist/ui/styles.css`) instead of an `import`/`require` target, and `dts` has nothing to do.\n const cssEntries: TsdownBuildEntry[] = ctx.cssExports.map((cssExport) => ({\n alias: cssEntryAlias(cssExport._path),\n source: cssExport.source,\n exportPath: cssExport._path,\n formats: ['esm'],\n }))\n if (cssEntries.length) {\n builds.push({\n key: CSS_BUILD_KEY,\n runtime: ctx.runtime,\n canonical: false,\n entries: cssEntries,\n css: true,\n })\n }\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\n/**\n * The tsdown entry alias of a `.css` export subpath: the subpath without its leading `./` and\n * `.css` ending, so `@tsdown/css` (with `splitting`) emits the stylesheet at exactly the path\n * the subpath promises — `\"./ui/styles.css\"` -> alias `ui/styles` -> `dist/ui/styles.css`.\n */\nfunction cssEntryAlias(exportPath: string): string {\n return exportPath.replace(/^\\.\\//, '').replace(/\\.css$/, '')\n}\n","/**\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 path from 'node:path'\nimport {cssShimDtsFileName, cssShimFileName} from './cssShimFileName.ts'\n\n/**\n * Build the conditional CSS export object that `exports.nodeCompat` 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 *\n * @internal\n */\nexport function createConditionalCssExport(\n cssName: string,\n distRel: string,\n): Record<string, string> {\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 return {types: shimDtsFile, browser: cssFile, style: cssFile, node: shimFile, default: shimFile}\n}\n","import path from 'node:path'\nimport type {PkgExport} from '../../core/config/types.ts'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {isRecord} from '../../core/isRecord.ts'\nimport {createConditionalCssExport} from '../../core/pkg/cssExport.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 and nested runtime variants\n * (tsdown emits bare `import`/`require` pairs; the Sanity convention always ends with\n * `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 // POSIX separators: on Windows `path.relative` yields backslashes, which must never leak\n // into generated `package.json` export targets.\n const distRel = (path.relative(ctx.cwd, ctx.distPath) || 'dist').split(path.sep).join('/')\n const cssExportPaths = new Set(ctx.cssExports.map((cssExport) => cssExport._path))\n const cssSources: Record<string, string> = {}\n for (const cssExport of ctx.cssExports) {\n cssSources[cssExport._path] = cssExport.source\n }\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 if (cssExportPaths.has(exportPath)) {\n // A `.css` subpath with a `source` is built by the stylesheet build, which does not\n // participate in exports generation (its entries are stylesheets, not JS). Its\n // conditions are materialized here instead, from the export subpath: `./ui/styles.css`\n // is built to `<dist>/ui/styles.css` with the shim next to it.\n result[exportPath] = reconcileCssEntry(exportPath, {\n distRel,\n source: cssSources[exportPath],\n isPublish,\n })\n } else {\n // Hand-written subpaths that aren't build entries (plain `.css`/`.json` exports,\n // `svelte` 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 * The conditional CSS export of a `.css` subpath built by the stylesheet build. `source`\n * resolves at development time, so it is kept in `exports` and stripped from the publish\n * variant — the same split the build entries get.\n */\nfunction reconcileCssEntry(\n exportPath: string,\n options: {distRel: string; source: string | undefined; isPublish: boolean},\n): Record<string, string> {\n const {distRel, source, isPublish} = options\n const cssName = exportPath.replace(/^\\.\\//, '')\n const conditions = createConditionalCssExport(cssName, distRel)\n return isPublish || source === undefined ? conditions : {source, ...conditions}\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 || exp.browser.default)\n ? pickConditions(exp.browser, {\n authored: browserOrder ?? exp.browser,\n isPublish,\n type,\n })\n : undefined\n const nodeOrder = isRecord(authoredRecord['node']) ? authoredRecord['node'] : exp.node\n const node =\n exp.node && (exp.node.import || exp.node.require || exp.node.default)\n ? pickConditions(exp.node, {\n authored: nodeOrder ?? exp.node,\n isPublish,\n type,\n })\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/**\n * The hand-written `browser`/`node` condition object, minus `source` for the publish map.\n * A nested runtime condition must have its own fallback: once a resolver matches `node` or\n * `browser`, an unmatched module-format condition otherwise backtracks to the outer entry.\n */\nfunction pickConditions(\n conditions: {source?: string; import?: string; require?: string; default?: string},\n options: {\n authored?: object\n isPublish: boolean\n type: 'commonjs' | 'module'\n },\n): Record<string, string> {\n const {authored = conditions, isPublish, type} = options\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 const fallback =\n conditions.default ?? (type === 'module' ? conditions.import : conditions.require)\n if (fallback) next['default'] = fallback\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 {\n defineConfig,\n type ReactCompilerOptions as TsdownConfigReactCompilerOptions,\n} from '@sanity/tsdown-config'\nimport {mergeConfig, type InlineConfig, type UserConfig} from 'tsdown'\nimport type {PkgConfigOptions} from '../../core/config/types.ts'\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\nfunction hasNativePreview(pkg: {devDependencies?: unknown}): boolean {\n return (\n typeof pkg.devDependencies === 'object' &&\n pkg.devDependencies !== null &&\n '@typescript/native-preview' in pkg.devDependencies\n )\n}\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 // `?? false` up front (like tsdown-config's own normalization): JS configs bypass the\n // types, and a `reactCompiler: null` would pass the `typeof … === 'object'` checks below\n const reactCompiler = config?.reactCompiler ?? false\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 // Pin the `'babel'` default before forwarding: `@sanity/tsdown-config` defaults to `'oxc'`\n // since 0.27, and inheriting the flip would break published configs.\n const reactCompilerOption: TsdownConfigReactCompilerOptions | boolean =\n typeof reactCompiler === 'object'\n ? reactCompiler.transform === 'oxc'\n ? reactCompiler\n : {...reactCompiler, transform: 'babel'}\n : reactCompiler\n ? {transform: 'babel'}\n : false\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 // The `@tsdown/css` pipeline turns on when it's configured, and automatically for a package\n // that declares a `.css` export subpath with a `source`. The stylesheet build needs\n // `splitting` so each entry emits its own file at the path its subpath promises; the JS\n // builds keep `@tsdown/css`'s merged default, so CSS imported from JS lands in a single\n // `style.css` with one export and one injected import - the `bundle.css` shape of\n // `vanillaExtract`.\n const css: PkgConfigOptions['css'] | undefined =\n config?.css || ctx.cssExports.length\n ? {...config?.css, ...(build.css ? {splitting: true} : {})}\n : undefined\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 const hasTsSources =\n !build.css && build.entries.some((buildEntry) => RE_TS_SOURCE.test(buildEntry.source))\n const dtsObject = typeof config?.dts === 'object' ? config.dts : undefined\n const nativePreviewGenerator = hasNativePreview(pkg) ? ({generator: 'tsgo'} as const) : undefined\n const dts =\n hasTsSources && config?.dts !== false\n ? {\n ...nativePreviewGenerator,\n newContext: true,\n ...dtsObject,\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 && !build.css\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 // `@sanity/tsdown-config` defaults `tsdoc` to `false`; pkg-utils keeps the historical\n // default of enabled (`true`), and forwards an options object (with `bundledPackages` for\n // API Extractor's type resolution of inlined deps) when the user customized rules/tags.\n const tsdocOption =\n config?.tsdoc === false\n ? false\n : {\n ...(typeof config?.tsdoc === 'object' ? config.tsdoc : {}),\n bundledPackages: ctx.bundledPackages,\n }\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 css,\n reactCompiler: reactCompilerOption,\n styledComponents: config?.styledComponents,\n vanillaExtract: config?.vanillaExtract,\n bundleAnalyzer: config?.bundleAnalyzer,\n // Types-only builds still emit `.d.ts` files that deserve the check; watch mode skips it\n // so a failing TSDoc rule doesn't tear down the watcher on every save.\n tsdoc: options.watch ? false : tsdocOption,\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 ...(options.watch && css ? {hooks: createWatchCssExportsHook(ctx, css)} : {}),\n })\n\n return {\n ...merged,\n config: false,\n logLevel: 'warn',\n ...(options.watch\n ? {\n watch: true,\n // tsdown restarts itself on these paths and discards the handle pkg-utils\n // holds. pkg watch reloads the waterfall instead.\n ignoreWatch: [path.join(cwd, 'package.json'), ctx.ts.configPath ?? 'tsconfig.json'],\n }\n : {}),\n }\n}\n\n/** @internal */\nfunction createWatchCssExportsHook(\n ctx: BuildContext,\n css: NonNullable<PkgConfigOptions['css']>,\n): NonNullable<UserConfig['hooks']> {\n // Only the merged mode has a CSS file name to declare up front. With `splitting` the names\n // follow the chunk names and the export is the host's to wire up, so a full build declares\n // nothing either.\n const mergedCssName = css.splitting ? undefined : css.fileName || 'style.css'\n\n return (hooks) => {\n hooks.hook('build:done', async ({chunks}) => {\n if (mergedCssName === undefined) return\n const emitted = chunks.some(\n (chunk) => chunk.type === 'asset' && chunk.fileName === mergedCssName,\n )\n if (!emitted) return\n\n const {writeBundleCssExports} = await import('../../core/pkg/writeBundleCssExports.ts')\n await writeBundleCssExports({\n cwd: ctx.cwd,\n distPath: ctx.distPath,\n cssNames: [mergedCssName],\n logger: ctx.logger,\n })\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsDA,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,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Y,KAAA,IAAY,CAAC,IAAI,EAAC,SAAS,OAAO,QAAO;GACjE,GAAI,QAAQ,SAAS,MAAM,EAAC,OAAO,0BAA0B,KAAK,GAAG,EAAC,IAAI,CAAC;EAC7E,CAGU;EACR,QAAQ;EACR,UAAU;EACV,GAAI,QAAQ,QACR;GACE,OAAO;GAGP,aAAa,CAAC,KAAK,KAAK,KAAK,cAAc,GAAG,IAAI,GAAG,cAAc,eAAe;EACpF,IACA,CAAC;CACP;AACF;;AAGA,SAAS,0BACP,KACA,KACkC;CAIlC,IAAM,gBAAgB,IAAI,YAAY,KAAA,IAAY,IAAI,YAAY;CAElE,QAAQ,UAAU;EAChB,MAAM,KAAK,cAAc,OAAO,EAAC,aAAY;GAK3C,IAJI,kBAAkB,KAAA,KAIlB,CAHY,OAAO,MACpB,UAAU,MAAM,SAAS,WAAW,MAAM,aAAa,aAE/C,GAAG;GAEd,IAAM,EAAC,0BAAyB,MAAM,OAAO,sCAA0C,CAAA,MAAA,MAAA,EAAA,CAAA;GACvF,MAAM,sBAAsB;IAC1B,KAAK,IAAI;IACT,UAAU,IAAI;IACd,UAAU,CAAC,aAAa;IACxB,QAAQ,IAAI;GACd,CAAC;EACH,CAAC;CACH;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as createLogger, r as isRecord, t as handleError } from "./handleError-83GwKIFM.js";
|
|
2
|
-
import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-
|
|
3
|
-
import { r as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-
|
|
4
|
-
import { t as writeBundleCssExports } from "./writeBundleCssExports-
|
|
2
|
+
import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-Cp6bOuom.js";
|
|
3
|
+
import { r as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-QaIhKS-s.js";
|
|
4
|
+
import { t as writeBundleCssExports } from "./writeBundleCssExports-DXkUB_7e.js";
|
|
5
5
|
import { up } from "empathic/package";
|
|
6
6
|
import { build } from "tsdown";
|
|
7
7
|
import { switchMap } from "rxjs";
|
|
@@ -31,23 +31,28 @@ import { switchMap } from "rxjs";
|
|
|
31
31
|
function usesCssExportNodeCompat(options) {
|
|
32
32
|
return options.exports === void 0 || isRecord(options.exports) && options.exports.nodeCompat === !0;
|
|
33
33
|
}
|
|
34
|
-
const asyncDispose = Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose");
|
|
35
34
|
/** @public */
|
|
36
35
|
async function watch(options) {
|
|
37
|
-
let { cwd, strict = !1, tsconfig: tsconfigOption, signal } = options, logger = createLogger(),
|
|
36
|
+
let { cwd, strict = !1, tsconfig: tsconfigOption, signal } = options, logger = createLogger(), bootstrapPkgPath = up({ cwd });
|
|
37
|
+
if (!bootstrapPkgPath) throw Error("missing package.json", { cause: { cwd } });
|
|
38
|
+
let bootstrapConfig = await loadConfig({
|
|
38
39
|
cwd,
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
pkgPath: bootstrapPkgPath
|
|
41
|
+
}), watchedTsconfig = tsconfigOption || bootstrapConfig?.tsconfig || "tsconfig.json", { watchConfigFiles } = await import("./watchConfigFiles-Bt03CSXT.js"), configFiles$ = await watchConfigFiles({
|
|
42
|
+
cwd,
|
|
43
|
+
logger,
|
|
44
|
+
tsconfig: watchedTsconfig
|
|
45
|
+
}), handles = [], runId = 0, closeHandles = async () => {
|
|
46
|
+
let closing = handles;
|
|
47
|
+
handles = [];
|
|
48
|
+
for (let handle of closing) await handle.watch.close();
|
|
44
49
|
}, ctxSubscription = configFiles$.pipe(switchMap(async () => {
|
|
45
50
|
let pkgPath = up({ cwd });
|
|
46
51
|
if (!pkgPath) throw Error("missing package.json", { cause: { cwd } });
|
|
47
52
|
let config = await loadConfig({
|
|
48
53
|
cwd,
|
|
49
54
|
pkgPath
|
|
50
|
-
}), { parseStrictOptions } = await import("./resolveBuildContext-
|
|
55
|
+
}), { parseStrictOptions } = await import("./resolveBuildContext-Cp6bOuom.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
|
|
51
56
|
pkgPath,
|
|
52
57
|
logger,
|
|
53
58
|
strict,
|
|
@@ -62,9 +67,9 @@ async function watch(options) {
|
|
|
62
67
|
tsconfig
|
|
63
68
|
});
|
|
64
69
|
})).subscribe(async (ctx) => {
|
|
65
|
-
let id = ++runId,
|
|
70
|
+
let id = ++runId, runHandles = [];
|
|
66
71
|
try {
|
|
67
|
-
await
|
|
72
|
+
await closeHandles();
|
|
68
73
|
let cssNames = [], cssSources = {}, vanillaExtract = ctx.config?.vanillaExtract;
|
|
69
74
|
if (vanillaExtract) {
|
|
70
75
|
let veOptions = vanillaExtract === !0 ? {} : vanillaExtract;
|
|
@@ -86,19 +91,19 @@ async function watch(options) {
|
|
|
86
91
|
clean: first,
|
|
87
92
|
watch: !0
|
|
88
93
|
});
|
|
89
|
-
first = !1,
|
|
94
|
+
first = !1, runHandles.push(await build(inlineConfig));
|
|
90
95
|
}
|
|
91
96
|
if (id !== runId) {
|
|
92
|
-
for (let
|
|
97
|
+
for (let handle of runHandles) await handle.watch.close();
|
|
93
98
|
return;
|
|
94
99
|
}
|
|
95
|
-
|
|
100
|
+
handles = runHandles, logger.success(`${ctx.pkg.name}: watching for file changes\u2026`), logger.log();
|
|
96
101
|
} catch (err) {
|
|
97
102
|
ctx.logger.error(err), ctx.logger.log(), process.exit(1);
|
|
98
103
|
}
|
|
99
104
|
});
|
|
100
105
|
signal && signal.addEventListener("abort", () => {
|
|
101
|
-
runId++, ctxSubscription.unsubscribe(),
|
|
106
|
+
runId++, ctxSubscription.unsubscribe(), closeHandles().catch((err) => logger.error(err));
|
|
102
107
|
}, { once: !0 });
|
|
103
108
|
}
|
|
104
109
|
async function watchAction(options) {
|
|
@@ -114,4 +119,4 @@ async function watchAction(options) {
|
|
|
114
119
|
}
|
|
115
120
|
export { watchAction };
|
|
116
121
|
|
|
117
|
-
//# sourceMappingURL=watchAction-
|
|
122
|
+
//# sourceMappingURL=watchAction-fgVjJMTR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchAction-fgVjJMTR.js","names":["findPkgPath","tsdownBuild"],"sources":["../src/node/core/pkg/cssExportOptions.ts","../src/node/watch.ts","../src/cli/watchAction.ts"],"sourcesContent":["import {isRecord} from '../isRecord.ts'\n\n/**\n * Whether a CSS pipeline's options wire up the conditional CSS export pattern — the no-op JS\n * shim, its declaration file, and the `\"./<fileName>\"` export whose `node`/`default` conditions\n * point at the shim.\n *\n * `pkg watch` needs this to decide which exports to maintain itself, because watch mode turns\n * tsdown's `exports` feature off. Full builds never ask: the plugins own the answer there.\n *\n * Only `exports` decides. `@sanity/tsdown-config` composes the plugin options as\n * `{inject: true, exports: {nodeCompat: true}, ...userOptions}`, so `exports` is always set by\n * the time `resolveCssExportOptions` sees them — a user-supplied `inject` never clears the\n * default. That makes the plugin's compatibility fallback for the deprecated\n * `inject: {nodeCompat: true}` spelling unreachable from here, and reading `inject` would get\n * `{inject: {nodeCompat: false}}` wrong: it still leaves the `exports` default in place, so the\n * conditional export is written.\n *\n * Kept in sync with `resolveCssExportOptions` in `@sanity/vanilla-extract-rolldown-plugin` —\n * the same reason `cssShimFileName` has a copy here. Importing the canonical one would make\n * `@sanity/vanilla-extract-tsdown-plugin` a static dependency of this module graph, pulling the\n * whole vanilla-extract toolchain into every `pkg build`.\n *\n * @internal\n */\nexport function usesCssExportNodeCompat(options: {exports?: unknown}): boolean {\n if (options.exports === undefined) {\n // `@sanity/tsdown-config`'s `exports: {nodeCompat: true}` default applies\n return true\n }\n return isRecord(options.exports) && options.exports['nodeCompat'] === true\n}\n","import {up as findPkgPath} from 'empathic/package'\nimport type {Subscription} from 'rxjs'\nimport {switchMap} from 'rxjs'\nimport {build as tsdownBuild, type TsdownHandle} from 'tsdown'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {usesCssExportNodeCompat} from './core/pkg/cssExportOptions.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\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 bootstrapPkgPath = findPkgPath({cwd})\n if (!bootstrapPkgPath) {\n throw new Error('missing package.json', {cause: {cwd}})\n }\n\n // The watched tsconfig is fixed when the watcher starts, so a `tsconfig` that a later\n // `package.config.ts` edit introduces is not picked up.\n const bootstrapConfig = await loadConfig({cwd, pkgPath: bootstrapPkgPath})\n const watchedTsconfig = tsconfigOption || bootstrapConfig?.tsconfig || 'tsconfig.json'\n\n const {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger, tsconfig: watchedTsconfig})\n\n // RxJS does not await async subscriber callbacks. Only the latest runId may\n // publish handles; a stale or aborted run must close the handles it created.\n let handles: TsdownHandle[] = []\n let runId = 0\n const closeHandles = async () => {\n const closing = handles\n handles = []\n for (const handle of closing) {\n await handle.watch.close()\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 runHandles: TsdownHandle[] = []\n try {\n await closeHandles()\n\n const cssNames: string[] = []\n const cssSources: Record<string, string> = {}\n\n const vanillaExtract = ctx.config?.vanillaExtract\n if (vanillaExtract) {\n const veOptions = vanillaExtract === true ? {} : vanillaExtract\n if (usesCssExportNodeCompat(veOptions)) {\n cssNames.push(veOptions.fileName || 'bundle.css')\n }\n }\n\n // The `@tsdown/css` pipeline's own exports: the `.css` export subpaths built by the\n // stylesheet build. Their file names follow their subpath and a declared entry always\n // emits, so they are known up front. The merged `style.css` of CSS imported from JS is\n // not — it only exists once something actually imports CSS — so `resolveTsdownConfig`\n // declares that one from a `build:done` hook instead, matching what\n // `cssNodeCompatPlugin` declares in a full build.\n const cssConfig = ctx.config?.css\n const cssNodeCompat =\n (Boolean(cssConfig) || ctx.cssExports.length > 0) &&\n usesCssExportNodeCompat(cssConfig ?? {})\n if (cssNodeCompat) {\n for (const cssExport of ctx.cssExports) {\n cssNames.push(cssExport._path.replace(/^\\.\\//, ''))\n cssSources[cssExport._path] = cssExport.source\n }\n }\n\n await writeBundleCssExports({\n cwd,\n distPath: ctx.distPath,\n cssNames,\n sources: cssSources,\n logger,\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 runHandles.push(await tsdownBuild(inlineConfig))\n }\n\n if (id !== runId) {\n for (const handle of runHandles) {\n await handle.watch.close()\n }\n return\n }\n\n handles = runHandles\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 closeHandles().catch((err) => logger.error(err))\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,wBAAwB,SAAuC;CAK7E,OAJI,QAAQ,YAAY,KAAA,KAIjB,SAAS,QAAQ,OAAO,KAAK,QAAQ,QAAQ,eAAkB;AACxE;;ACjBA,eAAsB,MAAM,SAKV;CAChB,IAAM,EAAC,KAAK,SAAS,IAAO,UAAU,gBAAgB,WAAU,SAE1D,SAAS,aAAa,GAEtB,mBAAmBA,GAAY,EAAC,IAAG,CAAC;CAC1C,IAAI,CAAC,kBACH,MAAU,MAAM,wBAAwB,EAAC,OAAO,EAAC,IAAG,EAAC,CAAC;CAKxD,IAAM,kBAAkB,MAAM,WAAW;EAAC;EAAK,SAAS;CAAgB,CAAC,GACnE,kBAAkB,kBAAkB,iBAAiB,YAAY,iBAEjE,EAAC,qBAAoB,MAAM,OAAO,mCAClC,eAAe,MAAM,iBAAiB;EAAC;EAAK;EAAQ,UAAU;CAAe,CAAC,GAIhF,UAA0B,CAAC,GAC3B,QAAQ,GACN,eAAe,YAAY;EAC/B,IAAM,UAAU;EAChB,UAAU,CAAC;EACX,KAAK,IAAM,UAAU,SACnB,MAAM,OAAO,MAAM,MAAM;CAE7B,GAmBM,kBAjBO,aAAa,KACxB,UAAU,YAAY;EACpB,IAAM,UAAUA,GAAY,EAAC,IAAG,CAAC;EACjC,IAAI,CAAC,SACH,MAAU,MAAM,wBAAwB,EAAC,OAAO,EAAC,IAAG,EAAC,CAAC;EAGxD,IAAM,SAAS,MAAM,WAAW;GAAC;GAAK;EAAO,CAAC,GACx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OAAO,MAAM,MAAM;IAE3B;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,aAAa,CAAC,CAAC,OAAO,QAAQ,OAAO,MAAM,GAAG,CAAC;CACjD,GACA,EAAC,MAAM,GAAI,CACb;AAEJ;ACtJA,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"}
|
|
@@ -21,23 +21,17 @@ function watchFiles(patterns) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
async function watchConfigFiles(options) {
|
|
24
|
-
let { cwd, logger } = options,
|
|
24
|
+
let { cwd, logger, tsconfig = "tsconfig.json" } = options, configFiles = [
|
|
25
25
|
path.resolve(cwd, "package.json"),
|
|
26
|
+
path.resolve(cwd, tsconfig),
|
|
26
27
|
path.resolve(cwd, "package.config.cjs"),
|
|
27
28
|
path.resolve(cwd, "package.config.js"),
|
|
28
29
|
path.resolve(cwd, "package.config.ts"),
|
|
29
30
|
path.resolve(cwd, "package.config.mjs"),
|
|
30
31
|
path.resolve(cwd, "package.config.mts")
|
|
31
|
-
]);
|
|
32
|
-
return watchFiles(
|
|
33
|
-
path.resolve(cwd, "package.json"),
|
|
34
|
-
path.resolve(cwd, "package.config.cjs"),
|
|
35
|
-
path.resolve(cwd, "package.config.js"),
|
|
36
|
-
path.resolve(cwd, "package.config.ts"),
|
|
37
|
-
path.resolve(cwd, "package.config.mjs"),
|
|
38
|
-
path.resolve(cwd, "package.config.mts")
|
|
39
|
-
]).pipe(scan((files, fileEvent) => fileEvent.type === "add" ? files.concat(fileEvent.file) : fileEvent.type === "unlink" ? files.filter((f) => f !== fileEvent.file) : fileEvent.type === "change" ? (logger.log("--------------------------------------------------------------------------------"), logger.info(path.relative(cwd, fileEvent.file), "changed"), logger.log(""), files.slice(0)) : files, initialFiles), startWith(initialFiles), distinctUntilChanged());
|
|
32
|
+
], initialFiles = await globFiles(configFiles);
|
|
33
|
+
return watchFiles(configFiles).pipe(scan((files, fileEvent) => fileEvent.type === "add" ? files.concat(fileEvent.file) : fileEvent.type === "unlink" ? files.filter((f) => f !== fileEvent.file) : fileEvent.type === "change" ? (logger.log("--------------------------------------------------------------------------------"), logger.info(path.relative(cwd, fileEvent.file), "changed"), logger.log(""), files.slice(0)) : files, initialFiles), startWith(initialFiles), distinctUntilChanged());
|
|
40
34
|
}
|
|
41
35
|
export { watchConfigFiles };
|
|
42
36
|
|
|
43
|
-
//# sourceMappingURL=watchConfigFiles-
|
|
37
|
+
//# sourceMappingURL=watchConfigFiles-Bt03CSXT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchConfigFiles-Bt03CSXT.js","names":[],"sources":["../src/node/globFiles.ts","../src/node/watchFiles.ts","../src/node/watchConfigFiles.ts"],"sourcesContent":["import path from 'node:path'\nimport {globby} from 'globby'\n\nexport function globFiles(patterns: string[]): Promise<string[]> {\n return globby(patterns.map((pattern) => pattern.split(path.sep).join(path.posix.sep)))\n}\n","import * as chokidar from 'chokidar'\nimport type {EventName} from 'chokidar/handler.js'\nimport {Observable} from 'rxjs'\n\nexport interface FileEvent {\n type: EventName\n file: string\n}\n\nexport function watchFiles(patterns: string[]): Observable<FileEvent> {\n return new Observable((observer) => {\n const watcher = chokidar.watch(patterns, {\n ignoreInitial: true,\n })\n\n function handleFileEvent(type: EventName, file: string | Error) {\n if (type === 'error' || file instanceof Error) {\n observer.error(file)\n } else {\n observer.next({type, file})\n }\n }\n\n watcher.on('all', handleFileEvent)\n\n return () => {\n watcher.off('all', handleFileEvent)\n void watcher.close()\n }\n })\n}\n","import path from 'node:path'\nimport type {Observable} from 'rxjs'\nimport {distinctUntilChanged, scan, startWith} from 'rxjs/operators'\nimport {globFiles} from './globFiles.ts'\nimport type {Logger} from './logger.ts'\nimport {watchFiles} from './watchFiles.ts'\n\nexport async function watchConfigFiles(options: {\n cwd: string\n logger: Logger\n tsconfig?: string\n}): Promise<Observable<string[]>> {\n const {cwd, logger, tsconfig = 'tsconfig.json'} = options\n\n const configFiles = [\n path.resolve(cwd, 'package.json'),\n path.resolve(cwd, tsconfig),\n path.resolve(cwd, 'package.config.cjs'),\n path.resolve(cwd, 'package.config.js'),\n path.resolve(cwd, 'package.config.ts'),\n path.resolve(cwd, 'package.config.mjs'),\n path.resolve(cwd, 'package.config.mts'),\n ]\n\n const initialFiles = await globFiles(configFiles)\n const fileEvent$ = watchFiles(configFiles)\n\n return fileEvent$.pipe(\n scan((files, fileEvent) => {\n if (fileEvent.type === 'add') {\n return files.concat(fileEvent.file)\n }\n\n if (fileEvent.type === 'unlink') {\n return files.filter((f) => f !== fileEvent.file)\n }\n\n if (fileEvent.type === 'change') {\n logger.log(\n '--------------------------------------------------------------------------------',\n )\n logger.info(path.relative(cwd, fileEvent.file), 'changed')\n logger.log('')\n\n return files.slice(0) // trigger update\n }\n\n return files\n }, initialFiles),\n startWith(initialFiles),\n distinctUntilChanged(),\n )\n}\n"],"mappings":";;;;;AAGA,SAAgB,UAAU,UAAuC;CAC/D,OAAO,OAAO,SAAS,KAAK,YAAY,QAAQ,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC;AACvF;ACIA,SAAgB,WAAW,UAA2C;CACpE,OAAO,IAAI,YAAY,aAAa;EAClC,IAAM,UAAU,SAAS,MAAM,UAAU,EACvC,eAAe,GACjB,CAAC;EAED,SAAS,gBAAgB,MAAiB,MAAsB;GAC9D,AAAI,SAAS,WAAW,gBAAgB,QACtC,SAAS,MAAM,IAAI,IAEnB,SAAS,KAAK;IAAC;IAAM;GAAI,CAAC;EAE9B;EAIA,OAFA,QAAQ,GAAG,OAAO,eAAe,SAEpB;GAEX,AADA,QAAQ,IAAI,OAAO,eAAe,GAClC,QAAa,MAAM;EACrB;CACF,CAAC;AACH;ACvBA,eAAsB,iBAAiB,SAIL;CAChC,IAAM,EAAC,KAAK,QAAQ,WAAW,oBAAmB,SAE5C,cAAc;EAClB,KAAK,QAAQ,KAAK,cAAc;EAChC,KAAK,QAAQ,KAAK,QAAQ;EAC1B,KAAK,QAAQ,KAAK,oBAAoB;EACtC,KAAK,QAAQ,KAAK,mBAAmB;EACrC,KAAK,QAAQ,KAAK,mBAAmB;EACrC,KAAK,QAAQ,KAAK,oBAAoB;EACtC,KAAK,QAAQ,KAAK,oBAAoB;CACxC,GAEM,eAAe,MAAM,UAAU,WAAW;CAGhD,OAFmB,WAAW,WAEd,CAAC,CAAC,KAChB,MAAM,OAAO,cACP,UAAU,SAAS,QACd,MAAM,OAAO,UAAU,IAAI,IAGhC,UAAU,SAAS,WACd,MAAM,QAAQ,MAAM,MAAM,UAAU,IAAI,IAG7C,UAAU,SAAS,YACrB,OAAO,IACL,kFACF,GACA,OAAO,KAAK,KAAK,SAAS,KAAK,UAAU,IAAI,GAAG,SAAS,GACzD,OAAO,IAAI,EAAE,GAEN,MAAM,MAAM,CAAC,KAGf,OACN,YAAY,GACf,UAAU,YAAY,GACtB,qBAAqB,CACvB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as isRecord } from "./handleError-83GwKIFM.js";
|
|
2
|
-
import { n as createConditionalCssExport } from "./resolveTsdownConfig-
|
|
2
|
+
import { n as createConditionalCssExport } from "./resolveTsdownConfig-QaIhKS-s.js";
|
|
3
3
|
import { t as __exportAll } from "./initAction-CmOO8eod.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { readFile, writeFile } from "node:fs/promises";
|
|
@@ -61,4 +61,4 @@ async function writeBundleCssExports(options) {
|
|
|
61
61
|
}
|
|
62
62
|
export { writeBundleCssExports_exports as n, writeBundleCssExports as t };
|
|
63
63
|
|
|
64
|
-
//# sourceMappingURL=writeBundleCssExports-
|
|
64
|
+
//# sourceMappingURL=writeBundleCssExports-DXkUB_7e.js.map
|
package/dist/{writeBundleCssExports-BO8zfc4U.js.map → writeBundleCssExports-DXkUB_7e.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeBundleCssExports-
|
|
1
|
+
{"version":3,"file":"writeBundleCssExports-DXkUB_7e.js","names":[],"sources":["../src/node/core/pkg/writeBundleCssExports.ts"],"sourcesContent":["import {readFile, writeFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport type {Logger} from '../../logger.ts'\nimport {isRecord} from '../isRecord.ts'\nimport {createConditionalCssExport} from './cssExport.ts'\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 of every CSS file to `package.json` (used by\n * `exports.nodeCompat`), so userland does not have to maintain it by hand. The write is\n * idempotent: if every export already matches, the file is left untouched.\n *\n * Full builds write these entries through tsdown's `exports.customExports` (the\n * `@sanity/vanilla-extract-tsdown-plugin` composition, and the `@sanity/tsdown-config` one for\n * `@tsdown/css` output), but watch mode disables tsdown's `exports` feature (a `package.json`\n * write per rebuild would loop the watcher) — `pkg watch` calls this once per context instead,\n * like v11 did.\n *\n * When `publishConfig.exports` is present, the same conditional CSS exports are mirrored into it.\n * A conditional CSS export has no `source`/`development`/`monorepo` conditions to strip, so the\n * entries are identical in both places — except for a hand-written `source`, which stays in\n * `exports` only. Keeping them in sync prevents the `publishConfig.exports` validation from\n * failing with a \"missing export path\" error for the auto-added `./<cssName>` exports.\n *\n * @internal\n */\nexport async function writeBundleCssExports(options: {\n cwd: string\n distPath: string\n cssNames: string[]\n /** Hand-written `source` conditions to preserve in `exports`, keyed by export subpath. */\n sources?: Record<string, string>\n logger: Logger\n}): Promise<void> {\n const {cwd, distPath, cssNames, sources = {}, logger} = options\n if (cssNames.length === 0) return\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\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 written: string[] = []\n let exports = pkg.exports ?? {}\n let publishExports = publishConfigExports\n\n for (const cssName of cssNames) {\n const exportKey = `./${cssName}`\n const publishExport = createConditionalCssExport(cssName, distRel)\n // A hand-written `source` resolves at development time only, so it stays out of the\n // publish map — the same split `composeExports` applies to build entries.\n const sourceCondition = sources[exportKey]\n const localExport =\n sourceCondition === undefined ? publishExport : {source: sourceCondition, ...publishExport}\n\n const exportsMatch = hasMatchingExport(exports[exportKey], localExport)\n const publishExportsMatch =\n !publishExports || hasMatchingExport(publishExports[exportKey], publishExport)\n if (exportsMatch && publishExportsMatch) continue\n\n exports = insertCssExport(exports, exportKey, localExport)\n if (publishExports) {\n publishExports = insertCssExport(publishExports, exportKey, publishExport)\n }\n written.push(exportKey)\n }\n\n if (written.length === 0) return\n\n pkg.exports = exports\n if (publishConfig && publishExports) {\n publishConfig.exports = publishExports\n }\n\n await writeFile(pkgPath, `${JSON.stringify(pkg, null, detectIndent(source))}\\n`)\n const maps = publishConfigExports ? ['exports', 'publishConfig.exports'] : ['exports']\n const keys = maps\n .flatMap((map) => written.map((key) => `\\`${map}[\"${key}\"]\\``))\n .join(', ')\n .replace(/, ([^,]*)$/, written.length * maps.length > 1 ? ' and $1' : '$1')\n logger.log(`Updated package.json: added ${keys} for the conditional CSS export pattern`)\n}\n"],"mappings":";;;;;;AAMA,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;CAKrB,OAHK,aACH,YAAY,aAAa,oBAEpB;AACT;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AM,aAAa,MAAM,CAAC,EAAE,GAAG;CAC/E,IAAM,OAAO,uBAAuB,CAAC,WAAW,uBAAuB,IAAI,CAAC,SAAS,GAC/E,OAAO,KACV,SAAS,QAAQ,QAAQ,KAAK,QAAQ,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,CAAC,CAC9D,KAAK,IAAI,CAAC,CACV,QAAQ,cAAc,QAAQ,SAAS,KAAK,SAAS,IAAI,YAAY,IAAI;CAC5E,OAAO,IAAI,+BAA+B,KAAK,wCAAwC;AACzF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"browserslist": "extends @sanity/browserslist-config",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/core": "^7.29.7",
|
|
48
|
-
"@rolldown/plugin-babel": "^0.2.
|
|
48
|
+
"@rolldown/plugin-babel": "^0.2.4",
|
|
49
49
|
"@sanity/browserslist-config": "^1.0.5",
|
|
50
|
-
"@sanity/parse-package-json": "^2.3.
|
|
51
|
-
"@sanity/tsdown-config": "^0.
|
|
50
|
+
"@sanity/parse-package-json": "^2.3.5",
|
|
51
|
+
"@sanity/tsdown-config": "^0.28.1",
|
|
52
52
|
"@typescript/typescript6": "^6.0.2",
|
|
53
|
-
"browserslist": "^4.
|
|
53
|
+
"browserslist": "^4.29.0",
|
|
54
54
|
"browserslist-to-esbuild": "2.1.1",
|
|
55
55
|
"cac": "^7.0.0",
|
|
56
56
|
"chalk": "^6.0.0",
|
|
@@ -61,32 +61,33 @@
|
|
|
61
61
|
"globby": "^16.2.4",
|
|
62
62
|
"mkdirp": "^3.0.1",
|
|
63
63
|
"outdent": "^0.8.0",
|
|
64
|
-
"prettier": "^3.9.
|
|
65
|
-
"pretty-bytes": "^7.1.
|
|
64
|
+
"prettier": "^3.9.7",
|
|
65
|
+
"pretty-bytes": "^7.1.3",
|
|
66
66
|
"prompts": "^2.4.2",
|
|
67
67
|
"publint": "^0.3.24",
|
|
68
68
|
"rxjs": "^7.8.2",
|
|
69
69
|
"treeify": "^1.1.0",
|
|
70
|
-
"tsdown": "^0.
|
|
71
|
-
"tsx": "^4.23.
|
|
72
|
-
"zod": "^4.
|
|
70
|
+
"tsdown": "^0.23.0",
|
|
71
|
+
"tsx": "^4.23.13",
|
|
72
|
+
"zod": "^4.6.5",
|
|
73
73
|
"zod-validation-error": "^5.0.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@sanity/tsconfig": "^2.2.1",
|
|
77
|
+
"@tsdown/css": "^0.23.0",
|
|
77
78
|
"@types/babel__core": "^7.20.5",
|
|
78
79
|
"@types/find-config": "^1.0.4",
|
|
79
|
-
"@types/node": "^24.13.
|
|
80
|
+
"@types/node": "^24.13.6",
|
|
80
81
|
"@types/parse-github-url": "^1.0.3",
|
|
81
82
|
"@types/prompts": "^2.4.9",
|
|
82
83
|
"@types/treeify": "^1.0.3",
|
|
83
84
|
"babel-plugin-react-compiler": "1.0.0",
|
|
84
85
|
"nanoexec": "^1.1.0",
|
|
85
|
-
"oxc-transform-react": "^0.
|
|
86
|
+
"oxc-transform-react": "^0.150.0",
|
|
86
87
|
"parse-github-url": "^1.0.4",
|
|
87
88
|
"rimraf": "^6.1.3",
|
|
88
89
|
"typescript": "7.0.2",
|
|
89
|
-
"vitest": "^
|
|
90
|
+
"vitest": "^5.0.1"
|
|
90
91
|
},
|
|
91
92
|
"peerDependencies": {
|
|
92
93
|
"@tsdown/css": "*",
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
}
|
|
107
108
|
},
|
|
108
109
|
"engines": {
|
|
109
|
-
"node": "^22.18.0 ||
|
|
110
|
+
"node": "^22.18.0 || ^24.11.0 || >=26.0.0"
|
|
110
111
|
},
|
|
111
112
|
"scripts": {
|
|
112
113
|
"build": "run-s clean build:pkg check:pkg",
|