@savvy-web/tsdown-plugins 2.2.2 → 2.4.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/README.md +1 -1
- package/build/build-target-groups.js +14 -2
- package/catalog/resolve-catalogs.js +1 -1
- package/changesets/next-versions.js +5 -2
- package/config-validation/ConfigValidator.js +58 -2
- package/dts/resolved-tsconfig.js +65 -13
- package/entry/package-json-entries.js +2 -1
- package/index.d.ts +50 -107
- package/index.js +5 -10
- package/jsx/config.js +4 -11
- package/meta/generate.js +2 -1
- package/meta/tsconfig-resolver.js +5 -225
- package/meta/tsdoc-config.js +2 -1
- package/package.json +5 -5
- package/report/issues-artifact.js +1 -1
- package/report/pipeline.js +2 -6
- package/report/services/EnvironmentDetector.js +11 -2
- package/report/services/ExecutorResolver.js +4 -2
- package/report/services/FormatSelector.js +4 -2
- package/report/services/OutputRenderer.js +19 -2
- package/tsconfig/sync-options.js +21 -0
- package/config-validation/ConfigValidatorLive.js +0 -67
- package/report/layers/EnvironmentDetectorLive.js +0 -16
- package/report/layers/ExecutorResolverLive.js +0 -9
- package/report/layers/FormatSelectorLive.js +0 -9
- package/report/layers/OutputRendererLive.js +0 -24
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ export default defineConfig({
|
|
|
46
46
|
- **Multi-target resolution** — `resolveTargets` turns a `publishConfig.targets` map into the distinct byte-variant groups to build and the registry bindings for each; `writeTargetsBinding` persists that resolution as `dist/prod/targets.json` for the release step.
|
|
47
47
|
- **JSX resolution** — `resolveJsxConfig` and `readTsconfigJsx` derive the effective JSX transform from a package's tsconfig, with an explicit override winning. The tsconfig is read through a loader that honors JSONC syntax and `extends` chains, so a `jsx` setting inherited from a base config resolves.
|
|
48
48
|
- **Executable binaries** — `normalizeExeOptions` fills the SEA defaults and infers targets from the package's `os`/`cpu`; `runExeBuild` drives `@tsdown/exe` to compile the binaries.
|
|
49
|
-
- **Config validation** — the `ConfigValidator` Effect service (with `
|
|
49
|
+
- **Config validation** — the `ConfigValidator` Effect service (with `ConfigValidator.layer`) fast-fails on a bad `publishConfig.targets`, `exe` or `meta` config, raising the typed `ConfigValidationError`.
|
|
50
50
|
- **dts tsconfig port** — `buildResolvedTsconfig` and `writeResolvedTsconfig` write a temp tsconfig with absolute paths so type declarations emit cleanly under pnpm symlinks.
|
|
51
51
|
- **Per-target build loop** — `deriveTargetGroupOptions` and `buildTargetGroups` map a target to its `tsdown` options and run the build once per target, exposed as a helper so the escape hatch gets multi-target builds too. A `format` of `["esm", "cjs"]` (the `BuildFormat` type) derives a dual-format build — a require-able CJS output with default-export interop and `.d.cts` declarations alongside the ESM one. The `bundleNodeModules`, `bundledPackages` and `dtsExternals` options thread the dependency-bundling posture into both the JS and declaration passes. A per-entry override partition can also set `platform` (the JS-pass target, `"browser"` for a client bundle), `css` (forwarded to tsdown's `css` option for `@tsdown/css`) and `outSubdir` (build the partition into an isolated `<group>/pkg/<subdir>/` sub-package). The `define` option forwards compile-time global replacements to both passes, merged with an auto-injected `process.env.__PACKAGE_VERSION__` constant.
|
|
52
52
|
- **Loose files** — `normalizeLooseFiles` resolves a `LooseFiles` map of literal output filenames to `NormalizedLooseFile` descriptors, inferring the module format from each `.mjs`/`.cjs` key and raising `ConfigValidationError` on a path separator, an unsupported extension or an ambiguous `.js`. `buildTargetGroups` takes the normalized form as its `looseFiles` option and emits one extra single-entry, bundled, declaration-free and manifest-free pass per file per target group, inheriting the group's bundling posture so each file is self-contained.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { analyzeReexportBarrel, collectExportNames, renderReexportStub } from "../dts/reexport-stub.js";
|
|
2
2
|
import { writeDtsEmitTsconfig } from "../dts/resolved-tsconfig.js";
|
|
3
|
+
import { extractAmbientDts } from "../entry/ambient-dts.js";
|
|
3
4
|
import { emitManifest } from "../manifest/emit-manifest.js";
|
|
4
5
|
import { buildMetricsPlugin } from "../report/metrics-plugin.js";
|
|
5
6
|
import { createTimer } from "../report/timer.js";
|
|
6
7
|
import { createTsdownLogger } from "../report/tsdown-logger.js";
|
|
7
8
|
import { cjsDefaultInterop } from "./cjs-default-interop.js";
|
|
8
9
|
import { nodeBuiltinDefaultInterop } from "./node-builtin-default-interop.js";
|
|
9
|
-
import { copyPublicDir } from "./sync-public.js";
|
|
10
|
+
import { copyAmbientDts, copyPublicDir } from "./sync-public.js";
|
|
10
11
|
import { deriveDeclarationsPassOptions, deriveDtsPassOptions, deriveTargetGroupOptions, outDirFor } from "./target-groups.js";
|
|
11
12
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
12
13
|
import { dirname, isAbsolute, join } from "node:path";
|
|
@@ -44,6 +45,11 @@ const STUB_BASE_ENTRY = "index";
|
|
|
44
45
|
async function buildTargetGroups(options) {
|
|
45
46
|
const build = options.build ?? (await import("tsdown")).build;
|
|
46
47
|
const publicDir = join(options.cwd, "public");
|
|
48
|
+
let pkgForAmbient = {};
|
|
49
|
+
try {
|
|
50
|
+
pkgForAmbient = JSON.parse(readFileSync(join(options.cwd, "package.json"), "utf-8"));
|
|
51
|
+
} catch {}
|
|
52
|
+
const ambient = extractAmbientDts(pkgForAmbient, {});
|
|
47
53
|
const dtsEmitTsconfigPath = writeDtsEmitTsconfig(options.tsconfigPath);
|
|
48
54
|
const collector = options.collector;
|
|
49
55
|
const verbose = options.verbose ?? false;
|
|
@@ -315,7 +321,13 @@ async function buildTargetGroups(options) {
|
|
|
315
321
|
]
|
|
316
322
|
}));
|
|
317
323
|
}
|
|
318
|
-
|
|
324
|
+
const groupOutDir = outDirFor(options.cwd, group.id);
|
|
325
|
+
copyPublicDir(publicDir, groupOutDir);
|
|
326
|
+
if (ambient.length > 0) copyAmbientDts({
|
|
327
|
+
ambient,
|
|
328
|
+
srcCwd: options.cwd,
|
|
329
|
+
outDir: groupOutDir
|
|
330
|
+
});
|
|
319
331
|
}
|
|
320
332
|
}
|
|
321
333
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Manifest } from "@effected/npm";
|
|
2
|
+
import { Effect, Layer } from "effect";
|
|
2
3
|
import { NodeFileSystem, NodePath } from "@effect/platform-node";
|
|
3
4
|
import { Workspaces } from "@effected/workspaces";
|
|
4
|
-
import { Effect, Layer } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/catalog/resolve-catalogs.ts
|
|
7
7
|
/** Bound once: the platform layer is stateless and layers memoize by reference. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
1
2
|
import { NodeFileSystem, NodePath } from "@effect/platform-node";
|
|
2
3
|
import { WorkspaceDiscovery, Workspaces } from "@effected/workspaces";
|
|
3
|
-
import { Effect, Layer } from "effect";
|
|
4
4
|
import { getReleasePlan } from "@changesets/get-release-plan";
|
|
5
5
|
|
|
6
6
|
//#region src/changesets/next-versions.ts
|
|
@@ -29,7 +29,10 @@ async function resolveNextVersions(cwd) {
|
|
|
29
29
|
}
|
|
30
30
|
try {
|
|
31
31
|
const plan = await getReleasePlan(rootDir);
|
|
32
|
-
for (const r of plan.releases)
|
|
32
|
+
for (const r of plan.releases) {
|
|
33
|
+
if (r.newVersion === void 0) continue;
|
|
34
|
+
versions.set(r.name, r.newVersion);
|
|
35
|
+
}
|
|
33
36
|
} catch {}
|
|
34
37
|
return {
|
|
35
38
|
root: rootDir,
|
|
@@ -1,12 +1,68 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigValidationError } from "../errors.js";
|
|
2
|
+
import { normalizeLooseFiles } from "../build/loose-files.js";
|
|
3
|
+
import { normalizeExeOptions } from "../exe/config.js";
|
|
4
|
+
import { resolveTargets } from "../targets/resolve-targets.js";
|
|
5
|
+
import { existsSync, statSync } from "node:fs";
|
|
6
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
7
|
|
|
3
8
|
//#region src/config-validation/ConfigValidator.ts
|
|
9
|
+
const VALID_SYNTAX_KINDS = /* @__PURE__ */ new Set([
|
|
10
|
+
"block",
|
|
11
|
+
"inline",
|
|
12
|
+
"modifier"
|
|
13
|
+
]);
|
|
14
|
+
/** Synchronous rule set; throws ConfigValidationError on the first violation. */
|
|
15
|
+
function check(input) {
|
|
16
|
+
if (input.targets !== void 0 && Object.keys(input.targets).length > 0) resolveTargets({
|
|
17
|
+
targets: input.targets,
|
|
18
|
+
baseName: input.baseName
|
|
19
|
+
});
|
|
20
|
+
if (input.exe !== void 0) {
|
|
21
|
+
const specs = normalizeExeOptions(input.exe, input.osCpu ?? {
|
|
22
|
+
os: [],
|
|
23
|
+
cpu: []
|
|
24
|
+
});
|
|
25
|
+
for (const spec of specs) {
|
|
26
|
+
if (spec.fileName.trim() === "") throw new ConfigValidationError({
|
|
27
|
+
path: "exe.fileName",
|
|
28
|
+
reason: "an exe binary needs a non-empty fileName"
|
|
29
|
+
});
|
|
30
|
+
if (spec.targets.length === 0) throw new ConfigValidationError({
|
|
31
|
+
path: `exe.${spec.fileName}.targets`,
|
|
32
|
+
reason: "no targets: the package declares no os/cpu and the exe config states none"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (input.meta !== void 0) {
|
|
37
|
+
if (!input.hasExports) throw new ConfigValidationError({
|
|
38
|
+
path: "meta",
|
|
39
|
+
reason: "meta requires an exports map to extract an api-model from"
|
|
40
|
+
});
|
|
41
|
+
for (const tag of input.meta.tsdoc?.tagDefinitions ?? []) if (!VALID_SYNTAX_KINDS.has(tag.syntaxKind)) throw new ConfigValidationError({
|
|
42
|
+
path: "meta.tsdoc.tagDefinitions",
|
|
43
|
+
reason: `tag "${tag.tagName}" has an invalid syntaxKind "${tag.syntaxKind}"`
|
|
44
|
+
});
|
|
45
|
+
for (const p of input.meta.localPaths ?? []) if (existsSync(p) && !statSync(p).isDirectory()) throw new ConfigValidationError({
|
|
46
|
+
path: "meta.localPaths",
|
|
47
|
+
reason: `"${p}" exists but is not a directory`
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (input.looseFiles !== void 0) normalizeLooseFiles(input.looseFiles);
|
|
51
|
+
}
|
|
4
52
|
/**
|
|
5
53
|
* Fast-fail config validator; runs first in the bundler over the resolved config.
|
|
6
54
|
*
|
|
7
55
|
* @public
|
|
8
56
|
*/
|
|
9
|
-
var ConfigValidator = class extends Context.Service()("@savvy-web/tsdown-plugins/ConfigValidator") {
|
|
57
|
+
var ConfigValidator = class extends Context.Service()("@savvy-web/tsdown-plugins/ConfigValidator") {
|
|
58
|
+
static layer = Layer.succeed(this, { validate: (input) => Effect.try({
|
|
59
|
+
try: () => check(input),
|
|
60
|
+
catch: (e) => e instanceof ConfigValidationError ? e : new ConfigValidationError({
|
|
61
|
+
path: "config",
|
|
62
|
+
reason: String(e)
|
|
63
|
+
})
|
|
64
|
+
}) });
|
|
65
|
+
};
|
|
10
66
|
|
|
11
67
|
//#endregion
|
|
12
68
|
export { ConfigValidator };
|
package/dts/resolved-tsconfig.js
CHANGED
|
@@ -1,28 +1,80 @@
|
|
|
1
|
+
import { tsconfigSyncOptions } from "../tsconfig/sync-options.js";
|
|
1
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { isAbsolute, join, resolve } from "node:path";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
5
|
+
import { TsconfigLoaderSync } from "@effected/tsconfig-json";
|
|
4
6
|
|
|
5
7
|
//#region src/dts/resolved-tsconfig.ts
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* The dts-pass deltas layered over whatever the package's own tsconfig declares. The shared
|
|
10
|
+
* `ecma.json` base sets `composite`/`incremental` true and points `tsBuildInfoFile` at a build
|
|
11
|
+
* info file; the declaration pass must never skip emit on stale build info, so all three are
|
|
12
|
+
* forced off here. `declarationMap` is forced on for the emitted maps. `declaration` and
|
|
13
|
+
* `emitDeclarationOnly` are forced on/off respectively because this pass's entire job is
|
|
14
|
+
* emitting declarations — it cannot honor a consumer's `declaration: false`; TypeScript's
|
|
15
|
+
* emitter asserts (`Debug Failure` in `getSourceMappingURL`) when `declarationMap` is
|
|
16
|
+
* requested without `declaration`.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
const DTS_OVERLAY = {
|
|
21
|
+
declaration: true,
|
|
22
|
+
declarationMap: true,
|
|
23
|
+
emitDeclarationOnly: false,
|
|
24
|
+
composite: false,
|
|
25
|
+
incremental: false,
|
|
26
|
+
tsBuildInfoFile: void 0
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The compiler options used when a package has no own `tsconfig.json` — today's synthesized
|
|
30
|
+
* defaults, preserved verbatim. The e2e `leaf` / `leaf-escape` fixtures build without one, so
|
|
31
|
+
* absence is a supported case, not an error.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
function fallbackCompilerOptions(cwd) {
|
|
36
|
+
return {
|
|
37
|
+
declaration: true,
|
|
38
|
+
emitDeclarationOnly: false,
|
|
39
|
+
rootDir: cwd,
|
|
40
|
+
outDir: join(cwd, "dist"),
|
|
41
|
+
declarationDir: join(cwd, "dist"),
|
|
42
|
+
typeRoots: [join(cwd, "node_modules/@types"), join(cwd, "types")],
|
|
43
|
+
types: ["node"]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build the portable absolute-path tsconfig object for the dts pass.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* Resolves the package's own `<cwd>/tsconfig.json` (which extends the shared
|
|
51
|
+
* `ecma.json` base) through `@effected/tsconfig-json`'s `TsconfigLoaderSync`, so the
|
|
52
|
+
* result carries the package's real effective options — target, module, lib, strict,
|
|
53
|
+
* jsx — with `${configDir}` already substituted to absolute paths. Only the dts-pass
|
|
54
|
+
* overlay (composite/incremental/tsBuildInfoFile forced off, declarationMap forced on)
|
|
55
|
+
* and an explicit jsx override are layered on top.
|
|
56
|
+
*
|
|
57
|
+
* `include`/`exclude` are NOT taken from the resolved config. The shared base includes
|
|
58
|
+
* `__test__` and `lib` sources, which have no business in a declaration program; the
|
|
59
|
+
* narrow list below is dts-pass-specific and deliberately held fixed.
|
|
8
60
|
*
|
|
9
61
|
* @public
|
|
10
62
|
*/
|
|
11
63
|
function buildResolvedTsconfig(options) {
|
|
12
64
|
const cwd = options.cwd;
|
|
65
|
+
const ownConfig = join(cwd, "tsconfig.json");
|
|
66
|
+
let base;
|
|
67
|
+
if (existsSync(ownConfig)) try {
|
|
68
|
+
base = { ...TsconfigLoaderSync.resolve(ownConfig, tsconfigSyncOptions).compilerOptions };
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
71
|
+
throw new Error(`Cannot resolve tsconfig at ${ownConfig}: ${message}`, { cause: error });
|
|
72
|
+
}
|
|
73
|
+
else base = fallbackCompilerOptions(cwd);
|
|
13
74
|
return {
|
|
14
75
|
compilerOptions: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
declarationMap: true,
|
|
18
|
-
rootDir: cwd,
|
|
19
|
-
outDir: join(cwd, "dist"),
|
|
20
|
-
declarationDir: join(cwd, "dist"),
|
|
21
|
-
typeRoots: [join(cwd, "node_modules/@types"), join(cwd, "types")],
|
|
22
|
-
types: options.types ? [...options.types] : ["node"],
|
|
23
|
-
composite: false,
|
|
24
|
-
incremental: false,
|
|
25
|
-
tsBuildInfoFile: void 0,
|
|
76
|
+
...base,
|
|
77
|
+
...DTS_OVERLAY,
|
|
26
78
|
...options.jsx !== void 0 ? { jsx: options.jsx } : {},
|
|
27
79
|
...options.jsxImportSource !== void 0 ? { jsxImportSource: options.jsxImportSource } : {}
|
|
28
80
|
},
|
|
@@ -30,7 +82,7 @@ function buildResolvedTsconfig(options) {
|
|
|
30
82
|
join(cwd, "src/**/*.ts"),
|
|
31
83
|
join(cwd, "src/**/*.mts"),
|
|
32
84
|
join(cwd, "src/**/*.tsx"),
|
|
33
|
-
join(cwd, "types/*.ts"),
|
|
85
|
+
join(cwd, "types/*.d.ts"),
|
|
34
86
|
join(cwd, "package.json")
|
|
35
87
|
],
|
|
36
88
|
exclude: [join(cwd, "node_modules"), join(cwd, "dist/**/*")]
|
|
@@ -9,7 +9,8 @@ import { resolve } from "node:path";
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
function packageJsonEntries(options = {}) {
|
|
12
|
-
|
|
12
|
+
const pkg = options.pkg ?? JSON.parse(readFileSync(resolve(options.cwd ?? process.cwd(), "package.json"), "utf-8"));
|
|
13
|
+
return extractEntries(pkg, {
|
|
13
14
|
exportsAsIndexes: options.exportsAsIndexes,
|
|
14
15
|
excludeSources: options.excludeSources
|
|
15
16
|
}).entries;
|
package/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { CatalogAssemblyError, DependencyResolutionError, ManifestDecodeError, UnresolvedDependencyError } from "@effected/npm";
|
|
10
10
|
import { Plugin } from "rolldown";
|
|
11
11
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
12
|
-
import { JsxEmit, ModuleDetectionKind, ModuleKind, ModuleResolutionKind, NewLineKind, ParsedCommandLine, ScriptTarget } from "typescript";
|
|
13
12
|
//#region src/manifest/transform.d.ts
|
|
14
13
|
/** @public */
|
|
15
14
|
type Json = Record<string, unknown>;
|
|
@@ -494,8 +493,13 @@ interface CssOptions {
|
|
|
494
493
|
}
|
|
495
494
|
/**
|
|
496
495
|
* One entry partition built with its own format + bundling posture, layered into the
|
|
497
|
-
* SAME outDir as the base build (clean:false).
|
|
498
|
-
*
|
|
496
|
+
* SAME outDir as the base build (clean:false). Each partition is built from ITS OWN values
|
|
497
|
+
* only — an option this override omits is simply absent for this partition, not inherited
|
|
498
|
+
* from the base build (partition 0 in `buildTargetGroups`). Callers that want a base-build
|
|
499
|
+
* value to also apply to an override must pass it again explicitly. This is relied upon
|
|
500
|
+
* deliberately by at least one consumer: `packages/silk/savvy.build.ts` has an override that
|
|
501
|
+
* depends on NOT inheriting the base build's externals. `entry` is a subset of the package's
|
|
502
|
+
* entries (`entryName -> source path`).
|
|
499
503
|
* @public
|
|
500
504
|
*/
|
|
501
505
|
interface EntryOverride {
|
|
@@ -1204,15 +1208,9 @@ declare const ConfigValidator_base: Context.ServiceClass<ConfigValidator, "@savv
|
|
|
1204
1208
|
*
|
|
1205
1209
|
* @public
|
|
1206
1210
|
*/
|
|
1207
|
-
declare class ConfigValidator extends ConfigValidator_base {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
/**
|
|
1211
|
-
* Live ConfigValidator: wraps the synchronous rule set, surfacing ConfigValidationError as a typed Effect failure.
|
|
1212
|
-
*
|
|
1213
|
-
* @public
|
|
1214
|
-
*/
|
|
1215
|
-
declare const ConfigValidatorLive: Layer.Layer<ConfigValidator, never, never>;
|
|
1211
|
+
declare class ConfigValidator extends ConfigValidator_base {
|
|
1212
|
+
static readonly layer: Layer.Layer<ConfigValidator>;
|
|
1213
|
+
}
|
|
1216
1214
|
//#endregion
|
|
1217
1215
|
//#region src/dts/reexport-stub.d.ts
|
|
1218
1216
|
/**
|
|
@@ -1285,11 +1283,9 @@ declare function findRelativeSpecifiers(source: string, fileName?: string): stri
|
|
|
1285
1283
|
interface ResolvedTsconfigOptions {
|
|
1286
1284
|
/** Absolute package root. */
|
|
1287
1285
|
readonly cwd: string;
|
|
1288
|
-
/**
|
|
1289
|
-
readonly types?: ReadonlyArray<string> | undefined;
|
|
1290
|
-
/** TS `compilerOptions.jsx` to forward into the dts tsconfig (e.g. "react-jsx"). */
|
|
1286
|
+
/** TS `compilerOptions.jsx` override (e.g. "react-jsx"); wins over the resolved config. */
|
|
1291
1287
|
readonly jsx?: string | undefined;
|
|
1292
|
-
/** TS `compilerOptions.jsxImportSource`
|
|
1288
|
+
/** TS `compilerOptions.jsxImportSource` override (e.g. "react"); wins over the resolved config. */
|
|
1293
1289
|
readonly jsxImportSource?: string | undefined;
|
|
1294
1290
|
}
|
|
1295
1291
|
/** @public */
|
|
@@ -1299,7 +1295,19 @@ interface ResolvedTsconfig {
|
|
|
1299
1295
|
readonly exclude: ReadonlyArray<string>;
|
|
1300
1296
|
}
|
|
1301
1297
|
/**
|
|
1302
|
-
* Build the portable absolute-path tsconfig object
|
|
1298
|
+
* Build the portable absolute-path tsconfig object for the dts pass.
|
|
1299
|
+
*
|
|
1300
|
+
* @remarks
|
|
1301
|
+
* Resolves the package's own `<cwd>/tsconfig.json` (which extends the shared
|
|
1302
|
+
* `ecma.json` base) through `@effected/tsconfig-json`'s `TsconfigLoaderSync`, so the
|
|
1303
|
+
* result carries the package's real effective options — target, module, lib, strict,
|
|
1304
|
+
* jsx — with `${configDir}` already substituted to absolute paths. Only the dts-pass
|
|
1305
|
+
* overlay (composite/incremental/tsBuildInfoFile forced off, declarationMap forced on)
|
|
1306
|
+
* and an explicit jsx override are layered on top.
|
|
1307
|
+
*
|
|
1308
|
+
* `include`/`exclude` are NOT taken from the resolved config. The shared base includes
|
|
1309
|
+
* `__test__` and `lib` sources, which have no business in a declaration program; the
|
|
1310
|
+
* narrow list below is dts-pass-specific and deliberately held fixed.
|
|
1303
1311
|
*
|
|
1304
1312
|
* @public
|
|
1305
1313
|
*/
|
|
@@ -1567,63 +1575,6 @@ interface PortableTsconfig {
|
|
|
1567
1575
|
/** Compiler options with enum values converted to strings. */
|
|
1568
1576
|
compilerOptions: ResolvedCompilerOptions;
|
|
1569
1577
|
}
|
|
1570
|
-
/**
|
|
1571
|
-
* Resolves a TypeScript `ParsedCommandLine` to a portable, JSON-serializable
|
|
1572
|
-
* tsconfig (compilerOptions-only) for virtual TypeScript environments.
|
|
1573
|
-
*
|
|
1574
|
-
* @remarks
|
|
1575
|
-
* Converts TypeScript's internal enum representation back to portable JSON
|
|
1576
|
-
* suitable for tooling that needs type information without emitting files:
|
|
1577
|
-
*
|
|
1578
|
-
* - Converts enum values (target, module, moduleResolution, jsx, etc.) to strings.
|
|
1579
|
-
* - Converts lib references from full paths (`lib.esnext.d.ts`) to short names (`esnext`).
|
|
1580
|
-
* - Forces `composite: false` and `noEmit: true`.
|
|
1581
|
-
* - Excludes path-dependent options (rootDir, outDir, baseUrl, paths, typeRoots, types).
|
|
1582
|
-
* - Excludes emit-related options (declaration, sourceMap, etc.).
|
|
1583
|
-
* - Excludes file selection (include, exclude, files, references).
|
|
1584
|
-
* - Adds `$schema` for IDE support.
|
|
1585
|
-
*
|
|
1586
|
-
* @public
|
|
1587
|
-
*/
|
|
1588
|
-
declare class TsconfigResolver {
|
|
1589
|
-
/** @internal */
|
|
1590
|
-
private static readonly SCRIPT_TARGET_MAP;
|
|
1591
|
-
/** @internal */
|
|
1592
|
-
private static readonly MODULE_KIND_MAP;
|
|
1593
|
-
/** @internal */
|
|
1594
|
-
private static readonly MODULE_RESOLUTION_MAP;
|
|
1595
|
-
/** @internal */
|
|
1596
|
-
private static readonly JSX_EMIT_MAP;
|
|
1597
|
-
/** @internal */
|
|
1598
|
-
private static readonly MODULE_DETECTION_MAP;
|
|
1599
|
-
/** @internal */
|
|
1600
|
-
private static readonly NEW_LINE_MAP;
|
|
1601
|
-
/** Converts a `ScriptTarget` enum value to its string form (e.g. `es2023`). */
|
|
1602
|
-
static convertScriptTarget(target: ScriptTarget | undefined): string | undefined;
|
|
1603
|
-
/** Converts a `ModuleKind` enum value to its string form (e.g. `nodenext`). */
|
|
1604
|
-
static convertModuleKind(module: ModuleKind | undefined): string | undefined;
|
|
1605
|
-
/** Converts a `ModuleResolutionKind` enum value to its string form (e.g. `nodenext`). */
|
|
1606
|
-
static convertModuleResolution(resolution: ModuleResolutionKind | undefined): string | undefined;
|
|
1607
|
-
/** Converts a `JsxEmit` enum value to its string form (e.g. `preserve`, `react-jsx`). */
|
|
1608
|
-
static convertJsxEmit(jsx: JsxEmit | undefined): string | undefined;
|
|
1609
|
-
/** Converts a `ModuleDetectionKind` enum value to its string form (e.g. `force`). */
|
|
1610
|
-
static convertModuleDetection(detection: ModuleDetectionKind | undefined): string | undefined;
|
|
1611
|
-
/** Converts a `NewLineKind` enum value to its string form (`lf` or `crlf`). */
|
|
1612
|
-
static convertNewLine(newLine: NewLineKind | undefined): string | undefined;
|
|
1613
|
-
/**
|
|
1614
|
-
* Converts a lib reference to its canonical short name.
|
|
1615
|
-
*
|
|
1616
|
-
* @remarks
|
|
1617
|
-
* `ParsedCommandLine` stores lib references as full paths like `lib.esnext.d.ts`
|
|
1618
|
-
* or `/path/to/typescript/lib/lib.dom.d.ts`. This returns the short tsconfig form
|
|
1619
|
-
* (`esnext`, `dom`).
|
|
1620
|
-
*/
|
|
1621
|
-
static convertLibReference(lib: string): string;
|
|
1622
|
-
/**
|
|
1623
|
-
* Resolves a parsed TypeScript config to a portable, compilerOptions-only tsconfig.
|
|
1624
|
-
*/
|
|
1625
|
-
resolve(parsed: ParsedCommandLine): PortableTsconfig;
|
|
1626
|
-
}
|
|
1627
1578
|
/**
|
|
1628
1579
|
* Resolves the package's effective compiler options (following `extends`) into a
|
|
1629
1580
|
* portable, JSON-serializable tsconfig for the meta release bundle.
|
|
@@ -1780,6 +1731,17 @@ declare function writeIssuesArtifact(opts: {
|
|
|
1780
1731
|
} | undefined;
|
|
1781
1732
|
}): string;
|
|
1782
1733
|
//#endregion
|
|
1734
|
+
//#region src/report/metrics-plugin.d.ts
|
|
1735
|
+
/**
|
|
1736
|
+
* Rolldown plugin that records emitted-file metrics into the BuildCollector via writeBundle (which
|
|
1737
|
+
* fires for the JS pass AND the emitDtsOnly dts pass — verified against tsdown 0.22.3), plus a
|
|
1738
|
+
* defensive onLog for rolldown-level diagnostics that bypass tsdown's logger. Append it to each
|
|
1739
|
+
* build pass's `plugins` array. `bytes` is taken from the in-memory chunk/asset content (no fs);
|
|
1740
|
+
* `gzip` is computed only when `verbose`.
|
|
1741
|
+
* @public
|
|
1742
|
+
*/
|
|
1743
|
+
declare function buildMetricsPlugin(collector: BuildCollector, groupId: string, pass: PassKind, verbose: boolean): Plugin;
|
|
1744
|
+
//#endregion
|
|
1783
1745
|
//#region src/report/services/EnvironmentDetector.d.ts
|
|
1784
1746
|
/** @public */
|
|
1785
1747
|
type Environment = "agent-shell" | "terminal" | "ci-github" | "ci-generic";
|
|
@@ -1787,11 +1749,9 @@ declare const EnvironmentDetector_base: Context.ServiceClass<EnvironmentDetector
|
|
|
1787
1749
|
readonly detect: () => Effect.Effect<Environment>;
|
|
1788
1750
|
}>;
|
|
1789
1751
|
/** @public */
|
|
1790
|
-
declare class EnvironmentDetector extends EnvironmentDetector_base {
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
/** @public */
|
|
1794
|
-
declare const EnvironmentDetectorLive: Layer.Layer<EnvironmentDetector, never, never>;
|
|
1752
|
+
declare class EnvironmentDetector extends EnvironmentDetector_base {
|
|
1753
|
+
static readonly layer: Layer.Layer<EnvironmentDetector>;
|
|
1754
|
+
}
|
|
1795
1755
|
//#endregion
|
|
1796
1756
|
//#region src/report/services/ExecutorResolver.d.ts
|
|
1797
1757
|
/** @public */
|
|
@@ -1800,11 +1760,9 @@ declare const ExecutorResolver_base: Context.ServiceClass<ExecutorResolver, "@sa
|
|
|
1800
1760
|
readonly resolve: (env: Environment) => Effect.Effect<Executor>;
|
|
1801
1761
|
}>;
|
|
1802
1762
|
/** @public */
|
|
1803
|
-
declare class ExecutorResolver extends ExecutorResolver_base {
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
/** @public */
|
|
1807
|
-
declare const ExecutorResolverLive: Layer.Layer<ExecutorResolver, never, never>;
|
|
1763
|
+
declare class ExecutorResolver extends ExecutorResolver_base {
|
|
1764
|
+
static readonly layer: Layer.Layer<ExecutorResolver>;
|
|
1765
|
+
}
|
|
1808
1766
|
//#endregion
|
|
1809
1767
|
//#region src/report/services/FormatSelector.d.ts
|
|
1810
1768
|
/** @public */
|
|
@@ -1813,37 +1771,22 @@ declare const FormatSelector_base: Context.ServiceClass<FormatSelector, "@savvy-
|
|
|
1813
1771
|
readonly select: (executor: Executor, explicit?: OutputFormat, env?: Environment) => Effect.Effect<OutputFormat>;
|
|
1814
1772
|
}>;
|
|
1815
1773
|
/** @public */
|
|
1816
|
-
declare class FormatSelector extends FormatSelector_base {
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
/** @public */
|
|
1820
|
-
declare const FormatSelectorLive: Layer.Layer<FormatSelector, never, never>;
|
|
1774
|
+
declare class FormatSelector extends FormatSelector_base {
|
|
1775
|
+
static readonly layer: Layer.Layer<FormatSelector>;
|
|
1776
|
+
}
|
|
1821
1777
|
//#endregion
|
|
1822
1778
|
//#region src/report/services/OutputRenderer.d.ts
|
|
1823
1779
|
declare const OutputRenderer_base: Context.ServiceClass<OutputRenderer, "@savvy-web/tsdown-plugins/OutputRenderer", {
|
|
1824
1780
|
readonly render: (reports: ReadonlyArray<BuildReport>, format: OutputFormat, ctx: FormatterContext) => Effect.Effect<ReadonlyArray<RenderedOutput>>;
|
|
1825
1781
|
}>;
|
|
1826
1782
|
/** @public */
|
|
1827
|
-
declare class OutputRenderer extends OutputRenderer_base {
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
/** @public */
|
|
1831
|
-
declare const OutputRendererLive: Layer.Layer<OutputRenderer, never, never>;
|
|
1832
|
-
//#endregion
|
|
1833
|
-
//#region src/report/metrics-plugin.d.ts
|
|
1834
|
-
/**
|
|
1835
|
-
* Rolldown plugin that records emitted-file metrics into the BuildCollector via writeBundle (which
|
|
1836
|
-
* fires for the JS pass AND the emitDtsOnly dts pass — verified against tsdown 0.22.3), plus a
|
|
1837
|
-
* defensive onLog for rolldown-level diagnostics that bypass tsdown's logger. Append it to each
|
|
1838
|
-
* build pass's `plugins` array. `bytes` is taken from the in-memory chunk/asset content (no fs);
|
|
1839
|
-
* `gzip` is computed only when `verbose`.
|
|
1840
|
-
* @public
|
|
1841
|
-
*/
|
|
1842
|
-
declare function buildMetricsPlugin(collector: BuildCollector, groupId: string, pass: PassKind, verbose: boolean): Plugin;
|
|
1783
|
+
declare class OutputRenderer extends OutputRenderer_base {
|
|
1784
|
+
static readonly layer: Layer.Layer<OutputRenderer>;
|
|
1785
|
+
}
|
|
1843
1786
|
//#endregion
|
|
1844
1787
|
//#region src/report/pipeline.d.ts
|
|
1845
1788
|
/** @public */
|
|
1846
|
-
declare const
|
|
1789
|
+
declare const ReportPipeline: Layer.Layer<EnvironmentDetector | ExecutorResolver | FormatSelector | OutputRenderer, never, never>;
|
|
1847
1790
|
/** @public */
|
|
1848
1791
|
interface RenderReportOptions {
|
|
1849
1792
|
readonly explicitFormat?: OutputFormat;
|
|
@@ -1913,5 +1856,5 @@ declare function resolveTargets(options: {
|
|
|
1913
1856
|
baseName: string;
|
|
1914
1857
|
}): TargetResolution;
|
|
1915
1858
|
//#endregion
|
|
1916
|
-
export { type AmbientDtsEntry, BuildCollector, BuildCollectorTag, type BuildEmittedManifestOptions, type BuildFormat, type BuildGroupSpec, type BuildIssues, type BuildPlatform, type BuildReport, BuildReport as BuildReportSchema, type BuildTargetGroupsOptions, CatalogAssemblyError, CiAnnotationsFormatter, ConfigValidationError, ConfigValidator,
|
|
1859
|
+
export { type AmbientDtsEntry, BuildCollector, BuildCollectorTag, type BuildEmittedManifestOptions, type BuildFormat, type BuildGroupSpec, type BuildIssues, type BuildPlatform, type BuildReport, BuildReport as BuildReportSchema, type BuildTargetGroupsOptions, CatalogAssemblyError, CiAnnotationsFormatter, ConfigValidationError, ConfigValidator, type CopyAmbientDtsOptions, type CssOptions, DEFAULT_EXE_NODE_VERSION, DependencyResolutionError, type DeriveOptions, type DerivedTsdownOptions, type DiagnosticEntry, type DiagnosticInput, type DtsExportClass, type DualExports, type EmitManifestOptions, type EmittedFile, type EntryOverride, type Environment, EnvironmentDetector, type ExeBuild, type ExeConfig, type ExeRewrite, type ExeSeaConfig, type ExeTarget, type ExeTargetInput, type Executor, ExecutorResolver, type ExtractAmbientOptions, type ExtractOptions, type ExtractResult, FormatSelector, type Formatter, type FormatterContext, type GenerateMetaOptions, type Json, JsonFormatter, type JsxConfig, type LooseFileSpec, type LooseFiles, ManifestDecodeError, type ManifestLike, MarkdownFormatter, MetaGenerationError, type MetaOptions, type MetaResult, type ModuleExportNames, type NextVersions, type NormalizedExe, type NormalizedLooseFile, type NormalizedMeta, type OutputFormat, OutputRenderer, type PackageJsonEntriesOptions, type PackageJsonLike, type PassKind, type PassReport, type PkgOsCpu, type PlainDiagnostic, type PortableTsconfig, type PublishTargetObject, type PublishTargetValue, type PublishTargets, type ReexportBarrelAnalysis, type RenderReportOptions, type RenderedOutput, ReportPipeline, ReportTimings, type ResolvedCompilerOptions, type ResolvedGroup, type ResolvedTarget, type ResolvedTsconfig, type ResolvedTsconfigOptions, type RunExeBuildOptions, type RunMetaPassOptions, SilentFormatter, type TargetGroupId, type TargetGroupRef, type TargetGroupReport, TargetGroupReport as TargetGroupReportSchema, type TargetResolution, TerminalFormatter, type Timer, type TransformManifestOptions, type TsconfigJsx, type TsdocOptions, type TsdocTagDefinition, type TsdownBuild, type TsdownLogger, UnresolvedDependencyError, type ValidationInput, type WarningSuppressionRule, ambientOutName, analyzeReexportBarrel, applySubdirMetaEntries, assertNoEntryCollisions, buildEmittedManifest, buildMetricsPlugin, buildResolvedTsconfig, buildTargetGroups, cjsDefaultInterop, classifyDtsExport, collectExportNames, computeExeFileName, copyAmbientDts, copyPublicDir, createEntryName, createTimer, createTsdownLogger, declarationExt, defaultManifestTransform, deriveExportPaths, deriveTargetGroupOptions, emitManifest, extractAmbientDts, extractEntries, findRelativeSpecifiers, flattenIssues, formatTime, generateMeta, isTargetObject, mixedDtsExportError, nodeBuiltinDefaultInterop, normalizeBinPaths, normalizeExeOptions, normalizeLooseFiles, normalizeMetaOptions, packageJsonEntries, readTsconfigJsx, removeDeclarationMaps, renderReexportStub, renderReport, resolveJsxConfig, resolveManifest, resolveNextVersions, resolvePortableTsconfig, resolveTargets, rewriteMetaVersions, runExeBuild, runMetaPass, serializeIssues, transformBin, transformExports, transformManifest, writeDtsEmitTsconfig, writeIssuesArtifact, writeResolvedTsconfig, writeTargetsBinding };
|
|
1917
1860
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { analyzeReexportBarrel, collectExportNames, renderReexportStub } from "./dts/reexport-stub.js";
|
|
2
2
|
import { buildResolvedTsconfig, writeDtsEmitTsconfig, writeResolvedTsconfig } from "./dts/resolved-tsconfig.js";
|
|
3
|
-
import { resolveManifest } from "./catalog/resolve-catalogs.js";
|
|
4
3
|
import { ConfigValidationError, MetaGenerationError } from "./errors.js";
|
|
5
4
|
import { createEntryName, extractEntries } from "./entry/extract.js";
|
|
6
5
|
import { ambientOutName, assertNoEntryCollisions, classifyDtsExport, declarationExt, extractAmbientDts, mixedDtsExportError } from "./entry/ambient-dts.js";
|
|
6
|
+
import { resolveManifest } from "./catalog/resolve-catalogs.js";
|
|
7
7
|
import { defaultManifestTransform, normalizeBinPaths, transformBin, transformExports, transformManifest } from "./manifest/transform.js";
|
|
8
8
|
import { buildEmittedManifest, emitManifest } from "./manifest/emit-manifest.js";
|
|
9
9
|
import { buildMetricsPlugin } from "./report/metrics-plugin.js";
|
|
@@ -18,17 +18,16 @@ import { buildTargetGroups } from "./build/build-target-groups.js";
|
|
|
18
18
|
import { normalizeLooseFiles } from "./build/loose-files.js";
|
|
19
19
|
import { removeDeclarationMaps } from "./build/strip-maps.js";
|
|
20
20
|
import { resolveNextVersions } from "./changesets/next-versions.js";
|
|
21
|
-
import { ConfigValidator } from "./config-validation/ConfigValidator.js";
|
|
22
21
|
import { DEFAULT_EXE_NODE_VERSION, normalizeExeOptions } from "./exe/config.js";
|
|
23
22
|
import { isTargetObject } from "./targets/config.js";
|
|
24
23
|
import { resolveTargets } from "./targets/resolve-targets.js";
|
|
25
|
-
import {
|
|
24
|
+
import { ConfigValidator } from "./config-validation/ConfigValidator.js";
|
|
26
25
|
import { packageJsonEntries } from "./entry/package-json-entries.js";
|
|
27
26
|
import { runExeBuild } from "./exe/build.js";
|
|
28
27
|
import { computeExeFileName } from "./exe/filename.js";
|
|
29
28
|
import { readTsconfigJsx, resolveJsxConfig } from "./jsx/config.js";
|
|
30
29
|
import { normalizeMetaOptions } from "./meta/config.js";
|
|
31
|
-
import {
|
|
30
|
+
import { resolvePortableTsconfig } from "./meta/tsconfig-resolver.js";
|
|
32
31
|
import { generateMeta } from "./meta/generate.js";
|
|
33
32
|
import { rewriteMetaVersions } from "./meta/optimistic.js";
|
|
34
33
|
import { applySubdirMetaEntries, deriveExportPaths, runMetaPass } from "./meta/run-pass.js";
|
|
@@ -41,15 +40,11 @@ import { SilentFormatter } from "./report/formatters/silent.js";
|
|
|
41
40
|
import { TerminalFormatter } from "./report/formatters/terminal.js";
|
|
42
41
|
import { flattenIssues, serializeIssues, writeIssuesArtifact } from "./report/issues-artifact.js";
|
|
43
42
|
import { EnvironmentDetector } from "./report/services/EnvironmentDetector.js";
|
|
44
|
-
import { EnvironmentDetectorLive } from "./report/layers/EnvironmentDetectorLive.js";
|
|
45
43
|
import { ExecutorResolver } from "./report/services/ExecutorResolver.js";
|
|
46
|
-
import { ExecutorResolverLive } from "./report/layers/ExecutorResolverLive.js";
|
|
47
44
|
import { FormatSelector } from "./report/services/FormatSelector.js";
|
|
48
|
-
import { FormatSelectorLive } from "./report/layers/FormatSelectorLive.js";
|
|
49
45
|
import { OutputRenderer } from "./report/services/OutputRenderer.js";
|
|
50
|
-
import {
|
|
51
|
-
import { ReportPipelineLive, renderReport } from "./report/pipeline.js";
|
|
46
|
+
import { ReportPipeline, renderReport } from "./report/pipeline.js";
|
|
52
47
|
import { writeTargetsBinding } from "./targets/binding.js";
|
|
53
48
|
import { CatalogAssemblyError, DependencyResolutionError, ManifestDecodeError, UnresolvedDependencyError } from "@effected/npm";
|
|
54
49
|
|
|
55
|
-
export { BuildCollector, BuildCollectorTag, BuildReport as BuildReportSchema, CatalogAssemblyError, CiAnnotationsFormatter, ConfigValidationError, ConfigValidator,
|
|
50
|
+
export { BuildCollector, BuildCollectorTag, BuildReport as BuildReportSchema, CatalogAssemblyError, CiAnnotationsFormatter, ConfigValidationError, ConfigValidator, DEFAULT_EXE_NODE_VERSION, DependencyResolutionError, EnvironmentDetector, ExecutorResolver, FormatSelector, JsonFormatter, ManifestDecodeError, MarkdownFormatter, MetaGenerationError, OutputRenderer, ReportPipeline, ReportTimings, SilentFormatter, TargetGroupReport as TargetGroupReportSchema, TerminalFormatter, UnresolvedDependencyError, ambientOutName, analyzeReexportBarrel, applySubdirMetaEntries, assertNoEntryCollisions, buildEmittedManifest, buildMetricsPlugin, buildResolvedTsconfig, buildTargetGroups, cjsDefaultInterop, classifyDtsExport, collectExportNames, computeExeFileName, copyAmbientDts, copyPublicDir, createEntryName, createTimer, createTsdownLogger, declarationExt, defaultManifestTransform, deriveExportPaths, deriveTargetGroupOptions, emitManifest, extractAmbientDts, extractEntries, findRelativeSpecifiers, flattenIssues, formatTime, generateMeta, isTargetObject, mixedDtsExportError, nodeBuiltinDefaultInterop, normalizeBinPaths, normalizeExeOptions, normalizeLooseFiles, normalizeMetaOptions, packageJsonEntries, readTsconfigJsx, removeDeclarationMaps, renderReexportStub, renderReport, resolveJsxConfig, resolveManifest, resolveNextVersions, resolvePortableTsconfig, resolveTargets, rewriteMetaVersions, runExeBuild, runMetaPass, serializeIssues, transformBin, transformExports, transformManifest, writeDtsEmitTsconfig, writeIssuesArtifact, writeResolvedTsconfig, writeTargetsBinding };
|
package/jsx/config.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tsconfigSyncOptions } from "../tsconfig/sync-options.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
2
3
|
import * as nodePath from "node:path";
|
|
3
|
-
import { Option } from "effect";
|
|
4
4
|
import { JsxConfig, TsconfigLoaderSync } from "@effected/tsconfig-json";
|
|
5
|
+
import { Option } from "effect";
|
|
5
6
|
|
|
6
7
|
//#region src/jsx/config.ts
|
|
7
8
|
/**
|
|
@@ -27,14 +28,6 @@ function resolveJsxConfig(tsconfig, override) {
|
|
|
27
28
|
})
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
/** The consumer-supplied sync operations for the tsconfig loader. @internal */
|
|
31
|
-
const syncOptions = {
|
|
32
|
-
fileSystem: {
|
|
33
|
-
exists: existsSync,
|
|
34
|
-
readFile: (p) => readFileSync(p, "utf8")
|
|
35
|
-
},
|
|
36
|
-
path: nodePath
|
|
37
|
-
};
|
|
38
31
|
/**
|
|
39
32
|
* Read the jsx-relevant compilerOptions from a package's own tsconfig.json (best-effort;
|
|
40
33
|
* returns empty on absence or parse error). Resolved through `@effected/tsconfig-json`'s
|
|
@@ -45,7 +38,7 @@ function readTsconfigJsx(cwd) {
|
|
|
45
38
|
const path = nodePath.join(cwd, "tsconfig.json");
|
|
46
39
|
if (!existsSync(path)) return {};
|
|
47
40
|
try {
|
|
48
|
-
const co = TsconfigLoaderSync.compilerOptions(path,
|
|
41
|
+
const co = TsconfigLoaderSync.compilerOptions(path, tsconfigSyncOptions);
|
|
49
42
|
return {
|
|
50
43
|
...co.jsx !== void 0 ? { jsx: co.jsx } : {},
|
|
51
44
|
...co.jsxImportSource !== void 0 ? { jsxImportSource: co.jsxImportSource } : {}
|
package/meta/generate.js
CHANGED
|
@@ -41,7 +41,8 @@ async function generateMeta(options) {
|
|
|
41
41
|
});
|
|
42
42
|
for (const entryName of entryNames) {
|
|
43
43
|
const modelEntryDts = join(dtsDir, `${entries[entryName]}.d.ts`);
|
|
44
|
-
const
|
|
44
|
+
const safeEntry = entryName.replace(/[\\/]/g, "__");
|
|
45
|
+
const perEntryApiJson = join(outMetaDir, `${safeEntry}.entry.api.json`);
|
|
45
46
|
intermediateApiJsons.push(perEntryApiJson);
|
|
46
47
|
const isMain = (exportPaths[entryName] ?? (entryName === "index" ? "." : `./${entryName}`)) === ".";
|
|
47
48
|
const captureRollupOnlyFatal = splitDiagnostics && onMessage !== void 0 && ci !== true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tsconfigSyncOptions } from "../tsconfig/sync-options.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
2
3
|
import * as nodePath from "node:path";
|
|
3
|
-
import { JsxEmit, ModuleDetectionKind, ModuleKind, ModuleResolutionKind, NewLineKind, ScriptTarget } from "typescript";
|
|
4
4
|
import { PortableTsconfig, TsconfigLoaderSync } from "@effected/tsconfig-json";
|
|
5
5
|
|
|
6
6
|
//#region src/meta/tsconfig-resolver.ts
|
|
@@ -10,226 +10,6 @@ import { PortableTsconfig, TsconfigLoaderSync } from "@effected/tsconfig-json";
|
|
|
10
10
|
*/
|
|
11
11
|
const TSCONFIG_SCHEMA_URL = "https://json.schemastore.org/tsconfig";
|
|
12
12
|
/**
|
|
13
|
-
* Boolean compiler options preserved in the portable config.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* These options affect type checking and module semantics without producing
|
|
17
|
-
* build artifacts. Emit-related options are excluded.
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
const PRESERVED_BOOLEAN_OPTIONS = [
|
|
22
|
-
"strict",
|
|
23
|
-
"strictNullChecks",
|
|
24
|
-
"strictFunctionTypes",
|
|
25
|
-
"strictBindCallApply",
|
|
26
|
-
"strictPropertyInitialization",
|
|
27
|
-
"noImplicitAny",
|
|
28
|
-
"noImplicitThis",
|
|
29
|
-
"alwaysStrict",
|
|
30
|
-
"noUnusedLocals",
|
|
31
|
-
"noUnusedParameters",
|
|
32
|
-
"exactOptionalPropertyTypes",
|
|
33
|
-
"noImplicitReturns",
|
|
34
|
-
"noFallthroughCasesInSwitch",
|
|
35
|
-
"noUncheckedIndexedAccess",
|
|
36
|
-
"noImplicitOverride",
|
|
37
|
-
"noPropertyAccessFromIndexSignature",
|
|
38
|
-
"allowUnusedLabels",
|
|
39
|
-
"allowUnreachableCode",
|
|
40
|
-
"esModuleInterop",
|
|
41
|
-
"allowSyntheticDefaultImports",
|
|
42
|
-
"forceConsistentCasingInFileNames",
|
|
43
|
-
"resolveJsonModule",
|
|
44
|
-
"isolatedModules",
|
|
45
|
-
"verbatimModuleSyntax",
|
|
46
|
-
"skipLibCheck",
|
|
47
|
-
"skipDefaultLibCheck",
|
|
48
|
-
"downlevelIteration",
|
|
49
|
-
"importHelpers",
|
|
50
|
-
"preserveConstEnums",
|
|
51
|
-
"isolatedDeclarations",
|
|
52
|
-
"allowImportingTsExtensions",
|
|
53
|
-
"rewriteRelativeImportExtensions",
|
|
54
|
-
"allowArbitraryExtensions",
|
|
55
|
-
"useDefineForClassFields",
|
|
56
|
-
"noLib",
|
|
57
|
-
"preserveSymlinks"
|
|
58
|
-
];
|
|
59
|
-
/**
|
|
60
|
-
* String compiler options preserved in the portable config.
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
const PRESERVED_STRING_OPTIONS = [
|
|
64
|
-
"jsxFactory",
|
|
65
|
-
"jsxFragmentFactory",
|
|
66
|
-
"jsxImportSource",
|
|
67
|
-
"reactNamespace"
|
|
68
|
-
];
|
|
69
|
-
/**
|
|
70
|
-
* Resolves a TypeScript `ParsedCommandLine` to a portable, JSON-serializable
|
|
71
|
-
* tsconfig (compilerOptions-only) for virtual TypeScript environments.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* Converts TypeScript's internal enum representation back to portable JSON
|
|
75
|
-
* suitable for tooling that needs type information without emitting files:
|
|
76
|
-
*
|
|
77
|
-
* - Converts enum values (target, module, moduleResolution, jsx, etc.) to strings.
|
|
78
|
-
* - Converts lib references from full paths (`lib.esnext.d.ts`) to short names (`esnext`).
|
|
79
|
-
* - Forces `composite: false` and `noEmit: true`.
|
|
80
|
-
* - Excludes path-dependent options (rootDir, outDir, baseUrl, paths, typeRoots, types).
|
|
81
|
-
* - Excludes emit-related options (declaration, sourceMap, etc.).
|
|
82
|
-
* - Excludes file selection (include, exclude, files, references).
|
|
83
|
-
* - Adds `$schema` for IDE support.
|
|
84
|
-
*
|
|
85
|
-
* @public
|
|
86
|
-
*/
|
|
87
|
-
var TsconfigResolver = class TsconfigResolver {
|
|
88
|
-
/** @internal */
|
|
89
|
-
static SCRIPT_TARGET_MAP = /* @__PURE__ */ new Map([
|
|
90
|
-
[ScriptTarget.ES5, "es5"],
|
|
91
|
-
[ScriptTarget.ES2015, "es2015"],
|
|
92
|
-
[ScriptTarget.ES2016, "es2016"],
|
|
93
|
-
[ScriptTarget.ES2017, "es2017"],
|
|
94
|
-
[ScriptTarget.ES2018, "es2018"],
|
|
95
|
-
[ScriptTarget.ES2019, "es2019"],
|
|
96
|
-
[ScriptTarget.ES2020, "es2020"],
|
|
97
|
-
[ScriptTarget.ES2021, "es2021"],
|
|
98
|
-
[ScriptTarget.ES2022, "es2022"],
|
|
99
|
-
[ScriptTarget.ES2023, "es2023"],
|
|
100
|
-
[ScriptTarget.ES2024, "es2024"],
|
|
101
|
-
[ScriptTarget.ES2025, "es2025"],
|
|
102
|
-
[ScriptTarget.ESNext, "esnext"],
|
|
103
|
-
[ScriptTarget.JSON, "json"]
|
|
104
|
-
]);
|
|
105
|
-
/** @internal */
|
|
106
|
-
static MODULE_KIND_MAP = /* @__PURE__ */ new Map([
|
|
107
|
-
[ModuleKind.CommonJS, "commonjs"],
|
|
108
|
-
[ModuleKind.ES2015, "es2015"],
|
|
109
|
-
[ModuleKind.ES2020, "es2020"],
|
|
110
|
-
[ModuleKind.ES2022, "es2022"],
|
|
111
|
-
[ModuleKind.ESNext, "esnext"],
|
|
112
|
-
[ModuleKind.Node16, "node16"],
|
|
113
|
-
[101, "node18"],
|
|
114
|
-
[102, "node20"],
|
|
115
|
-
[ModuleKind.NodeNext, "nodenext"],
|
|
116
|
-
[ModuleKind.Preserve, "preserve"]
|
|
117
|
-
]);
|
|
118
|
-
/** @internal */
|
|
119
|
-
static MODULE_RESOLUTION_MAP = /* @__PURE__ */ new Map([
|
|
120
|
-
[ModuleResolutionKind.Node10, "node10"],
|
|
121
|
-
[ModuleResolutionKind.Node16, "node16"],
|
|
122
|
-
[ModuleResolutionKind.NodeNext, "nodenext"],
|
|
123
|
-
[ModuleResolutionKind.Bundler, "bundler"]
|
|
124
|
-
]);
|
|
125
|
-
/** @internal */
|
|
126
|
-
static JSX_EMIT_MAP = /* @__PURE__ */ new Map([
|
|
127
|
-
[JsxEmit.None, "none"],
|
|
128
|
-
[JsxEmit.Preserve, "preserve"],
|
|
129
|
-
[JsxEmit.React, "react"],
|
|
130
|
-
[JsxEmit.ReactNative, "react-native"],
|
|
131
|
-
[JsxEmit.ReactJSX, "react-jsx"],
|
|
132
|
-
[JsxEmit.ReactJSXDev, "react-jsxdev"]
|
|
133
|
-
]);
|
|
134
|
-
/** @internal */
|
|
135
|
-
static MODULE_DETECTION_MAP = /* @__PURE__ */ new Map([
|
|
136
|
-
[ModuleDetectionKind.Legacy, "legacy"],
|
|
137
|
-
[ModuleDetectionKind.Auto, "auto"],
|
|
138
|
-
[ModuleDetectionKind.Force, "force"]
|
|
139
|
-
]);
|
|
140
|
-
/** @internal */
|
|
141
|
-
static NEW_LINE_MAP = /* @__PURE__ */ new Map([[NewLineKind.CarriageReturnLineFeed, "crlf"], [NewLineKind.LineFeed, "lf"]]);
|
|
142
|
-
/** Converts a `ScriptTarget` enum value to its string form (e.g. `es2023`). */
|
|
143
|
-
static convertScriptTarget(target) {
|
|
144
|
-
if (target === void 0) return void 0;
|
|
145
|
-
const mapped = TsconfigResolver.SCRIPT_TARGET_MAP.get(target);
|
|
146
|
-
if (mapped !== void 0) return mapped;
|
|
147
|
-
return `es${target}`;
|
|
148
|
-
}
|
|
149
|
-
/** Converts a `ModuleKind` enum value to its string form (e.g. `nodenext`). */
|
|
150
|
-
static convertModuleKind(module) {
|
|
151
|
-
if (module === void 0) return void 0;
|
|
152
|
-
const mapped = TsconfigResolver.MODULE_KIND_MAP.get(module);
|
|
153
|
-
if (mapped !== void 0) return mapped;
|
|
154
|
-
return String(module);
|
|
155
|
-
}
|
|
156
|
-
/** Converts a `ModuleResolutionKind` enum value to its string form (e.g. `nodenext`). */
|
|
157
|
-
static convertModuleResolution(resolution) {
|
|
158
|
-
if (resolution === void 0) return void 0;
|
|
159
|
-
const mapped = TsconfigResolver.MODULE_RESOLUTION_MAP.get(resolution);
|
|
160
|
-
if (mapped !== void 0) return mapped;
|
|
161
|
-
return String(resolution);
|
|
162
|
-
}
|
|
163
|
-
/** Converts a `JsxEmit` enum value to its string form (e.g. `preserve`, `react-jsx`). */
|
|
164
|
-
static convertJsxEmit(jsx) {
|
|
165
|
-
if (jsx === void 0) return void 0;
|
|
166
|
-
const mapped = TsconfigResolver.JSX_EMIT_MAP.get(jsx);
|
|
167
|
-
if (mapped !== void 0) return mapped;
|
|
168
|
-
return String(jsx);
|
|
169
|
-
}
|
|
170
|
-
/** Converts a `ModuleDetectionKind` enum value to its string form (e.g. `force`). */
|
|
171
|
-
static convertModuleDetection(detection) {
|
|
172
|
-
if (detection === void 0) return void 0;
|
|
173
|
-
const mapped = TsconfigResolver.MODULE_DETECTION_MAP.get(detection);
|
|
174
|
-
if (mapped !== void 0) return mapped;
|
|
175
|
-
return String(detection);
|
|
176
|
-
}
|
|
177
|
-
/** Converts a `NewLineKind` enum value to its string form (`lf` or `crlf`). */
|
|
178
|
-
static convertNewLine(newLine) {
|
|
179
|
-
if (newLine === void 0) return void 0;
|
|
180
|
-
const mapped = TsconfigResolver.NEW_LINE_MAP.get(newLine);
|
|
181
|
-
if (mapped !== void 0) return mapped;
|
|
182
|
-
return String(newLine);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Converts a lib reference to its canonical short name.
|
|
186
|
-
*
|
|
187
|
-
* @remarks
|
|
188
|
-
* `ParsedCommandLine` stores lib references as full paths like `lib.esnext.d.ts`
|
|
189
|
-
* or `/path/to/typescript/lib/lib.dom.d.ts`. This returns the short tsconfig form
|
|
190
|
-
* (`esnext`, `dom`).
|
|
191
|
-
*/
|
|
192
|
-
static convertLibReference(lib) {
|
|
193
|
-
return (lib.includes("/") || lib.includes("\\") ? lib.split(/[\\/]/).pop() ?? lib : lib).replace(/^lib\./, "").replace(/\.d\.ts$/, "");
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Resolves a parsed TypeScript config to a portable, compilerOptions-only tsconfig.
|
|
197
|
-
*/
|
|
198
|
-
resolve(parsed) {
|
|
199
|
-
const opts = parsed.options;
|
|
200
|
-
const compilerOptions = {};
|
|
201
|
-
if (opts.target !== void 0) compilerOptions.target = TsconfigResolver.convertScriptTarget(opts.target);
|
|
202
|
-
if (opts.module !== void 0) compilerOptions.module = TsconfigResolver.convertModuleKind(opts.module);
|
|
203
|
-
if (opts.moduleResolution !== void 0) compilerOptions.moduleResolution = TsconfigResolver.convertModuleResolution(opts.moduleResolution);
|
|
204
|
-
if (opts.moduleDetection !== void 0) compilerOptions.moduleDetection = TsconfigResolver.convertModuleDetection(opts.moduleDetection);
|
|
205
|
-
if (opts.jsx !== void 0) compilerOptions.jsx = TsconfigResolver.convertJsxEmit(opts.jsx);
|
|
206
|
-
if (opts.newLine !== void 0) compilerOptions.newLine = TsconfigResolver.convertNewLine(opts.newLine);
|
|
207
|
-
if (opts.lib && opts.lib.length > 0) compilerOptions.lib = opts.lib.map(TsconfigResolver.convertLibReference);
|
|
208
|
-
compilerOptions.composite = false;
|
|
209
|
-
compilerOptions.noEmit = true;
|
|
210
|
-
for (const opt of PRESERVED_BOOLEAN_OPTIONS) if (opts[opt] !== void 0) compilerOptions[opt] = opts[opt];
|
|
211
|
-
for (const opt of PRESERVED_STRING_OPTIONS) if (opts[opt] !== void 0) compilerOptions[opt] = opts[opt];
|
|
212
|
-
return {
|
|
213
|
-
$schema: TSCONFIG_SCHEMA_URL,
|
|
214
|
-
compilerOptions
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* The consumer-supplied sync operations backing {@link resolvePortableTsconfig}:
|
|
220
|
-
* Node's `existsSync`/`readFileSync` satisfy the loader's `SyncFileSystem`, and
|
|
221
|
-
* `node:path` satisfies `SyncPath` verbatim.
|
|
222
|
-
*
|
|
223
|
-
* @internal
|
|
224
|
-
*/
|
|
225
|
-
const syncOptions = {
|
|
226
|
-
fileSystem: {
|
|
227
|
-
exists: existsSync,
|
|
228
|
-
readFile: (p) => readFileSync(p, "utf8")
|
|
229
|
-
},
|
|
230
|
-
path: nodePath
|
|
231
|
-
};
|
|
232
|
-
/**
|
|
233
13
|
* Resolves the package's effective compiler options (following `extends`) into a
|
|
234
14
|
* portable, JSON-serializable tsconfig for the meta release bundle.
|
|
235
15
|
*
|
|
@@ -264,8 +44,8 @@ function resolvePortableTsconfig(cwd, fallbackConfigPath) {
|
|
|
264
44
|
}
|
|
265
45
|
};
|
|
266
46
|
try {
|
|
267
|
-
const resolved = TsconfigLoaderSync.resolve(configPath,
|
|
268
|
-
return PortableTsconfig.make(resolved);
|
|
47
|
+
const resolved = TsconfigLoaderSync.resolve(configPath, tsconfigSyncOptions);
|
|
48
|
+
return PortableTsconfig.make(resolved, { includeTypes: true });
|
|
269
49
|
} catch (error) {
|
|
270
50
|
const message = error instanceof Error ? error.message : String(error);
|
|
271
51
|
throw new Error(`Cannot resolve portable tsconfig at ${configPath}: ${message}`, { cause: error });
|
|
@@ -273,4 +53,4 @@ function resolvePortableTsconfig(cwd, fallbackConfigPath) {
|
|
|
273
53
|
}
|
|
274
54
|
|
|
275
55
|
//#endregion
|
|
276
|
-
export {
|
|
56
|
+
export { resolvePortableTsconfig };
|
package/meta/tsdoc-config.js
CHANGED
|
@@ -37,7 +37,8 @@ function writeTsdocConfig(cwd, tsdoc) {
|
|
|
37
37
|
tagDefinitions: tsdoc.tagDefinitions ?? []
|
|
38
38
|
});
|
|
39
39
|
if (existsSync(path)) try {
|
|
40
|
-
|
|
40
|
+
const existing = JSON.parse(readFileSync(path, "utf-8"));
|
|
41
|
+
if (isDeepStrictEqual(existing, config)) return path;
|
|
41
42
|
} catch {}
|
|
42
43
|
writeFileSync(path, `${JSON.stringify(config, null, " ")}\n`, "utf-8");
|
|
43
44
|
return path;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/tsdown-plugins",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Interface-only tsdown/rolldown plugin pack powering @savvy-web/bundler",
|
|
6
6
|
"homepage": "https://github.com/savvy-web/systems/tree/main/packages/tsdown-plugins",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@changesets/get-release-plan": "^5.0.0-next.7",
|
|
33
33
|
"@effect/platform-node": "4.0.0-beta.101",
|
|
34
|
-
"@effected/npm": "^0.
|
|
35
|
-
"@effected/package-json": "^0.
|
|
36
|
-
"@effected/tsconfig-json": "^0.
|
|
37
|
-
"@effected/workspaces": "^0.9.
|
|
34
|
+
"@effected/npm": "^0.8.0",
|
|
35
|
+
"@effected/package-json": "^0.7.1",
|
|
36
|
+
"@effected/tsconfig-json": "^0.4.0",
|
|
37
|
+
"@effected/workspaces": "^0.9.3",
|
|
38
38
|
"@microsoft/api-extractor": "^7.58.12",
|
|
39
39
|
"@microsoft/tsdoc": "^0.16.0",
|
|
40
40
|
"@microsoft/tsdoc-config": "^0.18.1",
|
|
@@ -40,7 +40,7 @@ function dedupe(entries) {
|
|
|
40
40
|
const MAX_FAILURE_MESSAGE = 2e3;
|
|
41
41
|
/** Normalize a caller-supplied failure into the stamped shape (message truncated, empty name dropped). */
|
|
42
42
|
function toFailure(failure) {
|
|
43
|
-
const message = failure.message.length > MAX_FAILURE_MESSAGE ? `${failure.message.slice(0,
|
|
43
|
+
const message = failure.message.length > MAX_FAILURE_MESSAGE ? `${failure.message.slice(0, 1999)}…` : failure.message;
|
|
44
44
|
return failure.name !== void 0 && failure.name !== "" ? {
|
|
45
45
|
name: failure.name,
|
|
46
46
|
message
|
package/report/pipeline.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { EnvironmentDetector } from "./services/EnvironmentDetector.js";
|
|
2
|
-
import { EnvironmentDetectorLive } from "./layers/EnvironmentDetectorLive.js";
|
|
3
2
|
import { ExecutorResolver } from "./services/ExecutorResolver.js";
|
|
4
|
-
import { ExecutorResolverLive } from "./layers/ExecutorResolverLive.js";
|
|
5
3
|
import { FormatSelector } from "./services/FormatSelector.js";
|
|
6
|
-
import { FormatSelectorLive } from "./layers/FormatSelectorLive.js";
|
|
7
4
|
import { OutputRenderer } from "./services/OutputRenderer.js";
|
|
8
|
-
import { OutputRendererLive } from "./layers/OutputRendererLive.js";
|
|
9
5
|
import { Effect, Layer } from "effect";
|
|
10
6
|
|
|
11
7
|
//#region src/report/pipeline.ts
|
|
12
8
|
/** @public */
|
|
13
|
-
const
|
|
9
|
+
const ReportPipeline = Layer.mergeAll(EnvironmentDetector.layer, ExecutorResolver.layer, FormatSelector.layer, OutputRenderer.layer);
|
|
14
10
|
/** @public */
|
|
15
11
|
const renderReport = (reports, options) => Effect.gen(function* () {
|
|
16
12
|
const detector = yield* EnvironmentDetector;
|
|
@@ -27,4 +23,4 @@ const renderReport = (reports, options) => Effect.gen(function* () {
|
|
|
27
23
|
});
|
|
28
24
|
|
|
29
25
|
//#endregion
|
|
30
|
-
export {
|
|
26
|
+
export { ReportPipeline, renderReport };
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import { isAgent, isCI } from "std-env";
|
|
2
3
|
|
|
3
4
|
//#region src/report/services/EnvironmentDetector.ts
|
|
5
|
+
const isGitHub = () => process.env.GITHUB_ACTIONS === "true" || process.env.GITHUB_ACTIONS === "1";
|
|
4
6
|
/** @public */
|
|
5
|
-
var EnvironmentDetector = class extends Context.Service()("@savvy-web/tsdown-plugins/EnvironmentDetector") {
|
|
7
|
+
var EnvironmentDetector = class extends Context.Service()("@savvy-web/tsdown-plugins/EnvironmentDetector") {
|
|
8
|
+
static layer = Layer.succeed(this, { detect: () => Effect.sync(() => {
|
|
9
|
+
if (isAgent) return "agent-shell";
|
|
10
|
+
if (isGitHub()) return "ci-github";
|
|
11
|
+
if (isCI) return "ci-generic";
|
|
12
|
+
return "terminal";
|
|
13
|
+
}) });
|
|
14
|
+
};
|
|
6
15
|
|
|
7
16
|
//#endregion
|
|
8
17
|
export { EnvironmentDetector };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
2
|
|
|
3
3
|
//#region src/report/services/ExecutorResolver.ts
|
|
4
4
|
/** @public */
|
|
5
|
-
var ExecutorResolver = class extends Context.Service()("@savvy-web/tsdown-plugins/ExecutorResolver") {
|
|
5
|
+
var ExecutorResolver = class extends Context.Service()("@savvy-web/tsdown-plugins/ExecutorResolver") {
|
|
6
|
+
static layer = Layer.succeed(this, { resolve: (env) => Effect.succeed(env === "agent-shell" ? "agent" : env === "terminal" ? "human" : "ci") });
|
|
7
|
+
};
|
|
6
8
|
|
|
7
9
|
//#endregion
|
|
8
10
|
export { ExecutorResolver };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
2
|
|
|
3
3
|
//#region src/report/services/FormatSelector.ts
|
|
4
4
|
/** @public */
|
|
5
|
-
var FormatSelector = class extends Context.Service()("@savvy-web/tsdown-plugins/FormatSelector") {
|
|
5
|
+
var FormatSelector = class extends Context.Service()("@savvy-web/tsdown-plugins/FormatSelector") {
|
|
6
|
+
static layer = Layer.succeed(this, { select: (executor, explicit, env) => Effect.succeed(explicit ?? (env === "ci-github" && executor === "ci" ? "ci-annotations" : executor === "agent" ? "markdown" : executor === "ci" ? "json" : "terminal")) });
|
|
7
|
+
};
|
|
6
8
|
|
|
7
9
|
//#endregion
|
|
8
10
|
export { FormatSelector };
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CiAnnotationsFormatter } from "../formatters/ci-annotations.js";
|
|
2
|
+
import { JsonFormatter } from "../formatters/json.js";
|
|
3
|
+
import { MarkdownFormatter } from "../formatters/markdown.js";
|
|
4
|
+
import { SilentFormatter } from "../formatters/silent.js";
|
|
5
|
+
import { TerminalFormatter } from "../formatters/terminal.js";
|
|
6
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
7
|
|
|
3
8
|
//#region src/report/services/OutputRenderer.ts
|
|
9
|
+
const formatters = /* @__PURE__ */ new Map([
|
|
10
|
+
["terminal", TerminalFormatter],
|
|
11
|
+
["json", JsonFormatter],
|
|
12
|
+
["markdown", MarkdownFormatter],
|
|
13
|
+
["ci-annotations", CiAnnotationsFormatter],
|
|
14
|
+
["silent", SilentFormatter]
|
|
15
|
+
]);
|
|
4
16
|
/** @public */
|
|
5
|
-
var OutputRenderer = class extends Context.Service()("@savvy-web/tsdown-plugins/OutputRenderer") {
|
|
17
|
+
var OutputRenderer = class extends Context.Service()("@savvy-web/tsdown-plugins/OutputRenderer") {
|
|
18
|
+
static layer = Layer.succeed(this, { render: (reports, format, ctx) => Effect.sync(() => {
|
|
19
|
+
const f = formatters.get(format);
|
|
20
|
+
return f ? f.render(reports, ctx) : [];
|
|
21
|
+
}) });
|
|
22
|
+
};
|
|
6
23
|
|
|
7
24
|
//#endregion
|
|
8
25
|
export { OutputRenderer };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import * as nodePath from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/tsconfig/sync-options.ts
|
|
5
|
+
/**
|
|
6
|
+
* The consumer-supplied sync operations backing every `TsconfigLoaderSync` call in this
|
|
7
|
+
* package: Node's `existsSync`/`readFileSync` satisfy the loader's `SyncFileSystem`, and
|
|
8
|
+
* `node:path` satisfies `SyncPath` verbatim.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
const tsconfigSyncOptions = {
|
|
13
|
+
fileSystem: {
|
|
14
|
+
exists: existsSync,
|
|
15
|
+
readFile: (p) => readFileSync(p, "utf8")
|
|
16
|
+
},
|
|
17
|
+
path: nodePath
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { tsconfigSyncOptions };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { ConfigValidationError } from "../errors.js";
|
|
2
|
-
import { normalizeLooseFiles } from "../build/loose-files.js";
|
|
3
|
-
import { ConfigValidator } from "./ConfigValidator.js";
|
|
4
|
-
import { normalizeExeOptions } from "../exe/config.js";
|
|
5
|
-
import { resolveTargets } from "../targets/resolve-targets.js";
|
|
6
|
-
import { existsSync, statSync } from "node:fs";
|
|
7
|
-
import { Effect, Layer } from "effect";
|
|
8
|
-
|
|
9
|
-
//#region src/config-validation/ConfigValidatorLive.ts
|
|
10
|
-
const VALID_SYNTAX_KINDS = /* @__PURE__ */ new Set([
|
|
11
|
-
"block",
|
|
12
|
-
"inline",
|
|
13
|
-
"modifier"
|
|
14
|
-
]);
|
|
15
|
-
/** Synchronous rule set; throws ConfigValidationError on the first violation. */
|
|
16
|
-
function check(input) {
|
|
17
|
-
if (input.targets !== void 0 && Object.keys(input.targets).length > 0) resolveTargets({
|
|
18
|
-
targets: input.targets,
|
|
19
|
-
baseName: input.baseName
|
|
20
|
-
});
|
|
21
|
-
if (input.exe !== void 0) {
|
|
22
|
-
const specs = normalizeExeOptions(input.exe, input.osCpu ?? {
|
|
23
|
-
os: [],
|
|
24
|
-
cpu: []
|
|
25
|
-
});
|
|
26
|
-
for (const spec of specs) {
|
|
27
|
-
if (spec.fileName.trim() === "") throw new ConfigValidationError({
|
|
28
|
-
path: "exe.fileName",
|
|
29
|
-
reason: "an exe binary needs a non-empty fileName"
|
|
30
|
-
});
|
|
31
|
-
if (spec.targets.length === 0) throw new ConfigValidationError({
|
|
32
|
-
path: `exe.${spec.fileName}.targets`,
|
|
33
|
-
reason: "no targets: the package declares no os/cpu and the exe config states none"
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (input.meta !== void 0) {
|
|
38
|
-
if (!input.hasExports) throw new ConfigValidationError({
|
|
39
|
-
path: "meta",
|
|
40
|
-
reason: "meta requires an exports map to extract an api-model from"
|
|
41
|
-
});
|
|
42
|
-
for (const tag of input.meta.tsdoc?.tagDefinitions ?? []) if (!VALID_SYNTAX_KINDS.has(tag.syntaxKind)) throw new ConfigValidationError({
|
|
43
|
-
path: "meta.tsdoc.tagDefinitions",
|
|
44
|
-
reason: `tag "${tag.tagName}" has an invalid syntaxKind "${tag.syntaxKind}"`
|
|
45
|
-
});
|
|
46
|
-
for (const p of input.meta.localPaths ?? []) if (existsSync(p) && !statSync(p).isDirectory()) throw new ConfigValidationError({
|
|
47
|
-
path: "meta.localPaths",
|
|
48
|
-
reason: `"${p}" exists but is not a directory`
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (input.looseFiles !== void 0) normalizeLooseFiles(input.looseFiles);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Live ConfigValidator: wraps the synchronous rule set, surfacing ConfigValidationError as a typed Effect failure.
|
|
55
|
-
*
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
const ConfigValidatorLive = Layer.succeed(ConfigValidator, { validate: (input) => Effect.try({
|
|
59
|
-
try: () => check(input),
|
|
60
|
-
catch: (e) => e instanceof ConfigValidationError ? e : new ConfigValidationError({
|
|
61
|
-
path: "config",
|
|
62
|
-
reason: String(e)
|
|
63
|
-
})
|
|
64
|
-
}) });
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
|
-
export { ConfigValidatorLive };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { EnvironmentDetector } from "../services/EnvironmentDetector.js";
|
|
2
|
-
import { Effect, Layer } from "effect";
|
|
3
|
-
import { isAgent, isCI } from "std-env";
|
|
4
|
-
|
|
5
|
-
//#region src/report/layers/EnvironmentDetectorLive.ts
|
|
6
|
-
const isGitHub = () => process.env.GITHUB_ACTIONS === "true" || process.env.GITHUB_ACTIONS === "1";
|
|
7
|
-
/** @public */
|
|
8
|
-
const EnvironmentDetectorLive = Layer.succeed(EnvironmentDetector, { detect: () => Effect.sync(() => {
|
|
9
|
-
if (isAgent) return "agent-shell";
|
|
10
|
-
if (isGitHub()) return "ci-github";
|
|
11
|
-
if (isCI) return "ci-generic";
|
|
12
|
-
return "terminal";
|
|
13
|
-
}) });
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { EnvironmentDetectorLive };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ExecutorResolver } from "../services/ExecutorResolver.js";
|
|
2
|
-
import { Effect, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/report/layers/ExecutorResolverLive.ts
|
|
5
|
-
/** @public */
|
|
6
|
-
const ExecutorResolverLive = Layer.succeed(ExecutorResolver, { resolve: (env) => Effect.succeed(env === "agent-shell" ? "agent" : env === "terminal" ? "human" : "ci") });
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ExecutorResolverLive };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FormatSelector } from "../services/FormatSelector.js";
|
|
2
|
-
import { Effect, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/report/layers/FormatSelectorLive.ts
|
|
5
|
-
/** @public */
|
|
6
|
-
const FormatSelectorLive = Layer.succeed(FormatSelector, { select: (executor, explicit, env) => Effect.succeed(explicit ?? (env === "ci-github" && executor === "ci" ? "ci-annotations" : executor === "agent" ? "markdown" : executor === "ci" ? "json" : "terminal")) });
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { FormatSelectorLive };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { CiAnnotationsFormatter } from "../formatters/ci-annotations.js";
|
|
2
|
-
import { JsonFormatter } from "../formatters/json.js";
|
|
3
|
-
import { MarkdownFormatter } from "../formatters/markdown.js";
|
|
4
|
-
import { SilentFormatter } from "../formatters/silent.js";
|
|
5
|
-
import { TerminalFormatter } from "../formatters/terminal.js";
|
|
6
|
-
import { OutputRenderer } from "../services/OutputRenderer.js";
|
|
7
|
-
import { Effect, Layer } from "effect";
|
|
8
|
-
|
|
9
|
-
//#region src/report/layers/OutputRendererLive.ts
|
|
10
|
-
const formatters = /* @__PURE__ */ new Map([
|
|
11
|
-
["terminal", TerminalFormatter],
|
|
12
|
-
["json", JsonFormatter],
|
|
13
|
-
["markdown", MarkdownFormatter],
|
|
14
|
-
["ci-annotations", CiAnnotationsFormatter],
|
|
15
|
-
["silent", SilentFormatter]
|
|
16
|
-
]);
|
|
17
|
-
/** @public */
|
|
18
|
-
const OutputRendererLive = Layer.succeed(OutputRenderer, { render: (reports, format, ctx) => Effect.sync(() => {
|
|
19
|
-
const f = formatters.get(format);
|
|
20
|
-
return f ? f.render(reports, ctx) : [];
|
|
21
|
-
}) });
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { OutputRendererLive };
|