@savvy-web/tsdown-plugins 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 (49) hide show
  1. package/README.md +61 -0
  2. package/build/build-target-groups.js +133 -0
  3. package/build/cjs-default-interop.js +98 -0
  4. package/build/node-builtin-default-interop.js +74 -0
  5. package/build/strip-maps.js +40 -0
  6. package/build/sync-public.js +67 -0
  7. package/build/target-groups.js +52 -0
  8. package/catalog/resolve-catalogs.js +24 -0
  9. package/config-validation/ConfigValidator.js +8 -0
  10. package/config-validation/ConfigValidatorLive.js +61 -0
  11. package/dts/resolved-tsconfig.js +44 -0
  12. package/entry/extract.js +68 -0
  13. package/entry/package-json-entries.js +12 -0
  14. package/errors.js +36 -0
  15. package/exe/build.js +23 -0
  16. package/exe/config.js +50 -0
  17. package/index.d.ts +1457 -0
  18. package/index.js +44 -0
  19. package/jsx/config.js +40 -0
  20. package/manifest/emit-manifest.js +56 -0
  21. package/manifest/transform.js +123 -0
  22. package/meta/api-extractor.js +59 -0
  23. package/meta/config.js +14 -0
  24. package/meta/generate.js +76 -0
  25. package/meta/merge-models.js +44 -0
  26. package/meta/message-suppressor.js +37 -0
  27. package/meta/tsconfig-resolver.js +260 -0
  28. package/meta/tsdoc-config.js +47 -0
  29. package/package.json +45 -0
  30. package/report/formatters/ci-annotations.js +20 -0
  31. package/report/formatters/json.js +12 -0
  32. package/report/formatters/markdown.js +25 -0
  33. package/report/formatters/silent.js +8 -0
  34. package/report/formatters/terminal.js +29 -0
  35. package/report/layers/EnvironmentDetectorLive.js +15 -0
  36. package/report/layers/ExecutorResolverLive.js +8 -0
  37. package/report/layers/FormatSelectorLive.js +8 -0
  38. package/report/layers/OutputRendererLive.js +23 -0
  39. package/report/pipeline.js +25 -0
  40. package/report/schema-export.js +18 -0
  41. package/report/schema.js +19 -0
  42. package/report/services/EnvironmentDetector.js +7 -0
  43. package/report/services/ExecutorResolver.js +7 -0
  44. package/report/services/FormatSelector.js +7 -0
  45. package/report/services/OutputRenderer.js +7 -0
  46. package/report/timer.js +15 -0
  47. package/targets/binding.js +15 -0
  48. package/targets/config.js +8 -0
  49. package/targets/resolve-targets.js +126 -0
