@sanity/pkg-utils 11.0.16 → 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
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveBuildContext.js","sources":["../../src/node/consoleSpy.ts","../../src/node/core/pkg/dependencyPlacement.ts","../../src/node/core/pkg/helpers.ts","../../src/node/core/pkg/validatePkg.ts","../../src/node/core/pkg/loadPkg.ts","../../src/node/core/pkg/loadPkgWithReporting.ts","../../../../../node_modules/.pnpm/browserslist-to-esbuild@2.1.1_browserslist@4.28.7/node_modules/browserslist-to-esbuild/src/index.js","../../src/node/core/config/resolveConfigProperty.ts","../../src/node/core/findCommonPath.ts","../../src/node/tasks/dts/getTargetPaths.ts","../../src/node/core/pkg/pkgExt.ts","../../src/node/core/pkg/validateExports.ts","../../src/node/core/pkg/parseAndValidateExports.ts","../../src/node/core/ts/loadTSConfig.ts","../../src/node/resolveBrowserTarget.ts","../../src/node/resolveNodeTarget.ts","../../src/node/strict.ts","../../src/node/resolveBuildContext.ts"],"sourcesContent":["// oxlint-disable no-console\nexport interface ConsoleSpyMsg {\n type: 'log' | 'warn' | 'error'\n code?: string\n args: unknown[]\n}\n\nexport interface ConsoleSpy {\n messages: ConsoleSpyMsg[]\n restore: () => void\n}\n\nexport function createConsoleSpy(options?: {\n onRestored?: (messages: ConsoleSpyMsg[]) => void\n}): ConsoleSpy {\n const {onRestored} = options || {}\n\n const original = {\n log: console.log,\n warn: console.warn,\n error: console.error,\n }\n\n const messages: ConsoleSpyMsg[] = []\n\n console.log = (...args: unknown[]) => messages.push({type: 'log', args})\n console.warn = (...args: unknown[]) => messages.push({type: 'warn', args})\n console.error = (...args: unknown[]) => messages.push({type: 'error', args})\n\n return {\n messages,\n restore: () => {\n console.log = original.log\n console.warn = original.warn\n console.error = original.error\n\n onRestored?.(messages)\n },\n }\n}\n","import type {PackageJSON} from '@sanity/parse-package-json'\nimport type {Logger} from '../../logger.ts'\nimport type {StrictOptions} from '../../strict.ts'\n\n/**\n * The `package.json` fields a dependency placement rule can reference.\n */\ntype DependencyField = 'dependencies' | 'devDependencies' | 'peerDependencies'\n\n/**\n * Describes where a given package may, and may not, be declared in `package.json`.\n */\ninterface DependencyPlacementRule {\n /** The name of the package this rule applies to. */\n name: string\n /** The `strictOptions` toggle that controls whether this rule runs. */\n option: keyof StrictOptions\n /** Fields the package must _not_ be declared in. */\n disallowedIn: DependencyField[]\n /** Fields the package is allowed to be declared in (used for messaging). */\n allowedIn: DependencyField[]\n /**\n * When set and the package is declared in `peerDependencies`, the version range must be\n * exactly this value (e.g. `*` for `@types/*` packages).\n */\n requiredPeerVersion?: string\n}\n\n/**\n * The set of dependency placement rules enforced in `--strict` mode.\n */\nconst dependencyPlacementRules: DependencyPlacementRule[] = [\n {\n name: 'react-is',\n option: 'noReactIsPeerDependency',\n disallowedIn: ['peerDependencies'],\n allowedIn: ['dependencies', 'devDependencies'],\n },\n {\n name: '@sanity/ui',\n option: 'noSanityUiPeerDependency',\n disallowedIn: ['peerDependencies'],\n allowedIn: ['dependencies', 'devDependencies'],\n },\n {\n name: '@sanity/icons',\n option: 'noSanityIconsPeerDependency',\n disallowedIn: ['peerDependencies'],\n allowedIn: ['dependencies', 'devDependencies'],\n },\n {\n name: 'sanity',\n option: 'noSanityDependency',\n disallowedIn: ['dependencies'],\n allowedIn: ['devDependencies', 'peerDependencies'],\n },\n {\n name: 'styled-components',\n option: 'noStyledComponentsDependency',\n disallowedIn: ['dependencies'],\n allowedIn: ['devDependencies', 'peerDependencies'],\n },\n {\n name: 'react',\n option: 'noReactDependency',\n disallowedIn: ['dependencies'],\n allowedIn: ['devDependencies', 'peerDependencies'],\n },\n {\n name: 'react-dom',\n option: 'noReactDomDependency',\n disallowedIn: ['dependencies'],\n allowedIn: ['devDependencies', 'peerDependencies'],\n },\n {\n name: '@types/react',\n option: 'noReactTypesDependency',\n disallowedIn: ['dependencies'],\n allowedIn: ['devDependencies', 'peerDependencies'],\n requiredPeerVersion: '*',\n },\n {\n name: '@types/react-dom',\n option: 'noReactDomTypesDependency',\n disallowedIn: ['dependencies'],\n allowedIn: ['devDependencies', 'peerDependencies'],\n requiredPeerVersion: '*',\n },\n {\n name: '@types/node',\n option: 'noNodeTypesDependency',\n disallowedIn: ['dependencies'],\n allowedIn: ['devDependencies', 'peerDependencies'],\n requiredPeerVersion: '*',\n },\n {\n name: 'rxjs',\n option: 'noRxjsPeerDependency',\n disallowedIn: ['peerDependencies'],\n allowedIn: ['dependencies', 'devDependencies'],\n },\n {\n name: '@sanity/client',\n option: 'noSanityClientPeerDependency',\n disallowedIn: ['peerDependencies'],\n allowedIn: ['dependencies', 'devDependencies'],\n },\n]\n\nfunction formatFields(fields: DependencyField[]): string {\n const labels = fields.map((field) => `\\`${field}\\``)\n\n if (labels.length <= 1) {\n return labels.join('')\n }\n\n return `${labels.slice(0, -1).join(', ')} or ${labels[labels.length - 1]}`\n}\n\n/**\n * Validates that well-known packages are declared in the correct `package.json` dependency\n * fields. Returns `true` if any rule with severity `error` was violated.\n * @internal\n */\nexport function checkDependencyPlacement(options: {\n pkg: PackageJSON\n logger: Logger\n strictOptions: StrictOptions\n}): boolean {\n const {pkg, logger, strictOptions} = options\n let shouldError = false\n\n const report = (level: 'error' | 'warn', message: string) => {\n if (level === 'error') {\n shouldError = true\n logger.error(message)\n } else {\n logger.warn(message)\n }\n }\n\n for (const rule of dependencyPlacementRules) {\n const level = strictOptions[rule.option]\n\n if (level === 'off') {\n continue\n }\n\n for (const field of rule.disallowedIn) {\n if (Object.hasOwn(pkg[field] ?? {}, rule.name)) {\n report(\n level,\n `package.json: \\`${rule.name}\\` should not be in \\`${field}\\`. It should be in ${formatFields(\n rule.allowedIn,\n )} instead.`,\n )\n }\n }\n\n if (rule.requiredPeerVersion !== undefined) {\n const peerDependencies = pkg.peerDependencies ?? {}\n\n if (\n Object.hasOwn(peerDependencies, rule.name) &&\n peerDependencies[rule.name] !== rule.requiredPeerVersion\n ) {\n report(\n level,\n `package.json: \\`${rule.name}\\` in \\`peerDependencies\\` should be set to \"${rule.requiredPeerVersion}\" (got \"${peerDependencies[rule.name]}\").`,\n )\n }\n }\n }\n\n return shouldError\n}\n","/** @internal */\nexport function assertLast<T>(a: T, arr: T[]): boolean {\n const aIdx = arr.indexOf(a)\n\n // if not found, then we don't care\n if (aIdx === -1) {\n return true\n }\n\n return aIdx === arr.length - 1\n}\n\n/** @internal */\nexport function assertOrder<T>(a: T, b: T, arr: T[]): boolean {\n const aIdx = arr.indexOf(a)\n const bIdx = arr.indexOf(b)\n\n // if either is not found, then we don't care\n if (aIdx === -1 || bIdx === -1) {\n return true\n }\n\n return aIdx < bIdx\n}\n","import {parsePackage, _typoMap as typoMap, type PackageJSON} from '@sanity/parse-package-json'\n\nexport function validatePkg(input: unknown): PackageJSON {\n const pkg = parsePackage(input)\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Need to check raw input for typos\n const invalidKey = Object.keys(input as PackageJSON).find((key) => {\n const needle = key.toUpperCase()\n\n return typoMap.has(needle) ? typoMap.get(needle) !== key : false\n })\n\n if (invalidKey) {\n throw new TypeError(\n `\n- package.json: \"${invalidKey}\" is not a valid key. Did you mean \"${typoMap.get(invalidKey.toUpperCase())}\"?`,\n )\n }\n\n return pkg\n}\n","import fs from 'node:fs/promises'\nimport type {PackageJSON} from '@sanity/parse-package-json'\nimport {validatePkg} from './validatePkg.ts'\n\n/** @internal */\nexport async function loadPkg(options: {pkgPath: string}): Promise<PackageJSON> {\n const {pkgPath} = options\n\n const raw = JSON.parse(await fs.readFile(pkgPath, 'utf-8'))\n\n validatePkg(raw)\n\n return raw\n}\n","import {ZodError, type PackageJSON} from '@sanity/parse-package-json'\nimport chalk from 'chalk'\nimport type {Logger} from '../../logger.ts'\nimport type {StrictOptions} from '../../strict.ts'\nimport {checkDependencyPlacement} from './dependencyPlacement.ts'\nimport {assertLast, assertOrder} from './helpers.ts'\nimport {loadPkg} from './loadPkg.ts'\n\n/**\n * Helper function to recursively compare export values, excluding source, development, and monorepo conditions\n */\nfunction areExportValuesEqual(value1: unknown, value2: unknown): boolean {\n // If both are strings, simple comparison\n if (typeof value1 === 'string' && typeof value2 === 'string') {\n return value1 === value2\n }\n\n // If types don't match, they're not equal\n if (typeof value1 !== typeof value2) {\n return false\n }\n\n // Both are objects, compare recursively\n if (\n typeof value1 === 'object' &&\n value1 !== null &&\n typeof value2 === 'object' &&\n value2 !== null &&\n !Array.isArray(value1) &&\n !Array.isArray(value2)\n ) {\n const obj1 = value1 as Record<string, any>\n const obj2 = value2 as Record<string, any>\n\n const keys1 = Object.keys(obj1).filter(\n (k) => k !== 'source' && k !== 'development' && k !== 'monorepo',\n )\n const keys2 = Object.keys(obj2).filter(\n (k) => k !== 'source' && k !== 'development' && k !== 'monorepo',\n )\n\n // Check if they have the same keys\n if (keys1.length !== keys2.length) {\n return false\n }\n\n for (const key of keys1) {\n if (!keys2.includes(key)) {\n return false\n }\n\n const val1 = obj1[key]\n const val2 = obj2[key]\n\n // Skip if either value is undefined\n if (val1 === undefined || val2 === undefined) {\n return false\n }\n\n // Recursively compare nested values\n if (!areExportValuesEqual(val1, val2)) {\n return false\n }\n }\n\n return true\n }\n\n return false\n}\n\n/** @alpha */\nexport async function loadPkgWithReporting(options: {\n pkgPath: string\n logger: Logger\n strict: boolean\n strictOptions: StrictOptions\n}): Promise<PackageJSON> {\n const {pkgPath, logger, strict, strictOptions} = options\n\n try {\n const pkg = await loadPkg({pkgPath})\n let shouldError = false\n\n if (strict) {\n // Check for missing or commonjs type field\n if (strictOptions.preferModuleType !== 'off') {\n if (!pkg.type) {\n const msg =\n 'package.json: `type` field is missing. Future versions of pkg-utils will require `\"type\": \"module\"`. Consider adding `\"type\": \"module\"` to prepare for this change.'\n if (strictOptions.preferModuleType === 'error') {\n shouldError = true\n logger.error(msg)\n } else {\n logger.warn(msg)\n }\n } else if (pkg.type === 'commonjs') {\n const msg =\n 'package.json: `type` is set to \"commonjs\". Future versions of pkg-utils will require `\"type\": \"module\"`. Consider migrating to ES modules to prepare for this change.'\n if (strictOptions.preferModuleType === 'error') {\n shouldError = true\n logger.error(msg)\n } else {\n logger.warn(msg)\n }\n }\n }\n\n // Check for banned root-level fields\n if (strictOptions.noPackageJsonBrowser !== 'off' && pkg.browser) {\n const msg =\n 'package.json: the `browser` field is no longer needed. Use the `browser` condition in `exports` instead for better support across modern bundlers.'\n if (strictOptions.noPackageJsonBrowser === 'error') {\n shouldError = true\n logger.error(msg)\n } else {\n logger.warn(msg)\n }\n }\n\n if (strictOptions.noPackageJsonTypesVersions !== 'off' && pkg.typesVersions) {\n const msg =\n 'package.json: the `typesVersions` field is no longer needed. TypeScript has long supported conditional exports and the `types` condition. Remove the `typesVersions` field and use the `types` condition in `exports` instead.'\n if (strictOptions.noPackageJsonTypesVersions === 'error') {\n shouldError = true\n logger.error(msg)\n } else {\n logger.warn(msg)\n }\n }\n\n // Check that well-known packages are declared in the correct dependency fields\n if (checkDependencyPlacement({pkg, logger, strictOptions})) {\n shouldError = true\n }\n }\n\n // validate exports\n if (pkg.exports) {\n const _exports = Object.entries(pkg.exports)\n\n for (const [expPath, exp] of _exports) {\n // Skip plain string exports, svelte exports, and conditional CSS exports (a flat\n // condition -> path map at a `.css` subpath); none of these use standard export conditions.\n if (typeof exp === 'string' || expPath.endsWith('.css') || 'svelte' in exp) {\n continue\n }\n\n const keys = Object.keys(exp)\n\n if (exp.types) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`types\\` condition shouldn't be used as dts files are generated in such a way that both CJS and ESM is supported`,\n )\n }\n\n if (exp.module) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`module\\` condition shouldn't be used as it's not well supported in all bundlers.`,\n )\n }\n\n if (exp.development && exp.source && exp.development !== exp.source) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`development\\` condition must have the same value as \\`source\\` when both are present. Expected \"${exp.source}\" but got \"${exp.development}\"`,\n )\n }\n\n if (exp.monorepo && exp.source && exp.monorepo !== exp.source) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`monorepo\\` condition must have the same value as \\`source\\` when both are present. Expected \"${exp.source}\" but got \"${exp.monorepo}\"`,\n )\n }\n\n if (exp.node) {\n if (exp.import && exp.node.import && !assertOrder('node', 'import', keys)) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`node\\` property should come before the \\`import\\` property`,\n )\n }\n\n if (exp.node.module) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`node.module\\` condition shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the \"dual package hazard\"`,\n )\n }\n\n if (\n !exp.node.source &&\n exp.node.import &&\n (exp.node.require || exp.require) &&\n (exp.node.import.endsWith('.cjs.js') || exp.node.import.endsWith('.cjs.mjs'))\n ) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`node.import\\` re-export pattern shouldn't be used as it's not well supported in all bundlers. A better strategy is to refactor the codebase to no longer be vulnerable to the \"dual package hazard\"`,\n )\n }\n\n if (exp.require && exp.node.require && exp.require === exp.node.require) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`node.require\\` property isn't necessary as it's identical to \\`require\\``,\n )\n } else if (exp.require && exp.node.require && !assertOrder('node', 'require', keys)) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`node\\` property should come before the \\`require\\` property`,\n )\n }\n } else {\n if (!assertOrder('import', 'require', keys)) {\n logger.warn(\n `exports[\"${expPath}\"]: the \\`import\\` property should come before the \\`require\\` property`,\n )\n }\n }\n\n if (!assertLast('default', keys)) {\n shouldError = true\n logger.error(\n `exports[\"${expPath}\"]: the \\`default\\` property should be the last property`,\n )\n }\n }\n }\n\n // validate publishConfig.exports\n if (strict && pkg.exports && Object.keys(pkg.exports).length > 0) {\n // Check if exports contains source, development, or monorepo conditions\n const hasSourceOrDevelopment = Object.entries(pkg.exports).some(([, exp]) => {\n if (typeof exp === 'string') return false\n if (typeof exp === 'object' && 'svelte' in exp) return false\n return Boolean(exp.source || exp.development || exp.monorepo)\n })\n\n if (hasSourceOrDevelopment) {\n if (!pkg.publishConfig?.exports) {\n const msg =\n 'package.json: `publishConfig.exports` is missing. Adding it helps avoid publishing to npm with the `source`, `development`, or `monorepo` condition that points to code that cannot be used by the resolver. ' +\n 'See https://tsdown.dev/options/package-exports#dev-exports for more information.'\n if (strictOptions.noPublishConfigExports === 'error') {\n shouldError = true\n logger.error(msg)\n } else if (strictOptions.noPublishConfigExports !== 'off') {\n logger.warn(msg)\n }\n } else {\n // Validate publishConfig.exports structure\n const publishExports = pkg.publishConfig.exports\n\n // Check that all keys in exports exist in publishConfig.exports\n for (const exportPath of Object.keys(pkg.exports)) {\n if (!(exportPath in publishExports)) {\n shouldError = true\n logger.error(\n `publishConfig.exports: missing export path \"${exportPath}\" that exists in exports`,\n )\n }\n }\n\n // Check that all keys in publishConfig.exports exist in exports\n for (const exportPath of Object.keys(publishExports)) {\n if (!(exportPath in pkg.exports)) {\n shouldError = true\n logger.error(\n `publishConfig.exports: unexpected export path \"${exportPath}\" that does not exist in exports`,\n )\n }\n }\n\n // Validate each export path\n for (const [exportPath, exp] of Object.entries(pkg.exports)) {\n if (typeof exp === 'string' || 'svelte' in exp) {\n // For string or svelte exports, publishConfig should match\n const publishExp = publishExports[exportPath]\n if (\n typeof publishExp !== 'string' &&\n (typeof publishExp !== 'object' || !('svelte' in publishExp))\n ) {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: should be a string matching exports[\"${exportPath}\"]`,\n )\n }\n continue\n }\n\n const publishExp = publishExports[exportPath]\n if (!publishExp) {\n continue\n }\n if (typeof publishExp === 'string') {\n // publishConfig has a string, validate it's correct\n // It should be a condensed form when only default remains after removing source/development/monorepo\n const conditions = Object.keys(exp).filter(\n (k) => k !== 'source' && k !== 'development' && k !== 'monorepo',\n )\n if (conditions.length !== 1 || conditions[0] !== 'default') {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: is a string but exports[\"${exportPath}\"] has multiple conditions besides source/development/monorepo: ${conditions.join(', ')}`,\n )\n } else {\n // Validate that the string value matches the default condition value\n const expectedValue = exp.default\n if (publishExp !== expectedValue) {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: should be \"${expectedValue}\" but got \"${publishExp}\"`,\n )\n }\n }\n continue\n }\n\n if ('svelte' in publishExp) {\n continue\n }\n\n // Validate conditions\n const exportConditions = Object.keys(exp).filter(\n (k) => k !== 'source' && k !== 'development' && k !== 'monorepo',\n )\n const publishConditions = Object.keys(publishExp)\n\n // Check for source, development, or monorepo in publishConfig\n if ('source' in publishExp) {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: should not contain the \\`source\\` condition`,\n )\n }\n\n if ('development' in publishExp) {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: should not contain the \\`development\\` condition`,\n )\n }\n\n if ('monorepo' in publishExp) {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: should not contain the \\`monorepo\\` condition`,\n )\n }\n\n // Check that all conditions match (except source/development/monorepo)\n for (const condition of exportConditions) {\n if (!(condition in publishExp)) {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: missing \\`${condition}\\` condition that exists in exports[\"${exportPath}\"]`,\n )\n }\n }\n\n for (const condition of publishConditions) {\n if (!exportConditions.includes(condition)) {\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"]: unexpected \\`${condition}\\` condition that does not exist in exports[\"${exportPath}\"]`,\n )\n }\n }\n\n // Validate that values match for all conditions\n for (const condition of exportConditions) {\n if (condition in publishExp) {\n const exportValue = (exp as Record<string, unknown>)[condition]\n const publishValue = (publishExp as Record<string, unknown>)[condition]\n\n // Compare values recursively for nested objects\n if (!areExportValuesEqual(exportValue, publishValue)) {\n const exportValueStr =\n typeof exportValue === 'string' ? exportValue : JSON.stringify(exportValue)\n const publishValueStr =\n typeof publishValue === 'string' ? publishValue : JSON.stringify(publishValue)\n shouldError = true\n logger.error(\n `publishConfig.exports[\"${exportPath}\"].${condition}: should be ${exportValueStr} but got ${publishValueStr}`,\n )\n }\n }\n }\n }\n }\n }\n }\n\n if (shouldError) {\n process.exit(1)\n }\n\n return pkg\n } catch (err) {\n if (err instanceof ZodError) {\n for (const issue of err.issues) {\n if (issue.code === 'invalid_type') {\n logger.error(\n [\n `\\`${formatPath(issue.path)}\\` `,\n `in \\`./package.json\\` must be of type ${chalk.magenta(issue.expected)} `,\n `(received ${chalk.magenta(issue.received)})`,\n ].join(''),\n )\n continue\n }\n\n logger.error(issue)\n }\n } else {\n logger.error(err)\n }\n\n return process.exit(1)\n }\n}\n\nfunction formatPath(segments: Array<string | number>) {\n return segments\n .map((s, idx) => {\n if (idx === 0) return s\n\n if (typeof s === 'number') {\n return `[${s}]`\n }\n\n if (s.startsWith('.')) {\n return `[\"${s}\"]`\n }\n\n return `.${s}`\n })\n .join('')\n}\n","import browserslist from 'browserslist'\n\n// convert the browserslist field in package.json to\n// esbuild compatible array of browsers\nexport default function browserslistToEsbuild(browserslistConfig, options = {}) {\n if (!browserslistConfig) {\n // the path from where the script is run\n const path = process.cwd()\n\n // read config if none is passed\n browserslistConfig = browserslist.loadConfig({ path, ...options })\n }\n\n const SUPPORTED_ESBUILD_TARGETS = [\n 'es',\n 'chrome',\n 'edge',\n 'firefox',\n 'ios',\n 'node',\n 'safari',\n 'opera',\n 'ie',\n ]\n\n // https://github.com/eBay/browserslist-config/issues/16#issuecomment-863870093\n const UNSUPPORTED = ['android 4']\n\n const replaces = {\n ios_saf: 'ios',\n android: 'chrome',\n }\n\n const separator = ' '\n\n return (\n browserslist(browserslistConfig, options)\n // filter out the unsupported ones\n .filter((b) => !UNSUPPORTED.some((u) => b.startsWith(u)))\n // replaces safari TP with latest safari version\n .map((b) => {\n if (b === 'safari TP') {\n return browserslist('last 1 safari version')[0]\n }\n\n return b\n })\n // transform into ['chrome', '88']\n .map((b) => b.split(separator))\n // replace the similar browser\n .map((b) => {\n if (replaces[b[0]]) {\n b[0] = replaces[b[0]]\n }\n\n return b\n })\n // 11.0-12.0 --> 11.0\n .map((b) => {\n if (b[1].includes('-')) {\n b[1] = b[1].slice(0, b[1].indexOf('-'))\n }\n\n return b\n })\n // 11.0 --> 11\n .map((b) => {\n if (b[1].endsWith('.0')) {\n b[1] = b[1].slice(0, -2)\n }\n\n return b\n })\n // removes invalid versions that will break esbuild\n // https://github.com/evanw/esbuild/blob/35c0d65b9d4f29a26176404d2890d1b499634e9f/compat-table/src/caniuse.ts#L119-L122\n .filter((b) => /^\\d+(\\.\\d+)*$/.test(b[1]))\n // only get the targets supported by esbuild\n .filter((b) => SUPPORTED_ESBUILD_TARGETS.includes(b[0]))\n // only get the oldest version, assuming that the older version\n // is last in the array\n .reduce((acc, b) => {\n const existingIndex = acc.findIndex((br) => br[0] === b[0])\n\n if (existingIndex !== -1) {\n acc[existingIndex][1] = b[1]\n } else {\n acc.push(b)\n }\n return acc\n }, [])\n // remove separator\n .map((b) => b.join(''))\n )\n}\n","import type {PkgConfigProperty, PkgConfigPropertyResolver} from './types.ts'\n\nfunction isPkgConfigPropertyResolver<T>(\n prop: PkgConfigProperty<T>,\n): prop is PkgConfigPropertyResolver<T> {\n return typeof prop === 'function'\n}\n\n/** @internal */\nexport function resolveConfigProperty<T>(\n prop: PkgConfigProperty<T> | undefined,\n initialValue: T,\n): T {\n if (!prop) return initialValue\n\n if (isPkgConfigPropertyResolver(prop)) {\n return prop(initialValue)\n }\n\n return prop\n}\n","import path from 'node:path'\n\nexport function pathContains(containerPath: string, itemPath: string): boolean {\n return !path.relative(containerPath, itemPath).startsWith('..')\n}\n\nexport function findCommonDirPath(filePaths: string[]): string | undefined {\n let ret: string | undefined = undefined\n\n for (const filePath of filePaths) {\n let dirPath = path.dirname(filePath)\n\n if (!ret) {\n ret = dirPath\n continue\n }\n\n while (dirPath !== ret) {\n if (pathContains(dirPath, ret)) {\n ret = dirPath\n break\n }\n\n dirPath = path.dirname(dirPath)\n\n if (dirPath === ret) {\n break\n }\n\n if (dirPath === '.') return undefined\n }\n }\n\n return ret\n}\n","import type {PackageJSON} from '@sanity/parse-package-json'\nimport type {PkgBundle, PkgExport} from '../../core/config/types.ts'\n\n/** @internal */\nexport const fileEnding: RegExp = /\\.[mc]?js$/\n/** @internal */\nconst dtsEnding = '.d.ts'\n/** @internal */\nexport const defaultEnding = '.js'\n/** @internal */\nexport const mjsEnding = '.mjs'\n/** @internal */\nexport const cjsEnding = '.cjs'\nconst mtsEnding = '.d.mts'\nconst ctsEnding = '.d.cts'\n\n/** @internal */\nexport function getTargetPaths(\n _type: PackageJSON['type'],\n expOrBundle: PkgExport | PkgExport['browser'] | PkgExport['node'] | PkgBundle,\n): string[] {\n const type = (_type === 'module' ? 'module' : 'commonjs') satisfies PackageJSON['type']\n\n const set = new Set<string>()\n\n if (expOrBundle?.import) {\n set.add(expOrBundle.import.replace(fileEnding, type === 'module' ? dtsEnding : mtsEnding))\n }\n\n if (expOrBundle?.require) {\n set.add(expOrBundle.require.replace(fileEnding, type === 'commonjs' ? dtsEnding : ctsEnding))\n }\n\n if (isPkgExport(expOrBundle)) {\n if (!expOrBundle.browser?.source) {\n if (expOrBundle.browser?.import) {\n set.add(\n expOrBundle.browser.import.replace(fileEnding, type === 'module' ? dtsEnding : mtsEnding),\n )\n }\n\n if (expOrBundle.browser?.require) {\n set.add(\n expOrBundle.browser.require.replace(\n fileEnding,\n type === 'commonjs' ? dtsEnding : ctsEnding,\n ),\n )\n }\n }\n\n if (!expOrBundle.node?.source) {\n if (expOrBundle.node?.import) {\n set.add(\n expOrBundle.node.import.replace(fileEnding, type === 'module' ? dtsEnding : mtsEnding),\n )\n }\n\n if (expOrBundle.node?.require) {\n set.add(\n expOrBundle.node.require.replace(fileEnding, type === 'commonjs' ? dtsEnding : ctsEnding),\n )\n }\n }\n }\n\n return Array.from(set)\n}\n\nfunction isPkgExport(exp: any): exp is PkgExport {\n return exp?.browser || exp?.node || exp?.default\n}\n","import {cjsEnding, defaultEnding, mjsEnding} from '../../tasks/dts/getTargetPaths.ts'\n\n/** @internal */\nexport interface PkgExtMap {\n commonjs: {commonjs: string; esm: string}\n module: {commonjs: string; esm: string}\n}\n\n/** @internal */\nexport const pkgExtMap: PkgExtMap = {\n // pkg.type: \"commonjs\"\n commonjs: {\n commonjs: defaultEnding,\n esm: mjsEnding,\n },\n\n // pkg.type: \"module\"\n module: {\n commonjs: cjsEnding,\n esm: defaultEnding,\n },\n}\n","import type {PackageJSON} from '@sanity/parse-package-json'\nimport type {PkgExport} from '../config/types.ts'\nimport {pkgExtMap as extMap} from './pkgExt.ts'\n\nexport function validateExports(\n _exports: (PkgExport & {_path: string})[],\n options: {pkg: PackageJSON},\n): string[] {\n const {pkg} = options\n const type = pkg.type || 'commonjs'\n const ext = extMap[type]\n\n const errors: string[] = []\n\n for (const exp of _exports) {\n if (exp._path === '.') {\n if (exp.require && pkg.main && exp.require !== pkg.main) {\n errors.push(\n 'package.json: mismatch between \"main\" and \"exports.require\". These must be equal.',\n )\n }\n\n if (exp.import && pkg.module && exp.import !== pkg.module) {\n errors.push(\n 'package.json: mismatch between \"module\" and \"exports.import\". These must be equal.',\n )\n }\n }\n if (exp.require && !exp.require.endsWith(ext.commonjs)) {\n errors.push(\n `package.json with \\`type: \"${type}\"\\` - \\`exports[\"${exp._path}\"].require\\` must end with \"${ext.commonjs}\"`,\n )\n }\n\n if (exp.import && !exp.import.endsWith(ext.esm)) {\n errors.push(\n `package.json with \\`type: \"${type}\"\\` - \\`exports[\"${exp._path}\"].import\\` must end with \"${ext.esm}\"`,\n )\n }\n }\n\n return errors\n}\n","import {existsSync} from 'node:fs'\nimport {resolve as resolvePath} from 'node:path'\nimport {parseExports, type PackageJSON} from '@sanity/parse-package-json'\nimport type {Logger} from '../../logger.ts'\nimport type {StrictOptions} from '../../strict.ts'\nimport {defaultEnding, fileEnding} from '../../tasks/dts/getTargetPaths.ts'\nimport type {PkgExport} from '../config/types.ts'\nimport {isRecord} from '../isRecord.ts'\nimport {pkgExtMap} from './pkgExt.ts'\nimport {validateExports} from './validateExports.ts'\n\n// Type guard to filter out falsy values\nfunction isTruthy<T>(value: T | false | null | undefined | 0 | ''): value is T {\n return Boolean(value)\n}\n\n/** @alpha */\nexport function parseAndValidateExports(options: {\n cwd: string\n pkg: PackageJSON\n strict: boolean\n strictOptions: StrictOptions\n logger: Logger\n}): (PkgExport & {_path: string})[] {\n const {cwd, pkg, strict, strictOptions, logger} = options\n const type = pkg.type || 'commonjs'\n const errors: string[] = []\n\n const report = (kind: 'warn' | 'error', message: string) => {\n if (kind === 'warn') {\n logger.warn(message)\n } else {\n errors.push(message)\n }\n }\n\n if (!Array.isArray(pkg.files) && strict && strictOptions.alwaysPackageJsonFiles !== 'off') {\n report(\n strictOptions.alwaysPackageJsonFiles,\n 'package.json: `files` should be used over `.npmignore`',\n )\n }\n\n if (pkg.source) {\n if (\n strict &&\n pkg.exports?.['.'] &&\n typeof pkg.exports['.'] === 'object' &&\n 'source' in pkg.exports['.'] &&\n pkg.exports['.'].source === pkg.source\n ) {\n errors.push(\n 'package.json: the \"source\" property can be removed, as it is equal to exports[\".\"].source.',\n )\n } else if (!pkg.exports && pkg.main) {\n const extMap = pkgExtMap[type]\n const importExport = pkg.main.replace(fileEnding, extMap.esm)\n const requireExport = pkg.main.replace(fileEnding, extMap.commonjs)\n const defaultExport = pkg.main.replace(fileEnding, defaultEnding)\n\n const maybeBrowserCondition = []\n\n if (pkg.browser) {\n const browserConditions = []\n\n if (pkg.module && pkg.browser?.[pkg.module]) {\n browserConditions.push(\n ` \"import\": ${JSON.stringify(pkg.browser[pkg.module]!.replace(fileEnding, extMap.esm))}`,\n )\n } else if (pkg.browser?.[pkg.main]) {\n browserConditions.push(\n ` \"import\": ${JSON.stringify(pkg.browser[pkg.main]!.replace(fileEnding, extMap.esm))}`,\n )\n }\n\n if (pkg.browser?.[pkg.main]) {\n browserConditions.push(\n ` \"require\": ${JSON.stringify(pkg.browser[pkg.main]!.replace(fileEnding, extMap.commonjs))}`,\n )\n }\n\n if (browserConditions.length) {\n maybeBrowserCondition.push(\n ` \"browser\": {`,\n ` \"source\": ${JSON.stringify(pkg.browser?.[pkg.source] || pkg.source)},`,\n ...browserConditions,\n ` }`,\n )\n }\n }\n\n errors.push(\n ...[\n 'package.json: `exports` are missing, it should be:',\n `\"exports\": {`,\n ` \".\": {`,\n ` \"source\": ${JSON.stringify(pkg.source)},`,\n // If browser conditions are detected then add them to the suggestion\n ...(maybeBrowserCondition.length > 0 ? maybeBrowserCondition : []),\n type === 'commonjs' && ` \"import\": ${JSON.stringify(importExport)},`,\n type === 'module' && ` \"require\": ${JSON.stringify(requireExport)},`,\n ` \"default\": ${JSON.stringify(defaultExport)}`,\n ` },`,\n ` \"./package.json\": \"./package.json\"`,\n `}`,\n ].filter(isTruthy),\n )\n }\n }\n\n if (errors.length) {\n throw new Error('\\n- ' + errors.join('\\n- '))\n }\n\n if (!pkg.exports) {\n throw new Error(\n '\\n- ' +\n [\n 'package.json: `exports` are missing, please set a minimal configuration, for example:',\n `\"exports\": {`,\n ` \".\": {`,\n ` \"source\": \"./src/index.js\",`,\n ` \"default\": \"./dist/index.js\"`,\n ` },`,\n ` \"./package.json\": \"./package.json\"`,\n `}`,\n ].join('\\n- '),\n )\n }\n\n const _exports = parseExports({pkg})\n\n if (strict && strictOptions.noPackageJsonTypings !== 'off' && 'typings' in pkg) {\n report(strictOptions.noPackageJsonTypings, 'package.json: `typings` should be `types`')\n }\n\n if (\n strict &&\n strictOptions.alwaysPackageJsonTypes !== 'off' &&\n !pkg.types &&\n typeof pkg.exports?.['.'] === 'object' &&\n 'source' in pkg.exports['.'] &&\n pkg.exports['.'].source?.endsWith('.ts')\n ) {\n report(\n strictOptions.alwaysPackageJsonTypes,\n 'package.json: `types` must be declared for the npm listing to show as a TypeScript module.',\n )\n }\n\n if (strict && !pkg.exports['./package.json']) {\n errors.push('package.json: `exports[\"./package.json\"] must be declared.')\n }\n\n for (const [exportPath, exportEntry] of Object.entries(pkg.exports)) {\n if (\n exportPath.endsWith('.json') ||\n (typeof exportEntry === 'string' && exportEntry.endsWith('.json'))\n ) {\n if (exportPath === './package.json') {\n if (exportEntry !== './package.json') {\n errors.push('package.json: `exports[\"./package.json\"]` must be \"./package.json\".')\n }\n }\n } else if (exportPath.endsWith('.css')) {\n if (typeof exportEntry === 'string') {\n if (!existsSync(resolvePath(cwd, exportEntry))) {\n errors.push(\n `package.json: \\`exports[${JSON.stringify(exportPath)}]\\`: file does not exist.`,\n )\n }\n } else if (isRecord(exportEntry)) {\n // Conditional CSS export, e.g.\n // \"./bundle.css\": { \"types\": \"./dist/bundle-css.d.ts\", \"browser\": \"./dist/bundle.css\", \"node\": \"./dist/bundle-css.js\", \"default\": \"./dist/bundle-css.js\" }\n // This lets a package re-add a `import \"<pkg>/bundle.css\"` that resolves to the real CSS in\n // bundler/browser environments and to a no-op JS shim in CSS-unaware runtimes (e.g. Node).\n // Only the shape is validated here: the targets usually point at generated `dist` files that\n // do not exist yet at validation time, so file existence is intentionally not checked.\n for (const [condition, target] of Object.entries(exportEntry)) {\n if (typeof target !== 'string') {\n errors.push(\n `package.json: \\`exports[${JSON.stringify(exportPath)}][${JSON.stringify(condition)}]\\`: must be a string path.`,\n )\n }\n }\n } else {\n errors.push(\n `package.json: \\`exports[${JSON.stringify(exportPath)}]\\`: must be a string path or an object of export conditions.`,\n )\n }\n } else if (isRecord(exportEntry) && 'svelte' in exportEntry) {\n // @TODO should we report a warning or a debug message here about a detected svelte export that is ignored?\n } else if (isPkgExport(exportEntry)) {\n const exp = {\n _exported: true,\n _path: exportPath,\n ...exportEntry,\n } satisfies PkgExport & {_path: string}\n\n // Infer the `default` condition based on the `type` and other conditions\n if (!exp.default) {\n const fallback = type === 'module' ? exp.import : exp.require\n\n if (fallback) {\n exp.default = fallback\n }\n }\n\n // Infer the `require` condition based on the `type` and other conditions\n if (!exp.require && type === 'commonjs' && exp.default) {\n exp.require = exp.default\n }\n\n // Infer the `import` condition based on the `type` and other conditions\n if (!exp.import && type === 'module' && exp.default) {\n exp.import = exp.default\n }\n\n if (exportPath === '.') {\n if (exportEntry.require && pkg.main && exportEntry.require !== pkg.main) {\n errors.push(\n 'package.json: mismatch between \"main\" and \"exports.require\". These must be equal.',\n )\n }\n\n if (exportEntry.import && pkg.module && exportEntry.import !== pkg.module) {\n errors.push(\n 'package.json: mismatch between \"module\" and \"exports.import\" These must be equal.',\n )\n }\n }\n } else if (!isRecord(exportEntry)) {\n errors.push('package.json: exports must be an object')\n }\n }\n\n errors.push(...validateExports(_exports, {pkg}))\n\n if (errors.length) {\n throw new Error('\\n- ' + errors.join('\\n- '))\n }\n\n return _exports\n}\n\nfunction isPkgExport(value: unknown): value is PkgExport {\n return isRecord(value) && 'source' in value && typeof value['source'] === 'string'\n}\n","// The JS compiler API is loaded from the official `@typescript/typescript6` compat package\n// instead of the `typescript` peer dependency, as TypeScript 7 (the Go-native compiler) no longer\n// ships it\nimport ts from '@typescript/typescript6'\n\n/** @internal */\nexport async function loadTSConfig(options: {\n cwd: string\n tsconfigPath: string\n}): Promise<ReturnType<typeof ts.parseJsonConfigFileContent> | undefined> {\n const {cwd, tsconfigPath} = options\n\n // oxlint-disable-next-line unbound-method\n const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, tsconfigPath)\n\n if (!configPath) {\n return undefined\n }\n\n // oxlint-disable-next-line unbound-method\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile)\n\n return ts.parseJsonConfigFileContent(configFile.config, ts.sys, cwd)\n}\n","export function resolveBrowserTarget(versions: string[]): string[] | undefined {\n const target: string[] = versions.filter(\n (version) =>\n version.startsWith('chrome') ||\n version.startsWith('edge') ||\n version.startsWith('firefox') ||\n version.startsWith('ios') ||\n version.startsWith('safari') ||\n version.startsWith('opera'),\n )\n\n if (target.length === 0) {\n return undefined\n }\n\n return target\n}\n","export function resolveNodeTarget(versions: string[]): string[] | undefined {\n const target: string[] = versions.filter((version) => version.startsWith('node'))\n\n if (target.length === 0) {\n return undefined\n }\n\n return target\n}\n","import {errorMap} from 'zod-validation-error/v3'\nimport {z} from 'zod/v3'\n\nconst toggle = z.union([z.literal('error'), z.literal('warn'), z.literal('off')])\n\ntype ToggleType = 'error' | 'warn' | 'off'\n\nconst strictOptions = z\n .object({\n noPackageJsonTypings: toggle.default('error'),\n noImplicitSideEffects: toggle.default('warn'),\n noImplicitBrowsersList: toggle.default('warn'),\n alwaysPackageJsonTypes: toggle.default('error'),\n alwaysPackageJsonFiles: toggle.default('error'),\n noCheckTypes: toggle.default('warn'),\n noPackageJsonBrowser: toggle.default('warn'),\n noPackageJsonTypesVersions: toggle.default('warn'),\n preferModuleType: toggle.default('warn'),\n noPublishConfigExports: toggle.default('warn'),\n noReactIsPeerDependency: toggle.default('error'),\n noSanityUiPeerDependency: toggle.default('error'),\n noSanityIconsPeerDependency: toggle.default('error'),\n noSanityDependency: toggle.default('error'),\n noStyledComponentsDependency: toggle.default('error'),\n noReactDependency: toggle.default('error'),\n noReactDomDependency: toggle.default('error'),\n noReactTypesDependency: toggle.default('error'),\n noReactDomTypesDependency: toggle.default('error'),\n noNodeTypesDependency: toggle.default('error'),\n noRxjsPeerDependency: toggle.default('error'),\n noSanityClientPeerDependency: toggle.default('error'),\n })\n .strict()\n\n/**\n * To make error message paths line up with the paths in package.config.ts the schema is hoisted into a root schema\n * This way errors will say `Expected boolean, received string at \"strict.noPackageJsonTypings\"` instead of `Expected boolean, received string at \"noPackageJsonTypings\"`.\n */\nconst validationSchema = z.object({\n strictOptions: strictOptions.default({}),\n})\n\n/**\n * @public\n */\nexport interface StrictOptions {\n /**\n * Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.\n * @defaultValue 'error'\n */\n noPackageJsonTypings: ToggleType\n /**\n * Requires specifying `sideEffects` in `package.json`.\n * @defaultValue 'warn'\n */\n noImplicitSideEffects: ToggleType\n /**\n * Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:\n * @example\n * ```\n * \"browserslist\": \"extends @sanity/browserslist-config\"\n * ```\n * @defaultValue 'warn'\n */\n noImplicitBrowsersList: ToggleType\n /**\n * If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon.\n * @defaultValue 'error'\n */\n alwaysPackageJsonTypes: ToggleType\n /**\n * Using `.npmignore` is error prone, it's best practice to always declare `files` instead\n * @defaultValue 'error'\n */\n alwaysPackageJsonFiles: ToggleType\n /**\n * It's slow to perform type checking while generating dts files, so it's best practice to disable it with a `\"noCheck\": true` in the tsconfig.json file used by `package.config.ts`\n * @defaultValue 'warn'\n */\n noCheckTypes: ToggleType\n /**\n * Disallows the `browser` field in `package.json` as the `browser` condition in `exports` is better supported.\n * @defaultValue 'warn'\n */\n noPackageJsonBrowser: ToggleType\n /**\n * Disallows the `typesVersions` field in `package.json` as TypeScript has long supported conditional exports and the `types` condition.\n * @defaultValue 'warn'\n */\n noPackageJsonTypesVersions: ToggleType\n /**\n * Warns if `type` field is missing or set to `commonjs`. Future versions will require `\"type\": \"module\"`.\n * @defaultValue 'warn'\n */\n preferModuleType: ToggleType\n /**\n * Warns if `publishConfig.exports` is missing when `source`, `development`, or `monorepo` conditions are used in exports.\n * @defaultValue 'warn'\n */\n noPublishConfigExports: ToggleType\n /**\n * Disallows `react-is` in `peerDependencies`. It should be in `dependencies` (or `devDependencies`) instead.\n * @defaultValue 'error'\n */\n noReactIsPeerDependency: ToggleType\n /**\n * Disallows `@sanity/ui` in `peerDependencies`. It should be in `dependencies` (or `devDependencies`) instead.\n * @defaultValue 'error'\n */\n noSanityUiPeerDependency: ToggleType\n /**\n * Disallows `@sanity/icons` in `peerDependencies`. It should be in `dependencies` (or `devDependencies`) instead.\n * @defaultValue 'error'\n */\n noSanityIconsPeerDependency: ToggleType\n /**\n * Disallows `sanity` in `dependencies`. It should only be in `devDependencies` and/or `peerDependencies`.\n * @defaultValue 'error'\n */\n noSanityDependency: ToggleType\n /**\n * Disallows `styled-components` in `dependencies`. It should only be in `devDependencies` and/or `peerDependencies`.\n * @defaultValue 'error'\n */\n noStyledComponentsDependency: ToggleType\n /**\n * Disallows `react` in `dependencies`. It should only be in `devDependencies` and/or `peerDependencies`.\n * @defaultValue 'error'\n */\n noReactDependency: ToggleType\n /**\n * Disallows `react-dom` in `dependencies`. It should only be in `devDependencies` and/or `peerDependencies`.\n * @defaultValue 'error'\n */\n noReactDomDependency: ToggleType\n /**\n * Disallows `@types/react` in `dependencies`. It should only be in `devDependencies` and/or `peerDependencies`, and when declared as a peer dependency the version range should be `*`.\n * @defaultValue 'error'\n */\n noReactTypesDependency: ToggleType\n /**\n * Disallows `@types/react-dom` in `dependencies`. It should only be in `devDependencies` and/or `peerDependencies`, and when declared as a peer dependency the version range should be `*`.\n * @defaultValue 'error'\n */\n noReactDomTypesDependency: ToggleType\n /**\n * Disallows `@types/node` in `dependencies`. It should only be in `devDependencies` and/or `peerDependencies`, and when declared as a peer dependency the version range should be `*`.\n * @defaultValue 'error'\n */\n noNodeTypesDependency: ToggleType\n /**\n * Disallows `rxjs` in `peerDependencies`. It should only be in `dependencies` and/or `devDependencies`.\n * @defaultValue 'error'\n */\n noRxjsPeerDependency: ToggleType\n /**\n * Disallows `@sanity/client` in `peerDependencies`. It should only be in `dependencies` and/or `devDependencies`.\n * @defaultValue 'error'\n */\n noSanityClientPeerDependency: ToggleType\n}\n\n/** @alpha */\nexport function parseStrictOptions(input: unknown): StrictOptions {\n return validationSchema.parse({strictOptions: input}, {errorMap}).strictOptions\n}\n","import path from 'node:path'\nimport type {PackageJSON} from '@sanity/parse-package-json'\nimport browserslistToEsbuild from 'browserslist-to-esbuild'\nimport {resolveConfigProperty} from './core/config/resolveConfigProperty.ts'\nimport {type PkgConfigOptions, type PkgExports, type PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {DEFAULT_BROWSERSLIST_QUERY} from './core/defaults.ts'\nimport {findCommonDirPath, pathContains} from './core/findCommonPath.ts'\nimport {parseAndValidateExports} from './core/pkg/parseAndValidateExports.ts'\nimport {loadTSConfig} from './core/ts/loadTSConfig.ts'\nimport type {Logger} from './logger.ts'\nimport {resolveBrowserTarget} from './resolveBrowserTarget.ts'\nimport {resolveNodeTarget} from './resolveNodeTarget.ts'\nimport {parseStrictOptions} from './strict.ts'\n\n// Type guard to filter out falsy values\nfunction isTruthy<T>(value: T | false | null | undefined | 0 | ''): value is T {\n return Boolean(value)\n}\n\nexport async function resolveBuildContext(options: {\n config?: PkgConfigOptions | undefined\n cwd: string\n emitDeclarationOnly?: boolean\n logger: Logger\n pkg: PackageJSON\n strict: boolean\n tsconfig: string\n}): Promise<BuildContext> {\n const {\n config,\n cwd,\n emitDeclarationOnly = false,\n logger,\n pkg,\n strict,\n tsconfig: tsconfigPath,\n } = options\n const tsconfig = await loadTSConfig({cwd, tsconfigPath})\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n\n if (strictOptions.noCheckTypes !== 'off' && tsconfig?.options && config?.dts !== 'rolldown') {\n if (\n tsconfig.options.noCheck !== false &&\n !tsconfig.options.noCheck &&\n config?.extract?.checkTypes !== false\n ) {\n if (strictOptions.noCheckTypes === 'error') {\n throw new Error(\n '`noCheck` is not set to `true` in the tsconfig.json file used by `package.config.ts`. This makes generating dts files slower than it needs to be, as it will perform type checking on the dts files while at it. You can set `noCheck: true` in tsconfig.json or set `extract: { checkTypes: false }` in package.config.ts to disable type checking.',\n )\n } else {\n logger.warn(\n '`noCheck` is not set to `true` in the tsconfig.json file used by `package.config.ts`. This makes generating dts files slower than it needs to be, as it will perform type checking on the dts files while at it. You can set `noCheck: true` in tsconfig.json or set `extract: { checkTypes: false }` in package.config.ts to disable type checking.',\n )\n }\n }\n }\n\n let browserslist = pkg.browserslist\n if (!browserslist) {\n if (strict && strictOptions.noImplicitBrowsersList !== 'off') {\n if (strictOptions.noImplicitBrowsersList === 'error') {\n throw new Error(\n '\\n- ' +\n `package.json: \"browserslist\" is missing, set it to \\`\"browserslist\": \"extends @sanity/browserslist-config\"\\``,\n )\n } else {\n logger.warn(\n 'Could not detect a `browserslist` property in `package.json`, using default configuration. Add `\"browserslist\": \"extends @sanity/browserslist-config\"` to silence this warning.',\n )\n }\n }\n browserslist = DEFAULT_BROWSERSLIST_QUERY\n }\n const targetVersions = browserslistToEsbuild(browserslist)\n\n if (\n strict &&\n strictOptions.noImplicitSideEffects !== 'off' &&\n typeof pkg.sideEffects === 'undefined'\n ) {\n const msg =\n 'package.json: `sideEffects` is missing, see https://webpack.js.org/guides/tree-shaking/#clarifying-tree-shaking-and-sideeffects for how to define `sideEffects`'\n\n if (strictOptions.noImplicitSideEffects === 'error') {\n throw new Error(msg)\n } else {\n logger.warn(msg)\n }\n }\n\n const nodeTarget = resolveNodeTarget(targetVersions)\n const webTarget = resolveBrowserTarget(targetVersions)\n\n if (!nodeTarget) {\n throw new Error('no matching `node` target')\n }\n\n if (!webTarget) {\n throw new Error('no matching `web` target')\n }\n\n const target: Record<PkgRuntime, string[]> = {\n '*': webTarget.concat(nodeTarget),\n 'browser': webTarget,\n 'node': nodeTarget,\n }\n\n const parsedExports = parseAndValidateExports({\n cwd,\n pkg,\n strict,\n strictOptions,\n logger,\n }).reduce<PkgExports>(\n (acc, {_path: exportPath, ...exportEntry}) => Object.assign(acc, {[exportPath]: exportEntry}),\n {},\n )\n\n const exports = resolveConfigProperty(config?.exports, parsedExports)\n\n const parsedExternal = [\n ...(pkg.dependencies ? Object.keys(pkg.dependencies) : []),\n ...(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : []),\n ]\n\n // Merge externals if an array is provided, replace if it's a function\n const external =\n config && Array.isArray(config.external)\n ? [...parsedExternal, ...config.external]\n : resolveConfigProperty(config?.external, parsedExternal)\n // Merge bundledPackages with dev deps, replace if it's a function\n const externalWithTypes = new Set([pkg.name, ...external, ...external.map(transformPackageName)])\n const bundledDependencies = (pkg.devDependencies ? Object.keys(pkg.devDependencies) : []).filter(\n // Do not bundle anything that is marked as external\n (_) => !externalWithTypes.has(_),\n )\n const bundledPackages =\n config && Array.isArray(config.extract?.bundledPackages)\n ? [...bundledDependencies, ...config.extract.bundledPackages]\n : resolveConfigProperty(config?.extract?.bundledPackages, bundledDependencies)\n\n const outputPaths = Object.values(exports)\n .flatMap((exportEntry) => {\n return [\n exportEntry.import,\n exportEntry.require,\n exportEntry.browser?.import,\n exportEntry.browser?.require,\n exportEntry.node?.source && exportEntry.node.import,\n exportEntry.node?.source && exportEntry.node.require,\n ].filter(isTruthy)\n })\n .map((p) => path.resolve(cwd, p))\n\n const commonDistPath = findCommonDirPath(outputPaths)\n\n if (commonDistPath === cwd) {\n throw new Error(\n 'all output files must share a common parent directory which is not the root package directory',\n )\n }\n\n if (commonDistPath && !pathContains(cwd, commonDistPath)) {\n throw new Error('all output files must be located within the package')\n }\n\n const configDistPath = config?.dist ? path.resolve(cwd, config.dist) : undefined\n\n if (\n configDistPath &&\n commonDistPath &&\n configDistPath !== commonDistPath &&\n !pathContains(configDistPath, commonDistPath)\n ) {\n logger.log(`did you mean to configure \\`dist: './${path.relative(cwd, commonDistPath)}'\\`?`)\n\n throw new Error('all output files must be located with the configured `dist` path')\n }\n\n const distPath = configDistPath || commonDistPath\n\n if (!distPath) {\n throw new Error('could not detect `dist` path')\n }\n\n const ctx: BuildContext = {\n config,\n cwd,\n distPath,\n emitDeclarationOnly,\n exports,\n external,\n bundledPackages,\n files: [],\n logger,\n pkg,\n runtime: config?.runtime ?? '*',\n strict,\n target,\n ts: {\n config: tsconfig,\n configPath: tsconfigPath,\n },\n dts: config?.dts === 'rolldown' ? 'rolldown' : 'api-extractor',\n }\n\n return ctx\n}\n\nfunction transformPackageName(packageName: string): string {\n if (packageName.startsWith('@types/')) {\n // If it already starts with @types, return it as is\n return packageName\n } else if (packageName.startsWith('@')) {\n // Handle scoped packages\n const [scope, name] = packageName.split('/')\n\n return `@types/${scope?.slice(1)}__${name}`\n } else {\n // Handle regular packages\n return `@types/${packageName}`\n }\n}\n"],"names":["strictOptions","typoMap","strict","publishExp","path","isPkgExport","extMap","isTruthy","resolvePath","browserslist"],"mappings":";;;;;;;;;;;AAYO,SAAS,iBAAiB,SAElB;AACb,QAAM,EAAC,WAAA,IAAc,WAAW,CAAA,GAE1B,WAAW;AAAA,IACf,KAAK,QAAQ;AAAA,IACb,MAAM,QAAQ;AAAA,IACd,OAAO,QAAQ;AAAA,EAAA,GAGX,WAA4B,CAAA;AAElC,SAAA,QAAQ,MAAM,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,OAAO,KAAA,CAAK,GACvE,QAAQ,OAAO,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,QAAQ,KAAA,CAAK,GACzE,QAAQ,QAAQ,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,SAAS,KAAA,CAAK,GAEpE;AAAA,IACL;AAAA,IACA,SAAS,MAAM;AACb,cAAQ,MAAM,SAAS,KACvB,QAAQ,OAAO,SAAS,MACxB,QAAQ,QAAQ,SAAS,OAEzB,aAAa,QAAQ;AAAA,IACvB;AAAA,EAAA;AAEJ;ACRA,MAAM,2BAAsD;AAAA,EAC1D;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,cAAc,CAAC,kBAAkB;AAAA,IACjC,WAAW,CAAC,gBAAgB,iBAAiB;AAAA,EAAA;AAAA,EAE/C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,cAAc,CAAC,kBAAkB;AAAA,IACjC,WAAW,CAAC,gBAAgB,iBAAiB;AAAA,EAAA;AAAA,EAE/C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,cAAc,CAAC,kBAAkB;AAAA,IACjC,WAAW,CAAC,gBAAgB,iBAAiB;AAAA,EAAA;AAAA,EAE/C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,cAAc,C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B,cAAc;AAE5C,UAAA,OAAO,IAAI,wCAAwC,KAAK,SAAS,KAAK,cAAc,CAAC,MAAM,GAErF,IAAI,MAAM,kEAAkE;AAGpF,QAAM,WAAW,kBAAkB;AAEnC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,8BAA8B;AAwBhD,SArB0B;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,CAAA;AAAA,IACP;AAAA,IACA;AAAA,IACA,SAAS,QAAQ,WAAW;AAAA,IAC5B,QAAAE;AAAA,IACA;AAAA,IACA,IAAI;AAAA,MACF,QAAQ;AAAA,MACR,YAAY;AAAA,IAAA;AAAA,IAEd,KAAK,QAAQ,QAAQ,aAAa,aAAa;AAAA,EAAA;AAInD;AAEA,SAAS,qBAAqB,aAA6B;AACzD,MAAI,YAAY,WAAW,SAAS;AAElC,WAAO;AACF,MAAI,YAAY,WAAW,GAAG,GAAG;AAEtC,UAAM,CAAC,OAAO,IAAI,IAAI,YAAY,MAAM,GAAG;AAE3C,WAAO,UAAU,OAAO,MAAM,CAAC,CAAC,KAAK,IAAI;AAAA,EAC3C;AAEE,WAAO,UAAU,WAAW;AAEhC;","x_google_ignoreList":[6]}
@@ -1,117 +0,0 @@
1
- import path from "node:path";
2
- import { dts } from "rolldown-plugin-dts";
3
- import { pkgExtMap } from "./resolveBuildContext.js";
4
- function resolveRolldownConfig(ctx, buildTask) {
5
- const { format, runtime } = buildTask, { config, cwd, exports: _exports, external, distPath, logger, pkg, ts } = ctx, outputExt = pkgExtMap[pkg.type || "commonjs"][format], outDir = path.relative(cwd, distPath), pathAliases = Object.fromEntries(
6
- Object.entries(ts.config?.options.paths || {}).flatMap(([key, val]) => {
7
- const pathAlias = val[0];
8
- return pathAlias ? [[key, path.resolve(cwd, ts.config?.options.baseUrl || ".", pathAlias)]] : [];
9
- })
10
- ), entries = buildTask.entries.map((entry) => ({
11
- ...entry,
12
- name: path.relative(outDir, entry.output).replace(/\.[^/.]+$/, "")
13
- }), {}), exportIds = _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath)), sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source)), replacements = Object.fromEntries(
14
- Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)])
15
- ), entryFileNames = `[name]${outputExt}`, inputOptions = {
16
- cwd,
17
- transform: {
18
- define: pkg.name === "@sanity/pkg-utils" ? { ...replacements } : {
19
- "process.env.PKG_FORMAT": JSON.stringify(format),
20
- "process.env.PKG_RUNTIME": JSON.stringify(runtime),
21
- "process.env.PKG_VERSION": JSON.stringify(process.env.PKG_VERSION || pkg.version),
22
- ...replacements
23
- }
24
- },
25
- platform: buildTask.type === "rolldown:dts" || runtime === "node" ? "node" : runtime === "browser" ? "browser" : "neutral",
26
- resolve: {
27
- alias: pathAliases
28
- },
29
- tsconfig: ctx.ts.configPath || "tsconfig.json",
30
- experimental: {
31
- attachDebugInfo: "none"
32
- },
33
- external: (id, importer) => {
34
- if (buildTask.type === "rolldown:dts" && ctx.bundledPackages.length > 0 && !id.startsWith(".") && (id.includes("/node_modules/") || id.split("/").length < 3))
35
- return !ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`));
36
- if (exportIds?.includes(id))
37
- return !0;
38
- if (importer && (id.startsWith(".") || id.startsWith("/"))) {
39
- const idPath = path.resolve(path.dirname(importer), id);
40
- if (sourcePaths?.includes(idPath))
41
- return logger.warn(
42
- `detected self-referencing import \u2013 treating as external: ${path.relative(
43
- cwd,
44
- idPath
45
- )}`
46
- ), !0;
47
- }
48
- const idParts = id.split("/"), idPackageName = idParts[0].startsWith("@") ? `${idParts[0]}/${idParts[1]}` : idParts[0];
49
- return external.some(
50
- (name) => name === id || name === idPackageName || id.includes(`/node_modules/${name}/`)
51
- );
52
- },
53
- input: entries.reduce(
54
- (acc, entry) => Object.assign(acc, { [entry.name]: entry.source }),
55
- {}
56
- ),
57
- plugins: [
58
- dts({
59
- emitDtsOnly: !0,
60
- tsconfig: ctx.ts.configPath || "tsconfig.json",
61
- // When neither the config nor `@typescript/native-preview` decides, leave `tsgo`
62
- // undefined so `rolldown-plugin-dts` applies its own default: tsgo is auto-enabled when
63
- // the installed `typescript` is v7 (the Go-native compiler), and disabled otherwise
64
- tsgo: config?.tsgo !== void 0 ? config.tsgo : typeof pkg.devDependencies == "object" && "@typescript/native-preview" in pkg.devDependencies || void 0,
65
- // Always create dts from scratch, don't reuse contexts from previous builds
66
- newContext: !0
67
- })
68
- ]
69
- // Rely on rolldown's default tree-shaking (`moduleSideEffects: true`) instead of the
70
- // equivalent of `moduleSideEffects: 'no-external'`, which stripped intentional
71
- // side-effect-only imports of external packages. Unused declarations are still
72
- // tree-shaken (that happens at the binding level, independent of `moduleSideEffects`).
73
- }, outputOptions = {
74
- dir: outDir,
75
- entryFileNames,
76
- chunkFileNames: buildTask.type === "rolldown:dts" ? `_chunks-dts/[name]${outputExt}` : void 0,
77
- esModule: !0,
78
- format: buildTask.type === "rolldown:dts" ? "es" : format,
79
- sourcemap: buildTask.type === "rolldown:dts" ? !1 : config?.sourcemap ?? !0,
80
- hoistTransitiveImports: !1
81
- /**
82
- * rolldown doesn't permit disabling chunks, we can only choose between automatic chunking (the default)
83
- * and manual chunking (using advancedChunks).
84
- * This matters for how we generate dts files.
85
- * While we use rolldown for dts generation, and rollup for the rest, we want to reduce the amount of dts files emitted as chunks,
86
- * and to make them predictable in how they're generated.
87
- */
88
- // @TODO the following breaks the dts generation, report bug to rolldown
89
- // advancedChunks:
90
- // buildTask.type === 'rolldown:dts'
91
- // ? {
92
- // groups: [
93
- // {
94
- // /**
95
- // * Groups all inlined typings specified by bundledPackages in extract.bundledPackages to its own chunk.
96
- // */
97
- // name: 'bundled-packages',
98
- // test: (id) => ctx.bundledPackages.includes(id),
99
- // priority: 1,
100
- // },
101
- // {
102
- // /**
103
- // * Put all other shared chunks into a single chunk.
104
- // */
105
- // name: 'shared',
106
- // minShareCount: 1,
107
- // },
108
- // ],
109
- // }
110
- // : {},
111
- };
112
- return { inputOptions, outputOptions };
113
- }
114
- export {
115
- resolveRolldownConfig
116
- };
117
- //# sourceMappingURL=resolveRolldownConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveRolldownConfig.js","sources":["../../src/node/tasks/rolldown/resolveRolldownConfig.ts"],"sourcesContent":["import path from 'node:path'\nimport type {InputOptions, OutputOptions} from 'rolldown'\nimport {dts as dtsPlugin} from 'rolldown-plugin-dts'\nimport type {BuildContext} from '../../core/contexts/buildContext.ts'\nimport {pkgExtMap as extMap} from '../../core/pkg/pkgExt.ts'\nimport type {RolldownDtsTask} from '../types.ts'\n\nexport interface RolldownConfig {\n inputOptions: InputOptions\n outputOptions: OutputOptions\n}\n\nexport function resolveRolldownConfig(\n ctx: BuildContext,\n buildTask: RolldownDtsTask,\n): RolldownConfig {\n const {format, runtime} = buildTask\n const {config, cwd, exports: _exports, external, distPath, logger, pkg, ts} = ctx\n const outputExt = extMap[pkg.type || 'commonjs'][format]\n const outDir = path.relative(cwd, distPath)\n\n const pathAliases = Object.fromEntries(\n Object.entries(ts.config?.options.paths || {}).flatMap(([key, val]) => {\n const pathAlias = val[0]\n if (!pathAlias) return []\n return [[key, path.resolve(cwd, ts.config?.options.baseUrl || '.', pathAlias)]]\n }),\n )\n\n const entries = buildTask.entries.map((entry) => {\n return {\n ...entry,\n name: path.relative(outDir, entry.output).replace(/\\.[^/.]+$/, ''),\n }\n }, {})\n\n const exportIds =\n _exports && Object.keys(_exports).map((exportPath) => path.join(pkg.name, exportPath))\n\n const sourcePaths = _exports && Object.values(_exports).map((e) => path.resolve(cwd, e.source))\n\n const replacements = Object.fromEntries(\n Object.entries(config?.define || {}).map(([key, val]) => [key, JSON.stringify(val)]),\n )\n\n const entryFileNames = `[name]${outputExt}`\n\n const inputOptions = {\n cwd,\n transform: {\n define:\n pkg.name === '@sanity/pkg-utils'\n ? {...replacements}\n : {\n 'process.env.PKG_FORMAT': JSON.stringify(format),\n 'process.env.PKG_RUNTIME': JSON.stringify(runtime),\n 'process.env.PKG_VERSION': JSON.stringify(process.env['PKG_VERSION'] || pkg.version),\n ...replacements,\n },\n },\n\n platform:\n buildTask.type === 'rolldown:dts'\n ? 'node'\n : runtime === 'node'\n ? 'node'\n : runtime === 'browser'\n ? 'browser'\n : 'neutral',\n\n resolve: {\n alias: pathAliases,\n },\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n experimental: {\n attachDebugInfo: 'none',\n },\n\n external: (id, importer) => {\n if (\n buildTask.type === 'rolldown:dts' &&\n ctx.bundledPackages.length > 0 &&\n !id.startsWith('.') &&\n (id.includes('/node_modules/') || id.split('/').length < 3)\n ) {\n return !ctx.bundledPackages.some((name) => name === id || id.includes(`/${name}/`))\n }\n\n // Check if the id is a self-referencing import\n if (exportIds?.includes(id)) {\n return true\n }\n\n // Check if the id is a file path that points to an exported source file\n if (importer && (id.startsWith('.') || id.startsWith('/'))) {\n const idPath = path.resolve(path.dirname(importer), id)\n\n if (sourcePaths?.includes(idPath)) {\n logger.warn(\n `detected self-referencing import – treating as external: ${path.relative(\n cwd,\n idPath,\n )}`,\n )\n\n return true\n }\n }\n\n // Derive the package name of bare specifiers so that subpath imports\n // (e.g. `@sanity/client/stega`) are externalized before resolution,\n // instead of resolving to absolute filesystem paths that leak into the\n // emitted declarations\n const idParts = id.split('/')\n const idPackageName = idParts[0]!.startsWith('@')\n ? `${idParts[0]}/${idParts[1]}`\n : idParts[0]!\n\n return external.some(\n (name) => name === id || name === idPackageName || id.includes(`/node_modules/${name}/`),\n )\n },\n\n input: entries.reduce<{[entryAlias: string]: string}>(\n (acc, entry) => Object.assign(acc, {[entry.name]: entry.source}),\n {},\n ),\n\n plugins: [\n dtsPlugin({\n emitDtsOnly: true,\n tsconfig: ctx.ts.configPath || 'tsconfig.json',\n // When neither the config nor `@typescript/native-preview` decides, leave `tsgo`\n // undefined so `rolldown-plugin-dts` applies its own default: tsgo is auto-enabled when\n // the installed `typescript` is v7 (the Go-native compiler), and disabled otherwise\n tsgo:\n config?.tsgo !== undefined\n ? config.tsgo\n : (typeof pkg.devDependencies === 'object' &&\n '@typescript/native-preview' in pkg.devDependencies) ||\n undefined,\n // Always create dts from scratch, don't reuse contexts from previous builds\n newContext: true,\n }),\n ],\n\n // Rely on rolldown's default tree-shaking (`moduleSideEffects: true`) instead of the\n // equivalent of `moduleSideEffects: 'no-external'`, which stripped intentional\n // side-effect-only imports of external packages. Unused declarations are still\n // tree-shaken (that happens at the binding level, independent of `moduleSideEffects`).\n } satisfies InputOptions\n const outputOptions = {\n dir: outDir,\n entryFileNames,\n chunkFileNames:\n buildTask.type === 'rolldown:dts' ? `_chunks-dts/[name]${outputExt}` : undefined,\n esModule: true,\n format: buildTask.type === 'rolldown:dts' ? 'es' : format,\n sourcemap: buildTask.type === 'rolldown:dts' ? false : (config?.sourcemap ?? true),\n hoistTransitiveImports: false,\n /**\n * rolldown doesn't permit disabling chunks, we can only choose between automatic chunking (the default)\n * and manual chunking (using advancedChunks).\n * This matters for how we generate dts files.\n * While we use rolldown for dts generation, and rollup for the rest, we want to reduce the amount of dts files emitted as chunks,\n * and to make them predictable in how they're generated.\n */\n // @TODO the following breaks the dts generation, report bug to rolldown\n // advancedChunks:\n // buildTask.type === 'rolldown:dts'\n // ? {\n // groups: [\n // {\n // /**\n // * Groups all inlined typings specified by bundledPackages in extract.bundledPackages to its own chunk.\n // */\n // name: 'bundled-packages',\n // test: (id) => ctx.bundledPackages.includes(id),\n // priority: 1,\n // },\n // {\n // /**\n // * Put all other shared chunks into a single chunk.\n // */\n // name: 'shared',\n // minShareCount: 1,\n // },\n // ],\n // }\n // : {},\n } satisfies OutputOptions\n\n return {inputOptions, outputOptions}\n}\n"],"names":["extMap","dtsPlugin"],"mappings":";;;AAYO,SAAS,sBACd,KACA,WACgB;AAChB,QAAM,EAAC,QAAQ,QAAA,IAAW,WACpB,EAAC,QAAQ,KAAK,SAAS,UAAU,UAAU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O;AAAA,MAC/D,CAAA;AAAA,IAAC;AAAA,IAGH,SAAS;AAAA,MACPC,IAAU;AAAA,QACR,aAAa;AAAA,QACb,UAAU,IAAI,GAAG,cAAc;AAAA;AAAA;AAAA;AAAA,QAI/B,MACE,QAAQ,SAAS,SACb,OAAO,OACN,OAAO,IAAI,mBAAoB,YAC9B,gCAAgC,IAAI,mBACtC;AAAA;AAAA,QAEN,YAAY;AAAA,MAAA,CACb;AAAA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EACH,GAOI,gBAAgB;AAAA,IACpB,KAAK;AAAA,IACL;AAAA,IACA,gBACE,UAAU,SAAS,iBAAiB,qBAAqB,SAAS,KAAK;AAAA,IACzE,UAAU;AAAA,IACV,QAAQ,UAAU,SAAS,iBAAiB,OAAO;AAAA,IACnD,WAAW,UAAU,SAAS,iBAAiB,KAAS,QAAQ,aAAa;AAAA,IAC7E,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AAiC1B,SAAO,EAAC,cAAc,cAAA;AACxB;"}
@@ -1,16 +0,0 @@
1
- import chalk from "chalk";
2
- function createSpinner(msg, quiet = !1) {
3
- const startTime = Date.now();
4
- return quiet || console.log(msg), {
5
- complete: () => {
6
- quiet || console.log(`${chalk.green("[success]")} ${chalk.gray(`${Date.now() - startTime}ms`)}`);
7
- },
8
- error: () => {
9
- console.log(`${chalk.red("[error]")} ${chalk.gray(`${Date.now() - startTime}ms`)}`);
10
- }
11
- };
12
- }
13
- export {
14
- createSpinner
15
- };
16
- //# sourceMappingURL=spinner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spinner.js","sources":["../../src/node/spinner.ts"],"sourcesContent":["// oxlint-disable no-console\nimport chalk from 'chalk'\n\nexport function createSpinner(\n msg: string,\n quiet = false,\n): {complete: () => void; error: () => void} {\n const startTime = Date.now()\n\n if (!quiet) console.log(msg)\n\n return {\n complete: () => {\n if (!quiet)\n console.log(`${chalk.green('[success]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n error: () => {\n console.log(`${chalk.red('[error]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n }\n}\n"],"names":[],"mappings":";AAGO,SAAS,cACd,KACA,QAAQ,IACmC;AAC3C,QAAM,YAAY,KAAK,IAAA;AAEvB,SAAK,SAAO,QAAQ,IAAI,GAAG,GAEpB;AAAA,IACL,UAAU,MAAM;AACT,eACH,QAAQ,IAAI,GAAG,MAAM,MAAM,WAAW,CAAC,IAAI,MAAM,KAAK,GAAG,KAAK,IAAA,IAAQ,SAAS,IAAI,CAAC,EAAE;AAAA,IAC1F;AAAA,IACA,OAAO,MAAM;AACX,cAAQ,IAAI,GAAG,MAAM,IAAI,SAAS,CAAC,IAAI,MAAM,KAAK,GAAG,KAAK,IAAA,IAAQ,SAAS,IAAI,CAAC,EAAE;AAAA,IACpF;AAAA,EAAA;AAEJ;"}
@@ -1,160 +0,0 @@
1
- import path from "node:path";
2
- import { up } from "empathic/package";
3
- import { switchMap } from "rxjs";
4
- import { loadConfig } from "./defaults.js";
5
- import { resolveVanillaExtract, writeBundleCssExports, resolveVanillaExtractCssName, watchTaskHandlers } from "./index.js";
6
- import { getTargetPaths, loadPkgWithReporting, resolveBuildContext } from "./resolveBuildContext.js";
7
- import { createLogger, handleError } from "./handleError.js";
8
- function resolveWatchTasks(ctx) {
9
- const { pkg, target } = ctx, tasks = [], exports = Object.entries(ctx.exports || {}).map(
10
- ([_path, exp]) => Object.assign({}, exp, { _path })
11
- ), dtsTask = {
12
- type: "watch:dts",
13
- entries: []
14
- }, rollupTasks = {};
15
- function addRollupTaskEntry(format, runtime, entry) {
16
- const buildId = `${format}:${runtime}`;
17
- rollupTasks[buildId] ? rollupTasks[buildId].entries.push(entry) : rollupTasks[buildId] = {
18
- type: "watch:js",
19
- buildId,
20
- entries: [entry],
21
- runtime,
22
- format,
23
- target: target[runtime]
24
- };
25
- }
26
- for (const exp of exports) {
27
- const importId = path.join(pkg.name, exp._path);
28
- exp.source?.endsWith(".ts") && dtsTask.entries.push({
29
- importId,
30
- exportPath: exp._path,
31
- sourcePath: exp.source,
32
- targetPaths: getTargetPaths(pkg.type, exp)
33
- }), exp.browser?.source?.endsWith(".ts") && dtsTask.entries.push({
34
- importId,
35
- exportPath: exp._path,
36
- sourcePath: exp.browser.source,
37
- targetPaths: getTargetPaths(pkg.type, exp.browser)
38
- }), exp.node?.source?.endsWith(".ts") && dtsTask.entries.push({
39
- importId,
40
- exportPath: exp._path,
41
- sourcePath: exp.node.source,
42
- targetPaths: getTargetPaths(pkg.type, exp.node)
43
- });
44
- }
45
- for (const exp of exports) {
46
- const output = exp.require;
47
- output && addRollupTaskEntry("commonjs", ctx.runtime, {
48
- path: exp._path,
49
- source: exp.source,
50
- output
51
- });
52
- }
53
- for (const exp of exports) {
54
- const output = exp.browser?.require;
55
- output && addRollupTaskEntry("commonjs", "browser", {
56
- path: exp._path,
57
- source: exp.browser?.source || exp.source,
58
- output
59
- });
60
- }
61
- for (const exp of exports) {
62
- const output = exp.import;
63
- output && addRollupTaskEntry("esm", ctx.runtime, {
64
- path: exp._path,
65
- source: exp.source,
66
- output
67
- });
68
- }
69
- for (const exp of exports) {
70
- const output = exp.browser?.import;
71
- output && addRollupTaskEntry("esm", "browser", {
72
- path: exp._path,
73
- source: exp.browser?.source || exp.source,
74
- output
75
- });
76
- }
77
- for (const exp of exports) {
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) {
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
- }
93
- return dtsTask.entries.length && tasks.push(dtsTask), tasks.push(...Object.values(rollupTasks)), tasks;
94
- }
95
- async function watch(options) {
96
- const { cwd, strict = !1, tsconfig: tsconfigOption, signal } = options, logger = createLogger(), { watchConfigFiles } = await import("./watchConfigFiles.js"), configFiles$ = await watchConfigFiles({ cwd, logger }), taskSubscriptions = [], ctxSubscription = configFiles$.pipe(
97
- switchMap(async (configFiles) => {
98
- const packageJsonPath = configFiles.map((f) => path.relative(cwd, f)).find((f) => f === "package.json"), pkgPath = up({ cwd });
99
- if (!packageJsonPath || !pkgPath)
100
- throw new Error("missing package.json", { cause: { cwd } });
101
- const config = await loadConfig({ cwd, pkgPath }), { parseStrictOptions } = await import("./resolveBuildContext.js").then(function(n) {
102
- return n.strict;
103
- }), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ pkgPath, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json";
104
- return resolveBuildContext({ config, cwd, logger, pkg, strict, tsconfig });
105
- })
106
- ).subscribe(async (ctx) => {
107
- for (const sub of taskSubscriptions)
108
- sub.unsubscribe();
109
- taskSubscriptions.length = 0;
110
- const vanillaExtract = resolveVanillaExtract(ctx.config);
111
- vanillaExtract.compatMode && await writeBundleCssExports({
112
- cwd,
113
- distPath: ctx.distPath,
114
- cssName: resolveVanillaExtractCssName(vanillaExtract.options, {
115
- compatMode: !0,
116
- runtime: "*"
117
- }),
118
- logger
119
- });
120
- const watchTasks = resolveWatchTasks(ctx);
121
- for (const task of watchTasks) {
122
- const handler = watchTaskHandlers[task.type], sub = handler.exec(ctx, task).subscribe({
123
- error: (err) => {
124
- ctx.logger.error(err), ctx.logger.log(), process.exit(1);
125
- },
126
- next: (result) => {
127
- handler.complete(ctx, task, result);
128
- },
129
- complete: () => {
130
- ctx.logger.success(handler.name(ctx, task)), ctx.logger.log();
131
- }
132
- });
133
- taskSubscriptions.push(sub);
134
- }
135
- });
136
- signal && signal.addEventListener(
137
- "abort",
138
- () => {
139
- for (const sub of taskSubscriptions)
140
- sub.unsubscribe();
141
- taskSubscriptions.length = 0, ctxSubscription.unsubscribe();
142
- },
143
- { once: !0 }
144
- );
145
- }
146
- async function watchAction(options) {
147
- try {
148
- await watch({
149
- cwd: process.cwd(),
150
- strict: options.strict,
151
- tsconfig: options.tsconfig
152
- });
153
- } catch (err) {
154
- handleError(err);
155
- }
156
- }
157
- export {
158
- watchAction
159
- };
160
- //# sourceMappingURL=watchAction.js.map
@@ -1 +0,0 @@
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: Array<PkgExport & {_path: string}> = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => Object.assign({}, exp, {_path}),\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 {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 {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 // Keep the conditional `./<css>` export in package.json in sync with the injected\n // `import \"<pkg>/<css>\"` for watch builds too (idempotent, so it won't loop).\n const vanillaExtract = resolveVanillaExtract(ctx.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 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":["findPkgPath"],"mappings":";;;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,KAAK,OAAA,IAAU,KAChB,QAAqB,CAAA,GAErB,UAA8C,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IACpF,CAAC,CAAC,OAAO,GAAG,MAAM,OAAO,OAAO,CAAA,GAAI,KAAK,EAAC,MAAA,CAAM;AAAA,EAAA,GAG5C,UAAwB;AAAA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d,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;AC9GA,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,49 +0,0 @@
1
- import path from "node:path";
2
- import { scan, startWith, distinctUntilChanged } from "rxjs/operators";
3
- import { globby } from "globby";
4
- import * as chokidar from "chokidar";
5
- import { Observable } from "rxjs";
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
- const watcher = chokidar.watch(patterns, {
12
- ignoreInitial: !0
13
- });
14
- function handleFileEvent(type, file) {
15
- type === "error" || file instanceof Error ? observer.error(file) : observer.next({ type, file });
16
- }
17
- return watcher.on("all", handleFileEvent), () => {
18
- watcher.off("all", handleFileEvent), watcher.close();
19
- };
20
- });
21
- }
22
- async function watchConfigFiles(options) {
23
- const { cwd, logger } = options, initialFiles = await globFiles([
24
- path.resolve(cwd, "package.json"),
25
- path.resolve(cwd, "package.config.cjs"),
26
- path.resolve(cwd, "package.config.js"),
27
- path.resolve(cwd, "package.config.ts"),
28
- path.resolve(cwd, "package.config.mjs"),
29
- path.resolve(cwd, "package.config.mts")
30
- ]);
31
- return watchFiles([
32
- path.resolve(cwd, "package.json"),
33
- path.resolve(cwd, "package.config.cjs"),
34
- path.resolve(cwd, "package.config.js"),
35
- path.resolve(cwd, "package.config.ts"),
36
- path.resolve(cwd, "package.config.mjs"),
37
- path.resolve(cwd, "package.config.mts")
38
- ]).pipe(
39
- scan((files, fileEvent) => fileEvent.type === "add" ? files.concat(fileEvent.file) : fileEvent.type === "unlink" ? files.filter((f) => f !== fileEvent.file) : fileEvent.type === "change" ? (logger.log(
40
- "--------------------------------------------------------------------------------"
41
- ), logger.info(path.relative(cwd, fileEvent.file), "changed"), logger.log(""), files.slice(0)) : files, initialFiles),
42
- startWith(initialFiles),
43
- distinctUntilChanged()
44
- );
45
- }
46
- export {
47
- watchConfigFiles
48
- };
49
- //# sourceMappingURL=watchConfigFiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"watchConfigFiles.js","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 startWith(initialFiles),\n distinctUntilChanged(),\n )\n}\n"],"names":[],"mappings":";;;;;AAGO,SAAS,UAAU,UAAuC;AAC/D,SAAO,OAAO,SAAS,IAAI,CAAC,YAAY,QAAQ,MAAM,KAAK,GAAG,EAAE,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC;AACvF;ACIO,SAAS,WAAW,UAA2C;AACpE,SAAO,IAAI,WAAW,CAAC,aAAa;AAClC,UAAM,UAAU,SAAS,M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