@sanity/pkg-utils 9.2.3 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-es/buildAction.js +151 -2
- package/dist/_chunks-es/buildAction.js.map +1 -1
- package/dist/_chunks-es/checkAction.js +183 -2
- package/dist/_chunks-es/checkAction.js.map +1 -1
- package/dist/_chunks-es/createApiExtractorConfig.js +52 -0
- package/dist/_chunks-es/createApiExtractorConfig.js.map +1 -0
- package/dist/_chunks-es/createTSDocConfig.js +31 -0
- package/dist/_chunks-es/createTSDocConfig.js.map +1 -0
- package/dist/_chunks-es/defaults.js +36 -0
- package/dist/_chunks-es/defaults.js.map +1 -0
- package/dist/_chunks-es/define.js +7 -0
- package/dist/_chunks-es/define.js.map +1 -0
- package/dist/_chunks-es/fileExists.js +12 -0
- package/dist/_chunks-es/fileExists.js.map +1 -0
- package/dist/_chunks-es/getExtractMessagesConfig.js +83 -0
- package/dist/_chunks-es/getExtractMessagesConfig.js.map +1 -0
- package/dist/_chunks-es/handleError.js +25 -1
- package/dist/_chunks-es/handleError.js.map +1 -1
- package/dist/_chunks-es/index.js +8 -212
- package/dist/_chunks-es/index.js.map +1 -1
- package/dist/_chunks-es/initAction.js +515 -2
- package/dist/_chunks-es/initAction.js.map +1 -1
- package/dist/_chunks-es/printExtractMessages.js +44 -0
- package/dist/_chunks-es/printExtractMessages.js.map +1 -0
- package/dist/_chunks-es/{consoleSpy.js → resolveBuildContext.js} +51 -167
- package/dist/_chunks-es/resolveBuildContext.js.map +1 -0
- package/dist/_chunks-es/resolveRolldownConfig.js +1 -1
- package/dist/_chunks-es/watchAction.js +108 -2
- package/dist/_chunks-es/watchAction.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +5 -208
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -18
- package/dist/index.js.map +1 -1
- package/package.json +8 -14
- package/dist/_chunks-es/build.js +0 -150
- package/dist/_chunks-es/build.js.map +0 -1
- package/dist/_chunks-es/check.js +0 -189
- package/dist/_chunks-es/check.js.map +0 -1
- package/dist/_chunks-es/consoleSpy.js.map +0 -1
- package/dist/_chunks-es/init.js +0 -520
- package/dist/_chunks-es/init.js.map +0 -1
- package/dist/_chunks-es/isRecord.js +0 -37
- package/dist/_chunks-es/isRecord.js.map +0 -1
- package/dist/_chunks-es/watch.js +0 -109
- package/dist/_chunks-es/watch.js.map +0 -1
- package/tsconfig/isolated-declarations.json +0 -11
- package/tsconfig/recommended.json +0 -24
- package/tsconfig/strict.json +0 -15
- package/tsconfig/strictest.json +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchAction.js","sources":["../../src/cli/watchAction.ts"],"sourcesContent":["import {watch} from '../node/watch.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function watchAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await watch({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"watchAction.js","sources":["../../src/node/resolveWatchTasks.ts","../../src/node/watch.ts","../../src/cli/watchAction.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsWatchTask} from './tasks/dts/types.ts'\nimport type {RollupTaskEntry, RollupWatchTask, WatchTask} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveWatchTasks(ctx: BuildContext): WatchTask[] {\n const {pkg, target} = ctx\n const tasks: WatchTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsWatchTask = {\n type: 'watch:dts',\n entries: [],\n }\n\n const rollupTasks: Record<string, RollupWatchTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'watch:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {up as findPkgPath} from 'empathic/package'\nimport {switchMap} from 'rxjs'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveWatchTasks} from './resolveWatchTasks.ts'\nimport {watchTaskHandlers} from './tasks/index.ts'\nimport {type TaskHandler, type WatchTask} from './tasks/types.ts'\n\n/** @public */\nexport async function watch(options: {\n cwd: string\n strict?: boolean\n tsconfig?: string\n}): Promise<void> {\n const {cwd, strict = false, tsconfig: tsconfigOption} = options\n\n const logger = createLogger()\n\n const {watchConfigFiles} = await import('./watchConfigFiles.ts')\n const configFiles$ = await watchConfigFiles({cwd, logger})\n\n const ctx$ = configFiles$.pipe(\n switchMap(async (configFiles) => {\n const files = configFiles.map((f) => path.relative(cwd, f))\n\n const packageJsonPath = files.find((f) => f === 'package.json')\n\n const pkgPath = findPkgPath({cwd})\n if (!packageJsonPath || !pkgPath) {\n throw new Error('missing package.json', {cause: {cwd}})\n }\n\n const config = await loadConfig({cwd, pkgPath})\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({pkgPath, logger, strict, strictOptions})\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n return resolveBuildContext({config, cwd, logger, pkg, strict, tsconfig})\n }),\n )\n\n ctx$.subscribe(async (ctx) => {\n const watchTasks = resolveWatchTasks(ctx)\n\n for (const task of watchTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = watchTaskHandlers[task.type] as TaskHandler<WatchTask, unknown>\n const result$ = handler.exec(ctx, task)\n\n result$.subscribe({\n error: (err) => {\n ctx.logger.error(err)\n ctx.logger.log()\n\n process.exit(1)\n },\n next: (result) => {\n handler.complete(ctx, task, result)\n },\n complete: () => {\n ctx.logger.success(handler.name(ctx, task))\n ctx.logger.log()\n },\n })\n }\n })\n}\n","import {watch} from '../node/watch.ts'\nimport {handleError} from './handleError.ts'\n\nexport async function watchAction(options: {strict?: boolean; tsconfig?: string}): Promise<void> {\n try {\n await watch({\n cwd: process.cwd(),\n strict: options.strict,\n tsconfig: options.tsconfig,\n })\n } catch (err) {\n handleError(err)\n }\n}\n"],"names":["exports","findPkgPath"],"mappings":";;;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,KAAK,OAAA,IAAU,KAChB,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAA;AAAA,EAAG,GAG7B,UAAwB;AAAA,IAC5B,MAAM;AAAA,IACN,SAAS,CAAA;AAAA,EAAC,GAGN,cAA+C,CAAA;AAErD,WAAS,mBAAmB,QAAmB,SAAqB,OAAwB;AAC1F,UAAM,UAAU,GAAG,MAAM,IAAI,OAAO;AAEhC,gBAAY,OAAO,IACrB,YAAY,OAAO,EAAE,QAAQ,KAAK,KAAK,IAEvC,YAAY,OAAO,IAAI;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,MACA,SAAS,CAAC,KAAK;AAAA,MACf;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,OAAO;AAAA,IAAA;AAAA,EAG5B;AAGA,aAAW,OAAOA,WAAS;AACzB,UAAM,WAAW,KAAK,KAAK,IAAI,MAAM,IAAI,KAAK;AAE1C,QAAI,QAAQ,SAAS,KAAK,KAC5B,QAAQ,QAAQ,KAAK;AAAA,MACnB;AAAA,MACA,YAAY,IAAI;AAAA,MAChB,YAAY,IAAI;AAAA,MAChB,aAAa,eAAe,IAAI,MAAM,GAAG;AAAA,IAAA,CAC1C,GAG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AAS,KAAK,MAAM,MAAM;AAAA,QACpC;AAAA,QACA,UAAU,MAAM;AACd,cAAI,OAAO,QAAQ,QAAQ,KAAK,KAAK,IAAI,CAAC,GAC1C,IAAI,OAAO,IAAA;AAAA,QACb;AAAA,MAAA,CACD;AAAA,IACH;AAAA,EACF,CAAC;AACH;ACnEA,eAAsB,YAAY,SAA+D;AAC/F,MAAI;AACF,UAAM,MAAM;AAAA,MACV,KAAK,QAAQ,IAAA;AAAA,MACb,QAAQ,QAAQ;AAAA,MAChB,UAAU,QAAQ;AAAA,IAAA,CACnB;AAAA,EACH,SAAS,KAAK;AACZ,gBAAY,GAAG;AAAA,EACjB;AACF;"}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cac } from "cac";
|
|
2
|
-
var version = "
|
|
2
|
+
var version = "10.1.0";
|
|
3
3
|
const cli = cac();
|
|
4
4
|
cli.command("", "Check").alias("check").option("--strict", "Strict mode").option("--tsconfig [tsconfig]", "[string] tsconfig.json").action(async (options) => {
|
|
5
5
|
const { checkAction } = await import("./_chunks-es/checkAction.js");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
import { PluginItem } from "@babel/core";
|
|
2
2
|
import { OptimizeLodashOptions } from "@optimize-lodash/rollup-plugin";
|
|
3
|
+
import { PkgExport, PkgExports, PkgExports as PkgExports$1 } from "@sanity/parse-package-json";
|
|
3
4
|
import { Options } from "@vanilla-extract/rollup-plugin";
|
|
4
5
|
import { PluginOptions } from "babel-plugin-react-compiler";
|
|
5
6
|
import { NormalizedOutputOptions, Plugin, Plugin as RollupPlugin, TreeshakingOptions } from "rollup";
|
|
6
|
-
import { IExtractorMessagesConfig } from "@microsoft/api-extractor";
|
|
7
|
-
/**
|
|
8
|
-
* Build the distribution files of a npm package.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import {build} from '@sanity/pkg-utils'
|
|
13
|
-
*
|
|
14
|
-
* build({
|
|
15
|
-
* cwd: process.cwd(),
|
|
16
|
-
* tsconfig: 'tsconfig.dist.json,
|
|
17
|
-
* }).then(() => {
|
|
18
|
-
* console.log('successfully built')
|
|
19
|
-
* }).catch((err) => {
|
|
20
|
-
* console.log(`build error: ${err.message}`)
|
|
21
|
-
* })
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
declare function build(options: {
|
|
27
|
-
cwd: string;
|
|
28
|
-
emitDeclarationOnly?: boolean;
|
|
29
|
-
strict?: boolean;
|
|
30
|
-
tsconfig?: string;
|
|
31
|
-
clean?: boolean;
|
|
32
|
-
quiet?: boolean;
|
|
33
|
-
}): Promise<void>;
|
|
34
|
-
/** @public */
|
|
35
|
-
declare function check(options: {
|
|
36
|
-
cwd: string;
|
|
37
|
-
strict?: boolean;
|
|
38
|
-
tsconfig?: string;
|
|
39
|
-
}): Promise<void>;
|
|
40
7
|
type ToggleType = 'error' | 'warn' | 'off';
|
|
41
8
|
/**
|
|
42
9
|
* @public
|
|
@@ -76,16 +43,6 @@ interface StrictOptions {
|
|
|
76
43
|
* @defaultValue 'warn'
|
|
77
44
|
*/
|
|
78
45
|
noCheckTypes: ToggleType;
|
|
79
|
-
/**
|
|
80
|
-
* Disallows the `main` field in `package.json` as all modern tools support the `exports` field.
|
|
81
|
-
* @defaultValue 'warn'
|
|
82
|
-
*/
|
|
83
|
-
noPackageJsonMain: ToggleType;
|
|
84
|
-
/**
|
|
85
|
-
* Disallows the `module` field in `package.json` as all modern tools support the `exports` field.
|
|
86
|
-
* @defaultValue 'warn'
|
|
87
|
-
*/
|
|
88
|
-
noPackageJsonModule: ToggleType;
|
|
89
46
|
/**
|
|
90
47
|
* Disallows the `browser` field in `package.json` as the `browser` condition in `exports` is better supported.
|
|
91
48
|
* @defaultValue 'warn'
|
|
@@ -102,33 +59,11 @@ interface StrictOptions {
|
|
|
102
59
|
*/
|
|
103
60
|
preferModuleType: ToggleType;
|
|
104
61
|
}
|
|
105
|
-
/** @alpha */
|
|
106
|
-
declare function parseStrictOptions(input: unknown): StrictOptions;
|
|
107
62
|
/** @public */
|
|
108
63
|
type PkgFormat = 'commonjs' | 'esm';
|
|
109
64
|
/** @public */
|
|
110
65
|
type PkgRuntime = '*' | 'browser' | 'node';
|
|
111
66
|
/** @public */
|
|
112
|
-
interface PkgExport {
|
|
113
|
-
/** @internal */
|
|
114
|
-
_exported?: boolean;
|
|
115
|
-
browser?: {
|
|
116
|
-
source: string;
|
|
117
|
-
import?: string;
|
|
118
|
-
require?: string;
|
|
119
|
-
};
|
|
120
|
-
node?: {
|
|
121
|
-
source?: string;
|
|
122
|
-
import?: string;
|
|
123
|
-
require?: string;
|
|
124
|
-
};
|
|
125
|
-
types?: string;
|
|
126
|
-
source: string;
|
|
127
|
-
import?: string;
|
|
128
|
-
require?: string;
|
|
129
|
-
default: string;
|
|
130
|
-
}
|
|
131
|
-
/** @public */
|
|
132
67
|
type PkgConfigPropertyResolver<T> = (prev: T) => T;
|
|
133
68
|
/** @public */
|
|
134
69
|
type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T;
|
|
@@ -140,10 +75,6 @@ interface PkgBundle {
|
|
|
140
75
|
runtime?: PkgRuntime;
|
|
141
76
|
}
|
|
142
77
|
/** @public */
|
|
143
|
-
interface PkgExports {
|
|
144
|
-
[path: string]: PkgExport;
|
|
145
|
-
}
|
|
146
|
-
/** @public */
|
|
147
78
|
type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off';
|
|
148
79
|
/** @public */
|
|
149
80
|
interface TSDocCustomTag {
|
|
@@ -195,7 +126,7 @@ interface PkgConfigOptions {
|
|
|
195
126
|
* Directory of distributed & bundled files.
|
|
196
127
|
*/
|
|
197
128
|
dist?: string;
|
|
198
|
-
exports?: PkgConfigProperty<PkgExports>;
|
|
129
|
+
exports?: PkgConfigProperty<PkgExports$1>;
|
|
199
130
|
/**
|
|
200
131
|
* Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.
|
|
201
132
|
* This is useful for packages that need to be consumed by TSDoc-based tooling.
|
|
@@ -324,110 +255,10 @@ declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T
|
|
|
324
255
|
/** @alpha */
|
|
325
256
|
declare function loadConfig(options: {
|
|
326
257
|
cwd: string;
|
|
258
|
+
pkgPath: string;
|
|
327
259
|
}): Promise<PkgConfigOptions | undefined>;
|
|
328
260
|
/** @public */
|
|
329
261
|
declare const DEFAULT_BROWSERSLIST_QUERY: string[];
|
|
330
|
-
/** @alpha */
|
|
331
|
-
interface PackageJSON {
|
|
332
|
-
type?: 'commonjs' | 'module' | undefined;
|
|
333
|
-
version: string;
|
|
334
|
-
private?: boolean;
|
|
335
|
-
author?: string | {
|
|
336
|
-
name: string;
|
|
337
|
-
email?: string;
|
|
338
|
-
url?: string;
|
|
339
|
-
};
|
|
340
|
-
name: string;
|
|
341
|
-
description?: string;
|
|
342
|
-
keywords?: string[];
|
|
343
|
-
bin?: Record<string, string>;
|
|
344
|
-
dependencies?: Record<string, string | undefined>;
|
|
345
|
-
devDependencies?: Record<string, string | undefined>;
|
|
346
|
-
peerDependencies?: Record<string, string | undefined>;
|
|
347
|
-
exports?: Record<string, `./${string}.json` | `./${string}.css` | {
|
|
348
|
-
source?: string;
|
|
349
|
-
types?: string;
|
|
350
|
-
browser?: {
|
|
351
|
-
source: string;
|
|
352
|
-
import?: string;
|
|
353
|
-
require?: string;
|
|
354
|
-
};
|
|
355
|
-
node?: {
|
|
356
|
-
source?: string;
|
|
357
|
-
module?: string;
|
|
358
|
-
import?: string;
|
|
359
|
-
require?: string;
|
|
360
|
-
};
|
|
361
|
-
module?: string;
|
|
362
|
-
import?: string;
|
|
363
|
-
require?: string;
|
|
364
|
-
default: string;
|
|
365
|
-
} | {
|
|
366
|
-
types?: string;
|
|
367
|
-
svelte: string;
|
|
368
|
-
default?: string;
|
|
369
|
-
}>;
|
|
370
|
-
main?: string;
|
|
371
|
-
browser?: Record<string, string>;
|
|
372
|
-
source?: string;
|
|
373
|
-
module?: string;
|
|
374
|
-
types?: string;
|
|
375
|
-
typesVersions?: Record<string, Record<string, string[]>>;
|
|
376
|
-
files?: string[];
|
|
377
|
-
scripts?: Record<string, string | undefined>;
|
|
378
|
-
browserslist?: string | string[];
|
|
379
|
-
sideEffects?: boolean | string[];
|
|
380
|
-
engines?: {
|
|
381
|
-
node?: string;
|
|
382
|
-
npm?: string;
|
|
383
|
-
};
|
|
384
|
-
repository?: string | {
|
|
385
|
-
type: 'git';
|
|
386
|
-
url: string;
|
|
387
|
-
};
|
|
388
|
-
bugs?: string | {
|
|
389
|
-
url: string;
|
|
390
|
-
email?: string;
|
|
391
|
-
};
|
|
392
|
-
homepage?: string;
|
|
393
|
-
license?: string;
|
|
394
|
-
}
|
|
395
|
-
/** @internal */
|
|
396
|
-
declare function loadPkg(options: {
|
|
397
|
-
cwd: string;
|
|
398
|
-
}): Promise<PackageJSON>;
|
|
399
|
-
/** @alpha */
|
|
400
|
-
interface Logger {
|
|
401
|
-
log: (...args: unknown[]) => void;
|
|
402
|
-
info: (...args: unknown[]) => void;
|
|
403
|
-
warn: (...args: unknown[]) => void;
|
|
404
|
-
error: (...args: unknown[]) => void;
|
|
405
|
-
success: (...args: unknown[]) => void;
|
|
406
|
-
}
|
|
407
|
-
/** @alpha */
|
|
408
|
-
declare function createLogger(quiet?: boolean): Logger;
|
|
409
|
-
/** @alpha */
|
|
410
|
-
declare function loadPkgWithReporting(options: {
|
|
411
|
-
cwd: string;
|
|
412
|
-
logger: Logger;
|
|
413
|
-
strict: boolean;
|
|
414
|
-
strictOptions: StrictOptions;
|
|
415
|
-
}): Promise<PackageJSON>;
|
|
416
|
-
/** @alpha */
|
|
417
|
-
declare function parseExports(options: {
|
|
418
|
-
cwd: string;
|
|
419
|
-
pkg: PackageJSON;
|
|
420
|
-
strict: boolean;
|
|
421
|
-
strictOptions: StrictOptions;
|
|
422
|
-
logger: Logger;
|
|
423
|
-
}): (PkgExport & {
|
|
424
|
-
_path: string;
|
|
425
|
-
})[];
|
|
426
|
-
/** @public */
|
|
427
|
-
interface PkgTemplateFile {
|
|
428
|
-
name: string;
|
|
429
|
-
contents: string;
|
|
430
|
-
}
|
|
431
262
|
/** @public */
|
|
432
263
|
interface PkgTemplateStringOption<T = string> {
|
|
433
264
|
name: string;
|
|
@@ -440,40 +271,6 @@ interface PkgTemplateStringOption<T = string> {
|
|
|
440
271
|
/** @public */
|
|
441
272
|
type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;
|
|
442
273
|
/** @public */
|
|
443
|
-
interface PkgTemplateDefinition {
|
|
444
|
-
options: PkgTemplateStringOption<any>[];
|
|
445
|
-
features: {
|
|
446
|
-
name: string;
|
|
447
|
-
optional: boolean;
|
|
448
|
-
initial: boolean;
|
|
449
|
-
}[];
|
|
450
|
-
getFiles: (options: Record<string, any>, features: Record<string, boolean>) => Promise<PkgTemplateFile[]>;
|
|
451
|
-
}
|
|
452
|
-
/** @public */
|
|
453
|
-
type PkgTemplateResolver = (options: {
|
|
454
|
-
cwd: string;
|
|
455
|
-
/** @internal */
|
|
456
|
-
logger: Logger;
|
|
457
|
-
packagePath: string;
|
|
458
|
-
}) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;
|
|
459
|
-
/** @public */
|
|
460
|
-
type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;
|
|
461
|
-
/** @public */
|
|
462
274
|
declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
cwd: string;
|
|
466
|
-
path: string;
|
|
467
|
-
}): Promise<void>;
|
|
468
|
-
/** @alpha */
|
|
469
|
-
declare function getExtractMessagesConfig(options: {
|
|
470
|
-
rules: NonNullable<PkgConfigOptions['extract']>['rules'];
|
|
471
|
-
disabled?: boolean;
|
|
472
|
-
}): IExtractorMessagesConfig;
|
|
473
|
-
/** @public */
|
|
474
|
-
declare function watch(options: {
|
|
475
|
-
cwd: string;
|
|
476
|
-
strict?: boolean;
|
|
477
|
-
tsconfig?: string;
|
|
478
|
-
}): Promise<void>;
|
|
479
|
-
export { DEFAULT_BROWSERSLIST_QUERY, PackageJSON, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type PkgTemplate, type PkgTemplateDefinition, type PkgTemplateFile, type PkgTemplateOption, type PkgTemplateResolver, type PkgTemplateStringOption, type RollupPlugin, type TSDocCustomTag, build, check, createLogger, defineConfig, defineTemplateOption, getExtractMessagesConfig, init, loadConfig, loadPkg, loadPkgWithReporting, parseExports, parseStrictOptions, watch };
|
|
275
|
+
export { DEFAULT_BROWSERSLIST_QUERY, type PkgBundle, type PkgConfigOptions, type PkgConfigProperty, type PkgConfigPropertyResolver, type PkgExport, type PkgExports, type PkgFormat, type PkgRuleLevel, type PkgRuntime, type RollupPlugin, type TSDocCustomTag, defineConfig, defineTemplateOption, loadConfig };
|
|
276
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["ToggleType","StrictOptions","parseStrictOptions","PluginItem","BabelPluginItem","OptimizeLodashOptions","PkgExports","Options","VanillaExtractOptions","PluginOptions","ReactCompilerOptions","NormalizedOutputOptions","Plugin","RollupPlugin","TreeshakingOptions","StrictOptions","PkgExport","PkgFormat","PkgRuntime","PkgConfigPropertyResolver","T","PkgConfigProperty","PkgBundle","PkgRuleLevel","TSDocCustomTag","DtsType","PkgConfigOptions","Partial","Record","PkgConfigOptions","defineConfig","T","PkgConfigOptions","loadConfig","Promise","DEFAULT_BROWSERSLIST_QUERY","Logger","PkgTemplateFile","PkgTemplateStringOption","T","Record","PkgTemplateOption","PkgTemplateDefinition","Promise","PkgTemplateResolver","PkgTemplate","PkgTemplateOption","defineTemplateOption","T"],"sources":["../src/node/strict.d.ts","../src/node/core/config/types.d.ts","../src/node/core/config/defineConfig.d.ts","../src/node/core/config/loadConfig.d.ts","../src/node/core/defaults.d.ts","../src/node/core/template/types.d.ts","../src/node/core/template/define.d.ts"],"sourcesContent":["type ToggleType = 'error' | 'warn' | 'off';\n/**\n * @public\n */\nexport interface StrictOptions {\n /**\n * Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.\n * @defaultValue 'error'\n */\n noPackageJsonTypings: ToggleType;\n /**\n * Requires specifying `sideEffects` in `package.json`.\n * @defaultValue 'warn'\n */\n noImplicitSideEffects: ToggleType;\n /**\n * Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:\n * @example\n * ```\n * \"browserslist\": \"extends @sanity/browserslist-config\"\n * ```\n * @defaultValue 'warn'\n */\n noImplicitBrowsersList: ToggleType;\n /**\n * If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon.\n * @defaultValue 'error'\n */\n alwaysPackageJsonTypes: ToggleType;\n /**\n * Using `.npmignore` is error prone, it's best practice to always declare `files` instead\n * @defaultValue 'error'\n */\n alwaysPackageJsonFiles: ToggleType;\n /**\n * It's slow to perform type checking while generating dts files, so it's best practice to disable it with a `\"noCheck\": true` in the tsconfig.json file used by `package.config.ts`\n * @defaultValue 'warn'\n */\n noCheckTypes: ToggleType;\n /**\n * Disallows the `browser` field in `package.json` as the `browser` condition in `exports` is better supported.\n * @defaultValue 'warn'\n */\n noPackageJsonBrowser: ToggleType;\n /**\n * Disallows the `typesVersions` field in `package.json` as TypeScript has long supported conditional exports and the `types` condition.\n * @defaultValue 'warn'\n */\n noPackageJsonTypesVersions: ToggleType;\n /**\n * Warns if `type` field is missing or set to `commonjs`. Future versions will require `\"type\": \"module\"`.\n * @defaultValue 'warn'\n */\n preferModuleType: ToggleType;\n}\n/** @alpha */\nexport declare function parseStrictOptions(input: unknown): StrictOptions;\nexport {};\n//# sourceMappingURL=strict.d.ts.map","import type { PluginItem as BabelPluginItem } from '@babel/core';\nimport type { OptimizeLodashOptions } from '@optimize-lodash/rollup-plugin';\nimport type { PkgExports } from '@sanity/parse-package-json';\nimport type { Options as VanillaExtractOptions } from '@vanilla-extract/rollup-plugin';\nimport type { PluginOptions as ReactCompilerOptions } from 'babel-plugin-react-compiler';\nimport type { NormalizedOutputOptions, Plugin as RollupPlugin, TreeshakingOptions } from 'rollup';\nimport type { StrictOptions } from '../../strict.ts';\nexport type { PkgExport, PkgExports } from '@sanity/parse-package-json';\n/** @public */\nexport type PkgFormat = 'commonjs' | 'esm';\n/** @public */\nexport type PkgRuntime = '*' | 'browser' | 'node';\n/** @public */\nexport type PkgConfigPropertyResolver<T> = (prev: T) => T;\n/** @public */\nexport type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T;\n/** @public */\nexport interface PkgBundle {\n source: string;\n import?: string;\n require?: string;\n runtime?: PkgRuntime;\n}\n/** @public */\nexport type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off';\n/** @public */\nexport interface TSDocCustomTag {\n name: string;\n syntaxKind: 'block' | 'modifier';\n allowMultiple?: boolean;\n}\nexport type DtsType = 'api-extractor' | 'rolldown';\n/** @public */\nexport interface PkgConfigOptions {\n /** @alpha */\n babel?: {\n plugins?: BabelPluginItem[] | null | undefined;\n /** @alpha */\n reactCompiler?: boolean;\n /** @alpha */\n styledComponents?: boolean | {\n /** @defaultValue true */\n displayName?: boolean;\n /**\n * @defaultValue []\n * @example [\"\\@xstyled/styled-components\", \"\\@xstyled/styled-components/*\"]\n */\n topLevelImportPaths?: string[];\n /** @defaultValue true */\n ssr?: boolean;\n /** @defaultValue fale */\n fileName?: boolean;\n /** @defaultValue [\"index\"] */\n meaninglessFileNames?: string[];\n /** @defaultValue true */\n minify?: boolean;\n /** @defaultValue false */\n transpileTemplateLiterals?: boolean;\n namespace?: string;\n /** @defaultValue true */\n pure?: boolean;\n };\n };\n /**\n * Configure the React Compiler.\n * To enable it set `babel.reactCompiler` to `true`\n * @beta */\n reactCompilerOptions?: Partial<ReactCompilerOptions>;\n bundles?: PkgBundle[];\n /** @alpha */\n define?: Record<string, string | number | boolean | undefined | null>;\n /**\n * Directory of distributed & bundled files.\n */\n dist?: string;\n exports?: PkgConfigProperty<PkgExports>;\n /**\n * Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.\n * This is useful for packages that need to be consumed by TSDoc-based tooling.\n * It's enabled by default, it can be disabled by setting `extract: {enabled: false}`\n */\n extract?: {\n /**\n * @defaultValue true\n */\n enabled?: boolean;\n /**\n * Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.\n * You can exclude a package from being bundled by using a callback:\n * ```\n * bundledPackages: (prev) => prev.filter(package => package !== 'sanity')\n * ```\n */\n bundledPackages?: PkgConfigProperty<string[]>;\n customTags?: TSDocCustomTag[];\n rules?: {\n /**\n * @deprecated as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873\n */\n 'ae-forgotten-export'?: never;\n 'ae-incompatible-release-tags'?: PkgRuleLevel;\n 'ae-internal-missing-underscore'?: PkgRuleLevel;\n 'ae-missing-release-tag'?: PkgRuleLevel;\n 'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel;\n 'tsdoc-undefined-tag'?: PkgRuleLevel;\n 'tsdoc-unsupported-tag'?: PkgRuleLevel;\n };\n };\n /**\n * Packages to exclude from bundles.\n * Provide an array to merge with default exclusions, use a function to replace them:\n * ```\n * exclude: (prev) => prev.filter(package => package !== 'foo')\n * ```\n */\n external?: PkgConfigProperty<string[]>;\n /**\n * Defaults to `\"automatic\"`\n */\n jsx?: 'transform' | 'preserve' | 'automatic';\n /**\n * Defaults to `\"createElement\"`\n */\n jsxFactory?: string;\n /**\n * Defaults to `\"Fragment\"`\n */\n jsxFragment?: string;\n /**\n * Defaults to `\"react\"`\n */\n jsxImportSource?: string;\n /**\n * @deprecated no longer supported\n */\n legacyExports?: never;\n minify?: boolean;\n /** @alpha */\n rollup?: {\n plugins?: PkgConfigProperty<RollupPlugin[]>;\n output?: Partial<NormalizedOutputOptions>;\n /**\n * Default options are `preset: 'recommended'` and `propertyReadSideEffects: false`\n * @alpha\n */\n treeshake?: TreeshakingOptions;\n /** @alpha */\n experimentalLogSideEffects?: boolean;\n /**\n * Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.\n * It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.\n * @defaultValue false\n */\n hashChunkFileNames?: boolean;\n /**\n * Optimizes lodash imports using `@optimize-lodash/rollup-plugin` when set to `true`.\n * It's enabled if `lodash` is found in `dependencies` or `peerDependencies`.\n * It will use `lodash-es` for ESM targets if found in `dependencies` or `peerDependencies`.\n * @defaultValue true\n * @alpha\n */\n optimizeLodash?: boolean | OptimizeLodashOptions;\n /**\n * Enables \\@vanilla-extract/rollup-plugin to extract CSS into a separate file, with support for minifying the extracted CSS.\n * @alpha\n */\n vanillaExtract?: boolean | (VanillaExtractOptions & {\n minify?: boolean;\n browserslist?: string | string[];\n });\n };\n /**\n * Default runtime of package exports\n */\n runtime?: PkgRuntime;\n sourcemap?: boolean;\n /**\n * Directory of source files.\n */\n src?: string;\n tsconfig?: string;\n /**\n * Configure what checks are made when running `--strict` builds and checks\n */\n strictOptions?: Partial<StrictOptions>;\n /**\n * .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`.\n * `rolldown` is the faster option, but is not yet stable.\n * @defaultValue 'api-extractor'\n */\n dts?: DtsType;\n /**\n * When using `dts: 'rolldown'`, enables the use of `@typescript/native-preview` for type generation.\n * By default, `tsgo` is automatically enabled if `@typescript/native-preview` is found in `devDependencies`.\n * Set to `true` to explicitly enable or `false` to explicitly disable.\n * @alpha\n */\n tsgo?: boolean;\n}\n//# sourceMappingURL=types.d.ts.map","import type { PkgConfigOptions } from './types.ts';\n/** @public */\nexport declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;\n//# sourceMappingURL=defineConfig.d.ts.map","import type { PkgConfigOptions } from './types.ts';\n/** @alpha */\nexport declare function loadConfig(options: {\n cwd: string;\n pkgPath: string;\n}): Promise<PkgConfigOptions | undefined>;\n//# sourceMappingURL=loadConfig.d.ts.map","/** @public */\nexport declare const DEFAULT_BROWSERSLIST_QUERY: string[];\n//# sourceMappingURL=defaults.d.ts.map","import type { Logger } from '../../logger.ts';\n/** @public */\nexport interface PkgTemplateFile {\n name: string;\n contents: string;\n}\n/** @public */\nexport interface PkgTemplateStringOption<T = string> {\n name: string;\n type: 'string';\n description: string;\n initial?: T | ((options: Record<string, any>) => T);\n parse?: (v: string) => T | null;\n validate?: (v: string) => string | true;\n}\n/** @public */\nexport type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;\n/** @public */\nexport interface PkgTemplateDefinition {\n options: PkgTemplateStringOption<any>[];\n features: {\n name: string;\n optional: boolean;\n initial: boolean;\n }[];\n getFiles: (options: Record<string, any>, features: Record<string, boolean>) => Promise<PkgTemplateFile[]>;\n}\n/** @public */\nexport type PkgTemplateResolver = (options: {\n cwd: string;\n /** @internal */\n logger: Logger;\n packagePath: string;\n}) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;\n/** @public */\nexport type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;\n//# sourceMappingURL=types.d.ts.map","import type { PkgTemplateOption } from './types.ts';\n/** @public */\nexport declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;\n//# sourceMappingURL=define.d.ts.map"],"mappings":";;;;;;KAAKA,UAAAA;;;;UAIYC,aAAAA;;;;AAAjB;EAK0BD,oBAAAA,EAAAA,UAAAA;EAKCA;;;;EAwBTA,qBAAAA,EAxBSA,UAwBTA;EAKQA;;;;;AClC1B;AAEA;AAEA;EAEYqB,sBAAiB,EDQDrB,UCRC;EAAgCoB;;;;EAE5CE,sBAAS,EDWEtB,UCPdkB;EAGFK;AAEZ;AAKA;AAEA;EAGkBnB,sBAAAA,EDHUJ,UCGVI;EA+BiBM;;;;EAQHJ,YAAAA,EDrCdN,UCqCcM;EAA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AA,MAAAA;EAKSD,IAAAA,EAAAA,QAAAA;EAKCA,WAAAA,EAAAA,MAAAA;EASCA,OAAAA,CAAAA,EKZduC,CLYcvC,GAAAA,CAAAA,CAAAA,OAAAA,EKZCwC,MLYDxC,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,EAAAA,GKZyBuC,CLYzBvC,CAAAA;EAKAA,KAAAA,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,MAAAA,EAAAA,GKhBDuC,CLgBCvC,GAAAA,IAAAA;EAKAA,QAAAA,CAAAA,EAAAA,CAAAA,CAAAA,EAAAA,MAAAA,EAAAA,GAAAA,MAAAA,GAAAA,IAAAA;;;AAeIA,KKhCpByC,iBLgCoBzC,CAAAA,IAAAA,MAAAA,CAAAA,GKhCYsC,uBLgCZtC,CKhCoCuC,CLgCpCvC,CAAAA;;iBM9CR+C,gCAAgCD,kBAAkBE,KAAKF,kBAAkBE"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DEFAULT_BROWSERSLIST_QUERY, loadConfig, loadPkg, loadPkgWithReporting, parseExports, parseStrictOptions } from "./_chunks-es/consoleSpy.js";
|
|
4
|
-
import { defineTemplateOption, init } from "./_chunks-es/init.js";
|
|
5
|
-
import { createLogger } from "./_chunks-es/isRecord.js";
|
|
6
|
-
import { getExtractMessagesConfig } from "./_chunks-es/index.js";
|
|
7
|
-
import { watch } from "./_chunks-es/watch.js";
|
|
1
|
+
import { DEFAULT_BROWSERSLIST_QUERY, loadConfig } from "./_chunks-es/defaults.js";
|
|
2
|
+
import { defineTemplateOption } from "./_chunks-es/define.js";
|
|
8
3
|
function defineConfig(configOptions) {
|
|
9
4
|
return configOptions;
|
|
10
5
|
}
|
|
11
6
|
export {
|
|
12
7
|
DEFAULT_BROWSERSLIST_QUERY,
|
|
13
|
-
build,
|
|
14
|
-
check,
|
|
15
|
-
createLogger,
|
|
16
8
|
defineConfig,
|
|
17
9
|
defineTemplateOption,
|
|
18
|
-
|
|
19
|
-
init,
|
|
20
|
-
loadConfig,
|
|
21
|
-
loadPkg,
|
|
22
|
-
loadPkgWithReporting,
|
|
23
|
-
parseExports,
|
|
24
|
-
parseStrictOptions,
|
|
25
|
-
watch
|
|
10
|
+
loadConfig
|
|
26
11
|
};
|
|
27
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/node/core/config/defineConfig.ts"],"sourcesContent":["import type {PkgConfigOptions} from './types.ts'\n\n/** @public */\nexport function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T {\n return configOptions\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/node/core/config/defineConfig.ts"],"sourcesContent":["import type {PkgConfigOptions} from './types.ts'\n\n/** @public */\nexport function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T {\n return configOptions\n}\n"],"names":[],"mappings":";;AAGO,SAAS,aAA+C,eAAqB;AAClF,SAAO;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/pkg-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Simple utilities for modern npm packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity-io",
|
|
@@ -29,13 +29,6 @@
|
|
|
29
29
|
"source": "./src/node/index.ts",
|
|
30
30
|
"default": "./dist/index.js"
|
|
31
31
|
},
|
|
32
|
-
"./tsconfig/recommended.json": "./tsconfig/recommended.json",
|
|
33
|
-
"./tsconfig/recommended": "./tsconfig/recommended.json",
|
|
34
|
-
"./tsconfig/strict.json": "./tsconfig/strict.json",
|
|
35
|
-
"./tsconfig/strict": "./tsconfig/strict.json",
|
|
36
|
-
"./tsconfig/strictest.json": "./tsconfig/strictest.json",
|
|
37
|
-
"./tsconfig/isolated-declarations.json": "./tsconfig/isolated-declarations.json",
|
|
38
|
-
"./tsconfig": "./tsconfig/strictest.json",
|
|
39
32
|
"./package.json": "./package.json"
|
|
40
33
|
},
|
|
41
34
|
"main": "./dist/index.js",
|
|
@@ -72,6 +65,7 @@
|
|
|
72
65
|
"cac": "^6.7.14",
|
|
73
66
|
"chalk": "^5.6.2",
|
|
74
67
|
"chokidar": "^5.0.0",
|
|
68
|
+
"empathic": "^2.0.0",
|
|
75
69
|
"esbuild": "^0.27.0",
|
|
76
70
|
"find-config": "^1.0.0",
|
|
77
71
|
"get-latest-version": "^5.1.0",
|
|
@@ -81,8 +75,7 @@
|
|
|
81
75
|
"lightningcss": "^1.30.2",
|
|
82
76
|
"mkdirp": "^3.0.1",
|
|
83
77
|
"outdent": "^0.8.0",
|
|
84
|
-
"
|
|
85
|
-
"prettier": "^3.7.2",
|
|
78
|
+
"prettier": "^3.7.3",
|
|
86
79
|
"pretty-bytes": "^7.1.0",
|
|
87
80
|
"prompts": "^2.4.2",
|
|
88
81
|
"recast": "^0.23.11",
|
|
@@ -96,13 +89,14 @@
|
|
|
96
89
|
"tsx": "^4.20.6",
|
|
97
90
|
"uuid": "^13.0.0",
|
|
98
91
|
"zod": "^4.1.13",
|
|
99
|
-
"zod-validation-error": "^5.0.0"
|
|
92
|
+
"zod-validation-error": "^5.0.0",
|
|
93
|
+
"@sanity/parse-package-json": "^1.0.0"
|
|
100
94
|
},
|
|
101
95
|
"devDependencies": {
|
|
102
96
|
"@types/babel__core": "^7.20.5",
|
|
103
97
|
"@types/find-config": "^1.0.4",
|
|
104
98
|
"@types/fs-extra": "^11.0.4",
|
|
105
|
-
"@types/node": "
|
|
99
|
+
"@types/node": "24.10.1",
|
|
106
100
|
"@types/prompts": "^2.4.9",
|
|
107
101
|
"@types/semver": "^7.7.1",
|
|
108
102
|
"@types/treeify": "^1.0.3",
|
|
@@ -113,7 +107,8 @@
|
|
|
113
107
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
114
108
|
"semver": "^7.7.3",
|
|
115
109
|
"typescript": "5.9.3",
|
|
116
|
-
"vitest": "^4.0.14"
|
|
110
|
+
"vitest": "^4.0.14",
|
|
111
|
+
"@sanity/tsconfig": "^2.0.0"
|
|
117
112
|
},
|
|
118
113
|
"peerDependencies": {
|
|
119
114
|
"babel-plugin-react-compiler": "*",
|
|
@@ -138,7 +133,6 @@
|
|
|
138
133
|
"extract": "sanity-tsdoc etl --outDir etc/api/@sanity/pkg-utils --tsconfig tsconfig.dist.json",
|
|
139
134
|
"pretest": "pnpm run clean && pnpm run build",
|
|
140
135
|
"test": "vitest run",
|
|
141
|
-
"test:update-snapshots": "pnpm test run -- --update",
|
|
142
136
|
"typecheck": "tsc --build",
|
|
143
137
|
"watch": "tsx scripts/watch.ts"
|
|
144
138
|
}
|
package/dist/_chunks-es/build.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { rimraf } from "rimraf";
|
|
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$1 = 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$1) {
|
|
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
|
-
});
|
|
51
|
-
}
|
|
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$1) {
|
|
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$1) {
|
|
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$1) {
|
|
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$1) {
|
|
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;
|
|
109
|
-
}
|
|
110
|
-
async function build(options) {
|
|
111
|
-
const {
|
|
112
|
-
cwd,
|
|
113
|
-
emitDeclarationOnly,
|
|
114
|
-
strict = !1,
|
|
115
|
-
tsconfig: tsconfigOption,
|
|
116
|
-
clean = !1,
|
|
117
|
-
quiet = !1
|
|
118
|
-
} = options, logger = createLogger(quiet), config = await loadConfig({ cwd }), { parseStrictOptions } = await import("./consoleSpy.js").then(function(n) {
|
|
119
|
-
return n.strict;
|
|
120
|
-
}), strictOptions = parseStrictOptions(config?.strictOptions ?? {}), pkg = await loadPkgWithReporting({ cwd, logger, strict, strictOptions }), tsconfig = tsconfigOption || config?.tsconfig || "tsconfig.json", ctx = await resolveBuildContext({
|
|
121
|
-
config,
|
|
122
|
-
cwd,
|
|
123
|
-
emitDeclarationOnly,
|
|
124
|
-
logger,
|
|
125
|
-
pkg,
|
|
126
|
-
strict,
|
|
127
|
-
tsconfig
|
|
128
|
-
});
|
|
129
|
-
clean && (quiet || logger.log(
|
|
130
|
-
`Deleting the \`dist\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`
|
|
131
|
-
), await rimraf(ctx.distPath));
|
|
132
|
-
const buildTasks = resolveBuildTasks(ctx);
|
|
133
|
-
for (const task of buildTasks) {
|
|
134
|
-
const handler = buildTaskHandlers[task.type], taskName = handler.name(ctx, task), spinner = createSpinner(taskName, quiet);
|
|
135
|
-
try {
|
|
136
|
-
const result = await handler.exec(ctx, task).toPromise();
|
|
137
|
-
spinner.complete(), ctx.logger.log(), handler.complete(ctx, task, result);
|
|
138
|
-
} catch (err) {
|
|
139
|
-
if (spinner.error(), err instanceof Error) {
|
|
140
|
-
const RE_CWD = new RegExp(cwd, "g");
|
|
141
|
-
ctx.logger.error(err.message.replace(RE_CWD, ".")), ctx.logger.log();
|
|
142
|
-
}
|
|
143
|
-
handler.error(ctx, task, err), process.exit(1);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
export {
|
|
148
|
-
build
|
|
149
|
-
};
|
|
150
|
-
//# sourceMappingURL=build.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sources":["../../src/node/resolveBuildTasks.ts","../../src/node/build.ts"],"sourcesContent":["import path from 'node:path'\nimport type {PkgExport, PkgFormat, PkgRuntime} from './core/config/types.ts'\nimport type {BuildContext} from './core/contexts/buildContext.ts'\nimport {getTargetPaths} from './tasks/dts/getTargetPaths.ts'\nimport type {DtsTask} from './tasks/dts/types.ts'\nimport type {BuildTask, RolldownDtsTask, RollupTask, RollupTaskEntry} from './tasks/types.ts'\n\n/** @internal */\nexport function resolveBuildTasks(ctx: BuildContext): BuildTask[] {\n const {config, pkg, target} = ctx\n\n const bundles = config?.bundles || []\n\n const tasks: BuildTask[] = []\n\n const exports = Object.entries(ctx.exports || {}).map(\n ([_path, exp]) => ({_path, ...exp}) as PkgExport & {_path: string},\n )\n\n const dtsTask: DtsTask = {\n type: 'build:dts',\n entries: [],\n }\n\n const rolldownDtsTask: Record<string, RolldownDtsTask> = {}\n const rollupTasks: Record<string, RollupTask> = {}\n\n function addRollupTaskEntry(format: PkgFormat, runtime: PkgRuntime, entry: RollupTaskEntry) {\n const buildId = `${format}:${runtime}`\n\n if (ctx.dts === 'rolldown') {\n if (rolldownDtsTask[buildId]) {\n rolldownDtsTask[buildId].entries.push(entry)\n } else {\n rolldownDtsTask[buildId] = {\n type: 'rolldown:dts',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n\n if (!ctx.emitDeclarationOnly) {\n if (rollupTasks[buildId]) {\n rollupTasks[buildId].entries.push(entry)\n } else {\n rollupTasks[buildId] = {\n type: 'build:js',\n buildId,\n entries: [entry],\n runtime,\n format,\n target: target[runtime],\n }\n }\n }\n }\n\n if (ctx.dts === 'api-extractor') {\n // Parse `dts` tasks\n for (const exp of exports) {\n const importId = path.join(pkg.name, exp._path)\n\n if (exp.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.source,\n targetPaths: getTargetPaths(pkg.type, exp),\n })\n }\n\n if (exp.browser?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.browser.source,\n targetPaths: getTargetPaths(pkg.type, exp.browser),\n })\n }\n\n if (exp.node?.source?.endsWith('.ts')) {\n dtsTask.entries.push({\n importId,\n exportPath: exp._path,\n sourcePath: exp.node.source,\n targetPaths: getTargetPaths(pkg.type, exp.node),\n })\n }\n }\n\n // Handle dts tasks for bundles\n for (const bundle of bundles) {\n if (bundle.source?.endsWith('.ts')) {\n // importId needs to be how the bundle is used, like `@sanity/pkg-utils/dist/cli`\n // exportPath needs to be the path to the bundle, like `./dist/cli`\n // targetPaths is then: [./dist/cli.d.ts, ./dist/cli.d.cts]\n const exportPath = (bundle.import || bundle.require)!.replace(/\\.[mc]?js$/, '')\n const importId = path.join(pkg.name, exportPath)\n\n dtsTask.entries.push({\n importId,\n exportPath,\n sourcePath: bundle.source,\n targetPaths: getTargetPaths(pkg.type, bundle),\n })\n }\n }\n\n // Add dts task\n if (dtsTask.entries.length) {\n tasks.push(dtsTask)\n }\n }\n\n // Parse rollup:commonjs:* tasks\n for (const exp of exports) {\n const output = exp.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:* tasks\n for (const exp of exports) {\n const output = exp.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', ctx.runtime, {\n path: exp._path,\n source: exp.source,\n output,\n })\n }\n\n // Parse rollup:commonjs:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.require\n\n if (!output) continue\n\n addRollupTaskEntry('commonjs', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n // Parse rollup:esm:browser tasks\n for (const exp of exports) {\n const output = exp.browser?.import\n\n if (!output) continue\n\n addRollupTaskEntry('esm', 'browser', {\n path: exp._path,\n source: exp.browser?.source || exp.source,\n output,\n })\n }\n\n for (const bundle of bundles) {\n const idx = bundles.indexOf(bundle)\n\n if (bundle.require) {\n addRollupTaskEntry('commonjs', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_cjs_${idx}$$__`,\n source: bundle.source,\n output: bundle.require,\n })\n }\n\n if (bundle.import) {\n addRollupTaskEntry('esm', bundle.runtime || ctx.runtime, {\n path: `__$$bundle_esm_${idx}$$__`,\n source: bundle.source,\n output: bundle.import,\n })\n }\n }\n\n // Perform rolldown dts tasks first, as they have special logic for removing non .d.ts chunks\n tasks.push(...Object.values(rolldownDtsTask))\n // Then run api-extractor tsdoc release tag checking (if rolldown is used for dts bundling, otherwise api-extractor performs both in the build:dts task)\n // @TODO\n // Then run rollup tasks\n tasks.push(...Object.values(rollupTasks))\n\n return tasks\n}\n","import path from 'node:path'\nimport {rimraf} from 'rimraf'\nimport {loadConfig} from './core/config/loadConfig.ts'\nimport {loadPkgWithReporting} from './core/pkg/loadPkgWithReporting.ts'\nimport {createLogger} from './logger.ts'\nimport {resolveBuildContext} from './resolveBuildContext.ts'\nimport {resolveBuildTasks} from './resolveBuildTasks.ts'\nimport {createSpinner} from './spinner.ts'\nimport {buildTaskHandlers} from './tasks/index.ts'\nimport {type BuildTask, type TaskHandler} from './tasks/types.ts'\n\n/**\n * Build the distribution files of a npm package.\n *\n * @example\n * ```ts\n * import {build} from '@sanity/pkg-utils'\n *\n * build({\n * cwd: process.cwd(),\n * tsconfig: 'tsconfig.dist.json,\n * }).then(() => {\n * console.log('successfully built')\n * }).catch((err) => {\n * console.log(`build error: ${err.message}`)\n * })\n * ```\n *\n * @public\n */\nexport async function build(options: {\n cwd: string\n emitDeclarationOnly?: boolean\n strict?: boolean\n tsconfig?: string\n clean?: boolean\n quiet?: boolean\n}): Promise<void> {\n const {\n cwd,\n emitDeclarationOnly,\n strict = false,\n tsconfig: tsconfigOption,\n clean = false,\n quiet = false,\n } = options\n const logger = createLogger(quiet)\n\n const config = await loadConfig({cwd})\n\n const {parseStrictOptions} = await import('./strict.ts')\n const strictOptions = parseStrictOptions(config?.strictOptions ?? {})\n const pkg = await loadPkgWithReporting({cwd, logger, strict, strictOptions})\n\n const tsconfig = tsconfigOption || config?.tsconfig || 'tsconfig.json'\n\n const ctx = await resolveBuildContext({\n config,\n cwd,\n emitDeclarationOnly,\n logger,\n pkg,\n strict,\n tsconfig,\n })\n\n if (clean) {\n if (!quiet) {\n logger.log(\n `Deleting the \\`dist\\` folder: './${path.relative(cwd, ctx.distPath)}' before building...`,\n )\n }\n await rimraf(ctx.distPath)\n }\n\n const buildTasks = resolveBuildTasks(ctx)\n\n for (const task of buildTasks) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- TypeScript can't infer the correct handler type from discriminated union\n const handler = buildTaskHandlers[task.type] as TaskHandler<BuildTask>\n const taskName = handler.name(ctx, task)\n\n const spinner = createSpinner(taskName, quiet)\n\n try {\n const result = await handler.exec(ctx, task).toPromise()\n\n spinner.complete()\n ctx.logger.log()\n\n handler.complete(ctx, task, result)\n } catch (err) {\n spinner.error()\n\n if (err instanceof Error) {\n const RE_CWD = new RegExp(cwd, 'g')\n\n ctx.logger.error(err.message.replace(RE_CWD, '.'))\n ctx.logger.log()\n }\n\n handler.error(ctx, task, err)\n\n process.exit(1)\n }\n }\n}\n"],"names":["exports"],"mappings":";;;;;;AAQO,SAAS,kBAAkB,KAAgC;AAChE,QAAM,EAAC,QAAQ,KAAK,OAAA,IAAU,KAExB,UAAU,QAAQ,WAAW,CAAA,GAE7B,QAAqB,CAAA,GAErBA,YAAU,OAAO,QAAQ,IAAI,WAAW,CAAA,CAAE,EAAE;AAAA,IAChD,CAAC,CAAC,OAAO,GAAG,OAAO,EAAC,OAAO,GAAG,IAAA;AAAA,EAAG,GAG7B,UAAmB;AAAA,IACvB,MAAM;AAAA,IACN,SA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