@effected/bundler 0.0.0-stage → 0.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.
Files changed (81) hide show
  1. package/Bundler.js +450 -0
  2. package/BundlerError.js +39 -0
  3. package/LICENSE +21 -0
  4. package/README.md +84 -2
  5. package/action/ActionBuilder.js +108 -0
  6. package/action/ActionBundle.js +261 -0
  7. package/action/ActionErrors.js +83 -0
  8. package/action/ActionValidation.js +195 -0
  9. package/action/ActionYml.js +366 -0
  10. package/action/PersistLocal.js +186 -0
  11. package/action/entries.js +23 -0
  12. package/action/ignore-stub-plugin.js +25 -0
  13. package/action/import-check.js +134 -0
  14. package/assets/Inter-SemiBold.ttf +0 -0
  15. package/assets/LICENSE-Inter.txt +92 -0
  16. package/catalog/resolve-catalogs.js +32 -0
  17. package/changesets/next-versions.js +50 -0
  18. package/config/ActionConfig.js +102 -0
  19. package/config/BuildConfig.js +427 -0
  20. package/config/EffectedConfigFile.js +160 -0
  21. package/config/merge.js +20 -0
  22. package/config/plugins.js +84 -0
  23. package/config-validation/ConfigValidator.js +67 -0
  24. package/dts/bundled-siblings.js +108 -0
  25. package/dts/parse.js +28 -0
  26. package/dts/reexport-stub.js +94 -0
  27. package/dts/relative-imports.js +33 -0
  28. package/dts/resolved-tsconfig.js +238 -0
  29. package/entries/ambient-dts.js +108 -0
  30. package/entries/export-paths.js +16 -0
  31. package/entries/extract.js +79 -0
  32. package/entries/package-json-entries.js +19 -0
  33. package/errors.js +37 -0
  34. package/exe/build.js +55 -0
  35. package/exe/config.js +54 -0
  36. package/exe/filename.js +13 -0
  37. package/index.d.ts +3919 -0
  38. package/index.js +58 -0
  39. package/internal/causeMessage.js +57 -0
  40. package/journal/BuildJournal.js +108 -0
  41. package/jsx/config.js +51 -0
  42. package/manifest/emit-manifest.js +88 -0
  43. package/manifest/export-patterns.js +58 -0
  44. package/manifest/transform.js +323 -0
  45. package/meta/BundleManifest.js +208 -0
  46. package/meta/ManifestSource.js +37 -0
  47. package/meta/api-extractor.js +241 -0
  48. package/meta/config.js +24 -0
  49. package/meta/generate.js +246 -0
  50. package/meta/merge-models.js +43 -0
  51. package/meta/message-suppressor.js +43 -0
  52. package/meta/og-image.js +137 -0
  53. package/meta/og-satori.js +140 -0
  54. package/meta/optimistic.js +32 -0
  55. package/meta/run-pass.js +117 -0
  56. package/meta/scrub-declaration-maps.js +63 -0
  57. package/meta/tsconfig-resolver.js +55 -0
  58. package/meta/tsdoc-config.js +47 -0
  59. package/meta/tsdoctor-config.js +22 -0
  60. package/meta/tsdoctor-manifest.js +134 -0
  61. package/meta/tsdoctor-source.js +94 -0
  62. package/package.json +85 -5
  63. package/passes/build-target-groups.js +346 -0
  64. package/passes/cjs-default-interop.js +98 -0
  65. package/passes/loose-files.js +57 -0
  66. package/passes/node-builtin-default-interop.js +79 -0
  67. package/passes/strip-maps.js +39 -0
  68. package/passes/sync-public.js +100 -0
  69. package/passes/target-groups.js +112 -0
  70. package/report/ci-annotations.js +36 -0
  71. package/report/collector.js +140 -0
  72. package/report/issues-artifact.js +155 -0
  73. package/report/metrics-plugin.js +76 -0
  74. package/report/schema.js +77 -0
  75. package/report/timer.js +19 -0
  76. package/report/tsdown-logger.js +58 -0
  77. package/targets/binding.js +18 -0
  78. package/targets/config.js +21 -0
  79. package/targets/resolve-targets.js +165 -0
  80. package/tsconfig/sync-options.js +20 -0
  81. package/tsdoc-metadata.json +11 -0
