@sanity/pkg-utils 10.4.17 → 10.5.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.
@@ -95,6 +95,22 @@ function resolveBuildTasks(ctx) {
95
95
  output
96
96
  });
97
97
  }
98
+ for (const exp of exports$1) {
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$1) {
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
+ }
98
114
  for (const bundle of bundles) {
99
115
  const idx = bundles.indexOf(bundle);
100
116
  bundle.require && addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
@@ -1 +1 @@
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 = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => Object.assign({}, exp, {_path}) as PkgExport & {_path: string},\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 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 {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.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","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":["exports","findPkgPath"],"mappings":";;;;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,MAAM,OAAO,OAAO,CAAA,GAAI,KAAK,EAAC,MAAA,CAAM;AAAA,EAAA,GAG5C,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,kBAAmD,IACnD,cAA0C,CAAA;AAEhD,WAAS,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,QAAI,QAAQ,eACV,gBAAgB,OAAO,IACzB,gBAAgB,OAAO,EAAE,QAAQ,KAAK,KAAK,IAE3C,gBAAgB,OAAO,IAAI;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,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,QAAQ,SAAS,KAAK,MAAM,MAAM;AAAA,IACpC,SAAS,KAAK;AAGZ,UAFA,QAAQ,SAEJ,eAAe,OAAO;AACxB,cAAM,SAAS,IAAI,OAAO,KAAK,GAAG;AAElC,YAAI,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GACjD,IAAI,OAAO,IAAA;AAAA,MACb;AAEA,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;AC5GA,eAAsB,YAAY,SAMhB;AAChB,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,qBAAqB,QAAQ;AAAA,MAC7B,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,MACf,OAAO,QAAQ;AAAA,IAAA,CAChB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
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 = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => Object.assign({}, exp, {_path}) as PkgExport & {_path: string},\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 {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.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","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":["exports","findPkgPath"],"mappings":";;;;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,MAAM,OAAO,OAAO,CAAA,GAAI,KAAK,EAAC,MAAA,CAAM;AAAA,EAAA,GAG5C,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;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AA,MAClB,OAAO,QAAQ;AAAA,MACf,OAAO,QAAQ;AAAA,IAAA,CAChB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
@@ -74,6 +74,22 @@ function resolveWatchTasks(ctx) {
74
74
  output
75
75
  });
76
76
  }
77
+ for (const exp of exports$1) {
78
+ const output = exp.node?.require;
79
+ output && addRollupTaskEntry("commonjs", "node", {
80
+ path: exp._path,
81
+ source: exp.node?.source || exp.source,
82
+ output
83
+ });
84
+ }
85
+ for (const exp of exports$1) {
86
+ const output = exp.node?.import;
87
+ output && addRollupTaskEntry("esm", "node", {
88
+ path: exp._path,
89
+ source: exp.node?.source || exp.source,
90
+ output
91
+ });
92
+ }
77
93
  return dtsTask.entries.length && tasks.push(dtsTask), tasks.push(...Object.values(rollupTasks)), tasks;
78
94
  }
