@sanity/pkg-utils 7.4.1-canary.0 → 7.5.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/index.cjs +2022 -260
- package/dist/_chunks-cjs/index.cjs.map +1 -1
- package/dist/_chunks-es/build.js +106 -17
- package/dist/_chunks-es/build.js.map +1 -1
- package/dist/_chunks-es/check.js +125 -37
- package/dist/_chunks-es/check.js.map +1 -1
- package/dist/_chunks-es/consoleSpy.js +541 -0
- package/dist/_chunks-es/consoleSpy.js.map +1 -0
- package/dist/_chunks-es/index.js +774 -180
- package/dist/_chunks-es/index.js.map +1 -1
- package/dist/_chunks-es/init.js +493 -9
- package/dist/_chunks-es/init.js.map +1 -1
- package/dist/_chunks-es/{logger.js → isRecord.js} +15 -2
- package/dist/_chunks-es/isRecord.js.map +1 -0
- package/dist/_chunks-es/resolveRolldownConfig.js +1 -1
- package/dist/_chunks-es/spinner.js +16 -0
- package/dist/_chunks-es/spinner.js.map +1 -0
- package/dist/_chunks-es/watch.js +115 -9
- package/dist/_chunks-es/watch.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.cts +421 -487
- package/dist/index.d.ts +421 -487
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/_chunks-cjs/findConfigFile.cjs +0 -24
- package/dist/_chunks-cjs/findConfigFile.cjs.map +0 -1
- package/dist/_chunks-cjs/index2.cjs +0 -781
- package/dist/_chunks-cjs/index2.cjs.map +0 -1
- package/dist/_chunks-cjs/index3.cjs +0 -50
- package/dist/_chunks-cjs/index3.cjs.map +0 -1
- package/dist/_chunks-cjs/printPackageTree.cjs +0 -42
- package/dist/_chunks-cjs/printPackageTree.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveBuildContext.cjs +0 -176
- package/dist/_chunks-cjs/resolveBuildContext.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveBuildTasks.cjs +0 -111
- package/dist/_chunks-cjs/resolveBuildTasks.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveConfigProperty.cjs +0 -6
- package/dist/_chunks-cjs/resolveConfigProperty.cjs.map +0 -1
- package/dist/_chunks-cjs/resolveWatchTasks.cjs +0 -79
- package/dist/_chunks-cjs/resolveWatchTasks.cjs.map +0 -1
- package/dist/_chunks-cjs/template.cjs +0 -446
- package/dist/_chunks-cjs/template.cjs.map +0 -1
- package/dist/_chunks-cjs/validatePkg.cjs +0 -71
- package/dist/_chunks-cjs/validatePkg.cjs.map +0 -1
- package/dist/_chunks-cjs/watchConfigFiles.cjs +0 -59
- package/dist/_chunks-cjs/watchConfigFiles.cjs.map +0 -1
- package/dist/_chunks-es/fileExists.js +0 -12
- package/dist/_chunks-es/fileExists.js.map +0 -1
- package/dist/_chunks-es/findConfigFile.js +0 -23
- package/dist/_chunks-es/findConfigFile.js.map +0 -1
- package/dist/_chunks-es/index2.js +0 -769
- package/dist/_chunks-es/index2.js.map +0 -1
- package/dist/_chunks-es/index3.js +0 -51
- package/dist/_chunks-es/index3.js.map +0 -1
- package/dist/_chunks-es/loadPkgWithReporting.js +0 -100
- package/dist/_chunks-es/loadPkgWithReporting.js.map +0 -1
- package/dist/_chunks-es/logger.js.map +0 -1
- package/dist/_chunks-es/printPackageTree.js +0 -44
- package/dist/_chunks-es/printPackageTree.js.map +0 -1
- package/dist/_chunks-es/resolveBuildContext.js +0 -177
- package/dist/_chunks-es/resolveBuildContext.js.map +0 -1
- package/dist/_chunks-es/resolveBuildTasks.js +0 -109
- package/dist/_chunks-es/resolveBuildTasks.js.map +0 -1
- package/dist/_chunks-es/resolveConfigProperty.js +0 -7
- package/dist/_chunks-es/resolveConfigProperty.js.map +0 -1
- package/dist/_chunks-es/resolveWatchTasks.js +0 -77
- package/dist/_chunks-es/resolveWatchTasks.js.map +0 -1
- package/dist/_chunks-es/template.js +0 -449
- package/dist/_chunks-es/template.js.map +0 -1
- package/dist/_chunks-es/validatePkg.js +0 -72
- package/dist/_chunks-es/validatePkg.js.map +0 -1
- package/dist/_chunks-es/watchConfigFiles.js +0 -45
- package/dist/_chunks-es/watchConfigFiles.js.map +0 -1
package/dist/_chunks-es/build.js
CHANGED
|
@@ -1,25 +1,114 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { rimraf } from "rimraf";
|
|
3
|
-
import { loadConfig, loadPkgWithReporting } from "./
|
|
4
|
-
import { createLogger } from "./
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
import { getTargetPaths, loadConfig, loadPkgWithReporting, resolveBuildContext } from "./consoleSpy.js";
|
|
4
|
+
import { createLogger } from "./isRecord.js";
|
|
5
|
+
import { createSpinner } from "./spinner.js";
|
|
6
|
+
import { buildTaskHandlers } from "./index.js";
|
|
7
|
+
function resolveBuildTasks(ctx) {
|
|
8
|
+
const { config, pkg, target } = ctx, bundles = config?.bundles || [], tasks = [], exports = Object.entries(ctx.exports || {}).map(
|
|
9
|
+
([_path, exp]) => ({ _path, ...exp })
|
|
10
|
+
), dtsTask = {
|
|
11
|
+
type: "build:dts",
|
|
12
|
+
entries: []
|
|
13
|
+
}, rolldownDtsTask = {}, rollupTasks = {};
|
|
14
|
+
function addRollupTaskEntry(format, runtime, entry) {
|
|
15
|
+
const buildId = `${format}:${runtime}`;
|
|
16
|
+
ctx.dts === "rolldown" && (rolldownDtsTask[buildId] ? rolldownDtsTask[buildId].entries.push(entry) : rolldownDtsTask[buildId] = {
|
|
17
|
+
type: "rolldown:dts",
|
|
18
|
+
buildId,
|
|
19
|
+
entries: [entry],
|
|
20
|
+
runtime,
|
|
21
|
+
format,
|
|
22
|
+
target: target[runtime]
|
|
23
|
+
}), ctx.emitDeclarationOnly || (rollupTasks[buildId] ? rollupTasks[buildId].entries.push(entry) : rollupTasks[buildId] = {
|
|
24
|
+
type: "build:js",
|
|
25
|
+
buildId,
|
|
26
|
+
entries: [entry],
|
|
27
|
+
runtime,
|
|
28
|
+
format,
|
|
29
|
+
target: target[runtime]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (ctx.dts === "api-extractor") {
|
|
33
|
+
for (const exp of exports) {
|
|
34
|
+
const importId = path.join(pkg.name, exp._path);
|
|
35
|
+
exp.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
36
|
+
importId,
|
|
37
|
+
exportPath: exp._path,
|
|
38
|
+
sourcePath: exp.source,
|
|
39
|
+
targetPaths: getTargetPaths(pkg.type, exp)
|
|
40
|
+
}), exp.browser?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
41
|
+
importId,
|
|
42
|
+
exportPath: exp._path,
|
|
43
|
+
sourcePath: exp.browser.source,
|
|
44
|
+
targetPaths: getTargetPaths(pkg.type, exp.browser)
|
|
45
|
+
}), exp.node?.source?.endsWith(".ts") && dtsTask.entries.push({
|
|
46
|
+
importId,
|
|
47
|
+
exportPath: exp._path,
|
|
48
|
+
sourcePath: exp.node.source,
|
|
49
|
+
targetPaths: getTargetPaths(pkg.type, exp.node)
|
|
50
|
+
});
|
|
14
51
|
}
|
|
15
|
-
|
|
52
|
+
for (const bundle of bundles)
|
|
53
|
+
if (bundle.source?.endsWith(".ts")) {
|
|
54
|
+
const exportPath = (bundle.import || bundle.require).replace(/\.[mc]?js$/, ""), importId = path.join(pkg.name, exportPath);
|
|
55
|
+
dtsTask.entries.push({
|
|
56
|
+
importId,
|
|
57
|
+
exportPath,
|
|
58
|
+
sourcePath: bundle.source,
|
|
59
|
+
targetPaths: getTargetPaths(pkg.type, bundle)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
dtsTask.entries.length && tasks.push(dtsTask);
|
|
63
|
+
}
|
|
64
|
+
for (const exp of exports) {
|
|
65
|
+
const output = exp.require;
|
|
66
|
+
output && addRollupTaskEntry("commonjs", ctx.runtime, {
|
|
67
|
+
path: exp._path,
|
|
68
|
+
source: exp.source,
|
|
69
|
+
output
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
for (const exp of exports) {
|
|
73
|
+
const output = exp.import;
|
|
74
|
+
output && addRollupTaskEntry("esm", ctx.runtime, {
|
|
75
|
+
path: exp._path,
|
|
76
|
+
source: exp.source,
|
|
77
|
+
output
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
for (const exp of exports) {
|
|
81
|
+
const output = exp.browser?.require;
|
|
82
|
+
output && addRollupTaskEntry("commonjs", "browser", {
|
|
83
|
+
path: exp._path,
|
|
84
|
+
source: exp.browser?.source || exp.source,
|
|
85
|
+
output
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
for (const exp of exports) {
|
|
89
|
+
const output = exp.browser?.import;
|
|
90
|
+
output && addRollupTaskEntry("esm", "browser", {
|
|
91
|
+
path: exp._path,
|
|
92
|
+
source: exp.browser?.source || exp.source,
|
|
93
|
+
output
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
for (const bundle of bundles) {
|
|
97
|
+
const idx = bundles.indexOf(bundle);
|
|
98
|
+
bundle.require && addRollupTaskEntry("commonjs", bundle.runtime || ctx.runtime, {
|
|
99
|
+
path: `__$$bundle_cjs_${idx}$$__`,
|
|
100
|
+
source: bundle.source,
|
|
101
|
+
output: bundle.require
|
|
102
|
+
}), bundle.import && addRollupTaskEntry("esm", bundle.runtime || ctx.runtime, {
|
|
103
|
+
path: `__$$bundle_esm_${idx}$$__`,
|
|
104
|
+
source: bundle.source,
|
|
105
|
+
output: bundle.import
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return tasks.push(...Object.values(rolldownDtsTask)), tasks.push(...Object.values(rollupTasks)), tasks;
|
|
16
109
|
}
|
|
17
110
|
async function build(options) {
|
|
18
|
-
const
|
|
19
|
-
import("./resolveBuildContext.js"),
|
|
20
|
-
import("./resolveBuildTasks.js"),
|
|
21
|
-
import("./index2.js")
|
|
22
|
-
]), {
|
|
111
|
+
const {
|
|
23
112
|
cwd,
|
|
24
113
|
emitDeclarationOnly,
|
|
25
114
|
strict = !1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sources":["../../src/node/spinner.ts","../../src/node/build.ts"],"sourcesContent":["// oxlint-disable no-console\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'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting'\nimport {createLogger} from './logger'\nimport {createSpinner} from './spinner'\nimport type {BuildTask, TaskHandler} from './tasks/types'\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 [{resolveBuildContext}, {resolveBuildTasks}, {buildTaskHandlers}] = await Promise.all([\n import('./resolveBuildContext'),\n import('./resolveBuildTasks'),\n import('./tasks'),\n ])\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 pkg = await loadPkgWithReporting({cwd, logger, strict})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n if (clean) {\n 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":[],"mappings":";;;;;AAGO,SAAS,cAAc,KAAwD;AAC9E,QAAA,YAAY,KAAK,IAAI;AAEnB,SAAA,QAAA,IAAI,GAAG,GAER;AAAA,IACL,UAAU,MAAM;AACd,cAAQ,IAAI,GAAG,MAAM,MAAM,WAAW,CAAC,IAAI,MAAM,KAAK,GAAG,KAAK,IAAI,IAAI,SAAS,IAAI,CAAC,EAAE;AAAA,IACxF;AAAA,IACA,OAAO,MAAM;AACX,cAAQ,IAAI,GAAG,MAAM,IAAI,SAAS,CAAC,IAAI,MAAM,KAAK,GAAG,KAAK,IAAI,IAAI,SAAS,IAAI,CAAC,EAAE;AAAA,IAAA;AAAA,EAEtF;AACF;ACWA,eAAsB,MAAM,SAMV;AAChB,QAAM,CAAC,EAAC,oBAAmB,GAAG,EAAC,kBAAA,GAAoB,EAAC,mBAAkB,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC1F,OAAO,0BAAuB;AAAA,IAC9B,OAAO,wBAAqB;AAAA,IAC5B,OAAO,aAAS;AAAA,EAAA,CACjB,GACK;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,EACN,IAAA,SACE,SAAS,aAAA,GAET,SAAS,MAAM,WAAW,EAAC,IAAA,CAAI,GAE/B,MAAM,MAAM,qBAAqB,EAAC,KAAK,QAAQ,QAAO,GAEtD,WAAW,kBAAkB,QAAQ,YAAY,iBAEjD,MAAM,MAAM,oBAAoB;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEG,YACF,OAAO;AAAA,IACL,oCAAoC,KAAK,SAAS,KAAK,IAAI,QAAQ,CAAC;AAAA,EAEtE,GAAA,MAAM,OAAO,IAAI,QAAQ;AAGrB,QAAA,aAAa,kBAAkB,GAAG;AAExC,aAAW,QAAQ,YAAY;AAC7B,UAAM,UAAU,kBAAkB,KAAK,IAAI,GACrC,WAAW,QAAQ,KAAK,KAAK,IAAI,GAEjC,UAAU,cAAc,QAAQ;AAElC,QAAA;AACF,YAAM,SAAS,MAAM,QAAQ,KAAK,KAAK,IAAI,EAAE,UAAU;AAE/C,cAAA,SAAA,GACR,IAAI,OAAO,OAEX,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,MAAA;AAGjB,cAAQ,MAAM,KAAK,MAAM,GAAG,GAE5B,QAAQ,KAAK,CAAC;AAAA,IAAA;AAAA,EAChB;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"build.js","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/build.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types'\nimport type {BuildContext} from './core/contexts/buildContext'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths'\nimport type {DtsTask} from './tasks/dts/types'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting'\nimport {createLogger} from './logger'\nimport {resolveBuildContext} from './resolveBuildContext'\nimport {resolveBuildTasks} from './resolveBuildTasks'\nimport {createSpinner} from './spinner'\nimport {buildTaskHandlers} from './tasks'\nimport {type BuildTask, type TaskHandler} from './tasks/types'\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 pkg = await loadPkgWithReporting({cwd, logger, strict})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n if (clean) {\n 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":[],"mappings":";;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAC1D,QAAA,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,IAErB,UAAU,OAAO,QAAQ,IAAI,WAAW,CAAE,CAAA,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAG;AAAA,KAG7B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,kBAAmD,IACnD,cAA0C,CAAC;AAExC,WAAA,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,QAAI,QAAQ,eACV,gBAAgB,OAAO,IACzB,gBAAgB,OAAO,EAAE,QAAQ,KAAK,KAAK,IAE3C,gBAAgB,OAAO,IAAI;AAAA,MACzB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,OAAO;AAAA,IAKvB,IAAA,IAAI,wBACH,YAAY,OAAO,IACrB,YAAY,OAAO,EAAE,QAAQ,KAAK,KAAK,IAEvC,YAAY,OAAO,IAAI;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import { loadConfig, loadPkgWithReporting, resolveBuildContext, createConsoleSpy } from "./consoleSpy.js";
|
|
3
|
+
import { fileExists, createLogger } from "./isRecord.js";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import treeify from "treeify";
|
|
6
|
+
import { statSync } from "node:fs";
|
|
7
|
+
import prettyBytes from "pretty-bytes";
|
|
8
|
+
import { createSpinner } from "./spinner.js";
|
|
9
|
+
function getFilesize(file) {
|
|
10
|
+
const stats = statSync(file);
|
|
11
|
+
return prettyBytes(stats.size);
|
|
12
|
+
}
|
|
13
|
+
function getFileInfo(cwd, filePath) {
|
|
14
|
+
const p = path.resolve(cwd, filePath), exists = fileExists(p), size = exists ? getFilesize(p) : void 0;
|
|
15
|
+
return { exists, size };
|
|
16
|
+
}
|
|
17
|
+
function printPackageTree(ctx) {
|
|
18
|
+
const { cwd, exports, logger, pkg } = ctx;
|
|
19
|
+
if (!exports) return;
|
|
20
|
+
logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`);
|
|
21
|
+
const tree = {};
|
|
22
|
+
pkg.type && (tree.type = chalk.yellow(pkg.type)), pkg.bin && (tree.bin = Object.fromEntries(
|
|
23
|
+
Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)])
|
|
24
|
+
));
|
|
25
|
+
function fileInfo(file) {
|
|
26
|
+
const info = getFileInfo(cwd, file);
|
|
27
|
+
return info.size ? `${chalk.yellow(file)} ${chalk.gray(info.size)}` : `${chalk.gray(file)} ${chalk.red("does not exist")}`;
|
|
28
|
+
}
|
|
29
|
+
tree.exports = Object.fromEntries(
|
|
30
|
+
Object.entries(exports).filter(([, entry]) => entry._exported).map(([exportPath, entry]) => {
|
|
31
|
+
const exp = {
|
|
32
|
+
source: fileInfo(entry.source),
|
|
33
|
+
browser: void 0,
|
|
34
|
+
require: void 0,
|
|
35
|
+
node: void 0,
|
|
36
|
+
import: void 0,
|
|
37
|
+
default: fileInfo(entry.default)
|
|
38
|
+
};
|
|
39
|
+
return entry.browser ? (exp.browser = { source: fileInfo(entry.browser.source) }, entry.browser.import && (exp.browser.import = fileInfo(entry.browser.import)), entry.browser.require && (exp.browser.require = fileInfo(entry.browser.require))) : delete exp.browser, entry.require ? exp.require = fileInfo(entry.require) : delete exp.require, entry.node ? (exp.node = {}, entry.node.source && (exp.node.source = fileInfo(entry.node.source)), entry.node.import && (exp.node.import = fileInfo(entry.node.import)), entry.node.require && (exp.node.require = fileInfo(entry.node.require))) : delete exp.node, entry.import ? exp.import = fileInfo(entry.import) : delete exp.import, [chalk.cyan(path.join(pkg.name, exportPath)), exp];
|
|
40
|
+
})
|
|
41
|
+
), logger.log(treeify.asTree(tree, !0, !0));
|
|
17
42
|
}
|
|
18
43
|
async function check(options) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
const { cwd, strict = !1, tsconfig: tsconfigOption } = options, logger = createLogger(), spinner = createSpinner("");
|
|
45
|
+
try {
|
|
46
|
+
const config = await loadConfig({ cwd }), pkg = await loadPkgWithReporting({ cwd, logger, strict }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({ config, cwd, logger, pkg, strict, tsconfig });
|
|
47
|
+
if (printPackageTree(ctx), strict) {
|
|
48
|
+
const missingFiles = [];
|
|
49
|
+
for (const [, exp] of Object.entries(ctx.exports || {}))
|
|
50
|
+
exp.source && !fileExists(path.resolve(cwd, exp.source)) && missingFiles.push(exp.source), exp.require && !fileExists(path.resolve(cwd, exp.require)) && missingFiles.push(exp.require), exp.import && !fileExists(path.resolve(cwd, exp.import)) && missingFiles.push(exp.import);
|
|
51
|
+
ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types)) && missingFiles.push(ctx.pkg.types), missingFiles.length && (logger.error(`missing files: ${missingFiles.join(", ")}`), process.exit(1));
|
|
52
|
+
const exportPaths = {
|
|
53
|
+
require: [],
|
|
54
|
+
import: []
|
|
55
|
+
};
|
|
56
|
+
for (const exp of Object.values(ctx.exports || {}))
|
|
57
|
+
exp._exported && (exp.require && exportPaths.require.push(exp.require), exp.import && exportPaths.import.push(exp.import));
|
|
58
|
+
const external = [
|
|
59
|
+
...Object.keys(pkg.dependencies || {}),
|
|
60
|
+
...Object.keys(pkg.devDependencies || {})
|
|
61
|
+
], consoleSpy = createConsoleSpy();
|
|
62
|
+
exportPaths.import.length && checkExports(exportPaths.import, { cwd, external, format: "esm", logger }), exportPaths.require.length && checkExports(exportPaths.require, { cwd, external, format: "cjs", logger }), consoleSpy.restore();
|
|
63
|
+
}
|
|
64
|
+
ctx.dts === "rolldown" && ctx.config?.extract?.enabled !== !1 && await checkApiExtractorReleaseTags(ctx), spinner.complete();
|
|
65
|
+
} catch (err) {
|
|
66
|
+
if (spinner.error(), err instanceof Error) {
|
|
67
|
+
const RE_CWD = new RegExp(`${cwd}`, "g");
|
|
68
|
+
logger.error(err.message.replace(RE_CWD, ".")), logger.log();
|
|
69
|
+
}
|
|
70
|
+
process.exit(1);
|
|
39
71
|
}
|
|
40
72
|
}
|
|
41
73
|
async function checkExports(exportPaths, options) {
|
|
@@ -92,8 +124,64 @@ function isEsbuildFailure(err) {
|
|
|
92
124
|
function isEsbuildMessage(msg) {
|
|
93
125
|
return typeof msg == "object" && msg !== null && "text" in msg && typeof msg.text == "string" && "location" in msg && (msg.location === null || typeof msg.location == "object");
|
|
94
126
|
}
|
|
127
|
+
async function checkApiExtractorReleaseTags(ctx) {
|
|
128
|
+
const [
|
|
129
|
+
{ Extractor, ExtractorConfig },
|
|
130
|
+
{ createApiExtractorConfig },
|
|
131
|
+
{ createTSDocConfig },
|
|
132
|
+
{ getExtractMessagesConfig },
|
|
133
|
+
{ printExtractMessages }
|
|
134
|
+
] = await Promise.all([
|
|
135
|
+
import("@microsoft/api-extractor"),
|
|
136
|
+
import("./index.js").then(function(n) {
|
|
137
|
+
return n.createApiExtractorConfig;
|
|
138
|
+
}),
|
|
139
|
+
import("./index.js").then(function(n) {
|
|
140
|
+
return n.createTSDocConfig;
|
|
141
|
+
}),
|
|
142
|
+
import("./index.js").then(function(n) {
|
|
143
|
+
return n.getExtractMessagesConfig$1;
|
|
144
|
+
}),
|
|
145
|
+
import("./index.js").then(function(n) {
|
|
146
|
+
return n.printExtractMessages;
|
|
147
|
+
})
|
|
148
|
+
]), customTags = ctx.config?.extract?.customTags || [], bundledPackages = ctx.bundledPackages, distPath = ctx.distPath, outDir = ctx.ts.config?.options.outDir, rules = ctx.config?.extract?.rules || {};
|
|
149
|
+
if (!outDir)
|
|
150
|
+
throw new Error("tsconfig.json is missing `compilerOptions.outDir`");
|
|
151
|
+
for (const exp of Object.values(ctx.exports || {})) {
|
|
152
|
+
if (!exp._exported || !exp.default.endsWith(".js")) continue;
|
|
153
|
+
const dtsPath = exp.default.replace(/\.js$/, ".d.ts"), exportPath = path.resolve(ctx.cwd, dtsPath), tsdocConfigFile = await createTSDocConfig({
|
|
154
|
+
customTags
|
|
155
|
+
}), extractorConfig = ExtractorConfig.prepare({
|
|
156
|
+
configObject: createApiExtractorConfig({
|
|
157
|
+
bundledPackages,
|
|
158
|
+
distPath,
|
|
159
|
+
exportPath,
|
|
160
|
+
filePath: path.relative(outDir, dtsPath),
|
|
161
|
+
messages: getExtractMessagesConfig({ rules }),
|
|
162
|
+
projectFolder: ctx.cwd,
|
|
163
|
+
mainEntryPointFilePath: exportPath,
|
|
164
|
+
tsconfig: ctx.ts.config,
|
|
165
|
+
tsconfigPath: path.resolve(ctx.cwd, ctx.ts.configPath || "tsconfig.json"),
|
|
166
|
+
dtsRollupEnabled: !1
|
|
167
|
+
}),
|
|
168
|
+
configObjectFullPath: void 0,
|
|
169
|
+
tsdocConfigFile,
|
|
170
|
+
packageJsonFullPath: path.resolve(ctx.cwd, "package.json")
|
|
171
|
+
}), messages = [];
|
|
172
|
+
Extractor.invoke(extractorConfig, {
|
|
173
|
+
// Equivalent to the "--local" command-line parameter
|
|
174
|
+
localBuild: !0,
|
|
175
|
+
// Equivalent to the "--verbose" command-line parameter
|
|
176
|
+
showVerboseMessages: !0,
|
|
177
|
+
// handle messages
|
|
178
|
+
messageCallback(message) {
|
|
179
|
+
messages.push(message), message.handled = !0;
|
|
180
|
+
}
|
|
181
|
+
}), printExtractMessages(ctx, messages);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
95
184
|
export {
|
|
96
|
-
check
|
|
97
|
-
createConsoleSpy
|
|
185
|
+
check
|
|
98
186
|
};
|
|
99
187
|
//# sourceMappingURL=check.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sources":["../../src/node/consoleSpy.ts","../../src/node/check.ts"],"sourcesContent":["export interface ConsoleSpyMsg {\n type: 'log' | 'warn' | 'error'\n code?: string\n args: unknown[]\n}\n\nexport interface ConsoleSpy {\n messages: ConsoleSpyMsg[]\n restore: () => void\n}\n\nexport function createConsoleSpy(options?: {\n onRestored?: (messages: ConsoleSpyMsg[]) => void\n}): ConsoleSpy {\n const {onRestored} = options || {}\n\n const original = {\n log: console.log,\n warn: console.warn,\n error: console.error,\n }\n\n const messages: ConsoleSpyMsg[] = []\n\n console.log = (...args: unknown[]) => messages.push({type: 'log', args})\n console.warn = (...args: unknown[]) => messages.push({type: 'warn', args})\n console.error = (...args: unknown[]) => messages.push({type: 'error', args})\n\n return {\n messages,\n restore: () => {\n console.log = original.log\n console.warn = original.warn\n console.error = original.error\n\n onRestored?.(messages)\n },\n }\n}\n","import path from 'node:path'\nimport type {BuildFailure, Message} from 'esbuild'\nimport {createConsoleSpy} from './consoleSpy'\nimport {loadConfig} from './core/config/loadConfig'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting'\nimport {fileExists} from './fileExists'\nimport {createLogger, type Logger} from './logger'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const [{resolveBuildContext}, {printPackageTree}] = await Promise.all([\n import('./resolveBuildContext'),\n import('./printPackageTree'),\n ])\n\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n\n const config = await loadConfig({cwd})\n const pkg = await loadPkgWithReporting({cwd, logger, strict})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n\n // Check if the files are resolved\n const exportPaths: {require: string[]; import: string[]} = {\n require: [],\n import: [],\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n if (exp.require) exportPaths.require.push(exp.require)\n if (exp.import) exportPaths.import.push(exp.import)\n }\n\n const external = [\n ...Object.keys(pkg.dependencies || {}),\n ...Object.keys(pkg.devDependencies || {}),\n ]\n\n const consoleSpy = createConsoleSpy()\n\n if (exportPaths.import.length) {\n checkExports(exportPaths.import, {cwd, external, format: 'esm', logger})\n }\n\n if (exportPaths.require.length) {\n checkExports(exportPaths.require, {cwd, external, format: 'cjs', logger})\n }\n\n consoleSpy.restore()\n }\n}\n\nasync function checkExports(\n exportPaths: string[],\n options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},\n) {\n const {build} = await import('esbuild')\n const {cwd, external, format, logger} = options\n\n const code = exportPaths\n .map((id) => (format ? `import('${id}');` : `require('${id}');`))\n .join('\\n')\n\n try {\n const esbuildResult = await build({\n bundle: true,\n external,\n format,\n logLevel: 'silent',\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n })\n\n if (esbuildResult.errors.length > 0) {\n for (const msg of esbuildResult.errors) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n\n process.exit(1)\n }\n\n const esbuildWarnings = esbuildResult.warnings.filter((msg) => {\n !(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)\n })\n\n for (const msg of esbuildWarnings) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n } catch (err) {\n if (isEsbuildFailure(err)) {\n const {errors} = err\n\n for (const msg of errors) {\n printEsbuildMessage(logger.error, msg)\n\n logger.log()\n }\n } else if (err instanceof Error) {\n logger.error(err.stack || err.message)\n\n logger.log()\n } else {\n logger.error(`${err}`)\n\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nfunction printEsbuildMessage(log: (...args: unknown[]) => void, msg: Message) {\n if (msg.location) {\n log(\n [\n `${msg.detail || msg.text}\\n`,\n `${msg.location.line} | ${msg.location.lineText}\\n`,\n `in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,\n ].join(''),\n )\n } else {\n log(msg.detail || msg.text)\n }\n}\n\nfunction isEsbuildFailure(err: unknown): err is BuildFailure {\n return (\n err instanceof Error &&\n 'errors' in err &&\n Array.isArray(err.errors) &&\n err.errors.every(isEsbuildMessage) &&\n 'warnings' in err &&\n Array.isArray(err.warnings) &&\n err.warnings.every(isEsbuildMessage)\n )\n}\n\nfunction isEsbuildMessage(msg: unknown): msg is Message {\n return (\n typeof msg === 'object' &&\n msg !== null &&\n 'text' in msg &&\n typeof msg.text === 'string' &&\n 'location' in msg &&\n (msg.location === null || typeof msg.location === 'object')\n )\n}\n"],"names":[],"mappings":";;;;AAWO,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,EACjB,GAEM,WAA4B,CAAC;AAEnC,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,IAAA;AAAA,EAEzB;AACF;AC7BA,eAAsB,MAAM,SAIV;AACV,QAAA,CAAC,EAAC,uBAAsB,EAAC,kBAAiB,IAAI,MAAM,QAAQ,IAAI;AAAA,IACpE,OAAO,0BAAuB;AAAA,IAC9B,OAAO,uBAAoB;AAAA,EAAA,CAC5B,GAEK,EAAC,KAAK,SAAS,IAAO,UAAU,eAAkB,IAAA,SAClD,SAAS,aAAa,GAEtB,SAAS,MAAM,WAAW,EAAC,KAAI,GAC/B,MAAM,MAAM,qBAAqB,EAAC,KAAK,QAAQ,QAAO,GACtD,WAAW,kBAAkB,QAAQ,YAAY,iBACjD,MAAM,MAAM,oB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MAAI,WACN;AAAA,IACE;AAAA,MACE,GAAG,IAAI,UAAU,IAAI,IAAI;AAAA;AAAA,MACzB,GAAG,IAAI,SAAS,IAAI,MAAM,IAAI,SAAS,QAAQ;AAAA;AAAA,MAC/C,QAAQ,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,MAAM;AAAA,IACvE,EAAE,KAAK,EAAE;AAAA,EAGX,IAAA,IAAI,IAAI,UAAU,IAAI,IAAI;AAE9B;AAEA,SAAS,iBAAiB,KAAmC;AAEzD,SAAA,eAAe,SACf,YAAY,OACZ,MAAM,QAAQ,IAAI,MAAM,KACxB,IAAI,OAAO,MAAM,gBAAgB,KACjC,cAAc,OACd,MAAM,QAAQ,IAAI,QAAQ,KAC1B,IAAI,SAAS,MAAM,gBAAgB;AAEvC;AAEA,SAAS,iBAAiB,KAA8B;AACtD,SACE,OAAO,OAAQ,YACf,QAAQ,QACR,UAAU,OACV,OAAO,IAAI,QAAS,YACpB,cAAc,QACb,IAAI,aAAa,QAAQ,OAAO,IAAI,YAAa;AAEtD;"}
|
|
1
|
+
{"version":3,"file":"check.js","sources":["../../src/node/getFilesize.ts","../../src/node/printPackageTree.ts","../../src/node/check.ts"],"sourcesContent":["import {statSync} from 'node:fs'\nimport prettyBytes from 'pretty-bytes'\n\nexport function getFilesize(file: string): string {\n const stats = statSync(file)\n\n return prettyBytes(stats.size)\n}\n","import path from 'node:path'\nimport chalk from 'chalk'\nimport treeify from 'treeify'\nimport type {PkgExport} from './core/config/types'\nimport type {BuildContext} from './core/contexts/buildContext'\nimport {fileExists} from './fileExists'\nimport {getFilesize} from './getFilesize'\n\nfunction getFileInfo(cwd: string, filePath: string) {\n const p = path.resolve(cwd, filePath)\n const exists = fileExists(p)\n const size = exists ? getFilesize(p) : undefined\n\n return {exists, size}\n}\n\nexport function printPackageTree(ctx: BuildContext): void {\n const {cwd, exports, logger, pkg} = ctx\n\n if (!exports) return\n\n logger.log(`${chalk.blue(pkg.name)}@${chalk.green(pkg.version)}`)\n\n const tree: Record<string, unknown> = {}\n\n if (pkg.type) {\n tree['type'] = chalk.yellow(pkg.type)\n }\n\n if (pkg.bin) {\n tree['bin'] = Object.fromEntries(\n Object.entries(pkg.bin).map(([name, file]) => [chalk.cyan(name), fileInfo(file)]),\n )\n }\n\n function fileInfo(file: string) {\n const info = getFileInfo(cwd, file)\n\n if (!info.size) {\n return `${chalk.gray(file)} ${chalk.red('does not exist')}`\n }\n\n return `${chalk.yellow(file)} ${chalk.gray(info.size)}`\n }\n\n tree['exports'] = Object.fromEntries(\n Object.entries(exports)\n .filter(([, entry]) => entry._exported)\n .map(([exportPath, entry]) => {\n const exp: Omit<PkgExport, '_exported'> = {\n source: fileInfo(entry.source),\n browser: undefined,\n require: undefined,\n node: undefined,\n import: undefined,\n default: fileInfo(entry.default),\n }\n\n if (entry.browser) {\n exp.browser = {source: fileInfo(entry.browser.source)}\n\n if (entry.browser.import) exp.browser.import = fileInfo(entry.browser.import)\n if (entry.browser.require) exp.browser.require = fileInfo(entry.browser.require)\n } else {\n delete exp.browser\n }\n\n if (entry.require) {\n exp.require = fileInfo(entry.require)\n } else {\n delete exp.require\n }\n\n if (entry.node) {\n exp.node = {}\n\n if (entry.node.source) exp.node.source = fileInfo(entry.node.source)\n if (entry.node.import) exp.node.import = fileInfo(entry.node.import)\n if (entry.node.require) exp.node.require = fileInfo(entry.node.require)\n } else {\n delete exp.node\n }\n\n if (entry.import) {\n exp.import = fileInfo(entry.import)\n } else {\n delete exp.import\n }\n\n return [chalk.cyan(path.join(pkg.name, exportPath)), exp]\n }),\n )\n\n logger.log(treeify.asTree(tree as Record<string, any>, true, true))\n}\n","import path from 'node:path'\nimport type {ExtractorMessage} from '@microsoft/api-extractor'\nimport type {BuildFailure, Message} from 'esbuild'\nimport {createConsoleSpy} from './consoleSpy'\nimport {loadConfig} from './core/config/loadConfig'\nimport type {BuildContext} from './core/contexts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting'\nimport {fileExists} from './fileExists'\nimport {createLogger, type Logger} from './logger'\nimport {printPackageTree} from './printPackageTree'\nimport {resolveBuildContext} from './resolveBuildContext'\nimport {createSpinner} from './spinner'\n\n/** @public */\nexport async function check(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n const logger = createLogger()\n const spinner = createSpinner('')\n try {\n const config = await loadConfig({cwd})\n const pkg = await loadPkgWithReporting({cwd, logger, strict})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n const ctx = await resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n\n printPackageTree(ctx)\n\n if (strict) {\n const missingFiles: string[] = []\n\n // Check if there are missing files\n for (const [, exp] of Object.entries(ctx.exports || {})) {\n if (exp.source && !fileExists(path.resolve(cwd, exp.source))) {\n missingFiles.push(exp.source)\n }\n\n if (exp.require && !fileExists(path.resolve(cwd, exp.require))) {\n missingFiles.push(exp.require)\n }\n\n if (exp.import && !fileExists(path.resolve(cwd, exp.import))) {\n missingFiles.push(exp.import)\n }\n }\n\n if (ctx.pkg.types && !fileExists(path.resolve(cwd, ctx.pkg.types))) {\n missingFiles.push(ctx.pkg.types)\n }\n\n if (missingFiles.length) {\n logger.error(`missing files: ${missingFiles.join(', ')}`)\n process.exit(1)\n }\n\n // Check if the files are resolved\n const exportPaths: {require: string[]; import: string[]} = {\n require: [],\n import: [],\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported) continue\n if (exp.require) exportPaths.require.push(exp.require)\n if (exp.import) exportPaths.import.push(exp.import)\n }\n\n const external = [\n ...Object.keys(pkg.dependencies || {}),\n ...Object.keys(pkg.devDependencies || {}),\n ]\n\n const consoleSpy = createConsoleSpy()\n\n if (exportPaths.import.length) {\n checkExports(exportPaths.import, {cwd, external, format: 'esm', logger})\n }\n\n if (exportPaths.require.length) {\n checkExports(exportPaths.require, {cwd, external, format: 'cjs', logger})\n }\n\n consoleSpy.restore()\n }\n\n if (ctx.dts === 'rolldown' && ctx.config?.extract?.enabled !== false) {\n await checkApiExtractorReleaseTags(ctx)\n }\n\n spinner.complete()\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(`${cwd}`, 'g')\n\n logger.error(err.message.replace(RE_CWD, '.'))\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nasync function checkExports(\n exportPaths: string[],\n options: {cwd: string; external: string[]; format: 'esm' | 'cjs'; logger: Logger},\n) {\n const {build} = await import('esbuild')\n const {cwd, external, format, logger} = options\n\n const code = exportPaths\n .map((id) => (format ? `import('${id}');` : `require('${id}');`))\n .join('\\n')\n\n try {\n const esbuildResult = await build({\n bundle: true,\n external,\n format,\n logLevel: 'silent',\n // otherwise output maps to stdout as we're using stdin\n outfile: '/dev/null',\n platform: 'node',\n stdin: {\n contents: code,\n loader: 'js',\n resolveDir: cwd,\n },\n })\n\n if (esbuildResult.errors.length > 0) {\n for (const msg of esbuildResult.errors) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n\n process.exit(1)\n }\n\n const esbuildWarnings = esbuildResult.warnings.filter((msg) => {\n !(msg.detail || msg.text).includes(`does not affect esbuild's own target setting`)\n })\n\n for (const msg of esbuildWarnings) {\n printEsbuildMessage(logger.warn, msg)\n\n logger.log()\n }\n } catch (err) {\n if (isEsbuildFailure(err)) {\n const {errors} = err\n\n for (const msg of errors) {\n printEsbuildMessage(logger.error, msg)\n\n logger.log()\n }\n } else if (err instanceof Error) {\n logger.error(err.stack || err.message)\n\n logger.log()\n } else {\n logger.error(`${err}`)\n\n logger.log()\n }\n\n process.exit(1)\n }\n}\n\nfunction printEsbuildMessage(log: (...args: unknown[]) => void, msg: Message) {\n if (msg.location) {\n log(\n [\n `${msg.detail || msg.text}\\n`,\n `${msg.location.line} | ${msg.location.lineText}\\n`,\n `in ./${msg.location.file}:${msg.location.line}:${msg.location.column}`,\n ].join(''),\n )\n } else {\n log(msg.detail || msg.text)\n }\n}\n\nfunction isEsbuildFailure(err: unknown): err is BuildFailure {\n return (\n err instanceof Error &&\n 'errors' in err &&\n Array.isArray(err.errors) &&\n err.errors.every(isEsbuildMessage) &&\n 'warnings' in err &&\n Array.isArray(err.warnings) &&\n err.warnings.every(isEsbuildMessage)\n )\n}\n\nfunction isEsbuildMessage(msg: unknown): msg is Message {\n return (\n typeof msg === 'object' &&\n msg !== null &&\n 'text' in msg &&\n typeof msg.text === 'string' &&\n 'location' in msg &&\n (msg.location === null || typeof msg.location === 'object')\n )\n}\n\nasync function checkApiExtractorReleaseTags(ctx: BuildContext) {\n const [\n {Extractor, ExtractorConfig},\n {createApiExtractorConfig},\n {createTSDocConfig},\n {getExtractMessagesConfig},\n {printExtractMessages},\n ] = await Promise.all([\n import('@microsoft/api-extractor'),\n import('./tasks/dts/createApiExtractorConfig'),\n import('./tasks/dts/createTSDocConfig'),\n import('./tasks/dts/getExtractMessagesConfig'),\n import('./printExtractMessages'),\n ])\n\n const customTags = ctx.config?.extract?.customTags || []\n const bundledPackages = ctx.bundledPackages\n const distPath = ctx.distPath\n const outDir = ctx.ts.config?.options.outDir\n const rules = ctx.config?.extract?.rules || {}\n\n if (!outDir) {\n throw new Error('tsconfig.json is missing `compilerOptions.outDir`')\n }\n\n for (const exp of Object.values(ctx.exports || {})) {\n if (!exp._exported || !exp.default.endsWith('.js')) continue\n const dtsPath = exp.default.replace(/\\.js$/, '.d.ts')\n const exportPath = path.resolve(ctx.cwd, dtsPath)\n\n const tsdocConfigFile = await createTSDocConfig({\n customTags,\n })\n const extractorConfig = ExtractorConfig.prepare({\n configObject: createApiExtractorConfig({\n bundledPackages,\n distPath,\n exportPath,\n filePath: path.relative(outDir, dtsPath),\n messages: getExtractMessagesConfig({rules}),\n projectFolder: ctx.cwd,\n mainEntryPointFilePath: exportPath,\n tsconfig: ctx.ts.config!,\n tsconfigPath: path.resolve(ctx.cwd, ctx.ts.configPath || 'tsconfig.json'),\n dtsRollupEnabled: false,\n }),\n configObjectFullPath: undefined,\n tsdocConfigFile,\n packageJsonFullPath: path.resolve(ctx.cwd, 'package.json'),\n })\n const messages: ExtractorMessage[] = []\n // Invoke API Extractor\n Extractor.invoke(extractorConfig, {\n // Equivalent to the \"--local\" command-line parameter\n localBuild: true,\n // Equivalent to the \"--verbose\" command-line parameter\n showVerboseMessages: true,\n // handle messages\n messageCallback(message: ExtractorMessage) {\n messages.push(message)\n message.handled = true\n },\n })\n\n printExtractMessages(ctx, messages)\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAGO,SAAS,YAAY,MAAsB;AAC1C,QAAA,QAAQ,SAAS,IAAI;AAEpB,SAAA,YAAY,MAAM,IAAI;AAC/B;ACCA,SAAS,YAAY,KAAa,UAAkB;AAClD,QAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,GAC9B,SAAS,WAAW,CAAC,GACrB,OAAO,SAAS,YAAY,CAAC,IAAI;AAEhC,SAAA,EAAC,QAAQ,KAAI;AACtB;AAEO,SAAS,iBAAiB,KAAyB;AACxD,QAAM,EAAC,KAAK,SAAS,QAAQ,IAAO,IAAA;AAEpC,MAAI,CAAC,QAAS;AAEd,SAAO,IAAI,GAAG,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,MAAM,MAAM,IAAI,OAAO,CAAC,EAAE;AAEhE,QAAM,OAAgC,CAAC;AAEnC,MAAI,SACN,KAAK,OAAU,MAAM,OAAO,IAAI,IAAI,IAGlC,IAAI,QACN,KAAK,MAAS,OAAO;AAAA,IACnB,OAAO,QAAQ,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,GAAG,SAAS,IAAI,CAAC,CAAC;AAAA,EAAA;AAIpF,WAAS,SAAS,MAAc;AACxB,UAAA,OAAO,YAAY,KAAK,IAAI;AAE7B,WAAA,KAAK,OAIH,GAAG,MAAM,OAAO,IAAI,CAAC,IAAI,MAAM,KAAK,KAAK,IAAI,CAAC,KA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