@@ -0,0 +1,155 @@
1
+ import { DiagnosticEntry } from "./schema.js";
2
+ import { Schema } from "effect";
3
+ import { mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+
6
+ // src/report/issues-artifact.ts
7
+ /**
8
+ * The schema of a {@link PlainDiagnostic}, for reading one back from `issues.json` or a journal.
9
+ *
10
+ * @public
11
+ */
12
+ const PlainDiagnosticSchema = Schema.Struct({
13
+ source: DiagnosticEntry.fields.source,
14
+ level: DiagnosticEntry.fields.level,
15
+ text: Schema.String,
16
+ code: Schema.optionalKey(Schema.String),
17
+ ciFatal: Schema.optionalKey(Schema.Boolean),
18
+ file: Schema.optionalKey(Schema.String),
19
+ line: Schema.optionalKey(Schema.Number),
20
+ column: Schema.optionalKey(Schema.Number)
21
+ });
22
+ /**
23
+ * The schema of a {@link BuildIssues} artifact, for reading `dist/<target>/issues.json` back.
24
+ *
25
+ * @remarks
26
+ * `buildOk` is required here: an artifact without the stamp is unknown rather than a pass, so it does not decode.
27
+ *
28
+ * @public
29
+ */
30
+ const BuildIssuesSchema = Schema.Struct({
31
+ generatedAt: Schema.String,
32
+ package: Schema.String,
33
+ target: Schema.Literals(["dev", "prod"]),
34
+ buildOk: Schema.Boolean,
35
+ failure: Schema.optionalKey(Schema.Struct({
36
+ name: Schema.optionalKey(Schema.String),
37
+ message: Schema.String
38
+ })),
39
+ warnings: Schema.Array(PlainDiagnosticSchema),
40
+ errors: Schema.Array(PlainDiagnosticSchema),
41
+ suppressed: Schema.Array(PlainDiagnosticSchema)
42
+ });
43
+ /** Copy a DiagnosticEntry to a plain object, omitting undefined optionals for stable output. */
44
+ function toPlain(d) {
45
+ const out = {
46
+ source: d.source,
47
+ level: d.level,
48
+ text: d.text
49
+ };
50
+ if (d.code !== void 0) out.code = d.code;
51
+ if (d.ciFatal !== void 0) out.ciFatal = d.ciFatal;
52
+ if (d.file !== void 0) out.file = d.file;
53
+ if (d.line !== void 0) out.line = d.line;
54
+ if (d.column !== void 0) out.column = d.column;
55
+ return out;
56
+ }
57
+ /** De-duplicate by the identity-bearing fields (registry target-groups carry identical diagnostics). */
58
+ function dedupe(entries) {
59
+ const seen = /* @__PURE__ */ new Set();
60
+ const out = [];
61
+ for (const e of entries) {
62
+ const key = JSON.stringify([
63
+ e.source,
64
+ e.level,
65
+ e.code ?? "",
66
+ e.text,
67
+ e.file ?? "",
68
+ e.line ?? -1,
69
+ e.column ?? -1
70
+ ]);
71
+ if (seen.has(key)) continue;
72
+ seen.add(key);
73
+ out.push(e);
74
+ }
75
+ return out;
76
+ }
77
+ /** Longest failure message kept in the artifact — enough for a stack-free error, short of a log dump. */
78
+ const MAX_FAILURE_MESSAGE = 2e3;
79
+ /** Normalize a caller-supplied failure into the stamped shape (message truncated, empty name dropped). */
80
+ function toFailure(failure) {
81
+ const message = failure.message.length > MAX_FAILURE_MESSAGE ? `${failure.message.slice(0, 1999)}…` : failure.message;
82
+ return failure.name !== void 0 && failure.name !== "" ? {
83
+ name: failure.name,
84
+ message
85
+ } : { message };
86
+ }
87
+ /**
88
+ * Flatten a build snapshot into the aggregated, de-duplicated issues artifact. Pure.
89
+ *
90
+ * `buildOk` defaults to `true`, so an existing caller that never fails keeps its current output plus
91
+ * the stamp; a caller that also writes on a failure path MUST pass `buildOk: false` (and ideally the
92
+ * `failure`), otherwise the artifact reads as a clean gate.
93
+ *
94
+ * @public
95
+ */
96
+ function flattenIssues(reports, opts) {
97
+ const warnings = [];
98
+ const errors = [];
99
+ const suppressed = [];
100
+ for (const report of reports) for (const g of report.targetGroups) {
101
+ for (const w of g.warnings) warnings.push(toPlain(w));
102
+ for (const e of g.errors) errors.push(toPlain(e));
103
+ for (const s of g.suppressed) suppressed.push(toPlain(s));
104
+ }
105
+ return {
106
+ generatedAt: opts.generatedAt,
107
+ package: reports[0]?.package ?? "unknown",
108
+ target: opts.target,
109
+ buildOk: opts.buildOk ?? true,
110
+ ...opts.failure !== void 0 ? { failure: toFailure(opts.failure) } : {},
111
+ warnings: dedupe(warnings),
112
+ errors: dedupe(errors),
113
+ suppressed: dedupe(suppressed)
114
+ };
115
+ }
116
+ /**
117
+ * Serialize the issues artifact to pretty JSON with a trailing newline.
118
+ *
119
+ * @public
120
+ */
121
+ function serializeIssues(issues) {
122
+ return `${JSON.stringify(issues, null, 2)}\n`;
123
+ }
124
+ /**
125
+ * Write the aggregated issues artifact to `<cwd>/dist/<target>/issues.json`. Returns the path written.
126
+ *
127
+ * The write is atomic: the JSON lands in a sibling temp file which is then `rename`d over the
128
+ * destination, so a concurrent reader observes either the previous artifact or the complete new one,
129
+ * never a torn or half-written file. Pass `buildOk: false` (plus `failure`, when there is an error to
130
+ * report) on a failure path — see the `buildOk` field of `BuildIssues`.
131
+ *
132
+ * @public
133
+ */
134
+ function writeIssuesArtifact(opts) {
135
+ const clock = opts.now ?? (() => /* @__PURE__ */ new Date());
136
+ const issues = flattenIssues(opts.reports, {
137
+ target: opts.target,
138
+ generatedAt: clock().toISOString(),
139
+ buildOk: opts.buildOk,
140
+ failure: opts.failure
141
+ });
142
+ const outPath = join(opts.cwd, "dist", opts.target, "issues.json");
143
+ mkdirSync(dirname(outPath), { recursive: true });
144
+ const tmpPath = `${outPath}.${process.pid}.tmp`;
145
+ try {
146
+ writeFileSync(tmpPath, serializeIssues(issues), "utf8");
147
+ renameSync(tmpPath, outPath);
148
+ } catch (err) {
149
+ rmSync(tmpPath, { force: true });
150
+ throw err;
151
+ }
152
+ return outPath;
153
+ }
154
+
155
+ export { BuildIssuesSchema, PlainDiagnosticSchema, flattenIssues, serializeIssues, writeIssuesArtifact };
@@ -0,0 +1,76 @@
1
+ import { gzipSync } from "node:zlib";
2
+
3
+ // src/report/metrics-plugin.ts
4
+ function contentOf(chunk) {
5
+ const c = chunk;
6
+ if (c.type === "chunk") return c.code;
7
+ if (c.type === "asset") return c.source;
8
+ return c.code ?? c.source;
9
+ }
10
+ function byteLength(content) {
11
+ return typeof content === "string" ? Buffer.byteLength(content) : content.byteLength;
12
+ }
13
+ /**
14
+ * Rolldown plugin that records emitted-file metrics into the BuildCollector via writeBundle (which
15
+ * fires for the JS pass AND the emitDtsOnly dts pass — verified against tsdown 0.22.3), plus a
16
+ * defensive onLog for rolldown-level diagnostics that bypass tsdown's logger. Append it to each
17
+ * build pass's `plugins` array. `bytes` is taken from the in-memory chunk/asset content (no fs);
18
+ * `gzip` is computed only when `verbose`.
19
+ *
20
+ * Set `suppressMixedExports` for a pass whose emitted CJS carries the `cjsDefaultInterop()`
21
+ * footer — see the onLog comment below for why rolldown's MIXED_EXPORTS advice does not apply
22
+ * there.
23
+ * @public
24
+ */
25
+ function buildMetricsPlugin(collector, groupId, pass, verbose, suppressMixedExports = false) {
26
+ return {
27
+ name: "savvy:build-metrics",
28
+ writeBundle(_outputOptions, bundle) {
29
+ for (const [key, chunk] of Object.entries(bundle)) {
30
+ const content = contentOf(chunk);
31
+ if (content === void 0) continue;
32
+ const bytes = byteLength(content);
33
+ collector.recordEmitted(groupId, pass, {
34
+ path: key,
35
+ bytes,
36
+ ...verbose ? { gzip: gzipSync(typeof content === "string" ? Buffer.from(content) : content).length } : {}
37
+ });
38
+ }
39
+ },
40
+ onLog(level, log) {
41
+ const l = log;
42
+ if (l.code === "SOURCEMAP_BROKEN" && l.plugin?.startsWith("@tsdown/css")) return false;
43
+ const entry = {
44
+ text: l.message ?? String(log),
45
+ ...l.id !== void 0 ? { file: l.id } : {},
46
+ ...l.loc?.line !== void 0 ? { line: l.loc.line } : {},
47
+ ...l.loc?.column !== void 0 ? { column: l.loc.column } : {}
48
+ };
49
+ if (suppressMixedExports && l.code === "MIXED_EXPORTS") {
50
+ collector.recordSuppressed(groupId, {
51
+ source: "rolldown",
52
+ level: "warn",
53
+ code: "MIXED_EXPORTS",
54
+ ...entry
55
+ });
56
+ return false;
57
+ }
58
+ if (level === "error") {
59
+ collector.recordError(groupId, {
60
+ source: "rolldown",
61
+ level: "error",
62
+ ...entry
63
+ });
64
+ return;
65
+ }
66
+ if (level === "warn") collector.recordWarning(groupId, {
67
+ source: "rolldown",
68
+ level: "warn",
69
+ ...entry
70
+ });
71
+ return false;
72
+ }
73
+ };
74
+ }
75
+
76
+ export { buildMetricsPlugin };
@@ -0,0 +1,77 @@
1
+ import { Schema } from "effect";
2
+
3
+ // src/report/schema.ts
4
+ /** @public */
5
+ var ReportTimings = class extends Schema.Class("ReportTimings")({ totalMs: Schema.Number }) {};
6
+ /**
7
+ * A captured warning or error, from tsdown's logger, rolldown's onLog, API Extractor, the meta
8
+ * pass's own sidecar work (`tsdoctor.json` sources, Open Graph generation), or an advisory finding
9
+ * about the build config itself (`config`, e.g. a `publishConfig.targets` set no final release reaches).
10
+ *
11
+ * @public
12
+ */
13
+ var DiagnosticEntry = class extends Schema.Class("DiagnosticEntry")({
14
+ source: Schema.Literals([
15
+ "tsdown",
16
+ "rolldown",
17
+ "api-extractor",
18
+ "meta",
19
+ "config"
20
+ ]),
21
+ level: Schema.Literals(["warn", "error"]),
22
+ text: Schema.String,
23
+ /**
24
+ * Diagnostic identifier — an API Extractor messageId (e.g. "ae-forgotten-export") or a
25
+ * rolldown warning code (e.g. "MIXED_EXPORTS"); used to group suppressed messages by type.
26
+ */
27
+ code: Schema.optional(Schema.String),
28
+ /** True when shown as `warn` locally but a hard error in CI (drives the "[fails CI]" nudge). */
29
+ ciFatal: Schema.optional(Schema.Boolean),
30
+ file: Schema.optional(Schema.String),
31
+ line: Schema.optional(Schema.Number),
32
+ column: Schema.optional(Schema.Number)
33
+ }) {};
34
+ /**
35
+ * One emitted output file with its in-memory byte size (gzip only when --verbose).
36
+ *
37
+ * @public
38
+ */
39
+ var EmittedFile = class extends Schema.Class("EmittedFile")({
40
+ path: Schema.String,
41
+ bytes: Schema.Number,
42
+ gzip: Schema.optional(Schema.Number)
43
+ }) {};
44
+ /**
45
+ * One build pass within a target group (js / dts / loose / exe / meta).
46
+ *
47
+ * @public
48
+ */
49
+ var PassReport = class extends Schema.Class("PassReport")({
50
+ id: Schema.Literals([
51
+ "js",
52
+ "dts",
53
+ "loose",
54
+ "exe",
55
+ "meta"
56
+ ]),
57
+ files: Schema.Array(EmittedFile),
58
+ ms: Schema.Number
59
+ }) {};
60
+ /** @public */
61
+ var TargetGroupReport = class extends Schema.Class("TargetGroupReport")({
62
+ id: Schema.String,
63
+ entries: Schema.Array(Schema.String),
64
+ passes: Schema.Array(PassReport),
65
+ warnings: Schema.Array(DiagnosticEntry),
66
+ errors: Schema.Array(DiagnosticEntry),
67
+ /** Messages matched by `suppressWarnings`, kept for accounting and `--verbose` expansion. */
68
+ suppressed: Schema.Array(DiagnosticEntry),
69
+ timings: ReportTimings
70
+ }) {};
71
+ /** @public */
72
+ var BuildReport = class extends Schema.Class("BuildReport")({
73
+ package: Schema.String,
74
+ targetGroups: Schema.Array(TargetGroupReport)
75
+ }) {};
76
+
77
+ export { BuildReport, DiagnosticEntry, EmittedFile, PassReport, ReportTimings, TargetGroupReport };
@@ -0,0 +1,19 @@
1
+ // src/report/timer.ts
2
+ /** @public */
3
+ function formatTime(ms) {
4
+ return ms < 1e3 ? `${Math.round(ms)}ms` : `${(ms / 1e3).toFixed(2)}s`;
5
+ }
6
+ /**
7
+ * Create a wall-clock timer. (Date.now is fine in runtime build code.)
8
+ *
9
+ * @public
10
+ */
11
+ function createTimer(now = Date.now) {
12
+ const start = now();
13
+ return {
14
+ elapsed: () => now() - start,
15
+ format: () => formatTime(now() - start)
16
+ };
17
+ }
18
+
19
+ export { createTimer, formatTime };
@@ -0,0 +1,58 @@
1
+ import { Sgr } from "@effected/env";
2
+
3
+ // src/report/tsdown-logger.ts
4
+ const join = (args) => Sgr.strip(args.map((a) => String(a)).join(" ")).trim();
5
+ /**
6
+ * Warnings that are advisory noise for THIS builder and go to the `suppressed` bucket (recorded
7
+ * for accounting, never surfaced). rolldown-plugin-dts announces its tsgo generator as experimental
8
+ * on every pass; the generator is the one this package deliberately pins, so the notice carries no
9
+ * action for a package author.
10
+ */
11
+ const SUPPRESSED_WARNINGS = /* @__PURE__ */ new Map([["TypeScript Go is experimental. Some options will be unavailable.", "TSGO_EXPERIMENTAL"]]);
12
+ /**
13
+ * A tsdown `customLogger` that routes warnings/errors into the BuildCollector instead of the
14
+ * console. Paired with `logLevel: "silent"` in the same build config: silent suppresses tsdown's
15
+ * own console output while this logger still receives every message (verified against tsdown 0.22.3).
16
+ * info/success are dropped — file metrics come from the writeBundle plugin and timing from our timer.
17
+ * @public
18
+ */
19
+ function createTsdownLogger(collector, groupId) {
20
+ const seenOnce = /* @__PURE__ */ new Set();
21
+ const warn = (text) => {
22
+ const code = SUPPRESSED_WARNINGS.get(text);
23
+ if (code !== void 0) {
24
+ collector.recordSuppressed(groupId, {
25
+ source: "tsdown",
26
+ level: "warn",
27
+ code,
28
+ text
29
+ });
30
+ return;
31
+ }
32
+ collector.recordWarning(groupId, {
33
+ source: "tsdown",
34
+ level: "warn",
35
+ text
36
+ });
37
+ };
38
+ return {
39
+ level: "info",
40
+ info: () => {},
41
+ success: () => {},
42
+ clearScreen: () => {},
43
+ warn: (...args) => warn(join(args)),
44
+ warnOnce: (...args) => {
45
+ const text = join(args);
46
+ if (seenOnce.has(text)) return;
47
+ seenOnce.add(text);
48
+ warn(text);
49
+ },
50
+ error: (...args) => collector.recordError(groupId, {
51
+ source: "tsdown",
52
+ level: "error",
53
+ text: join(args)
54
+ })
55
+ };
56
+ }
57
+
58
+ export { createTsdownLogger };
@@ -0,0 +1,18 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+
4
+ // src/targets/binding.ts
5
+ /**
6
+ * Write the target-to-group binding to dist/prod/targets.json for the release action to consume. Returns the path.
7
+ *
8
+ * @public
9
+ */
10
+ function writeTargetsBinding(cwd, resolution) {
11
+ const dir = join(cwd, "dist", "prod");
12
+ mkdirSync(dir, { recursive: true });
13
+ const path = join(dir, "targets.json");
14
+ writeFileSync(path, `${JSON.stringify(resolution, null, " ")}\n`, "utf-8");
15
+ return path;
16
+ }
17
+
18
+ export { writeTargetsBinding };
@@ -0,0 +1,21 @@
1
+ // src/targets/config.ts
2
+ /**
3
+ * Every {@link ReleaseChannel} value, in declaration order.
4
+ *
5
+ * @public
6
+ */
7
+ const RELEASE_CHANNELS = [
8
+ "all",
9
+ "stable",
10
+ "prerelease"
11
+ ];
12
+ /**
13
+ * True when a target value is the object form (carries registry/name/from).
14
+ *
15
+ * @public
16
+ */
17
+ function isTargetObject(value) {
18
+ return typeof value === "object" && value !== null;
19
+ }
20
+
21
+ export { RELEASE_CHANNELS, isTargetObject };
@@ -0,0 +1,165 @@
1
+ import { ConfigValidationError } from "../errors.js";
2
+ import { RELEASE_CHANNELS, isTargetObject } from "./config.js";
3
+
4
+ // src/targets/resolve-targets.ts
5
+ /** Default registry endpoints for the well-known target keys. */
6
+ const DEFAULT_REGISTRIES = {
7
+ npm: "https://registry.npmjs.org",
8
+ github: "https://npm.pkg.github.com"
9
+ };
10
+ /**
11
+ * Resolve a `publishConfig.targets` map into the distinct groups to build and every target bound to one. Pure; throws ConfigValidationError on structurally-invalid config.
12
+ *
13
+ * @public
14
+ */
15
+ function resolveTargets(options) {
16
+ const { targets, baseName } = options;
17
+ const ids = Object.keys(targets);
18
+ if (ids.length === 0) throw new ConfigValidationError({
19
+ path: "publishConfig.targets",
20
+ reason: "publishConfig.targets must declare at least one target"
21
+ });
22
+ const trueIds = ids.filter((id) => targets[id] === true);
23
+ const canonicalId = trueIds.includes("npm") ? "npm" : trueIds[0];
24
+ const registryFor = (id, explicit) => {
25
+ const registry = explicit ?? DEFAULT_REGISTRIES[id];
26
+ if (registry === void 0) throw new ConfigValidationError({
27
+ path: `publishConfig.targets.${id}`,
28
+ reason: `Target "${id}" has no registry; custom targets must set { registry }`
29
+ });
30
+ return registry;
31
+ };
32
+ const optionsFor = (id, value) => {
33
+ if (!isTargetObject(value)) return { releases: "all" };
34
+ const { releases, provenance } = value;
35
+ if (releases !== void 0 && !RELEASE_CHANNELS.includes(releases)) throw new ConfigValidationError({
36
+ path: `publishConfig.targets.${id}.releases`,
37
+ reason: `Target "${id}" has releases "${String(releases)}"; expected one of ${RELEASE_CHANNELS.map((c) => `"${c}"`).join(", ")}`
38
+ });
39
+ if (provenance !== void 0 && typeof provenance !== "boolean") throw new ConfigValidationError({
40
+ path: `publishConfig.targets.${id}.provenance`,
41
+ reason: `Target "${id}" has a non-boolean provenance; expected true or false`
42
+ });
43
+ return {
44
+ releases: releases ?? "all",
45
+ ...provenance !== void 0 ? { provenance } : {}
46
+ };
47
+ };
48
+ const groups = /* @__PURE__ */ new Map();
49
+ const addGroup = (id, name) => {
50
+ if (!groups.has(id)) groups.set(id, {
51
+ id,
52
+ name,
53
+ dir: `dist/prod/${id}/pkg`
54
+ });
55
+ };
56
+ const resolved = [];
57
+ const deferredFrom = [];
58
+ for (const id of ids) {
59
+ const value = targets[id];
60
+ if (value === true) {
61
+ if (DEFAULT_REGISTRIES[id] === void 0) throw new ConfigValidationError({
62
+ path: `publishConfig.targets.${id}`,
63
+ reason: `Target "${id}: true" is not a known registry; use an object with { registry }`
64
+ });
65
+ if (id === "github" && !baseName.startsWith("@")) throw new ConfigValidationError({
66
+ path: "publishConfig.targets.github",
67
+ reason: `"github: true" needs a scoped base name; use a string/name override to rescope "${baseName}"`
68
+ });
69
+ const gid = canonicalId;
70
+ addGroup(gid, baseName);
71
+ resolved.push({
72
+ id,
73
+ group: gid,
74
+ name: baseName,
75
+ registry: registryFor(id, void 0),
76
+ ...optionsFor(id, value)
77
+ });
78
+ } else if (typeof value === "string") {
79
+ if (DEFAULT_REGISTRIES[id] === void 0) throw new ConfigValidationError({
80
+ path: `publishConfig.targets.${id}`,
81
+ reason: `Target "${id}" uses a string name override but has no known registry; use an object { registry, name }`
82
+ });
83
+ addGroup(id, value);
84
+ resolved.push({
85
+ id,
86
+ group: id,
87
+ name: value,
88
+ registry: registryFor(id, void 0),
89
+ ...optionsFor(id, value)
90
+ });
91
+ } else if (isTargetObject(value)) {
92
+ if (value.from !== void 0 && value.name !== void 0) throw new ConfigValidationError({
93
+ path: `publishConfig.targets.${id}`,
94
+ reason: `Target "${id}" sets both "from" and "name"; they are mutually exclusive`
95
+ });
96
+ if (value.from !== void 0) deferredFrom.push({
97
+ id,
98
+ obj: value
99
+ });
100
+ else if (value.name !== void 0) {
101
+ addGroup(id, value.name);
102
+ resolved.push({
103
+ id,
104
+ group: id,
105
+ name: value.name,
106
+ registry: registryFor(id, value.registry),
107
+ ...optionsFor(id, value)
108
+ });
109
+ } else {
110
+ addGroup(id, baseName);
111
+ resolved.push({
112
+ id,
113
+ group: id,
114
+ name: baseName,
115
+ registry: registryFor(id, value.registry),
116
+ ...optionsFor(id, value)
117
+ });
118
+ }
119
+ }
120
+ }
121
+ for (const { id, obj } of deferredFrom) {
122
+ const fromId = obj.from;
123
+ if (fromId === id) throw new ConfigValidationError({
124
+ path: `publishConfig.targets.${id}`,
125
+ reason: `Target "${id}" references itself in "from" (self-referencing from is not allowed)`
126
+ });
127
+ if (deferredFrom.some((d) => d.id === fromId)) throw new ConfigValidationError({
128
+ path: `publishConfig.targets.${id}`,
129
+ reason: `Target "${id}" reuses "from: ${fromId}", which itself uses "from" (no chained reuse)`
130
+ });
131
+ const ref = resolved.find((t) => t.id === fromId);
132
+ if (ref === void 0) throw new ConfigValidationError({
133
+ path: `publishConfig.targets.${id}`,
134
+ reason: `Target "${id}" has a dangling "from: ${fromId}" (no such target)`
135
+ });
136
+ resolved.push({
137
+ id,
138
+ group: ref.group,
139
+ name: ref.name,
140
+ registry: registryFor(id, obj.registry),
141
+ ...optionsFor(id, obj)
142
+ });
143
+ }
144
+ return {
145
+ groups: [...groups.values()],
146
+ targets: resolved
147
+ };
148
+ }
149
+ /**
150
+ * Advisory warnings for a resolved target set that is valid but probably not what was meant.
151
+ *
152
+ * @remarks
153
+ * Today the only one is a set whose every target is `releases: "prerelease"`, which leaves final
154
+ * versions with nowhere to publish. A warning rather than a {@link ConfigValidationError}, since a
155
+ * prerelease-only package is a legitimate if unusual setup. Pure; returns one message per finding.
156
+ *
157
+ * @public
158
+ */
159
+ function releaseWarnings(resolution) {
160
+ const { targets } = resolution;
161
+ if (targets.length > 0 && targets.every((t) => t.releases === "prerelease")) return [`Every publish target sets releases: "prerelease", so final versions publish nowhere; set "all" or "stable" on at least one target`];
162
+ return [];
163
+ }
164
+
165
+ export { releaseWarnings, resolveTargets };
@@ -0,0 +1,20 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import * as nodePath from "node:path";
3
+
4
+ // 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
+ export { tsconfigSyncOptions };
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.60.1"
9
+ }
10
+ ]
11
+ }