@sanity/pkg-utils 11.0.17 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/MIGRATE.md +152 -0
  2. package/README.md +110 -55
  3. package/dist/buildAction-DFrmHzYY.js +146 -0
  4. package/dist/buildAction-DFrmHzYY.js.map +1 -0
  5. package/dist/checkAction-BMxszLZS.js +140 -0
  6. package/dist/checkAction-BMxszLZS.js.map +1 -0
  7. package/dist/cli.js +22 -28
  8. package/dist/cli.js.map +1 -1
  9. package/dist/createApiExtractorConfig-CJoZqw8e.js +30 -0
  10. package/dist/createApiExtractorConfig-CJoZqw8e.js.map +1 -0
  11. package/dist/createTSDocConfig-CwaWneTR.js +25 -0
  12. package/dist/createTSDocConfig-CwaWneTR.js.map +1 -0
  13. package/dist/getExtractMessagesConfig-CXljwFbQ.js +75 -0
  14. package/dist/getExtractMessagesConfig-CXljwFbQ.js.map +1 -0
  15. package/dist/handleError-83GwKIFM.js +40 -0
  16. package/dist/handleError-83GwKIFM.js.map +1 -0
  17. package/dist/index.d.ts +141 -195
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +203 -11
  20. package/dist/index.js.map +1 -1
  21. package/dist/initAction-Cv0oRwWP.js +618 -0
  22. package/dist/initAction-Cv0oRwWP.js.map +1 -0
  23. package/dist/printExtractMessages-DyaYtByp.js +33 -0
  24. package/dist/printExtractMessages-DyaYtByp.js.map +1 -0
  25. package/dist/resolveBuildContext-CwqbTV6p.js +713 -0
  26. package/dist/resolveBuildContext-CwqbTV6p.js.map +1 -0
  27. package/dist/resolveTsdownConfig-2OdGF-dM.js +258 -0
  28. package/dist/resolveTsdownConfig-2OdGF-dM.js.map +1 -0
  29. package/dist/spinner-DAHe7SuT.js +15 -0
  30. package/dist/spinner-DAHe7SuT.js.map +1 -0
  31. package/dist/watchAction-uRPAvgLE.js +179 -0
  32. package/dist/watchAction-uRPAvgLE.js.map +1 -0
  33. package/dist/watchConfigFiles-AGBDblwf.js +43 -0
  34. package/dist/watchConfigFiles-AGBDblwf.js.map +1 -0
  35. package/package.json +10 -24
  36. package/dist/_chunks-es/buildAction.js +0 -195
  37. package/dist/_chunks-es/buildAction.js.map +0 -1
  38. package/dist/_chunks-es/checkAction.js +0 -198
  39. package/dist/_chunks-es/checkAction.js.map +0 -1
  40. package/dist/_chunks-es/createApiExtractorConfig.js +0 -52
  41. package/dist/_chunks-es/createApiExtractorConfig.js.map +0 -1
  42. package/dist/_chunks-es/createTSDocConfig.js +0 -31
  43. package/dist/_chunks-es/createTSDocConfig.js.map +0 -1
  44. package/dist/_chunks-es/defaults.js +0 -36
  45. package/dist/_chunks-es/defaults.js.map +0 -1
  46. package/dist/_chunks-es/define.js +0 -7
  47. package/dist/_chunks-es/define.js.map +0 -1
  48. package/dist/_chunks-es/extractModuleBlocks.js +0 -48
  49. package/dist/_chunks-es/extractModuleBlocks.js.map +0 -1
  50. package/dist/_chunks-es/fileExists.js +0 -12
  51. package/dist/_chunks-es/fileExists.js.map +0 -1
  52. package/dist/_chunks-es/getExtractMessagesConfig.js +0 -83
  53. package/dist/_chunks-es/getExtractMessagesConfig.js.map +0 -1
  54. package/dist/_chunks-es/handleError.js +0 -32
  55. package/dist/_chunks-es/handleError.js.map +0 -1
  56. package/dist/_chunks-es/index.js +0 -825
  57. package/dist/_chunks-es/index.js.map +0 -1
  58. package/dist/_chunks-es/initAction.js +0 -654
  59. package/dist/_chunks-es/initAction.js.map +0 -1
  60. package/dist/_chunks-es/printExtractMessages.js +0 -44
  61. package/dist/_chunks-es/printExtractMessages.js.map +0 -1
  62. package/dist/_chunks-es/resolveBuildContext.js +0 -717
  63. package/dist/_chunks-es/resolveBuildContext.js.map +0 -1
  64. package/dist/_chunks-es/resolveRolldownConfig.js +0 -117
  65. package/dist/_chunks-es/resolveRolldownConfig.js.map +0 -1
  66. package/dist/_chunks-es/spinner.js +0 -16
  67. package/dist/_chunks-es/spinner.js.map +0 -1
  68. package/dist/_chunks-es/watchAction.js +0 -160
  69. package/dist/_chunks-es/watchAction.js.map +0 -1
  70. package/dist/_chunks-es/watchConfigFiles.js +0 -49
  71. package/dist/_chunks-es/watchConfigFiles.js.map +0 -1
