@sanity/pkg-utils 11.0.14 → 11.0.16

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.
@@ -6,8 +6,8 @@ import { fileExists } from "./fileExists.js";
6
6
  import { isRecord, createLogger, handleError } from "./handleError.js";
7
7
  import { execSync } from "node:child_process";
8
8
  import { getLatestVersion } from "get-latest-version";
9
- import gitUrlParse from "git-url-parse";
10
9
  import { outdent } from "outdent";
10
+ import require$$0 from "url";
11
11
  import { format } from "prettier";
12
12
  import { defineTemplateOption } from "./define.js";
13
13
  const promptsTypes = {
@@ -78,7 +78,133 @@ const overridableDefaults = {
78
78
  bracketSpacing: !1,
79
79
  plugins: ["prettier-plugin-packagejson"],
80
80
  overrides: [json5, yaml]
81
- }, RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i, defaultTemplate = async ({ cwd, logger, packagePath }) => {
81
+ };
82
+ function getDefaultExportFromCjs(x) {
83
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
84
+ }
85
+ var parseUrl, hasRequiredParseUrl;
86
+ function requireParseUrl() {
87
+ if (hasRequiredParseUrl) return parseUrl;
88
+ hasRequiredParseUrl = 1;
89
+ var urlModule = require$$0, URLCtor = typeof URL > "u" ? urlModule.URL || null : URL, legacyURLParse = URLCtor ? null : urlModule.parse;
90
+ function parseWHATWG(str) {
91
+ try {
92
+ var u = new URLCtor(str), auth = null;
93
+ u.username && (auth = u.password ? u.username + ":" + u.password : u.username);
94
+ var host = u.host || null, hostname = u.hostname || null, pathname = u.pathname || null, path = u.pathname + (u.search || "") || null;
95
+ if (!host && pathname && str.indexOf("//") === -1) {
96
+ var slashIdx = pathname.indexOf("/");
97
+ slashIdx === -1 ? (host = pathname, hostname = pathname, pathname = null, path = null) : (host = pathname.slice(0, slashIdx), hostname = host, pathname = pathname.slice(slashIdx), path = pathname + (u.search || ""));
98
+ }
99
+ return {
100
+ auth,
101
+ hash: u.hash || null,
102
+ host,
103
+ hostname,
104
+ href: u.href,
105
+ path,
106
+ pathname,
107
+ port: u.port || null,
108
+ protocol: u.protocol || null,
109
+ query: u.search ? u.search.slice(1) : null,
110
+ search: u.search || null,
111
+ slashes: str.indexOf("//") === -1 ? null : !0
112
+ };
113
+ } catch {
114
+ var hashIdx = str.indexOf("#"), hash = hashIdx === -1 ? null : str.slice(hashIdx), pathPart = hashIdx === -1 ? str : str.slice(0, hashIdx), queryIdx = pathPart.indexOf("?"), search = queryIdx === -1 ? null : pathPart.slice(queryIdx), pathnamePart = queryIdx === -1 ? pathPart : pathPart.slice(0, queryIdx);
115
+ return {
116
+ auth: null,
117
+ hash,
118
+ host: null,
119
+ hostname: null,
120
+ href: str,
121
+ path: pathPart || null,
122
+ pathname: pathnamePart || null,
123
+ port: null,
124
+ protocol: null,
125
+ query: search ? search.slice(1) : null,
126
+ search,
127
+ slashes: null
128
+ };
129
+ }
130
+ }
131
+ return parseUrl = URLCtor ? parseWHATWG : legacyURLParse, parseUrl;
132
+ }
133
+ /*!
134
+ * parse-github-url <https://github.com/jonschlinkert/parse-github-url>
135
+ *
136
+ * Copyright (c) 2015-2017, Jon Schlinkert.
137
+ * Released under the MIT License.
138
+ */
139
+ var parseGithubUrl$1, hasRequiredParseGithubUrl;
140
+ function requireParseGithubUrl() {
141
+ if (hasRequiredParseGithubUrl) return parseGithubUrl$1;
142
+ hasRequiredParseGithubUrl = 1;
143
+ var parseURL = requireParseUrl(), cache = { __proto__: null };
144
+ function isChecksum(str) {
145
+ return /^[a-f0-9]{40}$/i.test(str);
146
+ }
147
+ function getBranch(str, obj) {
148
+ var segs = str.split("#"), branch;
149
+ return segs.length > 1 && (branch = segs[segs.length - 1]), !branch && obj.hash && obj.hash.charAt(0) === "#" && (branch = obj.hash.slice(1)), branch || "master";
150
+ }
151
+ function trimSlash(path) {
152
+ return path.charAt(0) === "/" ? path.slice(1) : path;
153
+ }
154
+ function name(str) {
155
+ return str ? str.replace(/\.git$/, "") : null;
156
+ }
157
+ function owner(str) {
158
+ if (!str)
159
+ return null;
160
+ var idx = str.indexOf(":");
161
+ return idx > -1 ? str.slice(idx + 1) : str;
162
+ }
163
+ function getGitAtHost(str) {
164
+ var transformed = "http://" + str.replace(/git@([^:]+):/, "$1/");
165
+ return parseURL(transformed).host || null;
166
+ }
167
+ function parse(str) {
168
+ if (typeof str != "string" || !str.length || str.indexOf("git@gist") !== -1 || str.indexOf("//gist") !== -1)
169
+ return null;
170
+ var obj = parseURL(str);
171
+ if (typeof obj.path != "string" || !obj.path.length || typeof obj.pathname != "string" || !obj.pathname.length)
172
+ return null;
173
+ !obj.host && /^git@/.test(str) === !0 && (obj.host = getGitAtHost(str)), obj.path = trimSlash(obj.path), obj.pathname = trimSlash(obj.pathname), obj.filepath = null, obj.path.indexOf("repos") === 0 && (obj.path = obj.path.slice(6));
174
+ var seg = obj.path.split("/").filter(Boolean), hasBlob = seg[2] === "blob";
175
+ hasBlob && !isChecksum(seg[3]) && (obj.branch = seg[3], seg.length > 4 && (obj.filepath = seg.slice(4).join("/")));
176
+ var blob = str.indexOf("blob");
177
+ hasBlob && blob !== -1 && (obj.blob = str.slice(blob + 5));
178
+ var hasTree = seg[2] === "tree", tree = str.indexOf("tree");
179
+ if (hasTree && tree !== -1) {
180
+ var idx = tree + 5, branch = str.slice(idx), slash = branch.indexOf("/");
181
+ slash !== -1 && (branch = branch.slice(0, slash)), obj.branch = branch;
182
+ }
183
+ if (obj.owner = owner(seg[0]), obj.name = name(seg[1]), seg.length > 1 && obj.owner && obj.name)
184
+ obj.repo = obj.owner + "/" + obj.name;
185
+ else {
186
+ var href = obj.href.split(":");
187
+ if (href.length === 2 && obj.href.indexOf("//") === -1) {
188
+ obj.repo = obj.repo || href[href.length - 1];
189
+ var repoSegments = obj.repo.split("/");
190
+ obj.owner = repoSegments[0], obj.name = repoSegments[1];
191
+ } else {
192
+ var match = obj.href.match(/\/([^/]*)$/);
193
+ obj.owner = match ? match[1] : null, obj.repo = null;
194
+ }
195
+ if (obj.repo && (!obj.owner || !obj.name)) {
196
+ var segs = obj.repo.split("/");
197
+ segs.length === 2 && (obj.owner = segs[0], obj.name = segs[1]);
198
+ }
199
+ }
200
+ return obj.branch || (obj.branch = seg[2] || getBranch(obj.path, obj), seg.length > 3 && (obj.filepath = seg.slice(3).join("/"))), obj.host = obj.host || "github.com", obj.owner = obj.owner || null, obj.name = obj.name || null, obj.repository = obj.repo, obj;
201
+ }
202
+ return parseGithubUrl$1 = function(str) {
203
+ return cache[str] || (cache[str] = parse(str)), cache[str];
204
+ }, parseGithubUrl$1;
205
+ }
206
+ var parseGithubUrlExports = requireParseGithubUrl(), parseGithubUrl = /* @__PURE__ */ getDefaultExportFromCjs(parseGithubUrlExports);
207
+ const RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i, defaultTemplate = async ({ cwd, logger, packagePath }) => {
82
208
  const gitConfig = getGitUserConfig(cwd);
83
209
  return {
84
210
  options: [
@@ -88,16 +214,15 @@ const overridableDefaults = {
88
214
  description: "git url",
89
215
  validate: (v) => {
90
216
  if (!v) return !0;
91
- try {
92
- return gitUrlParse(v), !0;
93
- } catch {
94
- return "invalid git url";
95
- }
217
+ const result = parseGithubUrl(v);
218
+ return !result?.host || !result.owner || !result.name ? "invalid git url" : !0;
96
219
  },
97
220
  parse: (v) => {
98
221
  if (!v) return null;
99
- const result = gitUrlParse(v);
100
- return { source: result.source, owner: result.owner, name: result.name };
222
+ const result = parseGithubUrl(v);
223
+ if (!result?.host || !result.owner || !result.name)
224
+ throw new Error("invalid git url");
225
+ return { source: result.host, owner: result.owner, name: result.name };
101
226
  }
102
227
  }),
103
228
  defineTemplateOption({
@@ -1 +1 @@
1
- {"version":3,"file":"initAction.js","sources":["../../src/node/core/template/createFromTemplate.ts","../../src/node/isEmptyDirectory.ts","../../../../../node_modules/.pnpm/@sanity+prettier-config@3.0.0_prettier@3.9.5/node_modules/@sanity/prettier-config/dist/index.js","../../src/node/templates/default/template.ts","../../src/node/init.ts","../../src/cli/initAction.ts"],"sourcesContent":["import {writeFile} from 'node:fs/promises'\nimport {dirname, relative, resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport prompts from 'prompts'\nimport type {Logger} from '../../logger.ts'\nimport type {PkgTemplate} from './types.ts'\n\nconst promptsTypes = {\n string: 'text' as const,\n}\n\n/** @internal */\nexport async function createFromTemplate(options: {\n cwd: string\n logger: Logger\n packagePath: string\n template: PkgTemplate\n}): Promise<void> {\n const {cwd, logger, packagePath, template: templateOrResolver} = options\n\n const template =\n typeof templateOrResolver === 'function'\n ? await templateOrResolver({cwd, logger, packagePath})\n : templateOrResolver\n\n logger.log('create new package at', relative(cwd, packagePath))\n\n const templateOptions: Record<string, string> = {}\n\n for (const templateOption of template.options) {\n const templateValidate = templateOption.validate\n\n const res = await prompts(\n {\n type: promptsTypes[templateOption.type],\n name: templateOption.name,\n message: templateOption.description,\n validate: templateValidate ? (prev) => templateValidate(prev) : undefined,\n initial:\n typeof templateOption.initial === 'function'\n ? templateOption.initial(templateOptions)\n : templateOption.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n\n templateOptions[templateOption.name] = templateOption.parse\n ? templateOption.parse(res[templateOption.name])\n : res[templateOption.name]\n }\n\n const features: Record<string, boolean> = {}\n\n for (const templateFeature of template.features) {\n const res = templateFeature.optional\n ? await prompts(\n {\n type: 'confirm',\n name: 'confirm',\n message: `use ${templateFeature.name}?`,\n initial: templateFeature.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n : undefined\n\n features[templateFeature.name] = res?.confirm || !templateFeature.optional\n }\n\n const files = await template.getFiles(templateOptions, features)\n\n files.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n for (const file of files) {\n const filePath = resolve(packagePath, file.name)\n\n await mkdirp(dirname(filePath))\n await writeFile(filePath, file.contents.trim() + '\\n')\n\n logger.success(`wrote ${relative(cwd, filePath)}`)\n }\n}\n","import {readdir} from 'node:fs/promises'\n\nexport async function isEmptyDirectory(dirPath: string): Promise<boolean> {\n return (await readdir(dirPath)).length === 0\n}\n","const overridableDefaults = {\n endOfLine: \"lf\",\n tabWidth: 2,\n useTabs: !1\n}, json5 = {\n files: [\"*.json5\"],\n options: {\n quoteProps: \"preserve\",\n singleQuote: !1\n }\n}, yaml = {\n files: [\"*.yml\"],\n options: {\n singleQuote: !1\n }\n}, config = {\n ...overridableDefaults,\n printWidth: 100,\n semi: !1,\n singleQuote: !0,\n quoteProps: \"consistent\",\n bracketSpacing: !1,\n plugins: [\"prettier-plugin-packagejson\"],\n overrides: [json5, yaml]\n};\nexport {\n config as default\n};\n//# sourceMappingURL=index.js.map\n","import {execSync} from 'node:child_process'\nimport {resolve} from 'node:path'\nimport type {PackageJSON} from '@sanity/parse-package-json'\nimport prettierConfig from '@sanity/prettier-config'\nimport {getLatestVersion} from 'get-latest-version'\nimport gitUrlParse from 'git-url-parse'\nimport {outdent} from 'outdent'\nimport {format, type Config as PrettierConfig} from 'prettier'\nimport {isRecord} from '../../core/isRecord.ts'\nimport {defineTemplateOption} from '../../core/template/define.ts'\nimport {type PkgTemplate, type PkgTemplateFile} from '../../core/template/types.ts'\n\nconst RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\\/)?[a-z0-9-~][a-z0-9-._~]*$/i\n\nexport const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) => {\n const gitConfig = getGitUserConfig(cwd)\n\n return {\n options: [\n defineTemplateOption<{owner: string; name: string}>({\n name: 'repo',\n type: 'string',\n description: 'git url',\n validate: (v) => {\n if (!v) return true\n\n try {\n gitUrlParse(v)\n\n return true\n } catch {\n return 'invalid git url'\n }\n },\n parse: (v) => {\n if (!v) return null\n\n const result = gitUrlParse(v)\n\n return {source: result.source, owner: result.owner, name: result.name}\n },\n }),\n defineTemplateOption({\n name: 'pkgName',\n type: 'string',\n description: 'package name',\n initial: (options) => options['repo']?.name || undefined,\n validate: (v) => {\n if (!v) return 'package name is required'\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n return 'invalid package name'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) {\n throw new Error('package name is required')\n }\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n throw new Error('invalid package name')\n }\n\n const [scope, name] = v.split('/')\n\n return {scope, name, fullName: v}\n },\n }),\n defineTemplateOption({\n name: 'description',\n type: 'string',\n description: 'package description',\n }),\n defineTemplateOption({\n name: 'authorName',\n type: 'string',\n description: 'package author name',\n initial: gitConfig.user,\n }),\n defineTemplateOption({\n name: 'authorEmail',\n type: 'string',\n description: 'package author email',\n initial: gitConfig.email,\n }),\n defineTemplateOption({\n name: 'license',\n type: 'string',\n description: 'package license',\n initial: 'MIT',\n validate: (v) => {\n if (!v) return 'license is required'\n\n return true\n },\n }),\n ],\n\n features: [\n {\n name: 'eslint',\n optional: true,\n initial: true,\n },\n {\n name: 'prettier',\n optional: true,\n initial: true,\n },\n {\n name: 'typescript',\n optional: true,\n initial: true,\n },\n ],\n\n async getFiles(options, features) {\n const {pkgName, repo} = options\n const {fullName: name} = pkgName\n\n const author =\n [options['authorName'], options['authorEmail'] && `<${options['authorEmail']}>`]\n .filter(Boolean)\n .join(' ') ?? undefined\n\n const pkgJson: PackageJSON & {\n prettier?: '@sanity/prettier-config'\n ['lint-staged']?: Record<string, string[]>\n } = {\n name,\n 'version': '0.0.0',\n 'description': options['description'] ?? undefined,\n 'keywords': [],\n 'homepage': undefined,\n 'bugs': undefined,\n 'repository': undefined,\n 'license': options['license'],\n author,\n 'sideEffects': false,\n 'type': 'module',\n 'exports': {\n '.': {\n source: features['typescript'] ? './src/index.ts' : './src/index.js',\n require: './dist/index.cjs',\n default: './dist/index.js',\n },\n './package.json': './package.json',\n },\n 'main': './dist/index.cjs',\n 'module': './dist/index.js',\n 'types': undefined,\n 'files': ['dist', 'src'],\n 'scripts': {\n build: 'pkg build --strict --clean --check',\n format: features['prettier'] ? 'prettier --write --cache --ignore-unknown .' : undefined,\n },\n 'lint-staged': features['prettier']\n ? {\n '*': ['prettier --write --cache --ignore-unknown'],\n }\n : undefined,\n 'browserslist': 'extends @sanity/browserslist-config',\n 'prettier': features['prettier'] ? '@sanity/prettier-config' : undefined,\n 'dependencies': {},\n 'devDependencies': {\n '@sanity/tsconfig': features['typescript'] ? '^1' : undefined,\n '@sanity/pkg-utils': '^9',\n '@sanity/prettier-config': features['prettier'] ? '^1' : undefined,\n '@typescript-eslint/eslint-plugin': undefined,\n '@typescript-eslint/parser': undefined,\n 'eslint': undefined,\n 'eslint-config-prettier': undefined,\n 'eslint-plugin-import': undefined,\n 'eslint-plugin-prettier': undefined,\n 'eslint-plugin-simple-import-sort': undefined,\n 'lint-staged': '^15',\n 'prettier': features['prettier'] ? '^3' : undefined,\n 'typescript': undefined,\n },\n 'engines': {\n node: '>=20.19 <22 || >=22.12',\n },\n }\n\n const files: PkgTemplateFile[] = []\n\n // .editorconfig\n files.push({\n name: '.editorconfig',\n contents: outdent`\n root = true\n\n [*]\n charset = utf-8\n indent_style = space\n indent_size = 2\n end_of_line = lf\n insert_final_newline = true\n trim_trailing_whitespace = true\n `,\n })\n\n // .gitignore\n files.push({\n name: '.gitignore',\n contents: outdent`\n *.local\n *.log\n *.tgz\n\n .DS_Store\n dist\n etc\n node_modules\n `,\n })\n\n if (features['prettier']) {\n files.push({\n name: '.prettierignore',\n contents: outdent`\n dist\n pnpm-lock.yaml\n `,\n })\n }\n\n if (repo) {\n pkgJson.repository = {\n type: 'git',\n url: `git+ssh://git@${repo.source}/${repo.owner}/${repo.name}.git`,\n }\n pkgJson.bugs = {\n url: `https://${repo.source}/${repo.owner}/${repo.name}/issues`,\n }\n pkgJson.homepage = `https://${repo.source}/${repo.owner}/${repo.name}#readme`\n }\n\n if (features['typescript']) {\n pkgJson.types = './dist/index.d.ts'\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n ['ts:check']: 'tsc --noEmit',\n }\n\n const devDependencies = pkgJson.devDependencies\n\n if (isRecord(devDependencies)) {\n devDependencies['typescript'] = '^5.9'\n }\n }\n\n if (features['eslint']) {\n const eslintConfig: any = {\n root: true,\n env: {\n browser: true,\n es6: true,\n node: true,\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n ].filter(Boolean),\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n },\n plugins: [\n 'import',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n 'no-console': 'error',\n 'no-shadow': 'error',\n 'no-warning-comments': ['warn', {location: 'start', terms: ['todo', 'fixme']}],\n 'quote-props': ['warn', 'consistent-as-needed'],\n 'simple-import-sort/exports': 'warn',\n 'simple-import-sort/imports': 'warn',\n 'strict': ['warn', 'global'],\n },\n }\n\n files.push({\n name: '.eslintignore',\n contents: outdent`\n dist\n `,\n })\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n lint: features['typescript']\n ? 'eslint . --ext .cjs,.js,.ts,.tsx'\n : 'eslint . --ext .cjs,.js',\n }\n\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n 'eslint': '^8',\n 'eslint-config-prettier': features['prettier'] ? '^9' : undefined,\n 'eslint-plugin-import': '^2',\n 'eslint-plugin-prettier': features['prettier'] ? '^5' : undefined,\n 'eslint-plugin-simple-import-sort': '^12',\n }\n\n if (features['typescript']) {\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n '@typescript-eslint/eslint-plugin': '^7',\n '@typescript-eslint/parser': '^7',\n }\n\n const eslintConfigOverride: any = {\n files: ['**/*.ts', '**/*.tsx'],\n parser: '@typescript-eslint/parser',\n parserOptions: {\n project: ['./tsconfig.json'],\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n 'plugin:@typescript-eslint/eslint-recommended',\n 'plugin:@typescript-eslint/recommended',\n ].filter(Boolean),\n plugins: [\n 'import',\n '@typescript-eslint',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n '@typescript-eslint/explicit-module-boundary-types': 'error',\n '@typescript-eslint/interface-name-prefix': 'off',\n '@typescript-eslint/member-delimiter-style': 'off',\n '@typescript-eslint/no-empty-interface': 'off',\n },\n }\n\n eslintConfig.overrides = [eslintConfigOverride]\n }\n\n files.push({\n name: '.eslintrc.cjs',\n contents: await prettierFormat(\n resolve(packagePath, '.eslintrc.cjs'),\n outdent`\n 'use strict'\n\n /** @type import('eslint').Linter.Config */\n module.exports = ${JSON.stringify(eslintConfig, null, 2)}\n `,\n prettierConfig,\n ),\n })\n }\n\n if (features['typescript']) {\n files.push({\n name: 'tsconfig.settings.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.settings.json'),\n outdent`\n {\n \"extends\": \"@sanity/tsconfig/strictest\",\n \"compilerOptions\": {\n \"rootDir\": \".\",\n \"outDir\": \"./dist\"\n }\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.dist.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.dist.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./src\"],\n \"exclude\": [\"./src/**/*.test.ts\"]\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./**/*.cjs\", \"./**/*.ts\", \"./**/*.tsx\"],\n \"exclude\": [\"./node_modules\"]\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // source file\n if (features['typescript']) {\n files.push({\n name: 'package.config.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.ts'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n // https://github.com/sanity-io/pkg-utils#configuration\n export default defineConfig({\n // the path to the tsconfig file for distributed builds\n tsconfig: 'tsconfig.dist.json',\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.ts'),\n outdent`\n /** @public */\n export function main(): void {\n //\n }\n `,\n prettierConfig,\n ),\n })\n } else {\n files.push({\n name: 'package.config.js',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.js'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n export default defineConfig({\n extract: {\n rules: {\n // do not require internal members to be prefixed with \\`_\\`\n 'ae-internal-missing-underscore': 'off',\n },\n },\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.js',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.js'),\n outdent`\n /** @public */\n export function main() {\n //\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // Resolve latest dependencies\n try {\n pkgJson.dependencies = await resolveLatestDeps(pkgJson.dependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n // Resolve latest devDependencies\n try {\n pkgJson.devDependencies = await resolveLatestDeps(pkgJson.devDependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n files.push({\n name: 'package.json',\n contents: await prettierFormat(\n resolve(packagePath, 'package.json'),\n JSON.stringify(pkgJson, null, 2),\n prettierConfig,\n ),\n })\n\n return files\n },\n }\n}\n\nfunction prettierFormat(\n filepath: string,\n input: string,\n prettierOptions: PrettierConfig | undefined,\n) {\n return format(input, {...prettierOptions, plugins: [], filepath})\n}\n\nasync function resolveLatestDeps(deps: Record<string, string | undefined>) {\n const depsEntries = Object.entries(deps)\n const latestDeps: Record<string, string> = {}\n\n for (const entry of depsEntries) {\n const [name, version] = entry\n\n if (version) {\n const latestVersion = await getLatestVersion(name, {range: version})\n\n latestDeps[name] = latestVersion ? `^${latestVersion}` : version\n }\n }\n\n return latestDeps\n}\n\nfunction getGitUserConfig(cwd: string): {user: string | undefined; email: string | undefined} {\n let user: string | undefined\n let email: string | undefined\n\n try {\n user = execSync('git config user.name', {encoding: 'utf8', cwd}).trim() || undefined\n email = execSync('git config user.email', {encoding: 'utf8', cwd}).trim() || undefined\n } catch {\n /* ignore */\n }\n\n return {user, email}\n}\n","import {lstat} from 'node:fs/promises'\nimport {resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport {createFromTemplate} from './core/template/index.ts'\nimport {fileExists} from './fileExists.ts'\nimport {isEmptyDirectory} from './isEmptyDirectory.ts'\nimport {createLogger} from './logger.ts'\nimport {defaultTemplate} from './templates/default/template.ts'\n\n/** @public */\nexport async function init(options: {cwd: string; path: string}): Promise<void> {\n if (!options.cwd) {\n throw new Error('Missing required option: cwd')\n }\n\n if (!options.path) {\n throw new Error('Missing required option: path')\n }\n\n const logger = createLogger()\n\n const packagePath = resolve(options.cwd, options.path)\n\n await ensurePackagePath(packagePath)\n\n await createFromTemplate({\n cwd: options.cwd,\n logger,\n template: defaultTemplate,\n packagePath,\n })\n}\n\nasync function ensurePackagePath(packagePath: string): Promise<void> {\n const exists = fileExists(packagePath)\n\n if (!exists) {\n await mkdirp(packagePath)\n\n return\n }\n\n const dir = (await lstat(packagePath)).isDirectory()\n\n if (!dir) {\n throw new Error('the package path is a file, not a directory')\n }\n\n const empty = await isEmptyDirectory(packagePath)\n\n if (!empty) {\n throw new Error('the package directory is not empty')\n }\n}\n","import {init} from '../node/init.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function initAction(options: {path: string}): Promise<void> {\n try {\n await init({\n cwd: process.cwd(),\n path: options.path,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":["prettierConfig"],"mappings":";;;;;;;;;;;;AAOA,MAAM,eAAe;AAAA,EACnB,QAAQ;AACV;AAGA,eAAsB,mBAAmB,SAKvB;AAChB,QAAM,EAAC,KAAK,QAAQ,aAAa,UAAU,mBAAA,IAAsB,SAE3D,WACJ,OAAO,sBAAuB,aAC1B,MAAM,mBAAm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CACf;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;","x_google_ignoreList":[2]}
1
+ {"version":3,"file":"initAction.js","sources":["../../src/node/core/template/createFromTemplate.ts","../../src/node/isEmptyDirectory.ts","../../../../../node_modules/.pnpm/@sanity+prettier-config@3.0.0_prettier@3.9.6/node_modules/@sanity/prettier-config/dist/index.js","../../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/parse-url.js","../../../../../node_modules/.pnpm/parse-github-url@1.0.4/node_modules/parse-github-url/index.js","../../src/node/templates/default/template.ts","../../src/node/init.ts","../../src/cli/initAction.ts"],"sourcesContent":["import {writeFile} from 'node:fs/promises'\nimport {dirname, relative, resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport prompts from 'prompts'\nimport type {Logger} from '../../logger.ts'\nimport type {PkgTemplate} from './types.ts'\n\nconst promptsTypes = {\n string: 'text' as const,\n}\n\n/** @internal */\nexport async function createFromTemplate(options: {\n cwd: string\n logger: Logger\n packagePath: string\n template: PkgTemplate\n}): Promise<void> {\n const {cwd, logger, packagePath, template: templateOrResolver} = options\n\n const template =\n typeof templateOrResolver === 'function'\n ? await templateOrResolver({cwd, logger, packagePath})\n : templateOrResolver\n\n logger.log('create new package at', relative(cwd, packagePath))\n\n const templateOptions: Record<string, string> = {}\n\n for (const templateOption of template.options) {\n const templateValidate = templateOption.validate\n\n const res = await prompts(\n {\n type: promptsTypes[templateOption.type],\n name: templateOption.name,\n message: templateOption.description,\n validate: templateValidate ? (prev) => templateValidate(prev) : undefined,\n initial:\n typeof templateOption.initial === 'function'\n ? templateOption.initial(templateOptions)\n : templateOption.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n\n templateOptions[templateOption.name] = templateOption.parse\n ? templateOption.parse(res[templateOption.name])\n : res[templateOption.name]\n }\n\n const features: Record<string, boolean> = {}\n\n for (const templateFeature of template.features) {\n const res = templateFeature.optional\n ? await prompts(\n {\n type: 'confirm',\n name: 'confirm',\n message: `use ${templateFeature.name}?`,\n initial: templateFeature.initial,\n },\n {onCancel: () => process.exit(0)},\n )\n : undefined\n\n features[templateFeature.name] = res?.confirm || !templateFeature.optional\n }\n\n const files = await template.getFiles(templateOptions, features)\n\n files.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n for (const file of files) {\n const filePath = resolve(packagePath, file.name)\n\n await mkdirp(dirname(filePath))\n await writeFile(filePath, file.contents.trim() + '\\n')\n\n logger.success(`wrote ${relative(cwd, filePath)}`)\n }\n}\n","import {readdir} from 'node:fs/promises'\n\nexport async function isEmptyDirectory(dirPath: string): Promise<boolean> {\n return (await readdir(dirPath)).length === 0\n}\n","const overridableDefaults = {\n endOfLine: \"lf\",\n tabWidth: 2,\n useTabs: !1\n}, json5 = {\n files: [\"*.json5\"],\n options: {\n quoteProps: \"preserve\",\n singleQuote: !1\n }\n}, yaml = {\n files: [\"*.yml\"],\n options: {\n singleQuote: !1\n }\n}, config = {\n ...overridableDefaults,\n printWidth: 100,\n semi: !1,\n singleQuote: !0,\n quoteProps: \"consistent\",\n bracketSpacing: !1,\n plugins: [\"prettier-plugin-packagejson\"],\n overrides: [json5, yaml]\n};\nexport {\n config as default\n};\n//# sourceMappingURL=index.js.map\n","'use strict';\n\nvar urlModule = require('url');\nvar URLCtor = typeof URL === 'undefined' ? urlModule.URL || null : URL;\nvar legacyURLParse = URLCtor ? null : urlModule.parse;\n\nfunction parseWHATWG(str) {\n\ttry {\n\t\tvar u = new URLCtor(str);\n\t\tvar auth = null;\n\t\tif (u.username) {\n\t\t\tauth = u.password ? u.username + ':' + u.password : u.username;\n\t\t}\n\t\tvar host = u.host || null;\n\t\tvar hostname = u.hostname || null;\n\t\tvar pathname = u.pathname || null;\n\t\tvar path = u.pathname + (u.search || '') || null;\n\n\t\t// For non-special schemes without '//' (e.g. 'github:user/repo', 'foo:bar'),\n\t\t// the WHATWG URL API produces an opaque path (host is empty). Replicate the\n\t\t// legacy url.parse() behavior: treat the first path segment as the host.\n\t\tif (!host && pathname && str.indexOf('//') === -1) {\n\t\t\tvar slashIdx = pathname.indexOf('/');\n\t\t\tif (slashIdx === -1) {\n\t\t\t\t// e.g. 'foo:bar' — no path segment, only a host-like token → null path\n\t\t\t\thost = pathname;\n\t\t\t\thostname = pathname;\n\t\t\t\tpathname = null;\n\t\t\t\tpath = null;\n\t\t\t} else {\n\t\t\t\t// e.g. 'github:user/repo' — first segment is host, rest is path\n\t\t\t\thost = pathname.slice(0, slashIdx);\n\t\t\t\thostname = host;\n\t\t\t\tpathname = pathname.slice(slashIdx);\n\t\t\t\tpath = pathname + (u.search || '');\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tauth: auth,\n\t\t\thash: u.hash || null,\n\t\t\thost: host,\n\t\t\thostname: hostname,\n\t\t\thref: u.href,\n\t\t\tpath: path,\n\t\t\tpathname: pathname,\n\t\t\tport: u.port || null,\n\t\t\tprotocol: u.protocol || null,\n\t\t\tquery: u.search ? u.search.slice(1) : null,\n\t\t\tsearch: u.search || null,\n\t\t\tslashes: str.indexOf('//') === -1 ? null : true\n\t\t};\n\t} catch (_) {\n\t\t// Fall back for non-standard strings (bare paths, git@ URLs, etc.)\n\t\tvar hashIdx = str.indexOf('#');\n\t\tvar hash = hashIdx === -1 ? null : str.slice(hashIdx);\n\t\tvar pathPart = hashIdx === -1 ? str : str.slice(0, hashIdx);\n\t\tvar queryIdx = pathPart.indexOf('?');\n\t\tvar search = queryIdx === -1 ? null : pathPart.slice(queryIdx);\n\t\tvar pathnamePart = queryIdx === -1 ? pathPart : pathPart.slice(0, queryIdx);\n\t\treturn {\n\t\t\tauth: null,\n\t\t\thash: hash,\n\t\t\thost: null,\n\t\t\thostname: null,\n\t\t\thref: str,\n\t\t\tpath: pathPart || null,\n\t\t\tpathname: pathnamePart || null,\n\t\t\tport: null,\n\t\t\tprotocol: null,\n\t\t\tquery: search ? search.slice(1) : null,\n\t\t\tsearch: search,\n\t\t\tslashes: null\n\t\t};\n\t}\n}\n\nmodule.exports = URLCtor ? parseWHATWG : legacyURLParse;\n","/*!\n * parse-github-url <https://github.com/jonschlinkert/parse-github-url>\n *\n * Copyright (c) 2015-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\n'use strict';\n\nvar parseURL = require('./parse-url');\nvar cache = { __proto__: null };\n\nfunction isChecksum(str) {\n\treturn (/^[a-f0-9]{40}$/i).test(str);\n}\n\nfunction getBranch(str, obj) {\n\tvar segs = str.split('#');\n\tvar branch;\n\tif (segs.length > 1) {\n\t\tbranch = segs[segs.length - 1];\n\t}\n\tif (!branch && obj.hash && obj.hash.charAt(0) === '#') {\n\t\tbranch = obj.hash.slice(1);\n\t}\n\treturn branch || 'master';\n}\n\nfunction trimSlash(path) {\n\treturn path.charAt(0) === '/' ? path.slice(1) : path;\n}\n\nfunction name(str) {\n\treturn str ? str.replace(/\\.git$/, '') : null;\n}\n\nfunction owner(str) {\n\tif (!str) {\n\t\treturn null;\n\t}\n\tvar idx = str.indexOf(':');\n\tif (idx > -1) {\n\t\treturn str.slice(idx + 1);\n\t}\n\treturn str;\n}\n\n/**\n * Extract the host from a git@ URL using the WHATWG URL API.\n */\nfunction getGitAtHost(str) {\n\tvar transformed = 'http://' + str.replace(/git@([^:]+):/, '$1/');\n\treturn parseURL(transformed).host || null;\n}\n\nfunction parse(str) {\n\tif (typeof str !== 'string' || !str.length) {\n\t\treturn null;\n\t}\n\n\tif (str.indexOf('git@gist') !== -1 || str.indexOf('//gist') !== -1) {\n\t\treturn null;\n\t}\n\n\t// parse the URL\n\tvar obj = parseURL(str);\n\tif (typeof obj.path !== 'string' || !obj.path.length || typeof obj.pathname !== 'string' || !obj.pathname.length) {\n\t\treturn null;\n\t}\n\n\tif (!obj.host && (/^git@/).test(str) === true) {\n\t\t// return the correct host for git@ URLs\n\t\tobj.host = getGitAtHost(str);\n\t}\n\n\tobj.path = trimSlash(obj.path);\n\tobj.pathname = trimSlash(obj.pathname);\n\tobj.filepath = null;\n\n\tif (obj.path.indexOf('repos') === 0) {\n\t\tobj.path = obj.path.slice(6);\n\t}\n\n\tvar seg = obj.path.split('/').filter(Boolean);\n\tvar hasBlob = seg[2] === 'blob';\n\tif (hasBlob && !isChecksum(seg[3])) {\n\t\tobj.branch = seg[3];\n\t\tif (seg.length > 4) {\n\t\t\tobj.filepath = seg.slice(4).join('/');\n\t\t}\n\t}\n\n\tvar blob = str.indexOf('blob');\n\tif (hasBlob && blob !== -1) {\n\t\tobj.blob = str.slice(blob + 5);\n\t}\n\n\tvar hasTree = seg[2] === 'tree';\n\tvar tree = str.indexOf('tree');\n\tif (hasTree && tree !== -1) {\n\t\tvar idx = tree + 5;\n\t\tvar branch = str.slice(idx);\n\t\tvar slash = branch.indexOf('/');\n\t\tif (slash !== -1) {\n\t\t\tbranch = branch.slice(0, slash);\n\t\t}\n\t\tobj.branch = branch;\n\t}\n\n\tobj.owner = owner(seg[0]);\n\tobj.name = name(seg[1]);\n\n\tif (seg.length > 1 && obj.owner && obj.name) {\n\t\tobj.repo = obj.owner + '/' + obj.name;\n\t} else {\n\t\tvar href = obj.href.split(':');\n\t\tif (href.length === 2 && obj.href.indexOf('//') === -1) {\n\t\t\tobj.repo = obj.repo || href[href.length - 1];\n\t\t\tvar repoSegments = obj.repo.split('/');\n\t\t\tobj.owner = repoSegments[0];\n\t\t\tobj.name = repoSegments[1];\n\n\t\t} else {\n\t\t\tvar match = obj.href.match(/\\/([^/]*)$/);\n\t\t\tobj.owner = match ? match[1] : null;\n\t\t\tobj.repo = null;\n\t\t}\n\n\t\tif (obj.repo && (!obj.owner || !obj.name)) {\n\t\t\tvar segs = obj.repo.split('/');\n\t\t\tif (segs.length === 2) {\n\t\t\t\tobj.owner = segs[0];\n\t\t\t\tobj.name = segs[1];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!obj.branch) {\n\t\tobj.branch = seg[2] || getBranch(obj.path, obj);\n\t\tif (seg.length > 3) {\n\t\t\tobj.filepath = seg.slice(3).join('/');\n\t\t}\n\t}\n\n\tobj.host = obj.host || 'github.com';\n\tobj.owner = obj.owner || null;\n\tobj.name = obj.name || null;\n\tobj.repository = obj.repo;\n\treturn obj;\n}\n\nmodule.exports = function parseGithubUrl(str) {\n\tif (!cache[str]) {\n\t\tcache[str] = parse(str);\n\t}\n\treturn cache[str];\n};\n","import {execSync} from 'node:child_process'\nimport {resolve} from 'node:path'\nimport type {PackageJSON} from '@sanity/parse-package-json'\nimport prettierConfig from '@sanity/prettier-config'\nimport {getLatestVersion} from 'get-latest-version'\nimport {outdent} from 'outdent'\nimport parseGithubUrl from 'parse-github-url'\nimport {format, type Config as PrettierConfig} from 'prettier'\nimport {isRecord} from '../../core/isRecord.ts'\nimport {defineTemplateOption} from '../../core/template/define.ts'\nimport {type PkgTemplate, type PkgTemplateFile} from '../../core/template/types.ts'\n\nconst RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\\/)?[a-z0-9-~][a-z0-9-._~]*$/i\n\nexport const defaultTemplate: PkgTemplate = async ({cwd, logger, packagePath}) => {\n const gitConfig = getGitUserConfig(cwd)\n\n return {\n options: [\n defineTemplateOption<{owner: string; name: string}>({\n name: 'repo',\n type: 'string',\n description: 'git url',\n validate: (v) => {\n if (!v) return true\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n return 'invalid git url'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) return null\n\n const result = parseGithubUrl(v)\n\n if (!result?.host || !result.owner || !result.name) {\n throw new Error('invalid git url')\n }\n\n return {source: result.host, owner: result.owner, name: result.name}\n },\n }),\n defineTemplateOption({\n name: 'pkgName',\n type: 'string',\n description: 'package name',\n initial: (options) => options['repo']?.name || undefined,\n validate: (v) => {\n if (!v) return 'package name is required'\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n return 'invalid package name'\n }\n\n return true\n },\n parse: (v) => {\n if (!v) {\n throw new Error('package name is required')\n }\n\n const match = RE_NAME.exec(v)\n\n if (!match) {\n throw new Error('invalid package name')\n }\n\n const [scope, name] = v.split('/')\n\n return {scope, name, fullName: v}\n },\n }),\n defineTemplateOption({\n name: 'description',\n type: 'string',\n description: 'package description',\n }),\n defineTemplateOption({\n name: 'authorName',\n type: 'string',\n description: 'package author name',\n initial: gitConfig.user,\n }),\n defineTemplateOption({\n name: 'authorEmail',\n type: 'string',\n description: 'package author email',\n initial: gitConfig.email,\n }),\n defineTemplateOption({\n name: 'license',\n type: 'string',\n description: 'package license',\n initial: 'MIT',\n validate: (v) => {\n if (!v) return 'license is required'\n\n return true\n },\n }),\n ],\n\n features: [\n {\n name: 'eslint',\n optional: true,\n initial: true,\n },\n {\n name: 'prettier',\n optional: true,\n initial: true,\n },\n {\n name: 'typescript',\n optional: true,\n initial: true,\n },\n ],\n\n async getFiles(options, features) {\n const {pkgName, repo} = options\n const {fullName: name} = pkgName\n\n const author =\n [options['authorName'], options['authorEmail'] && `<${options['authorEmail']}>`]\n .filter(Boolean)\n .join(' ') ?? undefined\n\n const pkgJson: PackageJSON & {\n prettier?: '@sanity/prettier-config'\n ['lint-staged']?: Record<string, string[]>\n } = {\n name,\n 'version': '0.0.0',\n 'description': options['description'] ?? undefined,\n 'keywords': [],\n 'homepage': undefined,\n 'bugs': undefined,\n 'repository': undefined,\n 'license': options['license'],\n author,\n 'sideEffects': false,\n 'type': 'module',\n 'exports': {\n '.': {\n source: features['typescript'] ? './src/index.ts' : './src/index.js',\n require: './dist/index.cjs',\n default: './dist/index.js',\n },\n './package.json': './package.json',\n },\n 'main': './dist/index.cjs',\n 'module': './dist/index.js',\n 'types': undefined,\n 'files': ['dist', 'src'],\n 'scripts': {\n build: 'pkg build --strict --clean --check',\n format: features['prettier'] ? 'prettier --write --cache --ignore-unknown .' : undefined,\n },\n 'lint-staged': features['prettier']\n ? {\n '*': ['prettier --write --cache --ignore-unknown'],\n }\n : undefined,\n 'browserslist': 'extends @sanity/browserslist-config',\n 'prettier': features['prettier'] ? '@sanity/prettier-config' : undefined,\n 'dependencies': {},\n 'devDependencies': {\n '@sanity/tsconfig': features['typescript'] ? '^1' : undefined,\n '@sanity/pkg-utils': '^9',\n '@sanity/prettier-config': features['prettier'] ? '^1' : undefined,\n '@typescript-eslint/eslint-plugin': undefined,\n '@typescript-eslint/parser': undefined,\n 'eslint': undefined,\n 'eslint-config-prettier': undefined,\n 'eslint-plugin-import': undefined,\n 'eslint-plugin-prettier': undefined,\n 'eslint-plugin-simple-import-sort': undefined,\n 'lint-staged': '^15',\n 'prettier': features['prettier'] ? '^3' : undefined,\n 'typescript': undefined,\n },\n 'engines': {\n node: '>=20.19 <22 || >=22.12',\n },\n }\n\n const files: PkgTemplateFile[] = []\n\n // .editorconfig\n files.push({\n name: '.editorconfig',\n contents: outdent`\n root = true\n\n [*]\n charset = utf-8\n indent_style = space\n indent_size = 2\n end_of_line = lf\n insert_final_newline = true\n trim_trailing_whitespace = true\n `,\n })\n\n // .gitignore\n files.push({\n name: '.gitignore',\n contents: outdent`\n *.local\n *.log\n *.tgz\n\n .DS_Store\n dist\n etc\n node_modules\n `,\n })\n\n if (features['prettier']) {\n files.push({\n name: '.prettierignore',\n contents: outdent`\n dist\n pnpm-lock.yaml\n `,\n })\n }\n\n if (repo) {\n pkgJson.repository = {\n type: 'git',\n url: `git+ssh://git@${repo.source}/${repo.owner}/${repo.name}.git`,\n }\n pkgJson.bugs = {\n url: `https://${repo.source}/${repo.owner}/${repo.name}/issues`,\n }\n pkgJson.homepage = `https://${repo.source}/${repo.owner}/${repo.name}#readme`\n }\n\n if (features['typescript']) {\n pkgJson.types = './dist/index.d.ts'\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n ['ts:check']: 'tsc --noEmit',\n }\n\n const devDependencies = pkgJson.devDependencies\n\n if (isRecord(devDependencies)) {\n devDependencies['typescript'] = '^5.9'\n }\n }\n\n if (features['eslint']) {\n const eslintConfig: any = {\n root: true,\n env: {\n browser: true,\n es6: true,\n node: true,\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n ].filter(Boolean),\n parserOptions: {\n ecmaVersion: 2020,\n sourceType: 'module',\n },\n plugins: [\n 'import',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n 'no-console': 'error',\n 'no-shadow': 'error',\n 'no-warning-comments': ['warn', {location: 'start', terms: ['todo', 'fixme']}],\n 'quote-props': ['warn', 'consistent-as-needed'],\n 'simple-import-sort/exports': 'warn',\n 'simple-import-sort/imports': 'warn',\n 'strict': ['warn', 'global'],\n },\n }\n\n files.push({\n name: '.eslintignore',\n contents: outdent`\n dist\n `,\n })\n\n pkgJson.scripts = {\n ...pkgJson.scripts,\n lint: features['typescript']\n ? 'eslint . --ext .cjs,.js,.ts,.tsx'\n : 'eslint . --ext .cjs,.js',\n }\n\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n 'eslint': '^8',\n 'eslint-config-prettier': features['prettier'] ? '^9' : undefined,\n 'eslint-plugin-import': '^2',\n 'eslint-plugin-prettier': features['prettier'] ? '^5' : undefined,\n 'eslint-plugin-simple-import-sort': '^12',\n }\n\n if (features['typescript']) {\n pkgJson.devDependencies = {\n ...pkgJson.devDependencies,\n '@typescript-eslint/eslint-plugin': '^7',\n '@typescript-eslint/parser': '^7',\n }\n\n const eslintConfigOverride: any = {\n files: ['**/*.ts', '**/*.tsx'],\n parser: '@typescript-eslint/parser',\n parserOptions: {\n project: ['./tsconfig.json'],\n },\n extends: [\n 'eslint:recommended',\n features['prettier'] ? 'plugin:prettier/recommended' : undefined,\n 'plugin:@typescript-eslint/eslint-recommended',\n 'plugin:@typescript-eslint/recommended',\n ].filter(Boolean),\n plugins: [\n 'import',\n '@typescript-eslint',\n 'simple-import-sort',\n features['prettier'] ? 'prettier' : undefined,\n ].filter(Boolean),\n rules: {\n '@typescript-eslint/explicit-module-boundary-types': 'error',\n '@typescript-eslint/interface-name-prefix': 'off',\n '@typescript-eslint/member-delimiter-style': 'off',\n '@typescript-eslint/no-empty-interface': 'off',\n },\n }\n\n eslintConfig.overrides = [eslintConfigOverride]\n }\n\n files.push({\n name: '.eslintrc.cjs',\n contents: await prettierFormat(\n resolve(packagePath, '.eslintrc.cjs'),\n outdent`\n 'use strict'\n\n /** @type import('eslint').Linter.Config */\n module.exports = ${JSON.stringify(eslintConfig, null, 2)}\n `,\n prettierConfig,\n ),\n })\n }\n\n if (features['typescript']) {\n files.push({\n name: 'tsconfig.settings.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.settings.json'),\n outdent`\n {\n \"extends\": \"@sanity/tsconfig/strictest\",\n \"compilerOptions\": {\n \"rootDir\": \".\",\n \"outDir\": \"./dist\"\n }\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.dist.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.dist.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./src\"],\n \"exclude\": [\"./src/**/*.test.ts\"]\n }\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'tsconfig.json',\n contents: await prettierFormat(\n resolve(packagePath, 'tsconfig.json'),\n outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./**/*.cjs\", \"./**/*.ts\", \"./**/*.tsx\"],\n \"exclude\": [\"./node_modules\"]\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // source file\n if (features['typescript']) {\n files.push({\n name: 'package.config.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.ts'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n // https://github.com/sanity-io/pkg-utils#configuration\n export default defineConfig({\n // the path to the tsconfig file for distributed builds\n tsconfig: 'tsconfig.dist.json',\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.ts',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.ts'),\n outdent`\n /** @public */\n export function main(): void {\n //\n }\n `,\n prettierConfig,\n ),\n })\n } else {\n files.push({\n name: 'package.config.js',\n contents: await prettierFormat(\n resolve(packagePath, 'package.config.js'),\n outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n export default defineConfig({\n extract: {\n rules: {\n // do not require internal members to be prefixed with \\`_\\`\n 'ae-internal-missing-underscore': 'off',\n },\n },\n })\n `,\n prettierConfig,\n ),\n })\n\n files.push({\n name: 'src/index.js',\n contents: await prettierFormat(\n resolve(packagePath, 'src/index.js'),\n outdent`\n /** @public */\n export function main() {\n //\n }\n `,\n prettierConfig,\n ),\n })\n }\n\n // Resolve latest dependencies\n try {\n pkgJson.dependencies = await resolveLatestDeps(pkgJson.dependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n // Resolve latest devDependencies\n try {\n pkgJson.devDependencies = await resolveLatestDeps(pkgJson.devDependencies ?? {})\n } catch (error) {\n logger.warn(error instanceof Error ? error.message : error)\n }\n\n files.push({\n name: 'package.json',\n contents: await prettierFormat(\n resolve(packagePath, 'package.json'),\n JSON.stringify(pkgJson, null, 2),\n prettierConfig,\n ),\n })\n\n return files\n },\n }\n}\n\nfunction prettierFormat(\n filepath: string,\n input: string,\n prettierOptions: PrettierConfig | undefined,\n) {\n return format(input, {...prettierOptions, plugins: [], filepath})\n}\n\nasync function resolveLatestDeps(deps: Record<string, string | undefined>) {\n const depsEntries = Object.entries(deps)\n const latestDeps: Record<string, string> = {}\n\n for (const entry of depsEntries) {\n const [name, version] = entry\n\n if (version) {\n const latestVersion = await getLatestVersion(name, {range: version})\n\n latestDeps[name] = latestVersion ? `^${latestVersion}` : version\n }\n }\n\n return latestDeps\n}\n\nfunction getGitUserConfig(cwd: string): {user: string | undefined; email: string | undefined} {\n let user: string | undefined\n let email: string | undefined\n\n try {\n user = execSync('git config user.name', {encoding: 'utf8', cwd}).trim() || undefined\n email = execSync('git config user.email', {encoding: 'utf8', cwd}).trim() || undefined\n } catch {\n /* ignore */\n }\n\n return {user, email}\n}\n","import {lstat} from 'node:fs/promises'\nimport {resolve} from 'node:path'\nimport {mkdirp} from 'mkdirp'\nimport {createFromTemplate} from './core/template/index.ts'\nimport {fileExists} from './fileExists.ts'\nimport {isEmptyDirectory} from './isEmptyDirectory.ts'\nimport {createLogger} from './logger.ts'\nimport {defaultTemplate} from './templates/default/template.ts'\n\n/** @public */\nexport async function init(options: {cwd: string; path: string}): Promise<void> {\n if (!options.cwd) {\n throw new Error('Missing required option: cwd')\n }\n\n if (!options.path) {\n throw new Error('Missing required option: path')\n }\n\n const logger = createLogger()\n\n const packagePath = resolve(options.cwd, options.path)\n\n await ensurePackagePath(packagePath)\n\n await createFromTemplate({\n cwd: options.cwd,\n logger,\n template: defaultTemplate,\n packagePath,\n })\n}\n\nasync function ensurePackagePath(packagePath: string): Promise<void> {\n const exists = fileExists(packagePath)\n\n if (!exists) {\n await mkdirp(packagePath)\n\n return\n }\n\n const dir = (await lstat(packagePath)).isDirectory()\n\n if (!dir) {\n throw new Error('the package path is a file, not a directory')\n }\n\n const empty = await isEmptyDirectory(packagePath)\n\n if (!empty) {\n throw new Error('the package directory is not empty')\n }\n}\n","import {init} from '../node/init.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function initAction(options: {path: string}): Promise<void> {\n try {\n await init({\n cwd: process.cwd(),\n path: options.path,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":["require$$0","parseGithubUrl","prettierConfig"],"mappings":";;;;;;;;;;;;AAOA,MAAM,eAAe;AAAA,EACnB,QAAQ;AACV;AAGA,eAAsB,mBAAmB,SAKvB;AAChB,QAAM,EAAC,KAAK,QAAQ,aAAa,UAAU,mBAAA,IAAsB,SAE3D,WACJ,OAAO,sBAAuB,aAC1B,MAAM,mBAAmB,EAAC,KAAK,QAAQ,YAAA,CAAY,IACnD;AAEN,SAAO,IAAI,yBAAyB,SAAS,KAAK,WAAW,CAAC;AAE9D,QAAM,kBAA0C,CAAA;AAEhD,aAAW,kBAAkB,SAAS,SAAS;AAC7C,UAAM,mBAAmB,eAAe,UAElC,MAAM,MA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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.6/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;A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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
+ {"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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CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cac } from "cac";
2
- var version = "11.0.14";
2
+ var version = "11.0.16";
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": "11.0.14",
3
+ "version": "11.0.16",
4
4
  "description": "Simple utilities for modern npm packages.",
5
5
  "keywords": [
6
6
  "sanity-io",
@@ -57,7 +57,7 @@
57
57
  "@sanity/browserslist-config": "^1.0.5",
58
58
  "@typescript/typescript6": "^6.0.2",
59
59
  "@vanilla-extract/rollup-plugin": "^1.5.4",
60
- "browserslist": "^4.28.6",
60
+ "browserslist": "^4.28.7",
61
61
  "cac": "^7.0.0",
62
62
  "chalk": "^5.6.2",
63
63
  "chokidar": "^5.0.0",
@@ -65,18 +65,17 @@
65
65
  "esbuild": "^0.28.1",
66
66
  "find-config": "^1.0.0",
67
67
  "get-latest-version": "^6.0.1",
68
- "git-url-parse": "^16.1.0",
69
68
  "globby": "^16.2.2",
70
69
  "jsonc-parser": "^3.3.1",
71
70
  "lightningcss": "^1.33.0",
72
71
  "mkdirp": "^3.0.1",
73
72
  "outdent": "^0.8.0",
74
- "prettier": "^3.9.5",
73
+ "prettier": "^3.9.6",
75
74
  "pretty-bytes": "^7.1.1",
76
75
  "prompts": "^2.4.2",
77
76
  "rimraf": "^6.1.3",
78
77
  "rolldown": "1.2.0",
79
- "rolldown-plugin-dts": "0.27.13",
78
+ "rolldown-plugin-dts": "0.27.14",
80
79
  "rollup": "^4.62.2",
81
80
  "rollup-plugin-esbuild": "^6.2.1",
82
81
  "rxjs": "^7.8.2",
@@ -84,17 +83,19 @@
84
83
  "tsx": "^4.23.1",
85
84
  "zod": "^4.4.3",
86
85
  "zod-validation-error": "^5.0.0",
87
- "@sanity/parse-package-json": "^2.2.10"
86
+ "@sanity/parse-package-json": "^2.2.11"
88
87
  },
89
88
  "devDependencies": {
90
89
  "@types/babel__core": "^7.20.5",
91
90
  "@types/find-config": "^1.0.4",
92
91
  "@types/node": "^24.13.3",
92
+ "@types/parse-github-url": "^1.0.3",
93
93
  "@types/prompts": "^2.4.9",
94
94
  "@types/treeify": "^1.0.3",
95
95
  "babel-plugin-react-compiler": "1.0.0",
96
96
  "browserslist-to-esbuild": "2.1.1",
97
97
  "nanoexec": "^1.1.0",
98
+ "parse-github-url": "^1.0.4",
98
99
  "rollup-plugin-visualizer": "^7.0.1",
99
100
  "typescript": "7.0.2",
100
101
  "vitest": "^4.1.10",