@sanity/pkg-utils 6.4.1 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/consoleSpy.cjs +39 -11
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +39 -10
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/node/__snapshots__/strict.test.ts.snap +145 -0
- package/src/node/core/config/types.ts +7 -1
- package/src/node/core/pkg/parseExports.ts +15 -3
- package/src/node/index.ts +1 -0
- package/src/node/resolveBuildContext.ts +28 -8
- package/src/node/strict.test-d.ts +7 -0
- package/src/node/strict.ts +66 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var path = require("node:path"), node = require("esbuild-register/dist/node"), pkgUp = require("pkg-up"), findConfig = require("find-config"), logger = require("./logger.cjs"), chalk = require("chalk"), zod = require("zod"), fs = require("node:fs/promises"), browserslist = require("browserslist"), config = require("@sanity/browserslist-config"), ts = require("typescript");
|
|
2
|
+
var path = require("node:path"), node = require("esbuild-register/dist/node"), pkgUp = require("pkg-up"), findConfig = require("find-config"), logger = require("./logger.cjs"), chalk = require("chalk"), zod = require("zod"), fs = require("node:fs/promises"), browserslist = require("browserslist"), config = require("@sanity/browserslist-config"), ts = require("typescript"), zodValidationError = require("zod-validation-error");
|
|
3
3
|
function _interopDefaultCompat(e) {
|
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
5
5
|
}
|
|
@@ -155,7 +155,9 @@ function validateExports(_exports, options) {
|
|
|
155
155
|
return errors;
|
|
156
156
|
}
|
|
157
157
|
function parseExports(options) {
|
|
158
|
-
const { pkg, strict, legacyExports } = options, type = pkg.type || "commonjs", errors = []
|
|
158
|
+
const { pkg, strict, strictOptions: strictOptions2, legacyExports, logger: logger$1 } = options, type = pkg.type || "commonjs", errors = [], report = (kind, message) => {
|
|
159
|
+
kind === "warn" ? logger$1.warn(message) : errors.push(message);
|
|
160
|
+
};
|
|
159
161
|
if (pkg.source) {
|
|
160
162
|
if (strict && pkg.exports?.["."] && typeof pkg.exports["."] == "object" && "source" in pkg.exports["."] && pkg.exports["."].source === pkg.source)
|
|
161
163
|
errors.push(
|
|
@@ -231,7 +233,7 @@ function parseExports(options) {
|
|
|
231
233
|
- `)
|
|
232
234
|
);
|
|
233
235
|
const _exports = [];
|
|
234
|
-
strict && "typings" in pkg &&
|
|
236
|
+
strict && strictOptions2.noPackageJsonTypings !== "off" && "typings" in pkg && report(strictOptions2.noPackageJsonTypings, "package.json: `typings` should be `types`"), strict && !pkg.types && pkg.source?.endsWith(".ts") && errors.push(
|
|
235
237
|
"package.json: `types` must be declared for the npm listing to show as a TypeScript module."
|
|
236
238
|
), strict && !pkg.exports["./package.json"] && errors.push('package.json: `exports["./package.json"] must be declared.');
|
|
237
239
|
for (const [exportPath, exportEntry] of Object.entries(pkg.exports))
|
|
@@ -341,6 +343,16 @@ function resolveNodeTarget(versions) {
|
|
|
341
343
|
if (target.length !== 0)
|
|
342
344
|
return target;
|
|
343
345
|
}
|
|
346
|
+
const toggle = zod.z.union([zod.z.literal("error"), zod.z.literal("warn"), zod.z.literal("off")]), strictOptions = zod.z.object({
|
|
347
|
+
noPackageJsonTypings: toggle.default("error"),
|
|
348
|
+
noImplicitSideEffects: toggle.default("warn"),
|
|
349
|
+
noImplicitBrowsersList: toggle.default("warn")
|
|
350
|
+
}).strict(), validationSchema = zod.z.object({
|
|
351
|
+
strictOptions: strictOptions.default({})
|
|
352
|
+
});
|
|
353
|
+
function parseStrictOptions(input) {
|
|
354
|
+
return validationSchema.parse({ strictOptions: input }, { errorMap: zodValidationError.errorMap }).strictOptions;
|
|
355
|
+
}
|
|
344
356
|
async function resolveBuildContext(options) {
|
|
345
357
|
const {
|
|
346
358
|
config: config2,
|
|
@@ -350,15 +362,27 @@ async function resolveBuildContext(options) {
|
|
|
350
362
|
pkg,
|
|
351
363
|
strict,
|
|
352
364
|
tsconfig: tsconfigPath
|
|
353
|
-
} = options, tsconfig = await loadTSConfig({ cwd, tsconfigPath });
|
|
365
|
+
} = options, tsconfig = await loadTSConfig({ cwd, tsconfigPath }), strictOptions2 = parseStrictOptions(config2?.strictOptions ?? {});
|
|
354
366
|
let browserslist2 = pkg.browserslist;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
367
|
+
if (!browserslist2) {
|
|
368
|
+
if (strict && strictOptions2.noImplicitBrowsersList !== "off") {
|
|
369
|
+
if (strictOptions2.noImplicitBrowsersList === "error")
|
|
370
|
+
throw new Error(
|
|
371
|
+
'\n- package.json: "browserslist" is missing, set it to `"browserslist": "extends @sanity/browserslist-config"`'
|
|
372
|
+
);
|
|
373
|
+
logger2.warn(
|
|
374
|
+
'Could not detect a `browserslist` property in `package.json`, using default configuration. Add `"browserslist": "extends @sanity/browserslist-config"` to silence this warning.'
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
browserslist2 = DEFAULT_BROWSERSLIST_QUERY;
|
|
378
|
+
}
|
|
358
379
|
const targetVersions = browserslistToEsbuild(browserslist2);
|
|
359
|
-
strict && typeof pkg.sideEffects > "u"
|
|
360
|
-
|
|
361
|
-
|
|
380
|
+
if (strict && strictOptions2.noImplicitSideEffects !== "off" && typeof pkg.sideEffects > "u") {
|
|
381
|
+
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`";
|
|
382
|
+
if (strictOptions2.noImplicitSideEffects === "error")
|
|
383
|
+
throw new Error(msg);
|
|
384
|
+
logger2.warn(msg);
|
|
385
|
+
}
|
|
362
386
|
const nodeTarget = resolveNodeTarget(targetVersions), webTarget = resolveBrowserTarget(targetVersions);
|
|
363
387
|
if (!nodeTarget)
|
|
364
388
|
throw new Error("no matching `node` target");
|
|
@@ -371,7 +395,9 @@ async function resolveBuildContext(options) {
|
|
|
371
395
|
}, parsedExports = parseExports({
|
|
372
396
|
pkg,
|
|
373
397
|
strict,
|
|
374
|
-
legacyExports: config2?.legacyExports ?? !1
|
|
398
|
+
legacyExports: config2?.legacyExports ?? !1,
|
|
399
|
+
strictOptions: strictOptions2,
|
|
400
|
+
logger: logger2
|
|
375
401
|
}).reduce((acc, x) => {
|
|
376
402
|
const { _path: exportPath, ...exportEntry } = x;
|
|
377
403
|
return { ...acc, [exportPath]: exportEntry };
|
|
@@ -443,4 +469,6 @@ exports.parseExports = parseExports;
|
|
|
443
469
|
exports.pkgExtMap = pkgExtMap;
|
|
444
470
|
exports.resolveBuildContext = resolveBuildContext;
|
|
445
471
|
exports.resolveConfigProperty = resolveConfigProperty;
|
|
472
|
+
exports.strictOptions = strictOptions;
|
|
473
|
+
exports.toggle = toggle;
|
|
446
474
|
//# sourceMappingURL=consoleSpy.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleSpy.cjs","sources":["../../src/node/core/config/findConfigFile.ts","../../src/node/core/config/loadConfig.ts","../../src/node/core/config/resolveConfigProperty.ts","../../src/node/core/defaults.ts","../../src/node/core/pkg/loadPkg.ts","../../src/node/core/pkg/helpers.ts","../../src/node/core/pkg/loadPkgWithReporting.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","../../node_modules/.pnpm/browserslist-to-esbuild@2.1.1_browserslist@4.23.0/node_modules/browserslist-to-esbuild/src/index.js","../../src/node/core/findCommonPath.ts","../../src/node/resolveBrowserTarget.ts","../../src/node/resolveNodeTarget.ts","../../src/node/resolveBuildContext.ts","../../src/node/consoleSpy.ts"],"sourcesContent":["import path from 'node:path'\n\nimport findConfig from 'find-config'\n\nimport {fileExists} from '../../fileExists'\n\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\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'\n\nimport {register} from 'esbuild-register/dist/node'\nimport pkgUp from 'pkg-up'\n\nimport {findConfigFile} from './findConfigFile'\nimport type {PkgConfigOptions} from './types'\n\n/** @internal */\nexport async function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined> {\n const {cwd} = options\n\n const pkgPath = await pkgUp({cwd})\n\n if (!pkgPath) return undefined\n\n const root = path.dirname(pkgPath)\n\n const configFile = await 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 esbuildOptions = {extensions: ['.js', '.mjs', '.ts']}\n\n const {unregister} = globalThis.__DEV__ ? {unregister: () => undefined} : register(esbuildOptions)\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(configFile)\n\n unregister()\n\n return mod?.default || mod || undefined\n}\n","import type {PkgConfigProperty, PkgConfigPropertyResolver} from './types'\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 (typeof prop === 'function') {\n return (prop as PkgConfigPropertyResolver<T>)(initialValue)\n }\n\n return prop\n}\n","import config from '@sanity/browserslist-config'\n\n/** @public */\nexport const DEFAULT_BROWSERSLIST_QUERY = config\n","import fs from 'node:fs/promises'\n\nimport pkgUp from 'pkg-up'\n\nimport type {PackageJSON} from './types'\nimport {validatePkg} from './validatePkg'\n\n/** @internal */\nexport async function loadPkg(options: {cwd: string}): Promise<PackageJSON> {\n const {cwd} = options\n\n const pkgPath = await pkgUp({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","/** @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 chalk from 'chalk'\nimport {ZodError} from 'zod'\n\nimport type {Logger} from '../../logger'\nimport {assertLast, assertOrder} from './helpers'\nimport {loadPkg} from './loadPkg'\nimport type {PackageJSON} from './types'\n\n/** @internal */\nexport async function loadPkgWithReporting(options: {\n cwd: string\n logger: Logger\n strict: boolean\n legacyExports: boolean\n}): Promise<PackageJSON> {\n const {cwd, logger, strict, legacyExports} = options\n\n try {\n const pkg = await loadPkg({cwd})\n let shouldError = false\n\n if (strict) {\n if (legacyExports && pkg.type === 'commonjs') {\n shouldError = true\n logger.error(\n `the \\`type\\` field in \\`./package.json\\` shouldn't be \"commonjs\" when \\`legacyExports\\` is set to true)`,\n )\n }\n\n if (!legacyExports && !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 type {PackageJSON, PkgBundle, PkgExport} from '../../core'\n\n/** @internal */\nexport const fileEnding = /\\.[mc]?js$/\n/** @internal */\nexport const dtsEnding = '.d.ts' as const\n/** @internal */\nexport const defaultEnding = '.js' as const\n/** @internal */\nexport const legacyEnding = `.esm${defaultEnding}` as const\n/** @internal */\nexport const mjsEnding = '.mjs' as const\n/** @internal */\nexport const cjsEnding = '.cjs' as const\nconst mtsEnding = '.d.mts' as const\nconst ctsEnding = '.d.cts' as const\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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isPkgExport(exp: any): exp is PkgExport {\n return exp?.browser || exp?.node || exp?.default\n}\n","import {cjsEnding, defaultEnding, legacyEnding, mjsEnding} from '../../tasks/dts/getTargetPaths'\n\n/** @internal */\nexport interface PkgExtMap {\n commonjs: {commonjs: string; esm: string}\n module: {commonjs: string; esm: string}\n legacy: string\n}\n\n/** @internal */\nexport const 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 // package.config.legacyExports: true\n legacy: legacyEnding,\n} satisfies PkgExtMap\n","import type {PkgExport} from '../config'\nimport {pkgExtMap as extMap} from './pkgExt'\nimport type {PackageJSON} from './types'\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 // @TODO validate that no exports declare the legacy exports\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 {defaultEnding, fileEnding, legacyEnding} from '../../tasks/dts/getTargetPaths'\nimport type {PkgExport} from '../config'\nimport {isRecord} from '../isRecord'\nimport {pkgExtMap} from './pkgExt'\nimport type {PackageJSON} from './types'\nimport {validateExports} from './validateExports'\n\n/** @internal */\nexport function parseExports(options: {\n pkg: PackageJSON\n strict: boolean\n legacyExports: boolean\n}): (PkgExport & {_path: string})[] {\n const {pkg, strict, legacyExports} = options\n const type = pkg.type || 'commonjs'\n const errors: string[] = []\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 } else if (legacyExports) {\n const browserImport = pkg.main.replace(fileEnding, `.browser${extMap.esm}`)\n\n browserConditions.push(` \"import\": ${JSON.stringify(browserImport)}`)\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 } else if (legacyExports) {\n const browserRequire = pkg.main.replace(fileEnding, `.browser${extMap.commonjs}`)\n\n browserConditions.push(` \"require\": ${JSON.stringify(browserRequire)}`)\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 // If legacy exports are enabled we suggest the full list of exports, if not we can use the terse version\n (legacyExports || type === 'commonjs') &&\n ` \"import\": ${JSON.stringify(importExport)},`,\n (legacyExports || type === 'module') &&\n ` \"require\": ${JSON.stringify(requireExport)},`,\n ` \"default\": ${JSON.stringify(defaultExport)}`,\n ` },`,\n ` \"./package.json\": \"./package.json\"`,\n `}`,\n ].filter(Boolean) as string[]),\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 /*\n const rootExports: PkgExport & {_path: string} = {\n _exported: true,\n _path: '.',\n source: pkg.source || '',\n browser: pkg.browser && {\n source: pkg.source || '',\n require: pkg.main && pkg.browser[pkg.main],\n import: pkg.module && pkg.browser[pkg.module],\n },\n require: legacyExports\n ? pkg.main\n : typeof pkg.exports?.['.'] === 'object' && 'require' in pkg.exports['.']\n ? pkg.exports['.'].require\n : '',\n import: legacyExports\n ? pkg.module\n : typeof pkg.exports?.['.'] === 'object' && 'import' in pkg.exports['.']\n ? pkg.exports['.'].import\n : '',\n default: legacyExports\n ? pkg.module || pkg.main || ''\n : typeof pkg.exports?.['.'] === 'object' && 'default' in pkg.exports['.']\n ? pkg.exports['.'].default || ''\n : pkg.module || pkg.main || '',\n }\n // */\n\n const _exports: (PkgExport & {_path: string})[] = []\n\n // @TODO validate typesVersions when legacyExports is true\n\n if (strict && 'typings' in pkg) {\n errors.push('package.json: `typings` should be `types`')\n }\n\n if (strict && !pkg.types && pkg.source?.endsWith('.ts')) {\n errors.push(\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 (exportPath.endsWith('.json')) {\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 (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 (isRecord(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 if (legacyExports) {\n if (fallback) {\n errors.push(\n `package.json - \\`exports[\"${exp._path}\"].default\\` should be set to \"${fallback}\" when \"legacyExports\" is true`,\n )\n } else {\n errors.push(\n `package.json - \\`exports[\"${exp._path}\"].default\\` should be specified when \"legacyExports\" is true`,\n )\n }\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 (legacyExports) {\n const indexLegacyExport = (exportEntry.import || exportEntry.require || '').replace(\n /(\\.esm)?\\.[mc]?js$/,\n legacyEnding,\n )\n\n if (indexLegacyExport !== pkg.module) {\n errors.push(\n `package.json: \"module\" should be \"${indexLegacyExport}\" when \"legacyExports\" is true`,\n )\n }\n } else {\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\n _exports.push(exp)\n } else {\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","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, ts.sys.fileExists, tsconfigPath)\n\n if (!configPath) {\n return undefined\n }\n\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile)\n\n return ts.parseJsonConfigFileContent(configFile.config, ts.sys, cwd)\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 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","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 path from 'node:path'\n\nimport browserslistToEsbuild from 'browserslist-to-esbuild'\n\nimport {\n type BuildContext,\n DEFAULT_BROWSERSLIST_QUERY,\n loadTSConfig,\n type PackageJSON,\n parseExports,\n type PkgConfigOptions,\n type PkgExports,\n type PkgRuntime,\n resolveConfigProperty,\n} from './core'\nimport {findCommonDirPath, pathContains} from './core/findCommonPath'\nimport type {Logger} from './logger'\nimport {resolveBrowserTarget} from './resolveBrowserTarget'\nimport {resolveNodeTarget} from './resolveNodeTarget'\n\nexport async function resolveBuildContext(options: {\n config?: PkgConfigOptions\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\n /* eslint-disable padding-line-between-statements */\n let browserslist = pkg.browserslist\n if (!browserslist) {\n if (strict) {\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 browserslist = DEFAULT_BROWSERSLIST_QUERY\n }\n const targetVersions = browserslistToEsbuild(browserslist)\n /* eslint-enable padding-line-between-statements */\n\n if (strict && typeof pkg.sideEffects === 'undefined') {\n logger.error(\n 'No `sideEffects` field in `package.json`, assuming all files are side-effectful. Add `\"sideEffects\": true` to silence this warning. See https://webpack.js.org/guides/tree-shaking/#clarifying-tree-shaking-and-sideeffects for how to define `sideEffects`.',\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 pkg,\n strict,\n legacyExports: config?.legacyExports ?? false,\n }).reduce<PkgExports>((acc, x) => {\n const {_path: exportPath, ...exportEntry} = x\n\n return {...acc, [exportPath]: exportEntry}\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\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(Boolean) as string[]\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 files: [],\n logger,\n pkg,\n runtime: config?.runtime ?? '*',\n strict,\n target,\n ts: {\n config: tsconfig,\n configPath: tsconfigPath,\n },\n }\n\n return ctx\n}\n","/* eslint-disable no-console */\n\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":["findConfig","path","fileExists","pkgUp","register","config","fs","validatePkg","logger","ZodError","chalk","extMap","isRecord","ts","browserslist","exports"],"mappings":";;;;;;AAMA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,eAAe,KAAiC;AAC9D,QAAM,cAAcA,oBAAA,QAAW,gBAAgB,EAAC,IAAI,CAAA;AAEpD,MAAI,CAAC;AAAa;AAEZ,QAAA,UAAUC,cAAAA,QAAK,QAAQ,WAAW;AAExC,aAAW,YAAY,mBAAmB;AACxC,UAAM,aAAaA,cAAA,QAAK,QAAQ,SAAS,QAAQ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Aa,gBAAgB,cAAc;AAErC,UAAAG,QAAA,IAAI,wCAAwCP,cAAAA,QAAK,SAAS,KAAK,cAAc,CAAC,MAAM,GAErF,IAAI,MAAM,kEAAkE;AAGpF,QAAM,WAAW,kBAAkB;AAEnC,MAAI,CAAC;AACG,UAAA,IAAI,MAAM,8BAA8B;AAGtB,SAAA;AAAA,IACxB,QAAAI;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAAU;AAAA,IACA;AAAA,IACA,OAAO,CAAC;AAAA,IACR,QAAAP;AAAA,IACA;AAAA,IACA,SAASH,SAAQ,WAAW;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,IAAI;AAAA,MACF,QAAQ;AAAA,MACR,YAAY;AAAA,IACd;AAAA,EAAA;AAIJ;ACtJO,SAAS,iBAAiB,SAElB;AACb,QAAM,EAAC,WAAU,IAAI,WAAW,CAAA,GAE1B,WAAW;AAAA,IACf,KAAK,QAAQ;AAAA,IACb,MAAM,QAAQ;AAAA,IACd,OAAO,QAAQ;AAAA,EAAA,GAGX,WAA4B,CAAA;AAElC,SAAA,QAAQ,MAAM,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,OAAO,KAAA,CAAK,GACvE,QAAQ,OAAO,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,QAAQ,KAAA,CAAK,GACzE,QAAQ,QAAQ,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,SAAS,KAAA,CAAK,GAEpE;AAAA,IACL;AAAA,IACA,SAAS,MAAM;AACb,cAAQ,MAAM,SAAS,KACvB,QAAQ,OAAO,SAAS,MACxB,QAAQ,QAAQ,SAAS,OAEzB,aAAa,QAAQ;AAAA,IACvB;AAAA,EAAA;AAEJ;;;;;;;;;;;;;;","x_google_ignoreList":[12]}
|
|
1
|
+
{"version":3,"file":"consoleSpy.cjs","sources":["../../src/node/core/config/findConfigFile.ts","../../src/node/core/config/loadConfig.ts","../../src/node/core/config/resolveConfigProperty.ts","../../src/node/core/defaults.ts","../../src/node/core/pkg/loadPkg.ts","../../src/node/core/pkg/helpers.ts","../../src/node/core/pkg/loadPkgWithReporting.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","../../node_modules/.pnpm/browserslist-to-esbuild@2.1.1_browserslist@4.23.0/node_modules/browserslist-to-esbuild/src/index.js","../../src/node/core/findCommonPath.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'\n\nimport findConfig from 'find-config'\n\nimport {fileExists} from '../../fileExists'\n\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\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'\n\nimport {register} from 'esbuild-register/dist/node'\nimport pkgUp from 'pkg-up'\n\nimport {findConfigFile} from './findConfigFile'\nimport type {PkgConfigOptions} from './types'\n\n/** @internal */\nexport async function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined> {\n const {cwd} = options\n\n const pkgPath = await pkgUp({cwd})\n\n if (!pkgPath) return undefined\n\n const root = path.dirname(pkgPath)\n\n const configFile = await 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 esbuildOptions = {extensions: ['.js', '.mjs', '.ts']}\n\n const {unregister} = globalThis.__DEV__ ? {unregister: () => undefined} : register(esbuildOptions)\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(configFile)\n\n unregister()\n\n return mod?.default || mod || undefined\n}\n","import type {PkgConfigProperty, PkgConfigPropertyResolver} from './types'\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 (typeof prop === 'function') {\n return (prop as PkgConfigPropertyResolver<T>)(initialValue)\n }\n\n return prop\n}\n","import config from '@sanity/browserslist-config'\n\n/** @public */\nexport const DEFAULT_BROWSERSLIST_QUERY = config\n","import fs from 'node:fs/promises'\n\nimport pkgUp from 'pkg-up'\n\nimport type {PackageJSON} from './types'\nimport {validatePkg} from './validatePkg'\n\n/** @internal */\nexport async function loadPkg(options: {cwd: string}): Promise<PackageJSON> {\n const {cwd} = options\n\n const pkgPath = await pkgUp({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","/** @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 chalk from 'chalk'\nimport {ZodError} from 'zod'\n\nimport type {Logger} from '../../logger'\nimport {assertLast, assertOrder} from './helpers'\nimport {loadPkg} from './loadPkg'\nimport type {PackageJSON} from './types'\n\n/** @internal */\nexport async function loadPkgWithReporting(options: {\n cwd: string\n logger: Logger\n strict: boolean\n legacyExports: boolean\n}): Promise<PackageJSON> {\n const {cwd, logger, strict, legacyExports} = options\n\n try {\n const pkg = await loadPkg({cwd})\n let shouldError = false\n\n if (strict) {\n if (legacyExports && pkg.type === 'commonjs') {\n shouldError = true\n logger.error(\n `the \\`type\\` field in \\`./package.json\\` shouldn't be \"commonjs\" when \\`legacyExports\\` is set to true)`,\n )\n }\n\n if (!legacyExports && !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 type {PackageJSON, PkgBundle, PkgExport} from '../../core'\n\n/** @internal */\nexport const fileEnding = /\\.[mc]?js$/\n/** @internal */\nexport const dtsEnding = '.d.ts' as const\n/** @internal */\nexport const defaultEnding = '.js' as const\n/** @internal */\nexport const legacyEnding = `.esm${defaultEnding}` as const\n/** @internal */\nexport const mjsEnding = '.mjs' as const\n/** @internal */\nexport const cjsEnding = '.cjs' as const\nconst mtsEnding = '.d.mts' as const\nconst ctsEnding = '.d.cts' as const\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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isPkgExport(exp: any): exp is PkgExport {\n return exp?.browser || exp?.node || exp?.default\n}\n","import {cjsEnding, defaultEnding, legacyEnding, mjsEnding} from '../../tasks/dts/getTargetPaths'\n\n/** @internal */\nexport interface PkgExtMap {\n commonjs: {commonjs: string; esm: string}\n module: {commonjs: string; esm: string}\n legacy: string\n}\n\n/** @internal */\nexport const 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 // package.config.legacyExports: true\n legacy: legacyEnding,\n} satisfies PkgExtMap\n","import type {PkgExport} from '../config'\nimport {pkgExtMap as extMap} from './pkgExt'\nimport type {PackageJSON} from './types'\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 // @TODO validate that no exports declare the legacy exports\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 type {Logger} from '../../logger'\nimport type {InferredStrictOptions} from '../../strict'\nimport {defaultEnding, fileEnding, legacyEnding} from '../../tasks/dts/getTargetPaths'\nimport type {PkgExport} from '../config'\nimport {isRecord} from '../isRecord'\nimport {pkgExtMap} from './pkgExt'\nimport type {PackageJSON} from './types'\nimport {validateExports} from './validateExports'\n\n/** @internal */\nexport function parseExports(options: {\n pkg: PackageJSON\n strict: boolean\n strictOptions: InferredStrictOptions\n legacyExports: boolean\n logger: Logger\n}): (PkgExport & {_path: string})[] {\n const {pkg, strict, strictOptions, legacyExports, 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.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 } else if (legacyExports) {\n const browserImport = pkg.main.replace(fileEnding, `.browser${extMap.esm}`)\n\n browserConditions.push(` \"import\": ${JSON.stringify(browserImport)}`)\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 } else if (legacyExports) {\n const browserRequire = pkg.main.replace(fileEnding, `.browser${extMap.commonjs}`)\n\n browserConditions.push(` \"require\": ${JSON.stringify(browserRequire)}`)\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 // If legacy exports are enabled we suggest the full list of exports, if not we can use the terse version\n (legacyExports || type === 'commonjs') &&\n ` \"import\": ${JSON.stringify(importExport)},`,\n (legacyExports || type === 'module') &&\n ` \"require\": ${JSON.stringify(requireExport)},`,\n ` \"default\": ${JSON.stringify(defaultExport)}`,\n ` },`,\n ` \"./package.json\": \"./package.json\"`,\n `}`,\n ].filter(Boolean) as string[]),\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 /*\n const rootExports: PkgExport & {_path: string} = {\n _exported: true,\n _path: '.',\n source: pkg.source || '',\n browser: pkg.browser && {\n source: pkg.source || '',\n require: pkg.main && pkg.browser[pkg.main],\n import: pkg.module && pkg.browser[pkg.module],\n },\n require: legacyExports\n ? pkg.main\n : typeof pkg.exports?.['.'] === 'object' && 'require' in pkg.exports['.']\n ? pkg.exports['.'].require\n : '',\n import: legacyExports\n ? pkg.module\n : typeof pkg.exports?.['.'] === 'object' && 'import' in pkg.exports['.']\n ? pkg.exports['.'].import\n : '',\n default: legacyExports\n ? pkg.module || pkg.main || ''\n : typeof pkg.exports?.['.'] === 'object' && 'default' in pkg.exports['.']\n ? pkg.exports['.'].default || ''\n : pkg.module || pkg.main || '',\n }\n // */\n\n const _exports: (PkgExport & {_path: string})[] = []\n\n // @TODO validate typesVersions when legacyExports is true\n\n if (strict && strictOptions.noPackageJsonTypings !== 'off' && 'typings' in pkg) {\n report(strictOptions.noPackageJsonTypings, 'package.json: `typings` should be `types`')\n }\n\n if (strict && !pkg.types && pkg.source?.endsWith('.ts')) {\n errors.push(\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 (exportPath.endsWith('.json')) {\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 (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 (isRecord(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 if (legacyExports) {\n if (fallback) {\n errors.push(\n `package.json - \\`exports[\"${exp._path}\"].default\\` should be set to \"${fallback}\" when \"legacyExports\" is true`,\n )\n } else {\n errors.push(\n `package.json - \\`exports[\"${exp._path}\"].default\\` should be specified when \"legacyExports\" is true`,\n )\n }\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 (legacyExports) {\n const indexLegacyExport = (exportEntry.import || exportEntry.require || '').replace(\n /(\\.esm)?\\.[mc]?js$/,\n legacyEnding,\n )\n\n if (indexLegacyExport !== pkg.module) {\n errors.push(\n `package.json: \"module\" should be \"${indexLegacyExport}\" when \"legacyExports\" is true`,\n )\n }\n } else {\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\n _exports.push(exp)\n } else {\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","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, ts.sys.fileExists, tsconfigPath)\n\n if (!configPath) {\n return undefined\n }\n\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile)\n\n return ts.parseJsonConfigFileContent(configFile.config, ts.sys, cwd)\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 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","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 {z} from 'zod'\nimport {errorMap} from 'zod-validation-error'\n\n/**\n * @public\n */\nexport const toggle = z.union([z.literal('error'), z.literal('warn'), z.literal('off')])\n\n/**\n * @public\n */\nexport type ToggleType = z.infer<typeof toggle>\n\n/**\n * @public\n */\nexport const strictOptions = z\n .object({\n noPackageJsonTypings: toggle.default('error'),\n noImplicitSideEffects: toggle.default('warn'),\n noImplicitBrowsersList: 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 type InferredStrictOptions = z.infer<typeof strictOptions>\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\n/** @internal */\nexport function parseStrictOptions(input: unknown): InferredStrictOptions {\n return validationSchema.parse({strictOptions: input}, {errorMap}).strictOptions\n}\n","import path from 'node:path'\n\nimport browserslistToEsbuild from 'browserslist-to-esbuild'\n\nimport {\n type BuildContext,\n DEFAULT_BROWSERSLIST_QUERY,\n loadTSConfig,\n type PackageJSON,\n parseExports,\n type PkgConfigOptions,\n type PkgExports,\n type PkgRuntime,\n resolveConfigProperty,\n} from './core'\nimport {findCommonDirPath, pathContains} from './core/findCommonPath'\nimport type {Logger} from './logger'\nimport {resolveBrowserTarget} from './resolveBrowserTarget'\nimport {resolveNodeTarget} from './resolveNodeTarget'\nimport {parseStrictOptions} from './strict'\n\nexport async function resolveBuildContext(options: {\n config?: PkgConfigOptions\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 /* eslint-disable padding-line-between-statements */\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 /* eslint-enable padding-line-between-statements */\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 pkg,\n strict,\n legacyExports: config?.legacyExports ?? false,\n strictOptions,\n logger,\n }).reduce<PkgExports>((acc, x) => {\n const {_path: exportPath, ...exportEntry} = x\n\n return {...acc, [exportPath]: exportEntry}\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\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(Boolean) as string[]\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 files: [],\n logger,\n pkg,\n runtime: config?.runtime ?? '*',\n strict,\n target,\n ts: {\n config: tsconfig,\n configPath: tsconfigPath,\n },\n }\n\n return ctx\n}\n","/* eslint-disable no-console */\n\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":["findConfig","path","fileExists","pkgUp","register","config","fs","validatePkg","logger","ZodError","chalk","extMap","strictOptions","isRecord","ts","browserslist","z","errorMap","exports"],"mappings":";;;;;;AAMA,MAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,eAAe,KAAiC;AAC9D,QAAM,cAAcA,oBAAA,QAAW,gBAAgB,EAAC,IAAI,CAAA;AAEpD,MAAI,CAAC;AAAa;AAEZ,QAAA,UAAUC,cAAAA,QAAK,QAAQ,WAAW;AAExC,aAAW,YAAY,mBAAmB;AACxC,UAAM,aAAaA,cAAA,QAAK,QAAQ,SAAS,QAAQ;AAIjD,QAFeC,OAAAA,WAAW,UAAU;AAG3B,aAAA;AAAA,EAEX;AAGF;ACvBA,eAAsB,WAAW,SAA+D;AACxF,QAAA,EAAC,IAAO,IAAA,SAER,UAAU,MAAMC,uBAAM,EAAC,IAAA,CAAI;AAEjC,MAAI,CAAC;AAAS;AAER,QAAA,OAAOF,sBAAK,QAAQ,OAAO,GAE3B,aAAa,MAAM,eAAe,IAAI;AAO5C,MALI,CAAC,cAKD,CAAC,WAAW,WAAW,GAAG;AAC5B;AAGF,QAAM,iBAAiB,EAAC,YAAY,CAAC,OAAO,QAAQ,KAAK,KAEnD,EAAC,eAAc,WAAW,UAAU,EAAC,YAAY,MAAG;AAAA,EAAA,MAAgBG,KAAS,SAAA,cAAc,GAG3F,MAAM,QAAQ,UAAU;AAEnB,SAAA,WAAA,GA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AK,EAAC,MAAM,OAAO,KAAA,CAAK,GACvE,QAAQ,OAAO,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,QAAQ,KAAA,CAAK,GACzE,QAAQ,QAAQ,IAAI,SAAoB,SAAS,KAAK,EAAC,MAAM,SAAS,KAAA,CAAK,GAEpE;AAAA,IACL;AAAA,IACA,SAAS,MAAM;AACb,cAAQ,MAAM,SAAS,KACvB,QAAQ,OAAO,SAAS,MACxB,QAAQ,QAAQ,SAAS,OAEzB,aAAa,QAAQ;AAAA,IACvB;AAAA,EAAA;AAEJ;;;;;;;;;;;;;;;;","x_google_ignoreList":[12]}
|
package/dist/cli.cjs
CHANGED
|
@@ -3,7 +3,7 @@ var cac = require("cac");
|
|
|
3
3
|
function _interopDefaultCompat(e) {
|
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
5
5
|
}
|
|
6
|
-
var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "6.
|
|
6
|
+
var cac__default = /* @__PURE__ */ _interopDefaultCompat(cac), version = "6.5.0";
|
|
7
7
|
const cli = cac__default.default();
|
|
8
8
|
cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
|
|
9
9
|
const { checkAction } = await Promise.resolve().then(function() {
|
package/dist/index.cjs
CHANGED
|
@@ -15,6 +15,8 @@ exports.loadTSConfig = consoleSpy.loadTSConfig;
|
|
|
15
15
|
exports.parseExports = consoleSpy.parseExports;
|
|
16
16
|
exports.pkgExtMap = consoleSpy.pkgExtMap;
|
|
17
17
|
exports.resolveConfigProperty = consoleSpy.resolveConfigProperty;
|
|
18
|
+
exports.strictOptions = consoleSpy.strictOptions;
|
|
19
|
+
exports.toggle = consoleSpy.toggle;
|
|
18
20
|
exports.createLogger = logger.createLogger;
|
|
19
21
|
exports.isRecord = logger.isRecord;
|
|
20
22
|
exports.createFromTemplate = init.createFromTemplate;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/node/core/config/defineConfig.ts"],"sourcesContent":["import type {PkgConfigOptions} from './types'\n\n/** @public */\nexport function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T {\n return configOptions\n}\n"],"names":[],"mappings":";;;AAGO,SAAS,aAA+C,eAAqB;AAC3E,SAAA;AACT
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/node/core/config/defineConfig.ts"],"sourcesContent":["import type {PkgConfigOptions} from './types'\n\n/** @public */\nexport function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T {\n return configOptions\n}\n"],"names":[],"mappings":";;;AAGO,SAAS,aAA+C,eAAqB;AAC3E,SAAA;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,7 @@ import type {Plugin as RollupPlugin} from 'rollup'
|
|
|
8
8
|
import {RollupWatcherEvent} from 'rollup'
|
|
9
9
|
import type {TreeshakingOptions} from 'rollup'
|
|
10
10
|
import ts from 'typescript'
|
|
11
|
+
import {z} from 'zod'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Build the distribution files of a npm package.
|
|
@@ -145,6 +146,11 @@ export declare function getExtractMessagesConfig(options: {
|
|
|
145
146
|
rules: NonNullable<PkgConfigOptions['extract']>['rules']
|
|
146
147
|
}): IExtractorMessagesConfig
|
|
147
148
|
|
|
149
|
+
/**
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
export declare type InferredStrictOptions = z.infer<typeof strictOptions>
|
|
153
|
+
|
|
148
154
|
/** @public */
|
|
149
155
|
export declare function init(options: {cwd: string; path: string}): Promise<void>
|
|
150
156
|
|
|
@@ -260,7 +266,9 @@ export declare interface PackageJSON {
|
|
|
260
266
|
export declare function parseExports(options: {
|
|
261
267
|
pkg: PackageJSON
|
|
262
268
|
strict: boolean
|
|
269
|
+
strictOptions: InferredStrictOptions
|
|
263
270
|
legacyExports: boolean
|
|
271
|
+
logger: Logger
|
|
264
272
|
}): (PkgExport & {
|
|
265
273
|
_path: string
|
|
266
274
|
})[]
|
|
@@ -365,6 +373,10 @@ export declare interface PkgConfigOptions {
|
|
|
365
373
|
*/
|
|
366
374
|
src?: string
|
|
367
375
|
tsconfig?: string
|
|
376
|
+
/**
|
|
377
|
+
* Configure what checks are made when running `--strict` builds and checks
|
|
378
|
+
*/
|
|
379
|
+
strictOptions?: StrictOptions
|
|
368
380
|
}
|
|
369
381
|
|
|
370
382
|
/** @public */
|
|
@@ -535,6 +547,60 @@ export declare interface RollupWatchTask {
|
|
|
535
547
|
/** @internal */
|
|
536
548
|
export declare const rollupWatchTask: TaskHandler<RollupWatchTask, RollupWatcherEvent>
|
|
537
549
|
|
|
550
|
+
/**
|
|
551
|
+
* @public
|
|
552
|
+
*/
|
|
553
|
+
export declare interface StrictOptions {
|
|
554
|
+
/**
|
|
555
|
+
* Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.
|
|
556
|
+
* @defaultValue 'error'
|
|
557
|
+
*/
|
|
558
|
+
noPackageJsonTypings?: ToggleType
|
|
559
|
+
/**
|
|
560
|
+
* Requires specifying `sideEffects` in `package.json`.
|
|
561
|
+
* @defaultValue 'warn'
|
|
562
|
+
*/
|
|
563
|
+
noImplicitSideEffects?: ToggleType
|
|
564
|
+
/**
|
|
565
|
+
* Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:
|
|
566
|
+
* @example
|
|
567
|
+
* ```
|
|
568
|
+
* "browserslist": "extends @sanity/browserslist-config"
|
|
569
|
+
* ```
|
|
570
|
+
* @defaultValue 'warn'
|
|
571
|
+
*/
|
|
572
|
+
noImplicitBrowsersList?: ToggleType
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* @public
|
|
577
|
+
*/
|
|
578
|
+
export declare const strictOptions: z.ZodObject<
|
|
579
|
+
{
|
|
580
|
+
noPackageJsonTypings: z.ZodDefault<
|
|
581
|
+
z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
|
|
582
|
+
>
|
|
583
|
+
noImplicitSideEffects: z.ZodDefault<
|
|
584
|
+
z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
|
|
585
|
+
>
|
|
586
|
+
noImplicitBrowsersList: z.ZodDefault<
|
|
587
|
+
z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
|
|
588
|
+
>
|
|
589
|
+
},
|
|
590
|
+
'strict',
|
|
591
|
+
z.ZodTypeAny,
|
|
592
|
+
{
|
|
593
|
+
noPackageJsonTypings: 'error' | 'warn' | 'off'
|
|
594
|
+
noImplicitSideEffects: 'error' | 'warn' | 'off'
|
|
595
|
+
noImplicitBrowsersList: 'error' | 'warn' | 'off'
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
noPackageJsonTypings?: 'error' | 'warn' | 'off' | undefined
|
|
599
|
+
noImplicitSideEffects?: 'error' | 'warn' | 'off' | undefined
|
|
600
|
+
noImplicitBrowsersList?: 'error' | 'warn' | 'off' | undefined
|
|
601
|
+
}
|
|
602
|
+
>
|
|
603
|
+
|
|
538
604
|
/** @internal */
|
|
539
605
|
export declare type TaskHandler<Task, Result = void> = {
|
|
540
606
|
name: (ctx: BuildContext, task: Task) => string
|
|
@@ -543,6 +609,18 @@ export declare type TaskHandler<Task, Result = void> = {
|
|
|
543
609
|
error: (ctx: BuildContext, task: Task, error: unknown) => void
|
|
544
610
|
}
|
|
545
611
|
|
|
612
|
+
/**
|
|
613
|
+
* @public
|
|
614
|
+
*/
|
|
615
|
+
export declare const toggle: z.ZodUnion<
|
|
616
|
+
[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]
|
|
617
|
+
>
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @public
|
|
621
|
+
*/
|
|
622
|
+
export declare type ToggleType = z.infer<typeof toggle>
|
|
623
|
+
|
|
546
624
|
/** @public */
|
|
547
625
|
export declare interface TSDocCustomTag {
|
|
548
626
|
name: string
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {Plugin as RollupPlugin} from 'rollup'
|
|
|
8
8
|
import {RollupWatcherEvent} from 'rollup'
|
|
9
9
|
import type {TreeshakingOptions} from 'rollup'
|
|
10
10
|
import ts from 'typescript'
|
|
11
|
+
import {z} from 'zod'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Build the distribution files of a npm package.
|
|
@@ -145,6 +146,11 @@ export declare function getExtractMessagesConfig(options: {
|
|
|
145
146
|
rules: NonNullable<PkgConfigOptions['extract']>['rules']
|
|
146
147
|
}): IExtractorMessagesConfig
|
|
147
148
|
|
|
149
|
+
/**
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
export declare type InferredStrictOptions = z.infer<typeof strictOptions>
|
|
153
|
+
|
|
148
154
|
/** @public */
|
|
149
155
|
export declare function init(options: {cwd: string; path: string}): Promise<void>
|
|
150
156
|
|
|
@@ -260,7 +266,9 @@ export declare interface PackageJSON {
|
|
|
260
266
|
export declare function parseExports(options: {
|
|
261
267
|
pkg: PackageJSON
|
|
262
268
|
strict: boolean
|
|
269
|
+
strictOptions: InferredStrictOptions
|
|
263
270
|
legacyExports: boolean
|
|
271
|
+
logger: Logger
|
|
264
272
|
}): (PkgExport & {
|
|
265
273
|
_path: string
|
|
266
274
|
})[]
|
|
@@ -365,6 +373,10 @@ export declare interface PkgConfigOptions {
|
|
|
365
373
|
*/
|
|
366
374
|
src?: string
|
|
367
375
|
tsconfig?: string
|
|
376
|
+
/**
|
|
377
|
+
* Configure what checks are made when running `--strict` builds and checks
|
|
378
|
+
*/
|
|
379
|
+
strictOptions?: StrictOptions
|
|
368
380
|
}
|
|
369
381
|
|
|
370
382
|
/** @public */
|
|
@@ -535,6 +547,60 @@ export declare interface RollupWatchTask {
|
|
|
535
547
|
/** @internal */
|
|
536
548
|
export declare const rollupWatchTask: TaskHandler<RollupWatchTask, RollupWatcherEvent>
|
|
537
549
|
|
|
550
|
+
/**
|
|
551
|
+
* @public
|
|
552
|
+
*/
|
|
553
|
+
export declare interface StrictOptions {
|
|
554
|
+
/**
|
|
555
|
+
* Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.
|
|
556
|
+
* @defaultValue 'error'
|
|
557
|
+
*/
|
|
558
|
+
noPackageJsonTypings?: ToggleType
|
|
559
|
+
/**
|
|
560
|
+
* Requires specifying `sideEffects` in `package.json`.
|
|
561
|
+
* @defaultValue 'warn'
|
|
562
|
+
*/
|
|
563
|
+
noImplicitSideEffects?: ToggleType
|
|
564
|
+
/**
|
|
565
|
+
* Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:
|
|
566
|
+
* @example
|
|
567
|
+
* ```
|
|
568
|
+
* "browserslist": "extends @sanity/browserslist-config"
|
|
569
|
+
* ```
|
|
570
|
+
* @defaultValue 'warn'
|
|
571
|
+
*/
|
|
572
|
+
noImplicitBrowsersList?: ToggleType
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* @public
|
|
577
|
+
*/
|
|
578
|
+
export declare const strictOptions: z.ZodObject<
|
|
579
|
+
{
|
|
580
|
+
noPackageJsonTypings: z.ZodDefault<
|
|
581
|
+
z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
|
|
582
|
+
>
|
|
583
|
+
noImplicitSideEffects: z.ZodDefault<
|
|
584
|
+
z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
|
|
585
|
+
>
|
|
586
|
+
noImplicitBrowsersList: z.ZodDefault<
|
|
587
|
+
z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
|
|
588
|
+
>
|
|
589
|
+
},
|
|
590
|
+
'strict',
|
|
591
|
+
z.ZodTypeAny,
|
|
592
|
+
{
|
|
593
|
+
noPackageJsonTypings: 'error' | 'warn' | 'off'
|
|
594
|
+
noImplicitSideEffects: 'error' | 'warn' | 'off'
|
|
595
|
+
noImplicitBrowsersList: 'error' | 'warn' | 'off'
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
noPackageJsonTypings?: 'error' | 'warn' | 'off' | undefined
|
|
599
|
+
noImplicitSideEffects?: 'error' | 'warn' | 'off' | undefined
|
|
600
|
+
noImplicitBrowsersList?: 'error' | 'warn' | 'off' | undefined
|
|
601
|
+
}
|
|
602
|
+
>
|
|
603
|
+
|
|
538
604
|
/** @internal */
|
|
539
605
|
export declare type TaskHandler<Task, Result = void> = {
|
|
540
606
|
name: (ctx: BuildContext, task: Task) => string
|
|
@@ -543,6 +609,18 @@ export declare type TaskHandler<Task, Result = void> = {
|
|
|
543
609
|
error: (ctx: BuildContext, task: Task, error: unknown) => void
|
|
544
610
|
}
|
|
545
611
|
|
|
612
|
+
/**
|
|
613
|
+
* @public
|
|
614
|
+
*/
|
|
615
|
+
export declare const toggle: z.ZodUnion<
|
|
616
|
+
[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]
|
|
617
|
+
>
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @public
|
|
621
|
+
*/
|
|
622
|
+
export declare type ToggleType = z.infer<typeof toggle>
|
|
623
|
+
|
|
546
624
|
/** @public */
|
|
547
625
|
export declare interface TSDocCustomTag {
|
|
548
626
|
name: string
|