@@ -0,0 +1,179 @@
1
+ import { n as createLogger, r as isRecord, t as handleError } from "./handleError-83GwKIFM.js";
2
+ import { a as loadPkgWithReporting, o as loadConfig, t as resolveBuildContext } from "./resolveBuildContext-CwqbTV6p.js";
3
+ import { n as resolveTsdownBuilds, t as resolveTsdownConfig } from "./resolveTsdownConfig-2OdGF-dM.js";
4
+ import path from "node:path";
5
+ import { up } from "empathic/package";
6
+ import { build } from "tsdown";
7
+ import { readFile, writeFile } from "node:fs/promises";
8
+ import { switchMap } from "rxjs";
9
+ /**
10
+ * The no-op JS shim file name for a CSS file under vanilla-extract compat mode.
11
+ *
12
+ * `bundle.css` → `bundle-css.js` — deliberately not `${cssFileName}.js` (`bundle.css.js`),
13
+ * which vanilla-extract's `cssFileFilter` (`/\.css\.(js|cjs|mjs|jsx|ts|tsx)$/`) would treat as
14
+ * a stylesheet module. Kept in sync with `cssShimFileName` in
15
+ * `@sanity/vanilla-extract-rolldown-plugin`.
16
+ *
17
+ * @internal
18
+ */
19
+ function cssShimFileName(cssFileName) {
20
+ return `${cssFileName.replace(/\.css$/, "-css")}.js`;
21
+ }
22
+ /**
23
+ * The `.d.ts` companion for {@link cssShimFileName}. `bundle.css` → `bundle-css.d.ts`.
24
+ *
25
+ * @internal
26
+ */
27
+ function cssShimDtsFileName(cssFileName) {
28
+ return `${cssFileName.replace(/\.css$/, "-css")}.d.ts`;
29
+ }
30
+ /**
31
+ * Build the conditional CSS export object that vanilla-extract compat mode expects, e.g.
32
+ * ```json
33
+ * {
34
+ * "types": "./dist/bundle-css.d.ts",
35
+ * "browser": "./dist/bundle.css",
36
+ * "style": "./dist/bundle.css",
37
+ * "node": "./dist/bundle-css.js",
38
+ * "default": "./dist/bundle-css.js"
39
+ * }
40
+ * ```
41
+ * The shim is named `bundle-css.js` (not `bundle.css.js`) so it does not match
42
+ * vanilla-extract's `cssFileFilter`. An explicit `types` condition (rather than relying on
43
+ * TypeScript's extension-substitution fallback, which only works when the shim shares the CSS
44
+ * file's basename, and which TypeScript is deprecating anyway - microsoft/TypeScript#50762)
45
+ * points resolvers straight at the shim's declaration file.
46
+ *
47
+ * Kept in sync with `createConditionalCssExport` in `@sanity/vanilla-extract-tsdown-plugin`,
48
+ * which writes the same entry through tsdown's `exports.customExports` during full builds.
49
+ */
50
+ function createConditionalCssExport(cssFile, shimFile, shimDtsFile) {
51
+ return {
52
+ types: shimDtsFile,
53
+ browser: cssFile,
54
+ style: cssFile,
55
+ node: shimFile,
56
+ default: shimFile
57
+ };
58
+ }
59
+ function hasMatchingExport(value, expected) {
60
+ if (typeof value != "object" || !value) return !1;
61
+ let actual = Object.fromEntries(Object.entries(value)), keys = Object.keys(expected);
62
+ return keys.length === Object.keys(actual).length && keys.every((key) => actual[key] === expected[key]);
63
+ }
64
+ /**
65
+ * Insert (or replace) the `"./<cssName>"` export in an `exports`-shaped map, preserving the existing
66
+ * order and placing it before `./package.json` when present.
67
+ */
68
+ function insertCssExport(exports, exportKey, conditionalExport) {
69
+ let nextExports = {}, inserted = !1;
70
+ for (let [key, value] of Object.entries(exports)) key !== exportKey && (key === "./package.json" && !inserted && (nextExports[exportKey] = conditionalExport, inserted = !0), nextExports[key] = value);
71
+ return inserted || (nextExports[exportKey] = conditionalExport), nextExports;
72
+ }
73
+ function detectIndent(source) {
74
+ let match = source.match(/\n([ \t]+)\S/);
75
+ if (!match) return 2;
76
+ let indent = match[1];
77
+ return indent.includes(" ") ? " " : indent.length;
78
+ }
79
+ /**
80
+ * Write the conditional `"./<cssName>"` export to `package.json` (used by vanilla-extract compat
81
+ * mode), so userland does not have to maintain it by hand. The write is idempotent: if the export
82
+ * already matches, the file is left untouched.
83
+ *
84
+ * Full builds write this entry through tsdown's `exports.customExports` (the
85
+ * `@sanity/vanilla-extract-tsdown-plugin` composition), but watch mode disables tsdown's
86
+ * `exports` feature (a `package.json` write per rebuild would loop the watcher) — `pkg watch`
87
+ * calls this once per context instead, like v11 did.
88
+ *
89
+ * When `publishConfig.exports` is present, the same conditional CSS export is mirrored into it. The
90
+ * conditional CSS export has no `source`/`development`/`monorepo` conditions to strip, so the entry
91
+ * is identical in both places. Keeping them in sync prevents the `publishConfig.exports` validation
92
+ * from failing with a "missing export path" error for the auto-added `./<cssName>` export.
93
+ *
94
+ * @internal
95
+ */
96
+ async function writeBundleCssExports(options) {
97
+ let { cwd, distPath, cssName, logger } = options, pkgPath = path.resolve(cwd, "package.json"), source = await readFile(pkgPath, "utf8"), pkg = JSON.parse(source), distRel = (path.relative(cwd, distPath) || "dist").split(path.sep).join("/"), exportKey = `./${cssName}`, conditionalExport = createConditionalCssExport(`./${path.posix.join(distRel, cssName)}`, `./${path.posix.join(distRel, cssShimFileName(cssName))}`, `./${path.posix.join(distRel, cssShimDtsFileName(cssName))}`), publishConfig = pkg.publishConfig, publishConfigExports = isRecord(publishConfig?.exports) ? publishConfig.exports : void 0, exportsMatch = hasMatchingExport(pkg.exports?.[exportKey], conditionalExport), publishConfigExportsMatch = !publishConfigExports || hasMatchingExport(publishConfigExports[exportKey], conditionalExport);
98
+ exportsMatch && publishConfigExportsMatch || (pkg.exports = insertCssExport(pkg.exports ?? {}, exportKey, conditionalExport), publishConfig && publishConfigExports && (publishConfig.exports = insertCssExport(publishConfigExports, exportKey, conditionalExport)), await writeFile(pkgPath, `${JSON.stringify(pkg, null, detectIndent(source))}\n`), logger.log(`Updated package.json: added \`exports["${exportKey}"]\`${publishConfigExports ? ` and \`publishConfig.exports["${exportKey}"]\`` : ""} for vanilla-extract compat mode`));
99
+ }
100
+ const asyncDispose = Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose");
101
+ /** @public */
102
+ async function watch(options) {
103
+ let { cwd, strict = !1, tsconfig: tsconfigOption, signal } = options, logger = createLogger(), { watchConfigFiles } = await import("./watchConfigFiles-AGBDblwf.js"), configFiles$ = await watchConfigFiles({
104
+ cwd,
105
+ logger
106
+ }), bundles = [], runId = 0, disposeBundles = async () => {
107
+ let disposing = bundles;
108
+ bundles = [];
109
+ for (let bundle of disposing) await bundle[asyncDispose]();
110
+ }, ctxSubscription = configFiles$.pipe(switchMap(async () => {
111
+ let pkgPath = up({ cwd });
112
+ if (!pkgPath) throw Error("missing package.json", { cause: { cwd } });
113
+ let config = await loadConfig({
114
+ cwd,
115
+ pkgPath
116
+ }), { parseStrictOptions } = await import("./resolveBuildContext-CwqbTV6p.js").then((n) => n.n), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({
117
+ pkgPath,
118
+ logger,
119
+ strict,
120
+ strictOptions
121
+ }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json";
122
+ return resolveBuildContext({
123
+ config,
124
+ cwd,
125
+ logger,
126
+ pkg,
127
+ strict,
128
+ tsconfig
129
+ });
130
+ })).subscribe(async (ctx) => {
131
+ let id = ++runId, runBundles = [];
132
+ try {
133
+ await disposeBundles();
134
+ let vanillaExtract = ctx.config?.vanillaExtract;
135
+ if (vanillaExtract) {
136
+ let veOptions = vanillaExtract === !0 ? {} : vanillaExtract, inject = veOptions.inject ?? { nodeCompat: !0 };
137
+ isRecord(inject) && inject.nodeCompat && await writeBundleCssExports({
138
+ cwd,
139
+ distPath: ctx.distPath,
140
+ cssName: veOptions.fileName || "bundle.css",
141
+ logger
142
+ });
143
+ }
144
+ let builds = resolveTsdownBuilds(ctx), first = !0;
145
+ for (let buildDef of builds) {
146
+ if (id !== runId) break;
147
+ let inlineConfig = await resolveTsdownConfig(ctx, buildDef, {
148
+ clean: first,
149
+ watch: !0
150
+ });
151
+ first = !1, runBundles.push(...await build(inlineConfig));
152
+ }
153
+ if (id !== runId) {
154
+ for (let bundle of runBundles) await bundle[asyncDispose]();
155
+ return;
156
+ }
157
+ bundles = runBundles, logger.success(`${ctx.pkg.name}: watching for file changes\u2026`), logger.log();
158
+ } catch (err) {
159
+ ctx.logger.error(err), ctx.logger.log(), process.exit(1);
160
+ }
161
+ });
162
+ signal && signal.addEventListener("abort", () => {
163
+ runId++, ctxSubscription.unsubscribe(), disposeBundles();
164
+ }, { once: !0 });
165
+ }
166
+ async function watchAction(options) {
167
+ try {
168
+ await watch({
169
+ cwd: process.cwd(),
170
+ strict: options.strict,
171
+ tsconfig: options.tsconfig
172
+ });
173
+ } catch (err) {
174
+ handleError(err);
175
+ }
176
+ }
177
+ export { watchAction };
178
+
179
+ //# sourceMappingURL=watchAction-uRPAvgLE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchAction-uRPAvgLE.js","names":["findPkgPath","tsdownBuild"],"sources":["../src/node/core/pkg/cssShimFileName.ts","../src/node/core/pkg/writeBundleCssExports.ts","../src/node/watch.ts","../src/cli/watchAction.ts"],"sourcesContent":["/**\n * The no-op JS shim file name for a CSS file under vanilla-extract compat mode.\n *\n * `bundle.css` → `bundle-css.js` — deliberately not `${cssFileName}.js` (`bundle.css.js`),\n * which vanilla-extract's `cssFileFilter` (`/\\.css\\.(js|cjs|mjs|jsx|ts|tsx)$/`) would treat as\n * a stylesheet module. Kept in sync with `cssShimFileName` in\n * `@sanity/vanilla-extract-rolldown-plugin`.\n *\n * @internal\n */\nexport function cssShimFileName(cssFileName: string): string {\n return `${cssFileName.replace(/\\.css$/, '-css')}.js`\n}\n\n/**\n * The `.d.ts` companion for {@link cssShimFileName}. `bundle.css` → `bundle-css.d.ts`.\n *\n * @internal\n */\nexport function cssShimDtsFileName(cssFileName: string): string {\n return `${cssFileName.replace(/\\.css$/, '-css')}.d.ts`\n}\n","import {readFile, writeFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport type {Logger} from '../../logger.ts'\nimport {isRecord} from '../isRecord.ts'\nimport {cssShimDtsFileName, cssShimFileName} from './cssShimFileName.ts'\n\n/**\n * Build the conditional CSS export object that vanilla-extract compat mode expects, e.g.\n * ```json\n * {\n * \"types\": \"./dist/bundle-css.d.ts\",\n * \"browser\": \"./dist/bundle.css\",\n * \"style\": \"./dist/bundle.css\",\n * \"node\": \"./dist/bundle-css.js\",\n * \"default\": \"./dist/bundle-css.js\"\n * }\n * ```\n * The shim is named `bundle-css.js` (not `bundle.css.js`) so it does not match\n * vanilla-extract's `cssFileFilter`. An explicit `types` condition (rather than relying on\n * TypeScript's extension-substitution fallback, which only works when the shim shares the CSS\n * file's basename, and which TypeScript is deprecating anyway - microsoft/TypeScript#50762)\n * points resolvers straight at the shim's declaration file.\n *\n * Kept in sync with `createConditionalCssExport` in `@sanity/vanilla-extract-tsdown-plugin`,\n * which writes the same entry through tsdown's `exports.customExports` during full builds.\n */\nfunction createConditionalCssExport(cssFile: string, shimFile: string, shimDtsFile: string) {\n return {types: shimDtsFile, browser: cssFile, style: cssFile, node: shimFile, default: shimFile}\n}\n\nfunction hasMatchingExport(value: unknown, expected: Record<string, string>): boolean {\n if (typeof value !== 'object' || value === null) return false\n const actual = Object.fromEntries(Object.entries(value))\n const keys = Object.keys(expected)\n return (\n keys.length === Object.keys(actual).length && keys.every((key) => actual[key] === expected[key])\n )\n}\n\n/**\n * Insert (or replace) the `\"./<cssName>\"` export in an `exports`-shaped map, preserving the existing\n * order and placing it before `./package.json` when present.\n */\nfunction insertCssExport(\n exports: Record<string, unknown>,\n exportKey: string,\n conditionalExport: Record<string, string>,\n): Record<string, unknown> {\n const nextExports: Record<string, unknown> = {}\n let inserted = false\n for (const [key, value] of Object.entries(exports)) {\n if (key === exportKey) continue\n if (key === './package.json' && !inserted) {\n nextExports[exportKey] = conditionalExport\n inserted = true\n }\n nextExports[key] = value\n }\n if (!inserted) {\n nextExports[exportKey] = conditionalExport\n }\n return nextExports\n}\n\nfunction detectIndent(source: string): string | number {\n const match = source.match(/\\n([ \\t]+)\\S/)\n if (!match) return 2\n const indent = match[1]!\n return indent.includes('\\t') ? '\\t' : indent.length\n}\n\n/**\n * Write the conditional `\"./<cssName>\"` export to `package.json` (used by vanilla-extract compat\n * mode), so userland does not have to maintain it by hand. The write is idempotent: if the export\n * already matches, the file is left untouched.\n *\n * Full builds write this entry through tsdown's `exports.customExports` (the\n * `@sanity/vanilla-extract-tsdown-plugin` composition), but watch mode disables tsdown's\n * `exports` feature (a `package.json` write per rebuild would loop the watcher) — `pkg watch`\n * calls this once per context instead, like v11 did.\n *\n * When `publishConfig.exports` is present, the same conditional CSS export is mirrored into it. The\n * conditional CSS export has no `source`/`development`/`monorepo` conditions to strip, so the entry\n * is identical in both places. Keeping them in sync prevents the `publishConfig.exports` validation\n * from failing with a \"missing export path\" error for the auto-added `./<cssName>` export.\n *\n * @internal\n */\nexport async function writeBundleCssExports(options: {\n cwd: string\n distPath: string\n cssName: string\n logger: Logger\n}): Promise<void> {\n const {cwd, distPath, cssName, logger} = options\n\n const pkgPath = path.resolve(cwd, 'package.json')\n const source = await readFile(pkgPath, 'utf8')\n // oxlint-disable-next-line no-unsafe-type-assertion\n const pkg = JSON.parse(source) as {\n exports?: Record<string, unknown>\n publishConfig?: {exports?: Record<string, unknown>}\n }\n\n // Normalize to POSIX separators - `path.relative` uses `\\\\` on Windows, but `exports` paths in\n // package.json must always use `/`.\n const distRel = (path.relative(cwd, distPath) || 'dist').split(path.sep).join('/')\n const exportKey = `./${cssName}`\n const cssFile = `./${path.posix.join(distRel, cssName)}`\n const shimFile = `./${path.posix.join(distRel, cssShimFileName(cssName))}`\n const shimDtsFile = `./${path.posix.join(distRel, cssShimDtsFileName(cssName))}`\n const conditionalExport = createConditionalCssExport(cssFile, shimFile, shimDtsFile)\n\n // Only mirror into `publishConfig.exports` when it already exists; never create it here.\n const publishConfig = pkg.publishConfig\n const publishConfigExports = isRecord(publishConfig?.exports) ? publishConfig.exports : undefined\n\n const exportsMatch = hasMatchingExport(pkg.exports?.[exportKey], conditionalExport)\n const publishConfigExportsMatch =\n !publishConfigExports || hasMatchingExport(publishConfigExports[exportKey], conditionalExport)\n\n if (exportsMatch && publishConfigExportsMatch) {\n return\n }\n\n pkg.exports = insertCssExport(pkg.exports ?? {}, exportKey, conditionalExport)\n\n if (publishConfig && publishConfigExports) {\n publishConfig.exports = insertCssExport(publishConfigExports, exportKey, conditionalExport)\n }\n\n await writeFile(pkgPath, `${JSON.stringify(pkg, null, detectIndent(source))}\\n`)\n logger.log(\n `Updated package.json: added \\`exports[\"${exportKey}\"]\\`${\n publishConfigExports ? ` and \\`publishConfig.exports[\"${exportKey}\"]\\`` : ''\n } for vanilla-extract compat mode`,\n )\n}\n","import {up as findPkgPath} from 'empathic/package'\nimport type {Subscription} from 'rxjs'\nimport {switchMap} from 'rxjs'\nimport {build as tsdownBuild, type TsdownBundle} from 'tsdown'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {isRecord} from './core/isRecord.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {writeBundleCssExports} from './core/pkg/writeBundleCssExports.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveTsdownBuilds} from './tasks/tsdown/resolveTsdownBuilds.ts'\nimport {resolveTsdownConfig} from './tasks/tsdown/resolveTsdownConfig.ts'\n\nconst asyncDispose: typeof Symbol.asyncDispose =\n Symbol.asyncDispose || Symbol.for('Symbol.asyncDispose')\n\n/** @public */\nexport async function watch(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n signal?: AbortSignal\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption, signal} = options\n\n const logger = createLogger()\n\n const {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n // Every rebuild of the waterfall holds tsdown watchers (one per platform build); they are\n // disposed when the config files change (the waterfall restarts) or the signal aborts.\n // RxJS does not await async subscriber callbacks, so a monotonically increasing run id\n // guards the rebuilds: only the latest run may publish into `bundles`, and a run that turns\n // stale mid-flight (a newer config-file event, or the abort signal) disposes the watchers\n // it created instead of leaking them.\n let bundles: TsdownBundle[] = []\n let runId = 0\n const disposeBundles = async () => {\n const disposing = bundles\n bundles = []\n for (const bundle of disposing) {\n await bundle[asyncDispose]()\n }\n }\n\n const ctx$ = configFiles$.pipe(\n switchMap(async () => {\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('missing package.json', {cause: {cwd}})\n }\n\n const config = await loadConfig({cwd, pkgPath})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n return resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n }),\n )\n\n const ctxSubscription: Subscription = ctx$.subscribe(async (ctx) => {\n const id = ++runId\n const runBundles: TsdownBundle[] = []\n try {\n await disposeBundles()\n\n // Full builds write the conditional `./<css>` export through tsdown's\n // `exports.customExports` composition, but watch mode disables tsdown's `exports` feature\n // (a package.json write per rebuild would loop the watcher). Keep the export in sync here\n // instead, once per context, like v11 — the write is idempotent, so it won't loop.\n const vanillaExtract = ctx.config?.vanillaExtract\n if (vanillaExtract) {\n const veOptions = vanillaExtract === true ? {} : vanillaExtract\n // `@sanity/tsdown-config` defaults `inject` to `{nodeCompat: true}` (the conditional\n // CSS export pattern); an explicit user `inject` replaces that default\n const inject = veOptions.inject ?? {nodeCompat: true}\n if (isRecord(inject) && inject['nodeCompat']) {\n await writeBundleCssExports({\n cwd,\n distPath: ctx.distPath,\n cssName: veOptions.fileName || 'bundle.css',\n logger,\n })\n }\n }\n\n const builds = resolveTsdownBuilds(ctx)\n\n let first = true\n for (const buildDef of builds) {\n if (id !== runId) break\n\n const inlineConfig = await resolveTsdownConfig(ctx, buildDef, {\n clean: first,\n watch: true,\n })\n first = false\n\n runBundles.push(...(await tsdownBuild(inlineConfig)))\n }\n\n if (id !== runId) {\n // A newer run (or the abort signal) took over while this rebuild was in flight —\n // dispose everything this run created instead of publishing it\n for (const bundle of runBundles) {\n await bundle[asyncDispose]()\n }\n return\n }\n\n bundles = runBundles\n\n logger.success(`${ctx.pkg.name}: watching for file changes\\u2026`)\n logger.log()\n } catch (err) {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n }\n })\n\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n runId++\n ctxSubscription.unsubscribe()\n void disposeBundles()\n },\n {once: true},\n )\n }\n}\n","import {watch} from '../node/watch.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function watchAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await watch({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,SAAgB,gBAAgB,aAA6B;CAC3D,OAAO,GAAG,YAAY,QAAQ,UAAU,MAAM,EAAE;AAClD;;;;;;AAOA,SAAgB,mBAAmB,aAA6B;CAC9D,OAAO,GAAG,YAAY,QAAQ,UAAU,MAAM,EAAE;AAClD;;;;;;;;;;;;;;;;;;;;;ACKA,SAAS,2BAA2B,SAAiB,UAAkB,aAAqB;CAC1F,OAAO;EAAC,OAAO;EAAa,SAAS;EAAS,OAAO;EAAS,MAAM;EAAU,SAAS;CAAQ;AACjG;AAEA,SAAS,kBAAkB,OAAgB,UAA2C;CACpF,IAAI,OAAO,SAAU,aAAY,OAAgB,OAAO;CACxD,IAAM,SAAS,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,GACjD,OAAO,OAAO,KAAK,QAAQ;CACjC,OACE,KAAK,WAAW,OAAO,KAAK,MAAM,CAAC,CAAC,UAAU,KAAK,OAAO,QAAQ,OAAO,SAAS,SAAS,IAAI;AAEnG;;;;;AAMA,SAAS,gBACP,SACA,WACA,mBACyB;CACzB,IAAM,cAAuC,CAAC,GAC1C,WAAW;CACf,KAAK,IAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAC3C,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C,YAAY,GAAI;IACpD,AAAI,SAAS,MAAM,KAAK,OAAO,cAC7B,MAAM,sBAAsB;KAC1B;KACA,UAAU,IAAI;KACd,SAAS,UAAU,YAAY;KAC/B;IACF,CAAC;GAEL;GAEA,IAAM,SAAS,oBAAoB,GAAG,GAElC,QAAQ;GACZ,KAAK,IAAM,YAAY,QAAQ;IAC7B,IAAI,OAAO,OAAO;IAElB,IAAM,eAAe,MAAM,oBAAoB,KAAK,UAAU;KAC5D,OAAO;KACP,OAAO;IACT,CAAC;IAGD,AAFA,QAAQ,IAER,WAAW,KAAK,GAAI,MAAMC,MAAY,YAAY,CAAE;GACtD;GAEA,IAAI,OAAO,OAAO;IAGhB,KAAK,IAAM,UAAU,YACnB,MAAM,OAAO,aAAa,CAAC;IAE7B;GACF;GAKA,AAHA,UAAU,YAEV,OAAO,QAAQ,GAAG,IAAI,IAAI,KAAK,kCAAkC,GACjE,OAAO,IAAI;EACb,SAAS,KAAK;GAIZ,AAHA,IAAI,OAAO,MAAM,GAAG,GACpB,IAAI,OAAO,IAAI,GAEf,QAAQ,KAAK,CAAC;EAChB;CACF,CAAC;CAED,AAAI,UACF,OAAO,iBACL,eACM;EAGJ,AAFA,SACA,gBAAgB,YAAY,GAC5B,eAAoB;CACtB,GACA,EAAC,MAAM,GAAI,CACb;AAEJ;ACrIA,eAAsB,YAAY,SAA+D;CAC/F,IAAI;EACF,MAAM,MAAM;GACV,KAAK,QAAQ,IAAI;GACjB,QAAQ,QAAQ;GAChB,UAAU,QAAQ;EACpB,CAAC;CACH,SAAS,KAAK;EACZ,YAAY,GAAG;CACjB;AACF"}
@@ -0,0 +1,43 @@
1
+ import path from "node:path";
2
+ import { Observable } from "rxjs";
3
+ import { distinctUntilChanged, scan, startWith } from "rxjs/operators";
4
+ import { globby } from "globby";
5
+ import * as chokidar from "chokidar";
6
+ function globFiles(patterns) {
7
+ return globby(patterns.map((pattern) => pattern.split(path.sep).join(path.posix.sep)));
8
+ }
9
+ function watchFiles(patterns) {
10
+ return new Observable((observer) => {
11
+ let watcher = chokidar.watch(patterns, { ignoreInitial: !0 });
12
+ function handleFileEvent(type, file) {
13
+ type === "error" || file instanceof Error ? observer.error(file) : observer.next({
14
+ type,
15
+ file
16
+ });
17
+ }
18
+ return watcher.on("all", handleFileEvent), () => {
19
+ watcher.off("all", handleFileEvent), watcher.close();
20
+ };
21
+ });
22
+ }
23
+ async function watchConfigFiles(options) {
24
+ let { cwd, logger } = options, initialFiles = await globFiles([
25
+ path.resolve(cwd, "package.json"),
26
+ path.resolve(cwd, "package.config.cjs"),
27
+ path.resolve(cwd, "package.config.js"),
28
+ path.resolve(cwd, "package.config.ts"),
29
+ path.resolve(cwd, "package.config.mjs"),
30
+ 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());
40
+ }
41
+ export { watchConfigFiles };
42
+
43
+ //# sourceMappingURL=watchConfigFiles-AGBDblwf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchConfigFiles-AGBDblwf.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}): Promise<Observable<string[]>> {\n const {cwd, logger} = options\n\n const initialFiles = await globFiles([\n path.resolve(cwd, 'package.json'),\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 fileEvent$ = watchFiles([\n path.resolve(cwd, 'package.json'),\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 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 startW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AAI,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "11.0.17",
3
+ "version": "12.0.0",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -29,6 +29,7 @@
29
29
  "./package.json": "./package.json"
30
30
  },
31
31
  "main": "./dist/index.js",
32
+ "module": "./dist/index.js",
32
33
  "types": "./dist/index.d.ts",
33
34
  "bin": {
34
35
  "pkg": "./bin/pkg-utils.js",
@@ -38,65 +39,50 @@
38
39
  "bin",
39
40
  "dist",
40
41
  "tsconfig",
42
+ "MIGRATE.md",
41
43
  "!dist/stats.html"
42
44
  ],
43
45
  "browserslist": "extends @sanity/browserslist-config",
44
46
  "dependencies": {
45
- "@babel/core": "^7.29.7",
46
- "@babel/preset-typescript": "^7.29.7",
47
47
  "@microsoft/api-extractor": "^7.58.12",
48
48
  "@microsoft/tsdoc-config": "^0.18.1",
49
- "@optimize-lodash/rollup-plugin": "^6.0.0",
50
- "@rollup/plugin-alias": "^6.0.0",
51
- "@rollup/plugin-babel": "^7.1.0",
52
- "@rollup/plugin-commonjs": "^29.0.3",
53
- "@rollup/plugin-json": "^6.1.0",
54
- "@rollup/plugin-node-resolve": "^16.0.3",
55
- "@rollup/plugin-replace": "^6.0.3",
56
- "@rollup/plugin-terser": "^1.0.0",
57
49
  "@sanity/browserslist-config": "^1.0.5",
58
50
  "@typescript/typescript6": "^6.0.2",
59
- "@vanilla-extract/rollup-plugin": "^1.5.4",
60
51
  "browserslist": "^4.28.7",
52
+ "browserslist-to-esbuild": "2.1.1",
61
53
  "cac": "^7.0.0",
62
- "chalk": "^5.6.2",
54
+ "chalk": "^6.0.0",
63
55
  "chokidar": "^5.0.0",
64
56
  "empathic": "^2.0.1",
65
- "esbuild": "^0.28.1",
66
57
  "find-config": "^1.0.0",
67
58
  "get-latest-version": "^6.0.1",
68
59
  "globby": "^16.2.2",
69
60
  "jsonc-parser": "^3.3.1",
70
- "lightningcss": "^1.33.0",
71
61
  "mkdirp": "^3.0.1",
72
62
  "outdent": "^0.8.0",
73
63
  "prettier": "^3.9.6",
74
64
  "pretty-bytes": "^7.1.1",
75
65
  "prompts": "^2.4.2",
76
- "rimraf": "^6.1.3",
77
- "rolldown": "1.2.0",
78
- "rolldown-plugin-dts": "0.27.14",
79
- "rollup": "^4.62.3",
80
- "rollup-plugin-esbuild": "^6.2.1",
66
+ "publint": "^0.3.22",
81
67
  "rxjs": "^7.8.2",
82
68
  "treeify": "^1.1.0",
69
+ "tsdown": "^0.22.14",
83
70
  "tsx": "^4.23.1",
84
71
  "zod": "^4.4.3",
85
72
  "zod-validation-error": "^5.0.0",
73
+ "@sanity/tsdown-config": "^0.22.0",
86
74
  "@sanity/parse-package-json": "^2.2.11"
87
75
  },
88
76
  "devDependencies": {
89
- "@types/babel__core": "^7.20.5",
90
77
  "@types/find-config": "^1.0.4",
91
78
  "@types/node": "^24.13.3",
92
79
  "@types/parse-github-url": "^1.0.3",
93
80
  "@types/prompts": "^2.4.9",
94
81
  "@types/treeify": "^1.0.3",
95
82
  "babel-plugin-react-compiler": "1.0.0",
96
- "browserslist-to-esbuild": "2.1.1",
97
83
  "nanoexec": "^1.1.0",
98
84
  "parse-github-url": "^1.0.4",
99
- "rollup-plugin-visualizer": "^7.0.1",
85
+ "rimraf": "^6.1.3",
100
86
  "typescript": "7.0.2",
101
87
  "vitest": "^4.1.10",
102
88
  "@sanity/tsconfig": "^2.2.1"
@@ -111,7 +97,7 @@
111
97
  }
112
98
  },
113
99
  "engines": {
114
- "node": ">=20.19 <22 || >=22.12"
100
+ "node": "^22.18.0 || >=24.11.0"
115
101
  },
116
102
  "scripts": {
117
103
  "build": "run-s clean build:pkg check:pkg",
@@ -1,195 +0,0 @@
1
- import path from "node:path";
2
- import { up } from "empathic/package";
3
- import { rimraf } from "rimraf";
4
- import { loadConfig } from "./defaults.js";
5
- import { buildTaskHandlers, resolveVanillaExtract, writeBundleCssExports, resolveVanillaExtractCssName } from "./index.js";
6
- import { getTargetPaths, loadPkgWithReporting, resolveBuildContext } from "./resolveBuildContext.js";
7
- import { createLogger, handleError } from "./handleError.js";
8
- import { createSpinner } from "./spinner.js";
9
- function resolveBuildTasks(ctx) {
10
- const { config, pkg, target } = ctx, bundles = config?.bundles || [], tasks = [], exports = Object.entries(ctx.exports || {}).map(
11
- ([_path, exp]) => Object.assign({}, exp, { _path })
12
- ), dtsTask = {
13
- type: "build:dts",
14
- entries: []
15
- }, rolldownDtsTask = {}, rollupTasks = {};
16
- function addRollupTaskEntry(format, runtime, entry) {
17
- const buildId = `${format}:${runtime}`;
18
- ctx.dts === "rolldown" && (rolldownDtsTask[buildId] ? rolldownDtsTask[buildId].entries.push(entry) : rolldownDtsTask[buildId] = {
19
- type: "rolldown:dts",
20
- buildId,
21
- entries: [entry],
22
- runtime,
23
- format,
24
- target: target[runtime]
25
- }), ctx.emitDeclarationOnly || (rollupTasks[buildId] ? rollupTasks[buildId].entries.push(entry) : rollupTasks[buildId] = {
26
- type: "build:js",
27
- buildId,
28
- entries: [entry],
29
- runtime,
30
- format,
31
- target: target[runtime]
32
- });
33
- }
34
- if (ctx.dts === "api-extractor") {
35
- for (const exp of exports) {
36
- const importId = path.join(pkg.name, exp._path);
37
- exp.source?.endsWith(".ts") && dtsTask.entries.push({
38
- importId,
39
- exportPath: exp._path,
40
- sourcePath: exp.source,
41
- targetPaths: getTargetPaths(pkg.type, exp)
42
- }), exp.browser?.source?.endsWith(".ts") && dtsTask.entries.push({
43
- importId,
44
- exportPath: exp._path,
45
- sourcePath: exp.browser.source,
46
- targetPaths: getTargetPaths(pkg.type, exp.browser)
47
- }), exp.node?.source?.endsWith(".ts") && dtsTask.entries.push({
48
- importId,
49
- exportPath: exp._path,
50
- sourcePath: exp.node.source,
51
- targetPaths: getTargetPaths(pkg.type, exp.node)
52
- });
53
- }
54
- for (const bundle of bundles)
55
- if (bundle.source?.endsWith(".ts")) {
56
- const exportPath = (bundle.import || bundle.require).replace(/\.[mc]?js$/, ""), importId = path.join(pkg.name, exportPath);
57
- dtsTask.entries.push({
58
- importId,
59
- exportPath,
60
- sourcePath: bundle.source,
61
- targetPaths: getTargetPaths(pkg.type, bundle)
62
- });
63
- }
64
- dtsTask.entries.length && tasks.push(dtsTask);
65
- }
66
- for (const exp of exports) {
67
- const output = exp.require;
68
- output && addRollupTaskEntry("commonjs", ctx.runtime, {
69
- path: exp._path,
70
- source: exp.source,
71
- output
72
- });
73
- }
74
- for (const exp of exports) {
75
- const output = exp.import;
76
- output && addRollupTaskEntry("esm", ctx.runtime, {
77
- path: exp._path,
78
- source: exp.source,
79
- output
80
- });
81
- }
82
- for (const exp of exports) {
83
- const output = exp.browser?.require;
84
- output && addRollupTaskEntry("commonjs", "browser", {
85
- path: exp._path,
86
- source: exp.browser?.source || exp.source,
87
- output
88
- });
89
- }
90
- for (const exp of exports) {
91
- const output = exp.browser?.import;
92
- output && addRollupTaskEntry("esm", "browser", {
93
- path: exp._path,
94
- source: exp.browser?.source || exp.source,
95
- output
96
- });
97
- }
98
- for (const exp of exports) {
99
- const output = exp.node?.require;
100
- output && addRollupTaskEntry("commonjs", "node", {
101
- path: exp._path,
102
- source: exp.node?.source || exp.source,
103
- output
104
- });
105
- }
106
- for (const exp of exports) {
107
- const output = exp.node?.import;
108
- output && addRollupTaskEntry("esm", "node", {
109
- path: exp._path,
110
- source: exp.node?.source || exp.source,
111
- output
112
- });
113
- }
114
- for (const bundle of bundles) {
115
- const idx = bundles.indexOf(bundle);
116
- bundle.require && addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
117
- path: `__$$bundle_cjs_${idx}$$__`,
118
- source: bundle.source,
119
- output: bundle.require
120
- }), bundle.import && addRollupTaskEntry("esm", bundle.runtime || ctx.runtime, {
121
- path: `__$$bundle_esm_${idx}$$__`,
122
- source: bundle.source,
123
- output: bundle.import
124
- });
125
- }
126
- return tasks.push(...Object.values(rolldownDtsTask)), tasks.push(...Object.values(rollupTasks)), tasks;
127
- }
128
- async function build(options) {
129
- const {
130
- cwd,
131
- emitDeclarationOnly,
132
- strict = !1,
133
- tsconfig: tsconfigOption,
134
- clean = !1,
135
- quiet = !1
136
- } = options, logger = createLogger(quiet), pkgPath = up({ cwd });
137
- if (!pkgPath)
138
- throw new Error("no package.json found", { cause: { cwd } });
139
- const config = await loadConfig({ cwd, pkgPath }), { parseStrictOptions } = await import("./resolveBuildContext.js").then(function(n) {
140
- return n.strict;
141
- }), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ pkgPath, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({
142
- config,
143
- cwd,
144
- emitDeclarationOnly,
145
- logger,
146
- pkg,
147
- strict,
148
- tsconfig
149
- });
150
- clean && (quiet || logger.log(
151
- `Deleting the \`dist\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`
152
- ), await rimraf(ctx.distPath));
153
- const buildTasks = resolveBuildTasks(ctx);
154
- for (const task of buildTasks) {
155
- const handler = buildTaskHandlers[task.type], taskName = handler.name(ctx, task), spinner = createSpinner(taskName, quiet);
156
- try {
157
- const result = await handler.exec(ctx, task).toPromise();
158
- spinner.complete(), ctx.logger.log(), handler.complete(ctx, task, result);
159
- } catch (err) {
160
- if (spinner.error(), err instanceof Error) {
161
- const RE_CWD = new RegExp(cwd, "g");
162
- ctx.logger.error(err.message.replace(RE_CWD, ".")), ctx.logger.log();
163
- }
164
- handler.error(ctx, task, err), process.exit(1);
165
- }
166
- }
167
- const vanillaExtract = resolveVanillaExtract(config);
168
- vanillaExtract.compatMode && await writeBundleCssExports({
169
- cwd,
170
- distPath: ctx.distPath,
171
- cssName: resolveVanillaExtractCssName(vanillaExtract.options, {
172
- compatMode: !0,
173
- runtime: "*"
174
- }),
175
- logger
176
- });
177
- }
178
- async function buildAction(options) {
179
- try {
180
- await build({
181
- cwd: process.cwd(),
182
- emitDeclarationOnly: options.emitDeclarationOnly,
183
- strict: options.strict,
184
- tsconfig: options.tsconfig,
185
- clean: options.clean,
186
- quiet: options.quiet
187
- });
188
- } catch (err) {
189
- handleError(err);
190
- }
191
- }
192
- export {
193
- buildAction
194
- };
195
- //# sourceMappingURL=buildAction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildAction.js","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/build.ts","../../src/cli/buildAction.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsTask} from './tasks/dts/types.ts'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports: Array<PkgExport & {_path: string}> = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => Object.assign({}, exp, {_path}),\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:node tasks\n for (const exp of exports) {\n const output = exp.node?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'node', {\n path: exp._path,\n source: exp.node?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:node tasks\n for (const exp of exports) {\n const output = exp.node?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'node', {\n path: exp._path,\n source: exp.node?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {up as findPkgPath} from 'empathic/package'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {resolveVanillaExtract, resolveVanillaExtractCssName} from './core/config/vanillaExtract.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 {resolveBuildTasks} from './resolveBuildTasks.ts'\nimport {createSpinner} from './spinner.ts'\nimport {buildTaskHandlers} from './tasks/index.ts'\nimport {type BuildTask, type TaskHandler} from './tasks/types.ts'\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n clean = false,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const pkgPath = findPkgPath({cwd})\n if (!pkgPath) {\n throw new Error('no package.json found', {cause: {cwd}})\n }\n const config = await loadConfig({cwd, pkgPath})\n\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n if (clean) {\n if (!quiet) {\n logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n }\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const result = await handler.exec(ctx, task).toPromise()\n\n spinner.complete()\n ctx.logger.log()\n\n handler.complete(ctx, task, result)\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd, 'g')\n\n ctx.logger.error(err.message.replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n handler.error(ctx, task, err)\n\n process.exit(1)\n }\n }\n\n // In vanilla-extract compat mode, make sure package.json declares the conditional `./<css>`\n // export that the injected `import \"<pkg>/<css>\"` resolves through.\n const vanillaExtract = resolveVanillaExtract(config)\n if (vanillaExtract.compatMode) {\n await writeBundleCssExports({\n cwd,\n distPath: ctx.distPath,\n cssName: resolveVanillaExtractCssName(vanillaExtract.options, {\n compatMode: true,\n runtime: '*',\n }),\n logger,\n })\n }\n}\n","import {build} from '../node/build.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function buildAction(options: {\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n try {\n await build({\n cwd: process.cwd(),\n emitDeclarationOnly: options.emitDeclarationOnly,\n strict: options.strict,\n tsconfig: options.tsconfig,\n clean: options.clean,\n quiet: options.quiet,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":["findPkgPath"],"mappings":";;;;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,CAAA,GAErB,UAA8C,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IACpF,CAAC,CAAC,OAAO,GAAG,MAAM,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