@sanity/pkg-utils 9.0.8 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-es/build.js +3 -1
- package/dist/_chunks-es/build.js.map +1 -1
- package/dist/_chunks-es/check.js +3 -1
- package/dist/_chunks-es/check.js.map +1 -1
- package/dist/_chunks-es/consoleSpy.js +52 -17
- package/dist/_chunks-es/consoleSpy.js.map +1 -1
- package/dist/_chunks-es/watch.js +3 -1
- package/dist/_chunks-es/watch.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +27 -5
- package/package.json +8 -8
package/dist/_chunks-es/build.js
CHANGED
|
@@ -115,7 +115,9 @@ async function build(options) {
|
|
|
115
115
|
tsconfig: tsconfigOption,
|
|
116
116
|
clean = !1,
|
|
117
117
|
quiet = !1
|
|
118
|
-
} = options, logger = createLogger(quiet), config = await loadConfig({ cwd }),
|
|
118
|
+
} = options, logger = createLogger(quiet), config = await loadConfig({ cwd }), { parseStrictOptions } = await import("./consoleSpy.js").then(function(n) {
|
|
119
|
+
return n.strict;
|
|
120
|
+
}), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ cwd, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({
|
|
119
121
|
config,
|
|
120
122
|
cwd,
|
|
121
123
|
emitDeclarationOnly,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/build.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsTask} from './tasks/dts/types.ts'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveBuildTasks} from './resolveBuildTasks.ts'\nimport {createSpinner} from './spinner.ts'\nimport {buildTaskHandlers} from './tasks/index.ts'\nimport {type BuildTask, type TaskHandler} from './tasks/types.ts'\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n clean = false,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const config = await loadConfig({cwd})\n\n const pkg = await loadPkgWithReporting({cwd, logger, strict})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n if (clean) {\n if (!quiet) {\n logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n }\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const result = await handler.exec(ctx, task).toPromise()\n\n spinner.complete()\n ctx.logger.log()\n\n handler.complete(ctx, task, result)\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd, 'g')\n\n ctx.logger.error(err.message.replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n handler.error(ctx, task, err)\n\n process.exit(1)\n }\n }\n}\n"],"names":["exports"],"mappings":";;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAA;AAAA,EAAG,GAG7B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,kBAAmD,IACnD,cAA0C,CAAA;AAEhD,WAAS,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,QAAI,QAAQ,eACV,gBAAgB,OAAO,IACzB,gBAAgB,OAAO,EAAE,QAAQ,KAAK,KAAK,IAE3C,gBAAgB,OAAO,IAAI;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,OAAO;AAAA,IAAA,IAKvB,IAAI,wBACH,YAAY,OAAO,IACrB,YAAY,OAAO,EAAE,QAAQ,KAAK,KAAK,IAEvC,YAAY,OAAO,IAAI;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,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ACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,IACN,SACE,SAAS,aAAa,KAAK,GAE3B,SAAS,MAAM,WAAW,EAAC,KAAI,GAE/B,MAAM,MAAM,qBAAqB,EAAC,KAAK,QAAQ,OAAA,CAAO,GAEtD,WAAW,kBAAkB,QAAQ,YAAY,iBAEjD,MAAM,MAAM,oBAAoB;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEG,YACG,SACH,OAAO;AAAA,IACL,oCAAoC,KAAK,SAAS,KAAK,IAAI,QAAQ,CAAC;AAAA,EAAA,GAGxE,MAAM,OAAO,IAAI,QAAQ;AAG3B,QAAM,aAAa,kBAAkB,GAAG;AAExC,aAAW,QAAQ,YAAY;AAE7B,UAAM,UAAU,kBAAkB,KAAK,IAAI,GACrC,WAAW,QAAQ,KAAK,KAAK,IAAI,GAEjC,UAAU,cAAc,UAAU,KAAK;AAE7C,QAAI;AACF,YAAM,SAAS,MAAM,QAAQ,KAAK,KAAK,IAAI,EAAE,UAAA;AAE7C,cAAQ,SAAA,GACR,IAAI,OAAO,OAEX,QAAQ,SAAS,KAAK,MAAM,MAAM;AAAA,IACpC,SAAS,KAAK;AAGZ,UAFA,QAAQ,SAEJ,eAAe,OAAO;AACxB,cAAM,SAAS,IAAI,OAAO,KAAK,GAAG;AAElC,YAAI,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GACjD,IAAI,OAAO,IAAA;AAAA,MACb;AAEA,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"build.js","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/build.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsTask} from './tasks/dts/types.ts'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveBuildTasks} from './resolveBuildTasks.ts'\nimport {createSpinner} from './spinner.ts'\nimport {buildTaskHandlers} from './tasks/index.ts'\nimport {type BuildTask, type TaskHandler} from './tasks/types.ts'\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n clean = false,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const config = await loadConfig({cwd})\n\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({cwd, logger, strict, strictOptions})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n if (clean) {\n if (!quiet) {\n logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n }\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const result = await handler.exec(ctx, task).toPromise()\n\n spinner.complete()\n ctx.logger.log()\n\n handler.complete(ctx, task, result)\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd, 'g')\n\n ctx.logger.error(err.message.replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n handler.error(ctx, task, err)\n\n process.exit(1)\n }\n }\n}\n"],"names":["exports"],"mappings":";;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAA;AAAA,EAAG,GAG7B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,kBAAmD,IACnD,cAA0C,CAAA;AAEhD,WAAS,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,QAAI,QAAQ,eACV,gBAAgB,OAAO,IACzB,gBAAgB,OAAO,EAAE,QAAQ,KAAK,KAAK,IAE3C,gBAAgB,OA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,OAAO;AACxB,cAAM,SAAS,IAAI,OAAO,KAAK,GAAG;AAElC,YAAI,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GACjD,IAAI,OAAO,IAAA;AAAA,MACb;AAEA,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;"}
|
package/dist/_chunks-es/check.js
CHANGED
|
@@ -43,7 +43,9 @@ function printPackageTree(ctx) {
|
|
|
43
43
|
async function check(options) {
|
|
44
44
|
const { cwd, strict = !1, tsconfig: tsconfigOption } = options, logger = createLogger(), spinner = createSpinner("");
|
|
45
45
|
try {
|
|
46
|
-
const config = await loadConfig({ cwd }),
|
|
46
|
+
const config = await loadConfig({ cwd }), { parseStrictOptions } = await import("./consoleSpy.js").then(function(n) {
|
|
47
|
+
return n.strict;
|
|
48
|
+
}), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ cwd, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({ config, cwd, logger, pkg, strict, tsconfig });
|
|
47
49
|
if (printPackageTree(ctx), strict) {
|
|
48
50
|
const missingFiles = [];
|
|
49
51
|
for (const [, exp] of Object.entries(ctx.exports || {}))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sources":["../../src/node/getFilesize.ts","../../src/node/printPackageTree.ts","../../src/node/check.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {fileExists} from './fileExists.ts'\nimport {getFilesize} from './getFilesize.ts'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport type {ExtractorMessage} from '@microsoft/api-extractor'\nimport type {BuildFailure, Message} from 'esbuild'\nimport {createConsoleSpy} from './consoleSpy.ts'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport type {BuildContext} from './core/contexts/index.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {fileExists} from './fileExists.ts'\nimport {createLogger, type Logger} from './logger.ts'\nimport {printPackageTree} from './printPackageTree.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n const spinner = createSpinner('')\n try {\n const config = await loadConfig({cwd})\n const pkg = await loadPkgWithReporting({cwd, logger, strict})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n\n // Check if the files are resolved\n const exportPaths: {require: string[]; import: string[]} = {\n require: [],\n import: [],\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n if (exp.require) exportPaths.require.push(exp.require)\n if (exp.import) exportPaths.import.push(exp.import)\n }\n\n const external = [\n ...Object.keys(pkg.dependencies || {}),\n ...Object.keys(pkg.devDependencies || {}),\n ]\n\n const consoleSpy = createConsoleSpy()\n\n const checks = []\n if (exportPaths.import.length) {\n checks.push(checkExports(exportPaths.import, {cwd, external, format: 'esm', logger}))\n }\n\n if (exportPaths.require.length) {\n checks.push(checkExports(exportPaths.require, {cwd, external, format: 'cjs', logger}))\n }\n\n await Promise.all(checks)\n\n consoleSpy.restore()\n }\n\n if (ctx.dts === 'rolldown' && ctx.config?.extract?.enabled !== false) {\n await checkApiExtractorReleaseTags(ctx)\n }\n\n spinner.complete()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd, 'g')\n\n logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nasync function checkExports(\n exportPaths: string[],\n options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},\n) {\n const {build} = await import('esbuild')\n const {cwd, external, format, logger} = options\n\n const code = exportPaths\n .map((id) => (format ? `import('${id}');` : `require('${id}');`))\n .join('\\n')\n\n try {\n const esbuildResult = await build({\n bundle: true,\n external,\n format,\n logLevel: 'silent',\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n // We're not interested in CSS files that might be imported as a side effect, so we'll treat them as empty\n loader: {'.css': 'empty'},\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n })\n\n if (esbuildResult.errors.length > 0) {\n for (const msg of esbuildResult.errors) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n\n process.exit(1)\n }\n\n const esbuildWarnings = esbuildResult.warnings.filter((msg) => {\n return !(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)\n })\n\n for (const msg of esbuildWarnings) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n } catch (err) {\n if (isEsbuildFailure(err)) {\n const {errors} = err\n\n for (const msg of errors) {\n printEsbuildMessage(logger.error, msg)\n\n logger.log()\n }\n } else if (err instanceof Error) {\n logger.error(err.stack || err.message)\n\n logger.log()\n } else {\n logger.error(String(err))\n\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nfunction printEsbuildMessage(log: (...args: unknown[]) => void, msg: Message) {\n if (msg.location) {\n log(\n [\n `${msg.detail || msg.text}\\n`,\n `${msg.location.line} | ${msg.location.lineText}\\n`,\n `in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,\n ].join(''),\n )\n } else {\n log(msg.detail || msg.text)\n }\n}\n\nfunction isEsbuildFailure(err: unknown): err is BuildFailure {\n return (\n err instanceof Error &&\n 'errors' in err &&\n Array.isArray(err.errors) &&\n err.errors.every(isEsbuildMessage) &&\n 'warnings' in err &&\n Array.isArray(err.warnings) &&\n err.warnings.every(isEsbuildMessage)\n )\n}\n\nfunction isEsbuildMessage(msg: unknown): msg is Message {\n return (\n typeof msg === 'object' &&\n msg !== null &&\n 'text' in msg &&\n typeof msg.text === 'string' &&\n 'location' in msg &&\n (msg.location === null || typeof msg.location === 'object')\n )\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const [\n {Extractor, ExtractorConfig},\n {createApiExtractorConfig},\n {createTSDocConfig},\n {getExtractMessagesConfig},\n {printExtractMessages},\n ] = await Promise.all([\n import('@microsoft/api-extractor'),\n import('./tasks/dts/createApiExtractorConfig.ts'),\n import('./tasks/dts/createTSDocConfig.ts'),\n import('./tasks/dts/getExtractMessagesConfig.ts'),\n import('./printExtractMessages.ts'),\n ])\n\n const customTags = ctx.config?.extract?.customTags || []\n const bundledPackages = ctx.bundledPackages\n const distPath = ctx.distPath\n const outDir = ctx.ts.config?.options.outDir\n const rules = ctx.config?.extract?.rules || {}\n\n if (!outDir) {\n throw new Error('tsconfig.json is missing `compilerOptions.outDir`')\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported || !exp.default.endsWith('.js')) continue\n const dtsPath = exp.default.replace(/\\.js$/, '.d.ts')\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n\n const tsdocConfigFile = await createTSDocConfig({\n customTags,\n })\n const extractorConfig = ExtractorConfig.prepare({\n configObject: createApiExtractorConfig({\n bundledPackages,\n distPath,\n exportPath,\n filePath: path.relative(outDir, dtsPath),\n messages: getExtractMessagesConfig({rules}),\n projectFolder: ctx.cwd,\n mainEntryPointFilePath: exportPath,\n tsconfig: ctx.ts.config!,\n tsconfigPath: path.resolve(ctx.cwd, ctx.ts.configPath || 'tsconfig.json'),\n dtsRollupEnabled: false,\n }),\n configObjectFullPath: undefined,\n tsdocConfigFile,\n packageJsonFullPath: path.resolve(ctx.cwd, 'package.json'),\n })\n const messages: ExtractorMessage[] = []\n // Invoke API Extractor\n Extractor.invoke(extractorConfig, {\n // Equivalent to the \"--local\" command-line parameter\n localBuild: true,\n // Equivalent to the \"--verbose\" command-line parameter\n showVerboseMessages: true,\n // handle messages\n messageCallback(message: ExtractorMessage) {\n messages.push(message)\n message.handled = true\n },\n })\n\n printExtractMessages(ctx, messages)\n }\n}\n"],"names":["exports"],"mappings":";;;;;;;;AAGO,SAAS,YAAY,MAAsB;AAChD,QAAM,QAAQ,SAAS,IAAI;AAE3B,SAAO,YAAY,MAAM,IAAI;AAC/B;ACCA,SAAS,YAAY,KAAa,UAAkB;AAClD,QAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAC9B,SAAS,WAAW,CAAC,GACrB,OAAO,SAAS,YAAY,CAAC,IAAI;AAEvC,SAAO,EAAC,QAAQ,KAAA;AAClB;AAEO,SAAS,iBAAiB,KAAyB;AACxD,QAAM,EAAC,KAAA,SAAKA,WAAS,QAAQ,QAAO;AAEpC,MAAI,CAACA,UAAS;AAEd,SAAO,IAAI,GAAG,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,MAAM,MAAM,IAAI,OAAO,CAAC,EAAE;AAEhE,QAAM,OAAgC,CAAA;AAElC,MAAI,SACN,KAAK,OAAU,MAAM,OAAO,IAAI,IAAI,IAGl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SAAS,SAAS,CAAA;AAE5C,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,mDAAmD;AAGrE,aAAW,OAAO,OAAO,OAAO,IAAI,WAAW,CAAA,CAAE,GAAG;AAClD,QAAI,CAAC,IAAI,aAAa,CAAC,IAAI,QAAQ,SAAS,KAAK,EAAG;AACpD,UAAM,UAAU,IAAI,QAAQ,QAAQ,SAAS,OAAO,GAC9C,aAAa,KAAK,QAAQ,IAAI,KAAK,OAAO,GAE1C,kBAAkB,MAAM,kBAAkB;AAAA,MAC9C;AAAA,IAAA,CACD,GACK,kBAAkB,gBAAgB,QAAQ;AAAA,MAC9C,cAAc,yBAAyB;AAAA,QACrC;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU,KAAK,SAAS,QAAQ,OAAO;AAAA,QACvC,UAAU,yBAAyB,EAAC,OAAM;AAAA,QAC1C,eAAe,IAAI;AAAA,QACnB,wBAAwB;AAAA,QACxB,UAAU,IAAI,GAAG;AAAA,QACjB,cAAc,KAAK,QAAQ,IAAI,KAAK,IAAI,GAAG,cAAc,eAAe;AAAA,QACxE,kBAAkB;AAAA,MAAA,CACnB;AAAA,MACD,sBAAsB;AAAA,MACtB;AAAA,MACA,qBAAqB,KAAK,QAAQ,IAAI,KAAK,cAAc;AAAA,IAAA,CAC1D,GACK,WAA+B,CAAA;AAErC,cAAU,OAAO,iBAAiB;AAAA;AAAA,MAEhC,YAAY;AAAA;AAAA,MAEZ,qBAAqB;AAAA;AAAA,MAErB,gBAAgB,SAA2B;AACzC,iBAAS,KAAK,OAAO,GACrB,QAAQ,UAAU;AAAA,MACpB;AAAA,IAAA,CACD,GAED,qBAAqB,KAAK,QAAQ;AAAA,EACpC;AACF;"}
|
|
1
|
+
{"version":3,"file":"check.js","sources":["../../src/node/getFilesize.ts","../../src/node/printPackageTree.ts","../../src/node/check.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {fileExists} from './fileExists.ts'\nimport {getFilesize} from './getFilesize.ts'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport type {ExtractorMessage} from '@microsoft/api-extractor'\nimport type {BuildFailure, Message} from 'esbuild'\nimport {createConsoleSpy} from './consoleSpy.ts'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport type {BuildContext} from './core/contexts/index.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {fileExists} from './fileExists.ts'\nimport {createLogger, type Logger} from './logger.ts'\nimport {printPackageTree} from './printPackageTree.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {createSpinner} from './spinner.ts'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n const spinner = createSpinner('')\n try {\n const config = await loadConfig({cwd})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({cwd, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n\n // Check if the files are resolved\n const exportPaths: {require: string[]; import: string[]} = {\n require: [],\n import: [],\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n if (exp.require) exportPaths.require.push(exp.require)\n if (exp.import) exportPaths.import.push(exp.import)\n }\n\n const external = [\n ...Object.keys(pkg.dependencies || {}),\n ...Object.keys(pkg.devDependencies || {}),\n ]\n\n const consoleSpy = createConsoleSpy()\n\n const checks = []\n if (exportPaths.import.length) {\n checks.push(checkExports(exportPaths.import, {cwd, external, format: 'esm', logger}))\n }\n\n if (exportPaths.require.length) {\n checks.push(checkExports(exportPaths.require, {cwd, external, format: 'cjs', logger}))\n }\n\n await Promise.all(checks)\n\n consoleSpy.restore()\n }\n\n if (ctx.dts === 'rolldown' && ctx.config?.extract?.enabled !== false) {\n await checkApiExtractorReleaseTags(ctx)\n }\n\n spinner.complete()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd, 'g')\n\n logger.error((err.stack || err.message).replace(RE_CWD, '.'))\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nasync function checkExports(\n exportPaths: string[],\n options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},\n) {\n const {build} = await import('esbuild')\n const {cwd, external, format, logger} = options\n\n const code = exportPaths\n .map((id) => (format ? `import('${id}');` : `require('${id}');`))\n .join('\\n')\n\n try {\n const esbuildResult = await build({\n bundle: true,\n external,\n format,\n logLevel: 'silent',\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n // We're not interested in CSS files that might be imported as a side effect, so we'll treat them as empty\n loader: {'.css': 'empty'},\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n })\n\n if (esbuildResult.errors.length > 0) {\n for (const msg of esbuildResult.errors) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n\n process.exit(1)\n }\n\n const esbuildWarnings = esbuildResult.warnings.filter((msg) => {\n return !(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)\n })\n\n for (const msg of esbuildWarnings) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n } catch (err) {\n if (isEsbuildFailure(err)) {\n const {errors} = err\n\n for (const msg of errors) {\n printEsbuildMessage(logger.error, msg)\n\n logger.log()\n }\n } else if (err instanceof Error) {\n logger.error(err.stack || err.message)\n\n logger.log()\n } else {\n logger.error(String(err))\n\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nfunction printEsbuildMessage(log: (...args: unknown[]) => void, msg: Message) {\n if (msg.location) {\n log(\n [\n `${msg.detail || msg.text}\\n`,\n `${msg.location.line} | ${msg.location.lineText}\\n`,\n `in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,\n ].join(''),\n )\n } else {\n log(msg.detail || msg.text)\n }\n}\n\nfunction isEsbuildFailure(err: unknown): err is BuildFailure {\n return (\n err instanceof Error &&\n 'errors' in err &&\n Array.isArray(err.errors) &&\n err.errors.every(isEsbuildMessage) &&\n 'warnings' in err &&\n Array.isArray(err.warnings) &&\n err.warnings.every(isEsbuildMessage)\n )\n}\n\nfunction isEsbuildMessage(msg: unknown): msg is Message {\n return (\n typeof msg === 'object' &&\n msg !== null &&\n 'text' in msg &&\n typeof msg.text === 'string' &&\n 'location' in msg &&\n (msg.location === null || typeof msg.location === 'object')\n )\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const [\n {Extractor, ExtractorConfig},\n {createApiExtractorConfig},\n {createTSDocConfig},\n {getExtractMessagesConfig},\n {printExtractMessages},\n ] = await Promise.all([\n import('@microsoft/api-extractor'),\n import('./tasks/dts/createApiExtractorConfig.ts'),\n import('./tasks/dts/createTSDocConfig.ts'),\n import('./tasks/dts/getExtractMessagesConfig.ts'),\n import('./printExtractMessages.ts'),\n ])\n\n const customTags = ctx.config?.extract?.customTags || []\n const bundledPackages = ctx.bundledPackages\n const distPath = ctx.distPath\n const outDir = ctx.ts.config?.options.outDir\n const rules = ctx.config?.extract?.rules || {}\n\n if (!outDir) {\n throw new Error('tsconfig.json is missing `compilerOptions.outDir`')\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported || !exp.default.endsWith('.js')) continue\n const dtsPath = exp.default.replace(/\\.js$/, '.d.ts')\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n\n const tsdocConfigFile = await createTSDocConfig({\n customTags,\n })\n const extractorConfig = ExtractorConfig.prepare({\n configObject: createApiExtractorConfig({\n bundledPackages,\n distPath,\n exportPath,\n filePath: path.relative(outDir, dtsPath),\n messages: getExtractMessagesConfig({rules}),\n projectFolder: ctx.cwd,\n mainEntryPointFilePath: exportPath,\n tsconfig: ctx.ts.config!,\n tsconfigPath: path.resolve(ctx.cwd, ctx.ts.configPath || 'tsconfig.json'),\n dtsRollupEnabled: false,\n }),\n configObjectFullPath: undefined,\n tsdocConfigFile,\n packageJsonFullPath: path.resolve(ctx.cwd, 'package.json'),\n })\n const messages: ExtractorMessage[] = []\n // Invoke API Extractor\n Extractor.invoke(extractorConfig, {\n // Equivalent to the \"--local\" command-line parameter\n localBuild: true,\n // Equivalent to the \"--verbose\" command-line parameter\n showVerboseMessages: true,\n // handle messages\n messageCallback(message: ExtractorMessage) {\n messages.push(message)\n message.handled = true\n },\n })\n\n printExtractMessages(ctx, messages)\n }\n}\n"],"names":["exports"],"mappings":";;;;;;;;AAGO,SAAS,YAAY,MAAsB;AAChD,QAAM,QAAQ,SAAS,IAAI;AAE3B,SAAO,YAAY,MAAM,IAAI;AAC/B;ACCA,SAAS,YAAY,KAAa,UAAkB;AAClD,QAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAC9B,SAAS,WAAW,CAAC,GACrB,OAAO,SAAS,YAAY,CAAC,IAAI;AAEvC,SAAO,EAAC,QAAQ,KAAA;A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A,IAAA,CAC1D,GACK,WAA+B,CAAA;AAErC,cAAU,OAAO,iBAAiB;AAAA;AAAA,MAEhC,YAAY;AAAA;AAAA,MAEZ,qBAAqB;AAAA;AAAA,MAErB,gBAAgB,SAA2B;AACzC,iBAAS,KAAK,OAAO,GACrB,QAAQ,UAAU;AAAA,MACpB;AAAA,IAAA,CACD,GAED,qBAAqB,KAAK,QAAQ;AAAA,EACpC;AACF;"}
|
|
@@ -122,13 +122,39 @@ async function loadPkg(options) {
|
|
|
122
122
|
return validatePkg(raw), raw;
|
|
123
123
|
}
|
|
124
124
|
async function loadPkgWithReporting(options) {
|
|
125
|
-
const { cwd, logger, strict } = options;
|
|
125
|
+
const { cwd, logger, strict: strict2, strictOptions: strictOptions2 } = options;
|
|
126
126
|
try {
|
|
127
127
|
const pkg = await loadPkg({ cwd });
|
|
128
128
|
let shouldError = !1;
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
if (strict2) {
|
|
130
|
+
if (strictOptions2.preferModuleType !== "off")
|
|
131
|
+
if (pkg.type) {
|
|
132
|
+
if (pkg.type === "commonjs") {
|
|
133
|
+
const msg = '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.';
|
|
134
|
+
strictOptions2.preferModuleType === "error" ? (shouldError = !0, logger.error(msg)) : logger.warn(msg);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
const msg = 'package.json: `type` field is missing. Future versions of pkg-utils will require `"type": "module"`. Consider adding `"type": "module"` to prepare for this change.';
|
|
138
|
+
strictOptions2.preferModuleType === "error" ? (shouldError = !0, logger.error(msg)) : logger.warn(msg);
|
|
139
|
+
}
|
|
140
|
+
if (strictOptions2.noPackageJsonMain !== "off" && pkg.main) {
|
|
141
|
+
const msg = "package.json: the `main` field is no longer needed. All modern versions of Node.js and bundlers support the `exports` field. Remove the `main` field and use `exports` instead.";
|
|
142
|
+
strictOptions2.noPackageJsonMain === "error" ? (shouldError = !0, logger.error(msg)) : logger.warn(msg);
|
|
143
|
+
}
|
|
144
|
+
if (strictOptions2.noPackageJsonModule !== "off" && pkg.module) {
|
|
145
|
+
const msg = "package.json: the `module` field is no longer needed. All modern versions of Node.js and bundlers support the `exports` field. Remove the `module` field and use `exports` instead.";
|
|
146
|
+
strictOptions2.noPackageJsonModule === "error" ? (shouldError = !0, logger.error(msg)) : logger.warn(msg);
|
|
147
|
+
}
|
|
148
|
+
if (strictOptions2.noPackageJsonBrowser !== "off" && pkg.browser) {
|
|
149
|
+
const msg = "package.json: the `browser` field is no longer needed. Use the `browser` condition in `exports` instead for better support across modern bundlers.";
|
|
150
|
+
strictOptions2.noPackageJsonBrowser === "error" ? (shouldError = !0, logger.error(msg)) : logger.warn(msg);
|
|
151
|
+
}
|
|
152
|
+
if (strictOptions2.noPackageJsonTypesVersions !== "off" && pkg.typesVersions) {
|
|
153
|
+
const msg = "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.";
|
|
154
|
+
strictOptions2.noPackageJsonTypesVersions === "error" ? (shouldError = !0, logger.error(msg)) : logger.warn(msg);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (pkg.exports) {
|
|
132
158
|
const _exports = Object.entries(pkg.exports);
|
|
133
159
|
for (const [expPath, exp] of _exports) {
|
|
134
160
|
if (typeof exp == "string" || "svelte" in exp)
|
|
@@ -276,14 +302,14 @@ function isTruthy$1(value) {
|
|
|
276
302
|
return !!value;
|
|
277
303
|
}
|
|
278
304
|
function parseExports(options) {
|
|
279
|
-
const { cwd, pkg, strict, strictOptions: strictOptions2, logger } = options, type = pkg.type || "commonjs", errors = [], report = (kind, message) => {
|
|
305
|
+
const { cwd, pkg, strict: strict2, strictOptions: strictOptions2, logger } = options, type = pkg.type || "commonjs", errors = [], report = (kind, message) => {
|
|
280
306
|
kind === "warn" ? logger.warn(message) : errors.push(message);
|
|
281
307
|
};
|
|
282
|
-
if (!
|
|
308
|
+
if (!Array.isArray(pkg.files) && strict2 && strictOptions2.alwaysPackageJsonFiles !== "off" && report(
|
|
283
309
|
strictOptions2.alwaysPackageJsonFiles,
|
|
284
310
|
"package.json: `files` should be used over `.npmignore`"
|
|
285
311
|
), pkg.source) {
|
|
286
|
-
if (
|
|
312
|
+
if (strict2 && pkg.exports?.["."] && typeof pkg.exports["."] == "object" && "source" in pkg.exports["."] && pkg.exports["."].source === pkg.source)
|
|
287
313
|
errors.push(
|
|
288
314
|
'package.json: the "source" property can be removed, as it is equal to exports["."].source.'
|
|
289
315
|
);
|
|
@@ -342,10 +368,10 @@ function parseExports(options) {
|
|
|
342
368
|
- `)
|
|
343
369
|
);
|
|
344
370
|
const _exports = [];
|
|
345
|
-
|
|
371
|
+
strict2 && strictOptions2.noPackageJsonTypings !== "off" && "typings" in pkg && report(strictOptions2.noPackageJsonTypings, "package.json: `typings` should be `types`"), strict2 && strictOptions2.alwaysPackageJsonTypes !== "off" && !pkg.types && typeof pkg.exports?.["."] == "object" && "source" in pkg.exports["."] && pkg.exports["."].source?.endsWith(".ts") && report(
|
|
346
372
|
strictOptions2.alwaysPackageJsonTypes,
|
|
347
373
|
"package.json: `types` must be declared for the npm listing to show as a TypeScript module."
|
|
348
|
-
),
|
|
374
|
+
), strict2 && !pkg.exports["./package.json"] && errors.push('package.json: `exports["./package.json"] must be declared.');
|
|
349
375
|
for (const [exportPath, exportEntry] of Object.entries(pkg.exports))
|
|
350
376
|
if (exportPath.endsWith(".json") || typeof exportEntry == "string" && exportEntry.endsWith(".json"))
|
|
351
377
|
exportPath === "./package.json" && exportEntry !== "./package.json" && errors.push('package.json: `exports["./package.json"]` must be "./package.json".');
|
|
@@ -405,15 +431,23 @@ const toggle = z.union([z.literal("error"), z.literal("warn"), z.literal("off")]
|
|
|
405
431
|
noImplicitSideEffects: toggle.default("warn"),
|
|
406
432
|
noImplicitBrowsersList: toggle.default("warn"),
|
|
407
433
|
alwaysPackageJsonTypes: toggle.default("error"),
|
|
408
|
-
alwaysPackageJsonMain: toggle.default("error"),
|
|
409
434
|
alwaysPackageJsonFiles: toggle.default("error"),
|
|
410
|
-
noCheckTypes: toggle.default("warn")
|
|
435
|
+
noCheckTypes: toggle.default("warn"),
|
|
436
|
+
noPackageJsonMain: toggle.default("warn"),
|
|
437
|
+
noPackageJsonModule: toggle.default("warn"),
|
|
438
|
+
noPackageJsonBrowser: toggle.default("warn"),
|
|
439
|
+
noPackageJsonTypesVersions: toggle.default("warn"),
|
|
440
|
+
preferModuleType: toggle.default("warn")
|
|
411
441
|
}).strict(), validationSchema = z.object({
|
|
412
442
|
strictOptions: strictOptions.default({})
|
|
413
443
|
});
|
|
414
444
|
function parseStrictOptions(input) {
|
|
415
445
|
return validationSchema.parse({ strictOptions: input }, { errorMap }).strictOptions;
|
|
416
446
|
}
|
|
447
|
+
var strict = /* @__PURE__ */ Object.freeze({
|
|
448
|
+
__proto__: null,
|
|
449
|
+
parseStrictOptions
|
|
450
|
+
});
|
|
417
451
|
function isTruthy(value) {
|
|
418
452
|
return !!value;
|
|
419
453
|
}
|
|
@@ -424,7 +458,7 @@ async function resolveBuildContext(options) {
|
|
|
424
458
|
emitDeclarationOnly = !1,
|
|
425
459
|
logger,
|
|
426
460
|
pkg,
|
|
427
|
-
strict,
|
|
461
|
+
strict: strict2,
|
|
428
462
|
tsconfig: tsconfigPath
|
|
429
463
|
} = options, tsconfig = await loadTSConfig({ cwd, tsconfigPath }), strictOptions2 = parseStrictOptions(config2?.strictOptions ?? {});
|
|
430
464
|
if (strictOptions2.noCheckTypes !== "off" && tsconfig?.options && config2?.dts !== "rolldown" && tsconfig.options.noCheck !== !1 && !tsconfig.options.noCheck) {
|
|
@@ -438,7 +472,7 @@ async function resolveBuildContext(options) {
|
|
|
438
472
|
}
|
|
439
473
|
let browserslist2 = pkg.browserslist;
|
|
440
474
|
if (!browserslist2) {
|
|
441
|
-
if (
|
|
475
|
+
if (strict2 && strictOptions2.noImplicitBrowsersList !== "off") {
|
|
442
476
|
if (strictOptions2.noImplicitBrowsersList === "error")
|
|
443
477
|
throw new Error(
|
|
444
478
|
'\n- package.json: "browserslist" is missing, set it to `"browserslist": "extends @sanity/browserslist-config"`'
|
|
@@ -450,7 +484,7 @@ async function resolveBuildContext(options) {
|
|
|
450
484
|
browserslist2 = DEFAULT_BROWSERSLIST_QUERY;
|
|
451
485
|
}
|
|
452
486
|
const targetVersions = browserslistToEsbuild(browserslist2);
|
|
453
|
-
if (
|
|
487
|
+
if (strict2 && strictOptions2.noImplicitSideEffects !== "off" && typeof pkg.sideEffects > "u") {
|
|
454
488
|
const msg = "package.json: `sideEffects` is missing, see https://webpack.js.org/guides/tree-shaking/#clarifying-tree-shaking-and-sideeffects for how to define `sideEffects`";
|
|
455
489
|
if (strictOptions2.noImplicitSideEffects === "error")
|
|
456
490
|
throw new Error(msg);
|
|
@@ -468,7 +502,7 @@ async function resolveBuildContext(options) {
|
|
|
468
502
|
}, parsedExports = parseExports({
|
|
469
503
|
cwd,
|
|
470
504
|
pkg,
|
|
471
|
-
strict,
|
|
505
|
+
strict: strict2,
|
|
472
506
|
strictOptions: strictOptions2,
|
|
473
507
|
logger
|
|
474
508
|
}).reduce(
|
|
@@ -512,7 +546,7 @@ async function resolveBuildContext(options) {
|
|
|
512
546
|
logger,
|
|
513
547
|
pkg,
|
|
514
548
|
runtime: config2?.runtime ?? "*",
|
|
515
|
-
strict,
|
|
549
|
+
strict: strict2,
|
|
516
550
|
target,
|
|
517
551
|
ts: {
|
|
518
552
|
config: tsconfig,
|
|
@@ -554,6 +588,7 @@ export {
|
|
|
554
588
|
parseStrictOptions,
|
|
555
589
|
pkgExtMap,
|
|
556
590
|
resolveBuildContext,
|
|
557
|
-
resolveConfigProperty
|
|
591
|
+
resolveConfigProperty,
|
|
592
|
+
strict
|
|
558
593
|
};
|
|
559
594
|
//# sourceMappingURL=consoleSpy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleSpy.js","sources":["../../src/node/core/config/findConfigFile.ts","../../src/node/core/config/loadConfig.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.0/node_modules/browserslist-to-esbuild/src/index.js","../../src/node/core/config/resolveConfigProperty.ts","../../src/node/core/defaults.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/parseExports.ts","../../src/node/core/ts/loadTSConfig.ts","../../src/node/resolveBrowserTarget.ts","../../src/node/resolveNodeTarget.ts","../../src/node/strict.ts","../../src/node/resolveBuildContext.ts","../../src/node/consoleSpy.ts"],"sourcesContent":["import path from 'node:path'\nimport findConfig from 'find-config'\nimport {fileExists} from '../../fileExists.ts'\n\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\n 'package.config.mts',\n 'package.config.mjs',\n]\n\n/** @internal */\nexport function findConfigFile(cwd: string): string | undefined {\n const pkgJsonPath = findConfig('package.json', {cwd})\n\n if (!pkgJsonPath) return undefined\n\n const pkgPath = path.dirname(pkgJsonPath)\n\n for (const fileName of CONFIG_FILE_NAMES) {\n const configPath = path.resolve(pkgPath, fileName)\n\n const exists = fileExists(configPath)\n\n if (exists) {\n return configPath\n }\n }\n\n return undefined\n}\n","import path from 'node:path'\nimport {pathToFileURL} from 'node:url'\nimport {packageUp} from 'package-up'\nimport {tsImport} from 'tsx/esm/api'\nimport {findConfigFile} from './findConfigFile.ts'\nimport type {PkgConfigOptions} from './types.ts'\n\n/** @alpha */\nexport async function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined> {\n const {cwd} = options\n\n const pkgPath = await packageUp({cwd})\n\n if (!pkgPath) return undefined\n\n const root = path.dirname(pkgPath)\n\n const configFile = findConfigFile(root)\n\n if (!configFile) {\n return undefined\n }\n\n // Do not accept config files outside of the root\n if (!configFile.startsWith(cwd)) {\n return undefined\n }\n\n const mod = await tsImport(pathToFileURL(configFile).toString(), import.meta.url)\n\n return mod?.default || mod || undefined\n}\n","/** @internal */\nexport function assertFirst<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 === 0\n}\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 {z} from 'zod/v3'\nimport type {PackageJSON} from './types.ts'\n\nconst pkgSchema = z.object({\n type: z.optional(z.enum(['commonjs', 'module'])),\n name: z.string(),\n version: z.string(),\n license: z.string(),\n bin: z.optional(z.record(z.string())),\n dependencies: z.optional(z.record(z.string())),\n devDependencies: z.optional(z.record(z.string())),\n peerDependencies: z.optional(z.record(z.string())),\n source: z.optional(z.string()),\n main: z.optional(z.string()),\n browser: z.optional(z.record(z.string())),\n module: z.optional(z.string()),\n types: z.optional(z.string()),\n exports: z.optional(\n z.record(\n z.union([\n z.custom<`./${string}.json`>(\n (val) => typeof val === 'string' && /^\\.\\/.*\\.json$/.test(val),\n ),\n z.custom<`./${string}.css`>((val) => typeof val === 'string' && /^\\.\\/.*\\.css$/.test(val)),\n z.object({\n types: z.optional(z.string()),\n source: z.optional(z.string()),\n browser: z.optional(\n z.object({\n source: z.string(),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n node: z.optional(\n z.object({\n source: z.optional(z.string()),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n default: z.string(),\n }),\n z.object({\n types: z.optional(z.string()),\n svelte: z.string(),\n default: z.optional(z.string()),\n }),\n ]),\n ),\n ),\n browserslist: z.optional(z.union([z.string(), z.array(z.string())])),\n sideEffects: z.optional(z.union([z.boolean(), z.array(z.string())])),\n // @TODO type this properly\n typesVersions: z.optional(z.any()),\n})\n\n// Create a map over known keys to catch casing mistakes\nconst typoMap = new Map<string, string>()\n\nfor (const key of pkgSchema.keyof()._def.values) {\n typoMap.set(key.toUpperCase(), key)\n}\n\nexport function validatePkg(input: unknown): PackageJSON {\n const pkg = pkgSchema.parse(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 {packageUp} from 'package-up'\nimport type {PackageJSON} from './types.ts'\nimport {validatePkg} from './validatePkg.ts'\n\n/** @internal */\nexport async function loadPkg(options: {cwd: string}): Promise<PackageJSON> {\n const {cwd} = options\n\n const pkgPath = await packageUp({cwd})\n\n if (!pkgPath) throw new Error('no package.json found')\n\n const buf = await fs.readFile(pkgPath)\n\n const raw = JSON.parse(buf.toString())\n\n validatePkg(raw)\n\n return raw\n}\n","import chalk from 'chalk'\nimport {ZodError} from 'zod/v3'\nimport type {Logger} from '../../logger.ts'\nimport {assertLast, assertOrder} from './helpers.ts'\nimport {loadPkg} from './loadPkg.ts'\nimport type {PackageJSON} from './types.ts'\n\n/** @alpha */\nexport async function loadPkgWithReporting(options: {\n cwd: string\n logger: Logger\n strict: boolean\n}): Promise<PackageJSON> {\n const {cwd, logger, strict} = options\n\n try {\n const pkg = await loadPkg({cwd})\n let shouldError = false\n\n if (strict) {\n if (!pkg.type) {\n shouldError = true\n logger.error(\n `the \\`type\\` field in \\`./package.json\\` must be either \"module\" or \"commonjs\")`,\n )\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 if (typeof exp === 'string' || '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.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 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 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 config from '@sanity/browserslist-config'\n\n/** @public */\nexport const DEFAULT_BROWSERSLIST_QUERY: string[] = config\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 dirPath = path.dirname(dirPath)\n\n if (dirPath === ret) {\n break\n }\n\n if (pathContains(dirPath, ret)) {\n ret = dirPath\n break\n }\n\n if (dirPath === '.') return undefined\n }\n }\n\n return ret\n}\n","import type {PkgBundle, PkgExport} from '../../core/config/types.ts'\nimport type {PackageJSON} from '../../core/pkg/types.ts'\n\n/** @internal */\nexport const fileEnding: RegExp = /\\.[mc]?js$/\n/** @internal */\nexport const 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 {PkgExport} from '../config/types.ts'\nimport {pkgExtMap as extMap} from './pkgExt.ts'\nimport type {PackageJSON} from './types.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.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 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 type {PackageJSON} from './types.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 parseExports(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 (!pkg.main && strict && strictOptions.alwaysPackageJsonMain !== 'off') {\n report(strictOptions.alwaysPackageJsonMain, 'package.json: `main` must be declared')\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: (PkgExport & {_path: string})[] = []\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' && !existsSync(resolvePath(cwd, exportEntry))) {\n errors.push(\n `package.json: \\`exports[${JSON.stringify(exportPath)}]\\`: file does not exist.`,\n )\n } else if (typeof exportEntry !== 'string') {\n errors.push(\n `package.json: \\`exports[${JSON.stringify(exportPath)}]\\`: export conditions not supported for CSS files.`,\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\n _exports.push(exp)\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","import ts from 'typescript'\n\n/** @internal */\nexport async function loadTSConfig(options: {\n cwd: string\n tsconfigPath: string\n}): Promise<ts.ParsedCommandLine | undefined> {\n const {cwd, tsconfigPath} = options\n\n const configPath = ts.findConfigFile(cwd, (fileName) => ts.sys.fileExists(fileName), tsconfigPath)\n\n if (!configPath) {\n return undefined\n }\n\n const configFile = ts.readConfigFile(configPath, (path) => ts.sys.readFile(path))\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 alwaysPackageJsonMain: toggle.default('error'),\n alwaysPackageJsonFiles: toggle.default('error'),\n noCheckTypes: toggle.default('warn'),\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 * A lot of analysis tooling requiers the `main` field to work (like bundlephobia) and so it's best practice to always include it\n * @defaultValue 'error'\n */\n alwaysPackageJsonMain: 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\n/** @alpha */\nexport function parseStrictOptions(input: unknown): StrictOptions {\n return validationSchema.parse({strictOptions: input}, {errorMap}).strictOptions\n}\n","import path from 'node:path'\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 {parseExports} from './core/pkg/parseExports.ts'\nimport type {PackageJSON} from './core/pkg/types.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 (tsconfig.options.noCheck !== false && !tsconfig.options.noCheck) {\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.',\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.',\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 = parseExports({\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","// 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"],"names":["path","isPkgExport","extMap","isTruthy","strictOptions","resolvePath","config","browserslist","exports"],"mappings":";;;;;;;;;;;;;;AAIA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,eAAe,KAAiC;AAC9D,QAAM,cAAc,WAAW,gBAAgB,EAAC,KAAI;AAEpD,MAAI,CAAC,YAAa;AAElB,QAAM,UAAU,KAAK,QAAQ,WAAW;AAExC,aAAW,YAAY,mBAAmB;AACxC,UAAM,aAAa,KAAK,QAAQ,SAAS,QAAQ;AAIjD,QAFe,WAAW,UAAU;AAGlC,aAAO;AAAA,EAEX;AAGF;ACvBA,eAAsB,WAAW,SAA+D;AAC9F,QAAM,EAAC,QAAO,SAER,UAAU,MAAM,UAAU,EAAC,KAAI;AAErC,MAAI,CAAC,QAAS;AAEd,QAAM,OAAO,KAAK,QAAQ,OAAO,GAE3B,aAAa,eAAe,IAAI;AAOtC,MALI,CAAC,cAKD,CAAC,WAAW,WAAW,GAAG;AAC5B;AAGF,QAAM,MAAM,MAAM,SAAS,cAAc,UAAU,EAAE,YAAY,YAAY,GAAG;AAEhF,SAAO,KAAK,WAAW,OAAO;AAChC;AClBO,SAAS,WAAc,GAAM,KAAmB;AACrD,QAAM,OAAO,IAAI,QAAQ,CAAC;AAG1B,SAAI,SAAS,KACJ,KAGF,SAAS,IAAI,SAAS;AAC/B;AAGO,SAAS,YAAe,GAAM,GAAM,KAAmB;AAC5D,QAAM,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js","sources":["../../src/node/core/config/findConfigFile.ts","../../src/node/core/config/loadConfig.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.0/node_modules/browserslist-to-esbuild/src/index.js","../../src/node/core/config/resolveConfigProperty.ts","../../src/node/core/defaults.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/parseExports.ts","../../src/node/core/ts/loadTSConfig.ts","../../src/node/resolveBrowserTarget.ts","../../src/node/resolveNodeTarget.ts","../../src/node/strict.ts","../../src/node/resolveBuildContext.ts","../../src/node/consoleSpy.ts"],"sourcesContent":["import path from 'node:path'\nimport findConfig from 'find-config'\nimport {fileExists} from '../../fileExists.ts'\n\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\n 'package.config.mts',\n 'package.config.mjs',\n]\n\n/** @internal */\nexport function findConfigFile(cwd: string): string | undefined {\n const pkgJsonPath = findConfig('package.json', {cwd})\n\n if (!pkgJsonPath) return undefined\n\n const pkgPath = path.dirname(pkgJsonPath)\n\n for (const fileName of CONFIG_FILE_NAMES) {\n const configPath = path.resolve(pkgPath, fileName)\n\n const exists = fileExists(configPath)\n\n if (exists) {\n return configPath\n }\n }\n\n return undefined\n}\n","import path from 'node:path'\nimport {pathToFileURL} from 'node:url'\nimport {packageUp} from 'package-up'\nimport {tsImport} from 'tsx/esm/api'\nimport {findConfigFile} from './findConfigFile.ts'\nimport type {PkgConfigOptions} from './types.ts'\n\n/** @alpha */\nexport async function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined> {\n const {cwd} = options\n\n const pkgPath = await packageUp({cwd})\n\n if (!pkgPath) return undefined\n\n const root = path.dirname(pkgPath)\n\n const configFile = findConfigFile(root)\n\n if (!configFile) {\n return undefined\n }\n\n // Do not accept config files outside of the root\n if (!configFile.startsWith(cwd)) {\n return undefined\n }\n\n const mod = await tsImport(pathToFileURL(configFile).toString(), import.meta.url)\n\n return mod?.default || mod || undefined\n}\n","/** @internal */\nexport function assertFirst<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 === 0\n}\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 {z} from 'zod/v3'\nimport type {PackageJSON} from './types.ts'\n\nconst pkgSchema = z.object({\n type: z.optional(z.enum(['commonjs', 'module'])),\n name: z.string(),\n version: z.string(),\n license: z.string(),\n bin: z.optional(z.record(z.string())),\n dependencies: z.optional(z.record(z.string())),\n devDependencies: z.optional(z.record(z.string())),\n peerDependencies: z.optional(z.record(z.string())),\n source: z.optional(z.string()),\n main: z.optional(z.string()),\n browser: z.optional(z.record(z.string())),\n module: z.optional(z.string()),\n types: z.optional(z.string()),\n exports: z.optional(\n z.record(\n z.union([\n z.custom<`./${string}.json`>(\n (val) => typeof val === 'string' && /^\\.\\/.*\\.json$/.test(val),\n ),\n z.custom<`./${string}.css`>((val) => typeof val === 'string' && /^\\.\\/.*\\.css$/.test(val)),\n z.object({\n types: z.optional(z.string()),\n source: z.optional(z.string()),\n browser: z.optional(\n z.object({\n source: z.string(),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n node: z.optional(\n z.object({\n source: z.optional(z.string()),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n }),\n ),\n import: z.optional(z.string()),\n require: z.optional(z.string()),\n default: z.string(),\n }),\n z.object({\n types: z.optional(z.string()),\n svelte: z.string(),\n default: z.optional(z.string()),\n }),\n ]),\n ),\n ),\n browserslist: z.optional(z.union([z.string(), z.array(z.string())])),\n sideEffects: z.optional(z.union([z.boolean(), z.array(z.string())])),\n // @TODO type this properly\n typesVersions: z.optional(z.any()),\n})\n\n// Create a map over known keys to catch casing mistakes\nconst typoMap = new Map<string, string>()\n\nfor (const key of pkgSchema.keyof()._def.values) {\n typoMap.set(key.toUpperCase(), key)\n}\n\nexport function validatePkg(input: unknown): PackageJSON {\n const pkg = pkgSchema.parse(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 {packageUp} from 'package-up'\nimport type {PackageJSON} from './types.ts'\nimport {validatePkg} from './validatePkg.ts'\n\n/** @internal */\nexport async function loadPkg(options: {cwd: string}): Promise<PackageJSON> {\n const {cwd} = options\n\n const pkgPath = await packageUp({cwd})\n\n if (!pkgPath) throw new Error('no package.json found')\n\n const buf = await fs.readFile(pkgPath)\n\n const raw = JSON.parse(buf.toString())\n\n validatePkg(raw)\n\n return raw\n}\n","import chalk from 'chalk'\nimport {ZodError} from 'zod/v3'\nimport type {Logger} from '../../logger.ts'\nimport type {StrictOptions} from '../../strict.ts'\nimport {assertLast, assertOrder} from './helpers.ts'\nimport {loadPkg} from './loadPkg.ts'\nimport type {PackageJSON} from './types.ts'\n\n/** @alpha */\nexport async function loadPkgWithReporting(options: {\n cwd: string\n logger: Logger\n strict: boolean\n strictOptions: StrictOptions\n}): Promise<PackageJSON> {\n const {cwd, logger, strict, strictOptions} = options\n\n try {\n const pkg = await loadPkg({cwd})\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.noPackageJsonMain !== 'off' && pkg.main) {\n const msg =\n 'package.json: the `main` field is no longer needed. All modern versions of Node.js and bundlers support the `exports` field. Remove the `main` field and use `exports` instead.'\n if (strictOptions.noPackageJsonMain === 'error') {\n shouldError = true\n logger.error(msg)\n } else {\n logger.warn(msg)\n }\n }\n\n if (strictOptions.noPackageJsonModule !== 'off' && pkg.module) {\n const msg =\n 'package.json: the `module` field is no longer needed. All modern versions of Node.js and bundlers support the `exports` field. Remove the `module` field and use `exports` instead.'\n if (strictOptions.noPackageJsonModule === 'error') {\n shouldError = true\n logger.error(msg)\n } else {\n logger.warn(msg)\n }\n }\n\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\n // validate exports\n if (pkg.exports) {\n const _exports = Object.entries(pkg.exports)\n\n for (const [expPath, exp] of _exports) {\n if (typeof exp === 'string' || '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.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 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 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 config from '@sanity/browserslist-config'\n\n/** @public */\nexport const DEFAULT_BROWSERSLIST_QUERY: string[] = config\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 dirPath = path.dirname(dirPath)\n\n if (dirPath === ret) {\n break\n }\n\n if (pathContains(dirPath, ret)) {\n ret = dirPath\n break\n }\n\n if (dirPath === '.') return undefined\n }\n }\n\n return ret\n}\n","import type {PkgBundle, PkgExport} from '../../core/config/types.ts'\nimport type {PackageJSON} from '../../core/pkg/types.ts'\n\n/** @internal */\nexport const fileEnding: RegExp = /\\.[mc]?js$/\n/** @internal */\nexport const 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 {PkgExport} from '../config/types.ts'\nimport {pkgExtMap as extMap} from './pkgExt.ts'\nimport type {PackageJSON} from './types.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.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 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 type {PackageJSON} from './types.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 parseExports(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: (PkgExport & {_path: string})[] = []\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' && !existsSync(resolvePath(cwd, exportEntry))) {\n errors.push(\n `package.json: \\`exports[${JSON.stringify(exportPath)}]\\`: file does not exist.`,\n )\n } else if (typeof exportEntry !== 'string') {\n errors.push(\n `package.json: \\`exports[${JSON.stringify(exportPath)}]\\`: export conditions not supported for CSS files.`,\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\n _exports.push(exp)\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","import ts from 'typescript'\n\n/** @internal */\nexport async function loadTSConfig(options: {\n cwd: string\n tsconfigPath: string\n}): Promise<ts.ParsedCommandLine | undefined> {\n const {cwd, tsconfigPath} = options\n\n const configPath = ts.findConfigFile(cwd, (fileName) => ts.sys.fileExists(fileName), tsconfigPath)\n\n if (!configPath) {\n return undefined\n }\n\n const configFile = ts.readConfigFile(configPath, (path) => ts.sys.readFile(path))\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 noPackageJsonMain: toggle.default('warn'),\n noPackageJsonModule: toggle.default('warn'),\n noPackageJsonBrowser: toggle.default('warn'),\n noPackageJsonTypesVersions: toggle.default('warn'),\n preferModuleType: toggle.default('warn'),\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 `main` field in `package.json` as all modern tools support the `exports` field.\n * @defaultValue 'warn'\n */\n noPackageJsonMain: ToggleType\n /**\n * Disallows the `module` field in `package.json` as all modern tools support the `exports` field.\n * @defaultValue 'warn'\n */\n noPackageJsonModule: 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\n/** @alpha */\nexport function parseStrictOptions(input: unknown): StrictOptions {\n return validationSchema.parse({strictOptions: input}, {errorMap}).strictOptions\n}\n","import path from 'node:path'\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 {parseExports} from './core/pkg/parseExports.ts'\nimport type {PackageJSON} from './core/pkg/types.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 (tsconfig.options.noCheck !== false && !tsconfig.options.noCheck) {\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.',\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.',\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 = parseExports({\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","// 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"],"names":["strict","strictOptions","path","isPkgExport","extMap","isTruthy","resolvePath","config","browserslist","exports"],"mappings":";;;;;;;;;;;;;;AAIA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,eAAe,KAAiC;AAC9D,QAAM,cAAc,WAAW,gBAAgB,EAAC,KAAI;AAEpD,MAAI,CAAC,YAAa;AAElB,QAAM,UAAU,KAAK,QAAQ,WAAW;AAExC,aAAW,YAAY,mBAAmB;AACxC,UAAM,aAAa,KAAK,QAAQ,SAAS,QAAQ;AAIjD,QAFe,WAAW,UAAU;AAGlC,aAAO;AAAA,EAEX;AAGF;ACvBA,eAAsB,WAAW,SAA+D;AAC9F,QAAM,EAAC,QAAO,SAER,UAAU,MAAM,UAAU,EAAC,KAAI;AAErC,MAAI,CAAC,QAAS;AAEd,QAAM,OAAO,KAAK,QAAQ,OAAO,GAE3B,aAAa,eAA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L;AAAA,IACA,SAAS,MAAM;AACb,cAAQ,MAAM,SAAS,KACvB,QAAQ,OAAO,SAAS,MACxB,QAAQ,QAAQ,SAAS,OAEzB,aAAa,QAAQ;AAAA,IACvB;AAAA,EAAA;AAEJ;","x_google_ignoreList":[6]}
|
package/dist/_chunks-es/watch.js
CHANGED
|
@@ -80,7 +80,9 @@ async function watch(options) {
|
|
|
80
80
|
switchMap(async (configFiles) => {
|
|
81
81
|
if (!configFiles.map((f) => path.relative(cwd, f)).find((f) => f === "package.json"))
|
|
82
82
|
throw new Error("missing package.json");
|
|
83
|
-
const config = await loadConfig({ cwd }),
|
|
83
|
+
const config = await loadConfig({ cwd }), { parseStrictOptions } = await import("./consoleSpy.js").then(function(n) {
|
|
84
|
+
return n.strict;
|
|
85
|
+
}), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ cwd, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json";
|
|
84
86
|
return resolveBuildContext({ config, cwd, logger, pkg, strict, tsconfig });
|
|
85
87
|
})
|
|
86
88
|
).subscribe(async (ctx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sources":["../../src/node/resolveWatchTasks.ts","../../src/node/watch.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsWatchTask} from './tasks/dts/types.ts'\nimport type {RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveWatchTasks(ctx: BuildContext): WatchTask[] {\n const {pkg, target} = ctx\n const tasks: WatchTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsWatchTask = {\n type: 'watch:dts',\n entries: [],\n }\n\n const rollupTasks: Record<string, RollupWatchTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'watch:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {switchMap} from 'rxjs'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveWatchTasks} from './resolveWatchTasks.ts'\nimport {watchTaskHandlers} from './tasks/index.ts'\nimport {type TaskHandler, type WatchTask} from './tasks/types.ts'\n\n/** @public */\nexport async function watch(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n\n const logger = createLogger()\n\n const {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n const ctx$ = configFiles$.pipe(\n switchMap(async (configFiles) => {\n const files = configFiles.map((f) => path.relative(cwd, f))\n\n const packageJsonPath = files.find((f) => f === 'package.json')\n\n if (!packageJsonPath) {\n throw new Error('missing package.json')\n }\n\n const config = await loadConfig({cwd})\n const pkg = await loadPkgWithReporting({cwd, logger, strict})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n return resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n }),\n )\n\n ctx$.subscribe(async (ctx) => {\n const watchTasks = resolveWatchTasks(ctx)\n\n for (const task of watchTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = watchTaskHandlers[task.type] as TaskHandler<WatchTask, unknown>\n const result$ = handler.exec(ctx, task)\n\n result$.subscribe({\n error: (err) => {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n },\n next: (result) => {\n handler.complete(ctx, task, result)\n },\n complete: () => {\n ctx.logger.success(handler.name(ctx, task))\n ctx.logger.log()\n },\n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KAAK;AAAA,MACrB,aAAa,eAAe,IAAI,MAAM,IAAI,IAAI;AAAA,IAAA,CAC/C;AAAA,EAEL;AAGA,aAAW,OAAOA,WAAS;AACzB,UAAM,SAAS,IAAI;AAEd,cAEL,mBAAmB,YAAY,IAAI,SAAS;AAAA,MAC1C,MAAM,IAAI;AAAA,MACV,QAAQ,IAAI;AAAA,MACZ;AAAA,IAAA,CACD;AAAA,EACH;AAGA,aAAW,OAAOA,WAAS;AACzB,UAAM,SAAS,IAAI,SAAS;AAEvB,cAEL,mBAAmB,YAAY,WAAW;AAAA,MACxC,MAAM,IAAI;AAAA,MACV,QAAQ,IAAI,SAAS,UAAU,IAAI;AAAA,MACnC;AAAA,IAAA,CACD;AAAA,EACH;AAGA,aAAW,OAAOA,WAAS;AACzB,UAAM,SAAS,IAAI;AAEd,cAEL,mBAAmB,OAAO,IAAI,SAAS;AAAA,MACrC,MAAM,IAAI;AAAA,MACV,QAAQ,IAAI;AAAA,MACZ;AAAA,IAAA,CACD;AAAA,EACH;AAGA,aAAW,OAAOA,WAAS;AACzB,UAAM,SAAS,IAAI,SAAS;AAEvB,cAEL,mBAAmB,OAAO,WAAW;AAAA,MACnC,MAAM,IAAI;AAAA,MACV,QAAQ,IAAI,SAAS,UAAU,IAAI;AAAA,MACnC;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAI,QAAQ,QAAQ,UAClB,MAAM,KAAK,OAAO,GAGpB,MAAM,KAAK,GAAG,OAAO,OAAO,WAAW,CAAC,GAEjC;AACT;ACxHA,eAAsB,MAAM,SAIV;AAChB,QAAM,EAAC,KAAK,SAAS,IAAO,UAAU,mBAAkB,SAElD,SAAS,aAAA,GAET,EAAC,iBAAA,IAAoB,MAAM,OAAO,uBAAuB;
|
|
1
|
+
{"version":3,"file":"watch.js","sources":["../../src/node/resolveWatchTasks.ts","../../src/node/watch.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsWatchTask} from './tasks/dts/types.ts'\nimport type {RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveWatchTasks(ctx: BuildContext): WatchTask[] {\n const {pkg, target} = ctx\n const tasks: WatchTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsWatchTask = {\n type: 'watch:dts',\n entries: [],\n }\n\n const rollupTasks: Record<string, RollupWatchTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'watch:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {switchMap} from 'rxjs'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveWatchTasks} from './resolveWatchTasks.ts'\nimport {watchTaskHandlers} from './tasks/index.ts'\nimport {type TaskHandler, type WatchTask} from './tasks/types.ts'\n\n/** @public */\nexport async function watch(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n\n const logger = createLogger()\n\n const {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n const ctx$ = configFiles$.pipe(\n switchMap(async (configFiles) => {\n const files = configFiles.map((f) => path.relative(cwd, f))\n\n const packageJsonPath = files.find((f) => f === 'package.json')\n\n if (!packageJsonPath) {\n throw new Error('missing package.json')\n }\n\n const config = await loadConfig({cwd})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({cwd, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n return resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n }),\n )\n\n ctx$.subscribe(async (ctx) => {\n const watchTasks = resolveWatchTasks(ctx)\n\n for (const task of watchTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = watchTaskHandlers[task.type] as TaskHandler<WatchTask, unknown>\n const result$ = handler.exec(ctx, task)\n\n result$.subscribe({\n error: (err) => {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n },\n next: (result) => {\n handler.complete(ctx, task, result)\n },\n complete: () => {\n ctx.logger.success(handler.name(ctx, task))\n ctx.logger.log()\n },\n })\n }\n })\n}\n"],"names":["exports"],"mappings":";;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,KAAK,OAAA,IAAU,KAChB,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAA;AAAA,EAAG,GAG7B,UAAwB;AAAA,IAC5B,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,cAA+C,CAAA;AAErD,WAAS,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,gBAAY,OAAO,IACrB,YAAY,OAAO,EAAE,QAAQ,KAAK,KAAK,IAEvC,YAAY,OAAO,IAAI;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,OAAO;AAAA,IAAA;AAAA,EAG5B;AAGA,aAAW,OAAOA,WAAS;AACzB,UAAM,WAAW,KAAK,KAAK,IAAI,MAAM,IAAI,KAAK;AAE1C,QAAI,QAAQ,SAAS,KAAK,KAC5B,QAAQ,QAAQ,KAAK;AAAA,MACn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ChB,kBAAQ,SAAS,KAAK,MAAM,MAAM;AAAA,QACpC;AAAA,QACA,UAAU,MAAM;AACd,cAAI,OAAO,QAAQ,QAAQ,KAAK,KAAK,IAAI,CAAC,GAC1C,IAAI,OAAO,IAAA;AAAA,QACb;AAAA,MAAA,CACD;AAAA,IACH;AAAA,EACF,CAAC;AACH;"}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cac } from "cac";
|
|
2
|
-
var version = "9.0
|
|
2
|
+
var version = "9.1.0";
|
|
3
3
|
const cli = cac();
|
|
4
4
|
cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
|
|
5
5
|
const { checkAction } = await import("./_chunks-es/checkAction.js");
|
package/dist/index.d.ts
CHANGED
|
@@ -66,11 +66,6 @@ interface StrictOptions {
|
|
|
66
66
|
* @defaultValue 'error'
|
|
67
67
|
*/
|
|
68
68
|
alwaysPackageJsonTypes: ToggleType;
|
|
69
|
-
/**
|
|
70
|
-
* A lot of analysis tooling requiers the `main` field to work (like bundlephobia) and so it's best practice to always include it
|
|
71
|
-
* @defaultValue 'error'
|
|
72
|
-
*/
|
|
73
|
-
alwaysPackageJsonMain: ToggleType;
|
|
74
69
|
/**
|
|
75
70
|
* Using `.npmignore` is error prone, it's best practice to always declare `files` instead
|
|
76
71
|
* @defaultValue 'error'
|
|
@@ -81,6 +76,31 @@ interface StrictOptions {
|
|
|
81
76
|
* @defaultValue 'warn'
|
|
82
77
|
*/
|
|
83
78
|
noCheckTypes: ToggleType;
|
|
79
|
+
/**
|
|
80
|
+
* Disallows the `main` field in `package.json` as all modern tools support the `exports` field.
|
|
81
|
+
* @defaultValue 'warn'
|
|
82
|
+
*/
|
|
83
|
+
noPackageJsonMain: ToggleType;
|
|
84
|
+
/**
|
|
85
|
+
* Disallows the `module` field in `package.json` as all modern tools support the `exports` field.
|
|
86
|
+
* @defaultValue 'warn'
|
|
87
|
+
*/
|
|
88
|
+
noPackageJsonModule: ToggleType;
|
|
89
|
+
/**
|
|
90
|
+
* Disallows the `browser` field in `package.json` as the `browser` condition in `exports` is better supported.
|
|
91
|
+
* @defaultValue 'warn'
|
|
92
|
+
*/
|
|
93
|
+
noPackageJsonBrowser: ToggleType;
|
|
94
|
+
/**
|
|
95
|
+
* Disallows the `typesVersions` field in `package.json` as TypeScript has long supported conditional exports and the `types` condition.
|
|
96
|
+
* @defaultValue 'warn'
|
|
97
|
+
*/
|
|
98
|
+
noPackageJsonTypesVersions: ToggleType;
|
|
99
|
+
/**
|
|
100
|
+
* Warns if `type` field is missing or set to `commonjs`. Future versions will require `"type": "module"`.
|
|
101
|
+
* @defaultValue 'warn'
|
|
102
|
+
*/
|
|
103
|
+
preferModuleType: ToggleType;
|
|
84
104
|
}
|
|
85
105
|
/** @alpha */
|
|
86
106
|
declare function parseStrictOptions(input: unknown): StrictOptions;
|
|
@@ -345,6 +365,7 @@ interface PackageJSON {
|
|
|
345
365
|
source?: string;
|
|
346
366
|
module?: string;
|
|
347
367
|
types?: string;
|
|
368
|
+
typesVersions?: Record<string, Record<string, string[]>>;
|
|
348
369
|
files?: string[];
|
|
349
370
|
scripts?: Record<string, string | undefined>;
|
|
350
371
|
browserslist?: string | string[];
|
|
@@ -383,6 +404,7 @@ declare function loadPkgWithReporting(options: {
|
|
|
383
404
|
cwd: string;
|
|
384
405
|
logger: Logger;
|
|
385
406
|
strict: boolean;
|
|
407
|
+
strictOptions: StrictOptions;
|
|
386
408
|
}): Promise<PackageJSON>;
|
|
387
409
|
/** @alpha */
|
|
388
410
|
declare function parseExports(options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@babel/parser": "^7.28.5",
|
|
57
57
|
"@babel/preset-typescript": "^7.28.5",
|
|
58
58
|
"@babel/types": "^7.28.5",
|
|
59
|
-
"@microsoft/api-extractor": "^7.
|
|
60
|
-
"@microsoft/tsdoc-config": "^0.
|
|
59
|
+
"@microsoft/api-extractor": "^7.55.0",
|
|
60
|
+
"@microsoft/tsdoc-config": "^0.18.0",
|
|
61
61
|
"@optimize-lodash/rollup-plugin": "^5.0.2",
|
|
62
62
|
"@rollup/plugin-alias": "^6.0.0",
|
|
63
63
|
"@rollup/plugin-babel": "^6.1.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@rollup/plugin-replace": "^6.0.3",
|
|
68
68
|
"@rollup/plugin-terser": "^0.4.4",
|
|
69
69
|
"@sanity/browserslist-config": "^1.0.5",
|
|
70
|
-
"@vanilla-extract/rollup-plugin": "^1.4.
|
|
70
|
+
"@vanilla-extract/rollup-plugin": "^1.4.2",
|
|
71
71
|
"browserslist": "^4.28.0",
|
|
72
72
|
"cac": "^6.7.14",
|
|
73
73
|
"chalk": "^5.6.2",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"prompts": "^2.4.2",
|
|
88
88
|
"recast": "^0.23.11",
|
|
89
89
|
"rimraf": "^6.1.0",
|
|
90
|
-
"rolldown": "1.0.0-beta.
|
|
91
|
-
"rolldown-plugin-dts": "0.17.
|
|
90
|
+
"rolldown": "1.0.0-beta.50",
|
|
91
|
+
"rolldown-plugin-dts": "0.17.7",
|
|
92
92
|
"rollup": "^4.53.2",
|
|
93
93
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
94
94
|
"rxjs": "^7.8.2",
|
|
@@ -106,14 +106,14 @@
|
|
|
106
106
|
"@types/prompts": "^2.4.9",
|
|
107
107
|
"@types/semver": "^7.7.1",
|
|
108
108
|
"@types/treeify": "^1.0.3",
|
|
109
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
109
|
+
"@typescript/native-preview": "7.0.0-dev.20251114.1",
|
|
110
110
|
"babel-plugin-react-compiler": "1.0.0",
|
|
111
111
|
"browserslist-to-esbuild": "2.1.1",
|
|
112
112
|
"fs-extra": "^11.3.2",
|
|
113
113
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
114
114
|
"semver": "^7.7.3",
|
|
115
115
|
"typescript": "5.9.3",
|
|
116
|
-
"vitest": "^4.0.
|
|
116
|
+
"vitest": "^4.0.9"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
119
|
"babel-plugin-react-compiler": "*",
|