79
95
  async function watch(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"watchAction.js","sources":["../../src/node/resolveWatchTasks.ts","../../src/node/watch.ts","../../src/cli/watchAction.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 {DtsWatchTask} from './tasks/dts/types.ts'\nimport type {RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveWatchTasks(ctx: BuildContext): WatchTask[] {\n const {pkg, target} = ctx\n const tasks: WatchTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => Object.assign({}, exp, {_path}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsWatchTask = {\n type: 'watch:dts',\n entries: [],\n }\n\n const rollupTasks: Record<string, RollupWatchTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'watch:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\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 // 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: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:* 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: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 if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n\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 type {Subscription} from 'rxjs'\nimport {switchMap} from 'rxjs'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveWatchTasks} from './resolveWatchTasks.ts'\nimport {watchTaskHandlers} from './tasks/index.ts'\nimport {type TaskHandler, type WatchTask} from './tasks/types.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 {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n const taskSubscriptions: Subscription[] = []\n\n const ctx$ = configFiles$.pipe(\n switchMap(async (configFiles) => {\n const files = configFiles.map((f) => path.relative(cwd, f))\n\n const packageJsonPath = files.find((f) => f === 'package.json')\n\n const pkgPath = findPkgPath({cwd})\n if (!packageJsonPath || !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 = ctx$.subscribe(async (ctx) => {\n // Unsubscribe previous task subscriptions when config changes trigger a new context\n for (const sub of taskSubscriptions) {\n sub.unsubscribe()\n }\n taskSubscriptions.length = 0\n\n const watchTasks = resolveWatchTasks(ctx)\n\n for (const task of watchTasks) {\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 = watchTaskHandlers[task.type] as TaskHandler<WatchTask, unknown>\n const result$ = handler.exec(ctx, task)\n\n const sub = result$.subscribe({\n error: (err) => {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n },\n next: (result) => {\n handler.complete(ctx, task, result)\n },\n complete: () => {\n ctx.logger.success(handler.name(ctx, task))\n ctx.logger.log()\n },\n })\n\n taskSubscriptions.push(sub)\n }\n })\n\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n for (const sub of taskSubscriptions) {\n sub.unsubscribe()\n }\n taskSubscriptions.length = 0\n ctxSubscription.unsubscribe()\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"],"names":["exports","findPkgPath"],"mappings":";;;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,KAAK,OAAA,IAAU,KAChB,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,MAAM,OAAO,OAAO,CAAA,GAAI,KAAK,EAAC,MAAA,CAAM;AAAA,EAAA,GAG5C,UAAwB;AAAA,IAC5B,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,cAA+C,CAAA;AAErD,WAAS,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,gBAAY,OAAO,IACrB,YAAY,OAAO,EAAE,QAAQ,KAAK,KAAK,IAEvC,YAAY,OAAO,IAAI;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,OAAO;AAAA,IAAA;AAAA,EAG5B;AAGA,aAAW,OAAO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;AAChB,UAAI,YAAA;AAEN,sBAAkB,SAAS;AAE3B,UAAM,aAAa,kBAAkB,GAAG;AAExC,eAAW,QAAQ,YAAY;AAE7B,YAAM,UAAU,kBAAkB,KAAK,IAAI,GAGrC,MAFU,QAAQ,KAAK,KAAK,IAAI,EAElB,UAAU;AAAA,QAC5B,OAAO,CAAC,QAAQ;AACd,cAAI,OAAO,MAAM,GAAG,GACpB,IAAI,OAAO,IAAA,GAEX,QAAQ,KAAK,CAAC;AAAA,QAChB;AAAA,QACA,MAAM,CAAC,WAAW;AAChB,kBAAQ,SAAS,KAAK,MAAM,MAAM;AAAA,QACpC;AAAA,QACA,UAAU,MAAM;AACd,cAAI,OAAO,QAAQ,QAAQ,KAAK,KAAK,IAAI,CAAC,GAC1C,IAAI,OAAO,IAAA;AAAA,QACb;AAAA,MAAA,CACD;AAED,wBAAkB,KAAK,GAAG;AAAA,IAC5B;AAAA,EACF,CAAC;AAEG,YACF,OAAO;AAAA,IACL;AAAA,IACA,MAAM;AACJ,iBAAW,OAAO;AAChB,YAAI,YAAA;AAEN,wBAAkB,SAAS,GAC3B,gBAAgB,YAAA;AAAA,IAClB;AAAA,IACA,EAAC,MAAM,GAAA;AAAA,EAAI;AAGjB;AC7FA,eAAsB,YAAY,SAA+D;AAC/F,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,IAAA,CACnB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
1
+ {"version":3,"file":"watchAction.js","sources":["../../src/node/resolveWatchTasks.ts","../../src/node/watch.ts","../../src/cli/watchAction.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 {DtsWatchTask} from './tasks/dts/types.ts'\nimport type {RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveWatchTasks(ctx: BuildContext): WatchTask[] {\n const {pkg, target} = ctx\n const tasks: WatchTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => Object.assign({}, exp, {_path}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsWatchTask = {\n type: 'watch:dts',\n entries: [],\n }\n\n const rollupTasks: Record<string, RollupWatchTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'watch:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\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 // 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: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:* 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: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 if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n\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 type {Subscription} from 'rxjs'\nimport {switchMap} from 'rxjs'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveWatchTasks} from './resolveWatchTasks.ts'\nimport {watchTaskHandlers} from './tasks/index.ts'\nimport {type TaskHandler, type WatchTask} from './tasks/types.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 {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n const taskSubscriptions: Subscription[] = []\n\n const ctx$ = configFiles$.pipe(\n switchMap(async (configFiles) => {\n const files = configFiles.map((f) => path.relative(cwd, f))\n\n const packageJsonPath = files.find((f) => f === 'package.json')\n\n const pkgPath = findPkgPath({cwd})\n if (!packageJsonPath || !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 = ctx$.subscribe(async (ctx) => {\n // Unsubscribe previous task subscriptions when config changes trigger a new context\n for (const sub of taskSubscriptions) {\n sub.unsubscribe()\n }\n taskSubscriptions.length = 0\n\n const watchTasks = resolveWatchTasks(ctx)\n\n for (const task of watchTasks) {\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 = watchTaskHandlers[task.type] as TaskHandler<WatchTask, unknown>\n const result$ = handler.exec(ctx, task)\n\n const sub = result$.subscribe({\n error: (err) => {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n },\n next: (result) => {\n handler.complete(ctx, task, result)\n },\n complete: () => {\n ctx.logger.success(handler.name(ctx, task))\n ctx.logger.log()\n },\n })\n\n taskSubscriptions.push(sub)\n }\n })\n\n if (signal) {\n signal.addEventListener(\n 'abort',\n () => {\n for (const sub of taskSubscriptions) {\n sub.unsubscribe()\n }\n taskSubscriptions.length = 0\n ctxSubscription.unsubscribe()\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)\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rC,MAFU,QAAQ,KAAK,KAAK,IAAI,EAElB,UAAU;AAAA,QAC5B,OAAO,CAAC,QAAQ;AACd,cAAI,OAAO,MAAM,GAAG,GACpB,IAAI,OAAO,IAAA,GAEX,QAAQ,KAAK,CAAC;AAAA,QAChB;AAAA,QACA,MAAM,CAAC,WAAW;AAChB,kBAAQ,SAAS,KAAK,MAAM,MAAM;AAAA,QACpC;AAAA,QACA,UAAU,MAAM;AACd,cAAI,OAAO,QAAQ,QAAQ,KAAK,KAAK,IAAI,CAAC,GAC1C,IAAI,OAAO,IAAA;AAAA,QACb;AAAA,MAAA,CACD;AAED,wBAAkB,KAAK,GAAG;AAAA,IAC5B;AAAA,EACF,CAAC;AAEG,YACF,OAAO;AAAA,IACL;AAAA,IACA,MAAM;AACJ,iBAAW,OAAO;AAChB,YAAI,YAAA;AAEN,wBAAkB,SAAS,GAC3B,gBAAgB,YAAA;AAAA,IAClB;AAAA,IACA,EAAC,MAAM,GAAA;AAAA,EAAI;AAGjB;AC7FA,eAAsB,YAAY,SAA+D;AAC/F,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,IAAA,CACnB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cac } from "cac";
2
- var version = "10.4.17";
2
+ var version = "10.5.0";
3
3
  const cli = cac();
4
4
  cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
5
5
  const { checkAction } = await import("./_chunks-es/checkAction.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/pkg-utils",
3
- "version": "10.4.17",
3
+ "version": "10.5.0",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@babel/core": "^7.29.0",
46
46
  "@babel/preset-typescript": "^7.28.5",
47
- "@microsoft/api-extractor": "^7.58.5",
47
+ "@microsoft/api-extractor": "^7.58.7",
48
48
  "@microsoft/tsdoc-config": "^0.18.1",
49
49
  "@optimize-lodash/rollup-plugin": "^6.0.0",
50
50
  "@rollup/plugin-alias": "^6.0.0",
@@ -74,16 +74,16 @@
74
74
  "pretty-bytes": "^7.1.0",
75
75
  "prompts": "^2.4.2",
76
76
  "rimraf": "^6.1.3",
77
- "rolldown": "1.0.0-rc.16",
77
+ "rolldown": "1.0.0-rc.18",
78
78
  "rolldown-plugin-dts": "0.23.2",
79
- "rollup": "^4.60.1",
79
+ "rollup": "^4.60.2",
80
80
  "rollup-plugin-esbuild": "^6.2.1",
81
81
  "rxjs": "^7.8.2",
82
82
  "treeify": "^1.1.0",
83
83
  "tsx": "^4.21.0",
84
84
  "zod": "^4.3.6",
85
85
  "zod-validation-error": "^5.0.0",
86
- "@sanity/parse-package-json": "^2.1.3"
86
+ "@sanity/parse-package-json": "^2.1.4"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@types/babel__core": "^7.20.5",
@@ -92,14 +92,14 @@
92
92
  "@types/prompts": "^2.4.9",
93
93
  "@types/semver": "^7.7.1",
94
94
  "@types/treeify": "^1.0.3",
95
- "@typescript/native-preview": "7.0.0-dev.20260418.1",
95
+ "@typescript/native-preview": "7.0.0-dev.20260424.1",
96
96
  "babel-plugin-react-compiler": "1.0.0",
97
97
  "browserslist-to-esbuild": "2.1.1",
98
98
  "nanoexec": "^1.1.0",
99
99
  "rollup-plugin-visualizer": "^7.0.1",
100
100
  "semver": "^7.7.4",
101
101
  "typescript": "6.0.3",
102
- "vitest": "^4.1.4",
102
+ "vitest": "^4.1.5",
103
103
  "@sanity/tsconfig": "^2.1.0"
104
104
  },
105
105
  "peerDependencies": {