@sanity/pkg-utils 6.9.3 → 6.9.4-canary.1
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/build.cjs +19 -2
- package/dist/_chunks-cjs/build.cjs.map +1 -1
- package/dist/_chunks-cjs/consoleSpy.cjs +8 -1
- package/dist/_chunks-cjs/consoleSpy.cjs.map +1 -1
- package/dist/_chunks-cjs/index.cjs +66 -12
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/_chunks-cjs/init.cjs.map +1 -1
- package/dist/_chunks-cjs/logger.cjs +10 -0
- package/dist/_chunks-cjs/logger.cjs.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +104 -16
- package/dist/index.d.ts +104 -16
- package/dist/index.js +103 -15
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/node/core/config/types.ts +104 -15
- package/src/node/core/pkg/validatePkg.ts +17 -7
- package/src/node/resolveBuildContext.ts +2 -0
- package/src/node/resolveBuildTasks.ts +47 -1
- package/src/node/tasks/dts/getTargetPaths.ts +11 -0
- package/src/node/tasks/index.ts +2 -1
- package/src/node/tasks/rollup/index.ts +1 -0
- package/src/node/tasks/rollup/resolveRollupConfig.ts +12 -18
- package/src/node/tasks/rollup/rollupReactCompilerTask.ts +140 -0
- package/src/node/tasks/types.ts +11 -1
|
@@ -10,7 +10,13 @@ function resolveBuildTasks(ctx) {
|
|
|
10
10
|
), dtsTask = {
|
|
11
11
|
type: "build:dts",
|
|
12
12
|
entries: []
|
|
13
|
-
}, rollupTasks = {}, rollupLegacyTasks = {}
|
|
13
|
+
}, rollupTasks = {}, rollupLegacyTasks = {}, rollupReactCompilerTask = {
|
|
14
|
+
type: "build:react-compiler",
|
|
15
|
+
runtime: "browser",
|
|
16
|
+
format: "esm",
|
|
17
|
+
entries: [],
|
|
18
|
+
target: target.browser
|
|
19
|
+
};
|
|
14
20
|
function addRollupTaskEntry(format, runtime, entry) {
|
|
15
21
|
const buildId = `${format}:${runtime}`;
|
|
16
22
|
rollupTasks[buildId] ? rollupTasks[buildId].entries.push(entry) : rollupTasks[buildId] = {
|
|
@@ -34,6 +40,9 @@ function resolveBuildTasks(ctx) {
|
|
|
34
40
|
target: target[runtime]
|
|
35
41
|
};
|
|
36
42
|
}
|
|
43
|
+
function addRollupReactCompilerTaskEntry(entry) {
|
|
44
|
+
rollupReactCompilerTask.entries.push(entry);
|
|
45
|
+
}
|
|
37
46
|
for (const exp of exports2) {
|
|
38
47
|
const importId = path__default.default.join(pkg.name, exp._path);
|
|
39
48
|
exp.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
@@ -96,7 +105,15 @@ function resolveBuildTasks(ctx) {
|
|
|
96
105
|
output
|
|
97
106
|
});
|
|
98
107
|
}
|
|
99
|
-
|
|
108
|
+
for (const exp of exports2) {
|
|
109
|
+
const output = exp["react-compiler"]?.default;
|
|
110
|
+
output && addRollupReactCompilerTaskEntry({
|
|
111
|
+
path: exp._path,
|
|
112
|
+
source: exp["react-compiler"]?.source || exp.source,
|
|
113
|
+
output
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (rollupReactCompilerTask.entries.length && tasks.push(rollupReactCompilerTask), config?.legacyExports)
|
|
100
117
|
for (const exp of exports2) {
|
|
101
118
|
const runtime = exp.browser?.import ? "browser" : ctx.runtime, output = exp.browser?.import || exp.import;
|
|
102
119
|
if (!output) continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.cjs","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/spinner.ts","../../src/node/build.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport type {BuildContext, PkgExport, PkgFormat, PkgRuntime} from './core'\nimport type {BuildTask, DtsTask, RollupLegacyTask, RollupTask, RollupTaskEntry} from './tasks'\nimport {fileEnding, getTargetPaths, legacyEnding} from './tasks/dts/getTargetPaths'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, cwd, 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 rollupTasks: Record<string, RollupTask> = {}\n const rollupLegacyTasks: Record<string, RollupLegacyTask> = {}\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: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n function addRollupLegacyTaskEntry(runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `esm:${runtime}`\n\n if (rollupLegacyTasks[buildId]) {\n rollupLegacyTasks[buildId].entries.push(entry)\n } else {\n rollupLegacyTasks[buildId] = {\n type: 'build:legacy',\n buildId,\n entries: [entry],\n runtime,\n format: 'esm',\n // @TODO set a different target here that is compatible with legacy bundlers and testing tools like brownfield jest\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 // 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 if (!ctx.emitDeclarationOnly) {\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 // Create rollup bundles that legacy export files will re-export\n if (config?.legacyExports) {\n for (const exp of exports) {\n const runtime = exp.browser?.import ? 'browser' : ctx.runtime\n const output = exp.browser?.import || exp.import\n\n if (!output) continue\n\n // Change the suffix to what the legacy exports will use\n const legacyOutput = output.replace(fileEnding, legacyEnding)\n\n addRollupLegacyTaskEntry(runtime, {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output: legacyOutput,\n })\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 tasks.push(...Object.values(rollupTasks), ...Object.values(rollupLegacyTasks))\n\n // Write legacy exports files\n if (config?.legacyExports) {\n for (const exp of exports) {\n if (exp._exported && exp._path !== '.') {\n const output = (exp.browser?.import || exp.import || '').replace(fileEnding, legacyEnding)\n const relativeTargetPath = output.replace(/\\.[^/.]+$/, '')\n\n if (relativeTargetPath) {\n fs.writeFileSync(\n path.resolve(cwd, `${exp._path}.js`),\n ['// AUTO-GENERATED – DO NOT EDIT', `export * from '${relativeTargetPath}'`, ''].join(\n '\\n',\n ),\n )\n }\n }\n }\n }\n }\n\n return tasks\n}\n","/* eslint-disable no-console */\n\nimport chalk from 'chalk'\n\nexport function createSpinner(msg: string): {complete: () => void; error: () => void} {\n const startTime = Date.now()\n\n console.log(msg)\n\n return {\n complete: () => {\n console.log(`${chalk.green('[success]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n error: () => {\n console.log(`${chalk.red('[error]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n }\n}\n","import path from 'node:path'\n\nimport rimraf from 'rimraf'\n\nimport {loadConfig, loadPkgWithReporting} from './core'\nimport {createLogger} from './logger'\nimport {resolveBuildContext} from './resolveBuildContext'\nimport {resolveBuildTasks} from './resolveBuildTasks'\nimport {createSpinner} from './spinner'\nimport {type BuildTask, buildTaskHandlers, type TaskHandler} from './tasks'\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}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n clean = false,\n } = options\n const logger = createLogger()\n\n const config = await loadConfig({cwd})\n\n const legacyExports = config?.legacyExports ?? false\n const pkg = await loadPkgWithReporting({cwd, logger, strict, legacyExports})\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 logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName)\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","path","getTargetPaths","fileEnding","legacyEnding","fs","chalk","logger","createLogger","loadConfig","loadPkgWithReporting","resolveBuildContext","rimraf","buildTaskHandlers"],"mappings":";;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAC1D,QAAA,EAAC,QAAQ,KAAK,KAAK,WAAU,KAE7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oCN,cAAAA,QAAK,SAAS,KAAK,IAAI,QAAQ,CAAC;AAAA,EAEtE,GAAA,MAAMW,gBAAO,QAAA,IAAI,QAAQ;AAGrB,QAAA,aAAa,kBAAkB,GAAG;AAExC,aAAW,QAAQ,YAAY;AAC7B,UAAM,UAAUC,MAAA,kBAAkB,KAAK,IAAI,GACrC,WAAW,QAAQ,KAAK,KAAK,IAAI,GAEjC,UAAU,cAAc,QAAQ;AAElC,QAAA;AACF,YAAM,SAAS,MAAM,QAAQ,KAAK,KAAK,IAAI,EAAE;AAErC,cAAA,SAAA,GACR,IAAI,OAAO,IAAA,GAEX,QAAQ,SAAS,KAAK,MAAM,MAAM;AAAA,aAC3B,KAAK;AAGZ,UAFA,QAAQ,SAEJ,eAAe,OAAO;AACxB,cAAM,SAAS,IAAI,OAAO,GAAG,GAAG,IAAI,GAAG;AAEnC,YAAA,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GACjD,IAAI,OAAO,IAAI;AAAA,MACjB;AAEA,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;;;"}
|
|
1
|
+
{"version":3,"file":"build.cjs","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/spinner.ts","../../src/node/build.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport type {BuildContext, PkgExport, PkgFormat, PkgRuntime} from './core'\nimport type {\n BuildTask,\n DtsTask,\n RollupLegacyTask,\n RollupReactCompilerTask,\n RollupTask,\n RollupTaskEntry,\n} from './tasks'\nimport {fileEnding, getTargetPaths, legacyEnding} from './tasks/dts/getTargetPaths'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, cwd, 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 rollupTasks: Record<string, RollupTask> = {}\n const rollupLegacyTasks: Record<string, RollupLegacyTask> = {}\n const rollupReactCompilerTask: RollupReactCompilerTask = {\n type: 'build:react-compiler',\n runtime: 'browser',\n format: 'esm',\n entries: [],\n target: target.browser,\n }\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: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n function addRollupLegacyTaskEntry(runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `esm:${runtime}`\n\n if (rollupLegacyTasks[buildId]) {\n rollupLegacyTasks[buildId].entries.push(entry)\n } else {\n rollupLegacyTasks[buildId] = {\n type: 'build:legacy',\n buildId,\n entries: [entry],\n runtime,\n format: 'esm',\n // @TODO set a different target here that is compatible with legacy bundlers and testing tools like brownfield jest\n target: target[runtime],\n }\n }\n }\n\n function addRollupReactCompilerTaskEntry(entry: RollupTaskEntry) {\n rollupReactCompilerTask.entries.push(entry)\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 // @TODO implement this\n // if (exp['react-compiler']?.source?.endsWith('.ts')) {\n // dtsTask.entries.push({\n // importId,\n // exportPath: exp._path,\n // sourcePath: exp['react-compiler'].source,\n // targetPaths: getTargetPaths(pkg.type, exp['react-compiler']),\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 if (!ctx.emitDeclarationOnly) {\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:react-compiler tasks\n for (const exp of exports) {\n const output = exp['react-compiler']?.default\n\n if (!output) continue\n\n addRollupReactCompilerTaskEntry({\n path: exp._path,\n source: exp['react-compiler']?.source || exp.source,\n output,\n })\n }\n\n // Add react-compiler task\n if (rollupReactCompilerTask.entries.length) {\n tasks.push(rollupReactCompilerTask)\n }\n\n // Create rollup bundles that legacy export files will re-export\n if (config?.legacyExports) {\n for (const exp of exports) {\n const runtime = exp.browser?.import ? 'browser' : ctx.runtime\n const output = exp.browser?.import || exp.import\n\n if (!output) continue\n\n // Change the suffix to what the legacy exports will use\n const legacyOutput = output.replace(fileEnding, legacyEnding)\n\n addRollupLegacyTaskEntry(runtime, {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output: legacyOutput,\n })\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 tasks.push(...Object.values(rollupTasks), ...Object.values(rollupLegacyTasks))\n\n // Write legacy exports files\n if (config?.legacyExports) {\n for (const exp of exports) {\n if (exp._exported && exp._path !== '.') {\n const output = (exp.browser?.import || exp.import || '').replace(fileEnding, legacyEnding)\n const relativeTargetPath = output.replace(/\\.[^/.]+$/, '')\n\n if (relativeTargetPath) {\n fs.writeFileSync(\n path.resolve(cwd, `${exp._path}.js`),\n ['// AUTO-GENERATED – DO NOT EDIT', `export * from '${relativeTargetPath}'`, ''].join(\n '\\n',\n ),\n )\n }\n }\n }\n }\n }\n\n return tasks\n}\n","/* eslint-disable no-console */\n\nimport chalk from 'chalk'\n\nexport function createSpinner(msg: string): {complete: () => void; error: () => void} {\n const startTime = Date.now()\n\n console.log(msg)\n\n return {\n complete: () => {\n console.log(`${chalk.green('[success]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n error: () => {\n console.log(`${chalk.red('[error]')} ${chalk.gray(`${Date.now() - startTime}ms`)}`)\n },\n }\n}\n","import path from 'node:path'\n\nimport rimraf from 'rimraf'\n\nimport {loadConfig, loadPkgWithReporting} from './core'\nimport {createLogger} from './logger'\nimport {resolveBuildContext} from './resolveBuildContext'\nimport {resolveBuildTasks} from './resolveBuildTasks'\nimport {createSpinner} from './spinner'\nimport {type BuildTask, buildTaskHandlers, type TaskHandler} from './tasks'\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}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n clean = false,\n } = options\n const logger = createLogger()\n\n const config = await loadConfig({cwd})\n\n const legacyExports = config?.legacyExports ?? false\n const pkg = await loadPkgWithReporting({cwd, logger, strict, legacyExports})\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 logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName)\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","path","getTargetPaths","fileEnding","legacyEnding","fs","chalk","logger","createLogger","loadConfig","loadPkgWithReporting","resolveBuildContext","rimraf","buildTaskHandlers"],"mappings":";;;;;;AAeO,SAAS,kBAAkB,KAAgC;AAC1D,QAAA,EAAC,QAAQ,KAAK,KAAK,WAAU,KAE7B,UAAU,QAAQ,WAAW,IAE7B,QAAqB,CAAA,GAErBA,WAAU,OAAO,QAAQ,IAAI,WAAW,CAAE,CAAA,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG;KAG1B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,KAGN,cAA0C,IAC1C,oBAAsD,CAAA,GACtD,0BAAmD;AAAA,IACvD,MAAM;AAAA,IACN,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS,CAAC;AAAA,IACV,QAAQ,OAAO;AAAA,EAAA;AAGR,WAAA,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;AAES,WAAA,yBAAyB,SAAqB,OAAwB;AACvE,UAAA,UAAU,OAAO,OAAO;AAE1B,sBAAkB,OAAO,IAC3B,kBAAkB,OAAO,EAAE,QAAQ,KAAK,KAAK,IAE7C,kBAAkB,OAAO,IAAI;AAAA,MAC3B,MAAM;AAAA,MACN;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GZ,UAFA,QAAQ,SAEJ,eAAe,OAAO;AACxB,cAAM,SAAS,IAAI,OAAO,GAAG,GAAG,IAAI,GAAG;AAEnC,YAAA,OAAO,MAAM,IAAI,QAAQ,QAAQ,QAAQ,GAAG,CAAC,GACjD,IAAI,OAAO,IAAI;AAAA,MACjB;AAEA,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;;;"}
|
|
@@ -122,7 +122,12 @@ function getTargetPaths(_type, expOrBundle) {
|
|
|
122
122
|
expOrBundle.node.import.replace(fileEnding, type === "module" ? dtsEnding : mtsEnding)
|
|
123
123
|
), expOrBundle.node?.require && set.add(
|
|
124
124
|
expOrBundle.node.require.replace(fileEnding, type === "commonjs" ? dtsEnding : ctsEnding)
|
|
125
|
-
))
|
|
125
|
+
)), expOrBundle["react-compiler"]?.source || expOrBundle["react-compiler"]?.default && set.add(
|
|
126
|
+
expOrBundle["react-compiler"].default.replace(
|
|
127
|
+
fileEnding,
|
|
128
|
+
type === "module" ? dtsEnding : mtsEnding
|
|
129
|
+
)
|
|
130
|
+
)), Array.from(set);
|
|
126
131
|
}
|
|
127
132
|
function isPkgExport$1(exp) {
|
|
128
133
|
return exp?.browser || exp?.node || exp?.default;
|
|
@@ -416,6 +421,8 @@ async function resolveBuildContext(options) {
|
|
|
416
421
|
exportEntry.browser?.require,
|
|
417
422
|
exportEntry.node?.source && exportEntry.node.import,
|
|
418
423
|
exportEntry.node?.source && exportEntry.node.require
|
|
424
|
+
// @TODO implement this
|
|
425
|
+
// exportEntry['react-compiler']?.source && exportEntry['react-compiler']?.default,
|
|
419
426
|
].filter(Boolean)).map((p) => path__default.default.resolve(cwd, p)), commonDistPath = findCommonDirPath(outputPaths);
|
|
420
427
|
if (commonDistPath === cwd)
|
|
421
428
|
throw new Error(
|
|
@@ -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.1/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.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 } 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 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 (\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 (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 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 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, 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 alwaysPackageJsonTypes: toggle.default('error'),\n alwaysPackageJsonMain: toggle.default('error'),\n alwaysPackageJsonFiles: toggle.default('error'),\n })\n .strict()\n\n/**\n * To make error message paths line up with the paths in package.config.ts the schema is hoisted into a root schema\n * This way errors will say `Expected boolean, received string at \"strict.noPackageJsonTypings\"` instead of `Expected boolean, received string at \"noPackageJsonTypings\"`.\n */\nconst validationSchema = z.object({\n strictOptions: strictOptions.default({}),\n})\n\n/**\n * @public\n */\nexport 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 * 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\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","isPkgExport","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,YAAa;AAEZ,QAAA,UAAUC,cAAAA,QAAK,QAAQ,WAAW;AAExC,aAAW,YAAY,mBAAmB;AACxC,UAAM,aAAaA,cAAA,QAAK,QAAQ,SAAS,QAAQ;AAIjD,QAFeC,OAAAA,WAAW,UAAU;AA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M,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.1/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 if (!expOrBundle['react-compiler']?.source) {\n if (expOrBundle['react-compiler']?.default) {\n set.add(\n expOrBundle['react-compiler'].default.replace(\n fileEnding,\n type === 'module' ? dtsEnding : mtsEnding,\n ),\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.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 } 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 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 (\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 (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 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 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, 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 alwaysPackageJsonTypes: toggle.default('error'),\n alwaysPackageJsonMain: toggle.default('error'),\n alwaysPackageJsonFiles: toggle.default('error'),\n })\n .strict()\n\n/**\n * To make error message paths line up with the paths in package.config.ts the schema is hoisted into a root schema\n * This way errors will say `Expected boolean, received string at \"strict.noPackageJsonTypings\"` instead of `Expected boolean, received string at \"noPackageJsonTypings\"`.\n */\nconst validationSchema = z.object({\n strictOptions: strictOptions.default({}),\n})\n\n/**\n * @public\n */\nexport 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 * 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\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 // @TODO implement this\n // exportEntry['react-compiler']?.source && exportEntry['react-compiler']?.default,\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","isPkgExport","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,YAAa;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,QAAS;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,GAEJ,KAAK,WAAW,OAAO;AAChC;ACpCgB,SAAA,sBACd,MACA,cACG;AACH,SAAK,OAED,OAAO,QAAS,aACV,KAAsC,YAAY,IAGrD,OANW;AAOpB;ACXO,MAAM,6BAA6BC,gBAAAA;ACK1C,eAAsB,QAAQ,SAA8C;AACpE,QAAA,EAAC,IAAO,IAAA,SAER,UAAU,MAAMF,uBAAM,EAAC,IAAA,CAAI;AAEjC,MAAI,C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A;AAAA,IACxB,QAAAI;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAAc;AAAA,IACA;AAAA,IACA,OAAO,CAAC;AAAA,IACR,QAAAX;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;AC5KO,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]}
|
|
@@ -389,7 +389,7 @@ const dtsTask = {
|
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
function resolveRollupConfig(ctx, buildTask) {
|
|
392
|
-
const { format, runtime, target } = buildTask, { config, cwd, exports: _exports, external, distPath, logger, pkg, ts: ts2 } = ctx, isLegacyExports = buildTask.type === "build:legacy", outputExt = isLegacyExports ? consoleSpy.pkgExtMap.legacy : consoleSpy.pkgExtMap[pkg.type || "commonjs"][format], minify = config?.minify ?? !1, outDir = path__default.default.relative(cwd, distPath), pathAliases = Object.fromEntries(
|
|
392
|
+
const { format, runtime, target } = buildTask, { config, cwd, exports: _exports, external, distPath, logger, pkg, ts: ts2 } = ctx, isLegacyExports = buildTask.type === "build:legacy", isReactCompiler = buildTask.type === "build:react-compiler", outputExt = isLegacyExports ? consoleSpy.pkgExtMap.legacy : consoleSpy.pkgExtMap[pkg.type || "commonjs"][format], minify = config?.minify ?? !1, outDir = path__default.default.relative(cwd, distPath), pathAliases = Object.fromEntries(
|
|
393
393
|
Object.entries(ts2.config?.options.paths || {}).map(([key, val]) => [key, path__default.default.resolve(cwd, ts2.config?.options.baseUrl || ".", val[0])])
|
|
394
394
|
), entries = buildTask.entries.map((entry) => ({
|
|
395
395
|
...entry,
|
|
@@ -424,19 +424,12 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
424
424
|
}),
|
|
425
425
|
commonjs__default.default(),
|
|
426
426
|
json__default.default(),
|
|
427
|
-
config?.babel?.reactCompiler && pluginBabel.babel({
|
|
427
|
+
(isReactCompiler || config?.babel?.reactCompiler) && pluginBabel.babel({
|
|
428
428
|
babelrc: !1,
|
|
429
429
|
presets: ["@babel/preset-typescript"],
|
|
430
430
|
babelHelpers: "bundled",
|
|
431
431
|
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
432
|
-
plugins: [
|
|
433
|
-
[
|
|
434
|
-
"babel-plugin-react-compiler",
|
|
435
|
-
{
|
|
436
|
-
...typeof config?.babel?.reactCompiler == "object" ? config?.babel?.reactCompiler : {}
|
|
437
|
-
}
|
|
438
|
-
]
|
|
439
|
-
]
|
|
432
|
+
plugins: [["babel-plugin-react-compiler", config?.reactCompilerOptions || {}]]
|
|
440
433
|
}),
|
|
441
434
|
esbuild__default.default({
|
|
442
435
|
jsx: config?.jsx ?? "automatic",
|
|
@@ -468,7 +461,7 @@ function resolveRollupConfig(ctx, buildTask) {
|
|
|
468
461
|
}
|
|
469
462
|
}
|
|
470
463
|
})
|
|
471
|
-
].filter(Boolean), userPlugins = config?.rollup?.plugins, plugins = Array.isArray(userPlugins) ? defaultPlugins.concat(userPlugins) : consoleSpy.resolveConfigProperty(config?.rollup?.plugins, defaultPlugins), hashChunkFileNames = config?.rollup?.hashChunkFileNames ?? !1, chunkFileNames = `${isLegacyExports ? "_legacy" : hashChunkFileNames ? "_chunks" : "_chunks-[format]"}/${hashChunkFileNames ? "[name]-[hash]" : "[name]"}${outputExt}`, entryFileNames = isLegacyExports ? "[name].js" : `[name]${outputExt}`;
|
|
464
|
+
].filter(Boolean), userPlugins = config?.rollup?.plugins, plugins = Array.isArray(userPlugins) ? defaultPlugins.concat(userPlugins) : consoleSpy.resolveConfigProperty(config?.rollup?.plugins, defaultPlugins), hashChunkFileNames = config?.rollup?.hashChunkFileNames ?? !1, chunkFileNames = `${isReactCompiler ? "_compiled" : isLegacyExports ? "_legacy" : hashChunkFileNames ? "_chunks" : "_chunks-[format]"}/${hashChunkFileNames ? "[name]-[hash]" : "[name]"}${outputExt}`, entryFileNames = isLegacyExports ? "[name].js" : `[name]${outputExt}`;
|
|
472
465
|
return {
|
|
473
466
|
inputOptions: {
|
|
474
467
|
context: cwd,
|
|
@@ -539,6 +532,65 @@ const rollupLegacyTask = {
|
|
|
539
532
|
...targetLines,
|
|
540
533
|
...entriesLines
|
|
541
534
|
].join(`
|
|
535
|
+
`);
|
|
536
|
+
},
|
|
537
|
+
exec: (ctx, task) => new rxjs.Observable((observer) => {
|
|
538
|
+
execPromise$2(ctx, task).then((result) => {
|
|
539
|
+
observer.next(result), observer.complete();
|
|
540
|
+
}).catch((err) => observer.error(err));
|
|
541
|
+
}),
|
|
542
|
+
complete: () => {
|
|
543
|
+
},
|
|
544
|
+
error: (_ctx, _task, err) => {
|
|
545
|
+
console.error(err);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
async function execPromise$2(ctx, task) {
|
|
549
|
+
const { distPath, files, logger } = ctx, outDir = path__default.default.relative(ctx.cwd, distPath), consoleSpy$1 = consoleSpy.createConsoleSpy({
|
|
550
|
+
onRestored: (messages) => {
|
|
551
|
+
for (const msg of messages) {
|
|
552
|
+
const text = String(msg.args[0]);
|
|
553
|
+
msg.code !== "CIRCULAR_DEPENDENCY" && (text.startsWith("Dynamic import can only") || text.startsWith("Sourcemap is likely to be incorrect") || (msg.type === "log" && logger.info(...msg.args), msg.type === "warn" && logger.warn(...msg.args), msg.type === "error" && logger.error(...msg.args)));
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
try {
|
|
558
|
+
const { inputOptions, outputOptions } = resolveRollupConfig(ctx, task), bundle = await rollup.rollup({
|
|
559
|
+
...inputOptions,
|
|
560
|
+
onwarn(warning) {
|
|
561
|
+
consoleSpy$1.messages.push({
|
|
562
|
+
type: "warn",
|
|
563
|
+
code: warning.code,
|
|
564
|
+
args: [warning.message]
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
}), { output } = await bundle.generate(outputOptions);
|
|
568
|
+
for (const chunkOrAsset of output)
|
|
569
|
+
chunkOrAsset.type === "asset" ? files.push({
|
|
570
|
+
type: "asset",
|
|
571
|
+
path: path__default.default.resolve(outDir, chunkOrAsset.fileName)
|
|
572
|
+
}) : files.push({
|
|
573
|
+
type: "chunk",
|
|
574
|
+
path: path__default.default.resolve(outDir, chunkOrAsset.fileName)
|
|
575
|
+
});
|
|
576
|
+
await bundle.write(outputOptions), await bundle.close(), consoleSpy$1.restore();
|
|
577
|
+
} catch (err) {
|
|
578
|
+
throw consoleSpy$1.restore(), err;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
const rollupReactCompilerTask = {
|
|
582
|
+
name: (ctx, task) => {
|
|
583
|
+
const entries = task.entries.filter((e) => !e.path.includes("__$$bundle_")), targetLines = task.target.length ? [" target:", ...task.target.map((t) => ` - ${chalk__default.default.yellow(t)}`)] : [], entriesLines = entries.length ? [
|
|
584
|
+
" entries:",
|
|
585
|
+
...entries.map(
|
|
586
|
+
(e) => [
|
|
587
|
+
" - ",
|
|
588
|
+
`${chalk__default.default.cyan(path__default.default.join(ctx.pkg.name, e.path))}: `,
|
|
589
|
+
`${chalk__default.default.yellow(e.source)} ${chalk__default.default.gray("\u2192")} ${chalk__default.default.yellow(e.output)}`
|
|
590
|
+
].join("")
|
|
591
|
+
)
|
|
592
|
+
] : [];
|
|
593
|
+
return ["Build react compiler exports...", ...targetLines, ...entriesLines].join(`
|
|
542
594
|
`);
|
|
543
595
|
},
|
|
544
596
|
exec: (ctx, task) => new rxjs.Observable((observer) => {
|
|
@@ -698,7 +750,8 @@ const rollupWatchTask = {
|
|
|
698
750
|
}, buildTaskHandlers = {
|
|
699
751
|
"build:dts": dtsTask,
|
|
700
752
|
"build:js": rollupTask,
|
|
701
|
-
"build:legacy": rollupLegacyTask
|
|
753
|
+
"build:legacy": rollupLegacyTask,
|
|
754
|
+
"build:react-compiler": rollupReactCompilerTask
|
|
702
755
|
}, watchTaskHandlers = {
|
|
703
756
|
"watch:dts": dtsWatchTask,
|
|
704
757
|
"watch:js": rollupWatchTask
|
|
@@ -708,6 +761,7 @@ exports.dtsTask = dtsTask;
|
|
|
708
761
|
exports.dtsWatchTask = dtsWatchTask;
|
|
709
762
|
exports.getExtractMessagesConfig = getExtractMessagesConfig;
|
|
710
763
|
exports.rollupLegacyTask = rollupLegacyTask;
|
|
764
|
+
exports.rollupReactCompilerTask = rollupReactCompilerTask;
|
|
711
765
|
exports.rollupTask = rollupTask;
|
|
712
766
|
exports.rollupWatchTask = rollupWatchTask;
|
|
713
767
|
exports.watchTaskHandlers = watchTaskHandlers;
|