@@ -0,0 +1,126 @@
1
+ import { ConfigValidationError } from "../errors.js";
2
+ import { isTargetObject } from "./config.js";
3
+
4
+ //#region 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
+ /** Resolve a `publishConfig.targets` map into the distinct groups to build and every target bound to one. Pure; throws ConfigValidationError on structurally-invalid config. */
11
+ function resolveTargets(options) {
12
+ const { targets, baseName } = options;
13
+ const ids = Object.keys(targets);
14
+ if (ids.length === 0) throw new ConfigValidationError({
15
+ path: "publishConfig.targets",
16
+ reason: "publishConfig.targets must declare at least one target"
17
+ });
18
+ const trueIds = ids.filter((id) => targets[id] === true);
19
+ const canonicalId = trueIds.includes("npm") ? "npm" : trueIds[0];
20
+ const registryFor = (id, explicit) => {
21
+ const registry = explicit ?? DEFAULT_REGISTRIES[id];
22
+ if (registry === void 0) throw new ConfigValidationError({
23
+ path: `publishConfig.targets.${id}`,
24
+ reason: `Target "${id}" has no registry; custom targets must set { registry }`
25
+ });
26
+ return registry;
27
+ };
28
+ const groups = /* @__PURE__ */ new Map();
29
+ const addGroup = (id, name) => {
30
+ if (!groups.has(id)) groups.set(id, {
31
+ id,
32
+ name,
33
+ dir: `dist/prod/${id}/pkg`
34
+ });
35
+ };
36
+ const resolved = [];
37
+ const deferredFrom = [];
38
+ for (const id of ids) {
39
+ const value = targets[id];
40
+ if (value === true) {
41
+ if (DEFAULT_REGISTRIES[id] === void 0) throw new ConfigValidationError({
42
+ path: `publishConfig.targets.${id}`,
43
+ reason: `Target "${id}: true" is not a known registry; use an object with { registry }`
44
+ });
45
+ if (id === "github" && !baseName.startsWith("@")) throw new ConfigValidationError({
46
+ path: "publishConfig.targets.github",
47
+ reason: `"github: true" needs a scoped base name; use a string/name override to rescope "${baseName}"`
48
+ });
49
+ const gid = canonicalId;
50
+ addGroup(gid, baseName);
51
+ resolved.push({
52
+ id,
53
+ group: gid,
54
+ name: baseName,
55
+ registry: registryFor(id, void 0)
56
+ });
57
+ } else if (typeof value === "string") {
58
+ if (DEFAULT_REGISTRIES[id] === void 0) throw new ConfigValidationError({
59
+ path: `publishConfig.targets.${id}`,
60
+ reason: `Target "${id}" uses a string name override but has no known registry; use an object { registry, name }`
61
+ });
62
+ addGroup(id, value);
63
+ resolved.push({
64
+ id,
65
+ group: id,
66
+ name: value,
67
+ registry: registryFor(id, void 0)
68
+ });
69
+ } else if (isTargetObject(value)) {
70
+ if (value.from !== void 0 && value.name !== void 0) throw new ConfigValidationError({
71
+ path: `publishConfig.targets.${id}`,
72
+ reason: `Target "${id}" sets both "from" and "name"; they are mutually exclusive`
73
+ });
74
+ if (value.from !== void 0) deferredFrom.push({
75
+ id,
76
+ obj: value
77
+ });
78
+ else if (value.name !== void 0) {
79
+ addGroup(id, value.name);
80
+ resolved.push({
81
+ id,
82
+ group: id,
83
+ name: value.name,
84
+ registry: registryFor(id, value.registry)
85
+ });
86
+ } else {
87
+ addGroup(id, baseName);
88
+ resolved.push({
89
+ id,
90
+ group: id,
91
+ name: baseName,
92
+ registry: registryFor(id, value.registry)
93
+ });
94
+ }
95
+ }
96
+ }
97
+ for (const { id, obj } of deferredFrom) {
98
+ const fromId = obj.from;
99
+ if (fromId === id) throw new ConfigValidationError({
100
+ path: `publishConfig.targets.${id}`,
101
+ reason: `Target "${id}" references itself in "from" (self-referencing from is not allowed)`
102
+ });
103
+ if (deferredFrom.some((d) => d.id === fromId)) throw new ConfigValidationError({
104
+ path: `publishConfig.targets.${id}`,
105
+ reason: `Target "${id}" reuses "from: ${fromId}", which itself uses "from" (no chained reuse)`
106
+ });
107
+ const ref = resolved.find((t) => t.id === fromId);
108
+ if (ref === void 0) throw new ConfigValidationError({
109
+ path: `publishConfig.targets.${id}`,
110
+ reason: `Target "${id}" has a dangling "from: ${fromId}" (no such target)`
111
+ });
112
+ resolved.push({
113
+ id,
114
+ group: ref.group,
115
+ name: ref.name,
116
+ registry: registryFor(id, obj.registry)
117
+ });
118
+ }
119
+ return {
120
+ groups: [...groups.values()],
121
+ targets: resolved
122
+ };
123
+ }
124
+
125
+ //#endregion
126
+ export { resolveTargets };