@savvy-web/tsdown-plugins 2.2.1 → 2.3.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.
@@ -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
- copyPublicDir(publicDir, outDirFor(options.cwd, group.id));
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) versions.set(r.name, r.newVersion);
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,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
- * Build the portable absolute-path tsconfig object (ported from rslib writeBundleTempConfig).
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
- declaration: true,
16
- emitDeclarationOnly: false,
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/**/*")]
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). Anything omitted falls back to the base
498
- * build's value. `entry` is a subset of the package's entries (`entryName -> source path`).
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 {
@@ -1285,11 +1289,9 @@ declare function findRelativeSpecifiers(source: string, fileName?: string): stri
1285
1289
  interface ResolvedTsconfigOptions {
1286
1290
  /** Absolute package root. */
1287
1291
  readonly cwd: string;
1288
- /** Explicit `types` to forward (default ["node"]). Pulled from the project tsconfig by the caller. */
1289
- readonly types?: ReadonlyArray<string> | undefined;
1290
- /** TS `compilerOptions.jsx` to forward into the dts tsconfig (e.g. "react-jsx"). */
1292
+ /** TS `compilerOptions.jsx` override (e.g. "react-jsx"); wins over the resolved config. */
1291
1293
  readonly jsx?: string | undefined;
1292
- /** TS `compilerOptions.jsxImportSource` to forward (e.g. "react"). */
1294
+ /** TS `compilerOptions.jsxImportSource` override (e.g. "react"); wins over the resolved config. */
1293
1295
  readonly jsxImportSource?: string | undefined;
1294
1296
  }
1295
1297
  /** @public */
@@ -1299,7 +1301,19 @@ interface ResolvedTsconfig {
1299
1301
  readonly exclude: ReadonlyArray<string>;
1300
1302
  }
1301
1303
  /**
1302
- * Build the portable absolute-path tsconfig object (ported from rslib writeBundleTempConfig).
1304
+ * Build the portable absolute-path tsconfig object for the dts pass.
1305
+ *
1306
+ * @remarks
1307
+ * Resolves the package's own `<cwd>/tsconfig.json` (which extends the shared
1308
+ * `ecma.json` base) through `@effected/tsconfig-json`'s `TsconfigLoaderSync`, so the
1309
+ * result carries the package's real effective options — target, module, lib, strict,
1310
+ * jsx — with `${configDir}` already substituted to absolute paths. Only the dts-pass
1311
+ * overlay (composite/incremental/tsBuildInfoFile forced off, declarationMap forced on)
1312
+ * and an explicit jsx override are layered on top.
1313
+ *
1314
+ * `include`/`exclude` are NOT taken from the resolved config. The shared base includes
1315
+ * `__test__` and `lib` sources, which have no business in a declaration program; the
1316
+ * narrow list below is dts-pass-specific and deliberately held fixed.
1303
1317
  *
1304
1318
  * @public
1305
1319
  */
@@ -1567,63 +1581,6 @@ interface PortableTsconfig {
1567
1581
  /** Compiler options with enum values converted to strings. */
1568
1582
  compilerOptions: ResolvedCompilerOptions;
1569
1583
  }
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
1584
  /**
1628
1585
  * Resolves the package's effective compiler options (following `extends`) into a
1629
1586
  * portable, JSON-serializable tsconfig for the meta release bundle.
@@ -1913,5 +1870,5 @@ declare function resolveTargets(options: {
1913
1870
  baseName: string;
1914
1871
  }): TargetResolution;
1915
1872
  //#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, ConfigValidatorLive, 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, EnvironmentDetectorLive, type ExeBuild, type ExeConfig, type ExeRewrite, type ExeSeaConfig, type ExeTarget, type ExeTargetInput, type Executor, ExecutorResolver, ExecutorResolverLive, type ExtractAmbientOptions, type ExtractOptions, type ExtractResult, FormatSelector, FormatSelectorLive, 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, OutputRendererLive, 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, ReportPipelineLive, 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, TsconfigResolver, 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 };
1873
+ 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, ConfigValidatorLive, 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, EnvironmentDetectorLive, type ExeBuild, type ExeConfig, type ExeRewrite, type ExeSeaConfig, type ExeTarget, type ExeTargetInput, type Executor, ExecutorResolver, ExecutorResolverLive, type ExtractAmbientOptions, type ExtractOptions, type ExtractResult, FormatSelector, FormatSelectorLive, 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, OutputRendererLive, 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, ReportPipelineLive, 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
1874
  //# 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";
@@ -28,7 +28,7 @@ import { runExeBuild } from "./exe/build.js";
28
28
  import { computeExeFileName } from "./exe/filename.js";
29
29
  import { readTsconfigJsx, resolveJsxConfig } from "./jsx/config.js";
30
30
  import { normalizeMetaOptions } from "./meta/config.js";
31
- import { TsconfigResolver, resolvePortableTsconfig } from "./meta/tsconfig-resolver.js";
31
+ import { resolvePortableTsconfig } from "./meta/tsconfig-resolver.js";
32
32
  import { generateMeta } from "./meta/generate.js";
33
33
  import { rewriteMetaVersions } from "./meta/optimistic.js";
34
34
  import { applySubdirMetaEntries, deriveExportPaths, runMetaPass } from "./meta/run-pass.js";
@@ -52,4 +52,4 @@ import { ReportPipelineLive, renderReport } from "./report/pipeline.js";
52
52
  import { writeTargetsBinding } from "./targets/binding.js";
53
53
  import { CatalogAssemblyError, DependencyResolutionError, ManifestDecodeError, UnresolvedDependencyError } from "@effected/npm";
54
54
 
55
- export { BuildCollector, BuildCollectorTag, BuildReport as BuildReportSchema, CatalogAssemblyError, CiAnnotationsFormatter, ConfigValidationError, ConfigValidator, ConfigValidatorLive, DEFAULT_EXE_NODE_VERSION, DependencyResolutionError, EnvironmentDetector, EnvironmentDetectorLive, ExecutorResolver, ExecutorResolverLive, FormatSelector, FormatSelectorLive, JsonFormatter, ManifestDecodeError, MarkdownFormatter, MetaGenerationError, OutputRenderer, OutputRendererLive, ReportPipelineLive, ReportTimings, SilentFormatter, TargetGroupReport as TargetGroupReportSchema, TerminalFormatter, TsconfigResolver, 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 };
55
+ export { BuildCollector, BuildCollectorTag, BuildReport as BuildReportSchema, CatalogAssemblyError, CiAnnotationsFormatter, ConfigValidationError, ConfigValidator, ConfigValidatorLive, DEFAULT_EXE_NODE_VERSION, DependencyResolutionError, EnvironmentDetector, EnvironmentDetectorLive, ExecutorResolver, ExecutorResolverLive, FormatSelector, FormatSelectorLive, JsonFormatter, ManifestDecodeError, MarkdownFormatter, MetaGenerationError, OutputRenderer, OutputRendererLive, ReportPipelineLive, 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 { existsSync, readFileSync } from "node:fs";
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, syncOptions);
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 } : {}
@@ -1,6 +1,6 @@
1
- import { existsSync, readFileSync } from "node:fs";
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, syncOptions);
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 { TsconfigResolver, resolvePortableTsconfig };
56
+ export { resolvePortableTsconfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/tsdown-plugins",
3
- "version": "2.2.1",
3
+ "version": "2.3.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,17 +31,17 @@
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.5.0",
35
- "@effected/package-json": "^0.6.0",
36
- "@effected/tsconfig-json": "^0.3.2",
37
- "@effected/workspaces": "^0.9.0",
34
+ "@effected/npm": "^0.6.0",
35
+ "@effected/package-json": "^0.6.1",
36
+ "@effected/tsconfig-json": "^0.4.0",
37
+ "@effected/workspaces": "^0.9.1",
38
38
  "@microsoft/api-extractor": "^7.58.12",
39
39
  "@microsoft/tsdoc": "^0.16.0",
40
40
  "@microsoft/tsdoc-config": "^0.18.1",
41
41
  "effect": "4.0.0-beta.101",
42
42
  "picocolors": "^1.1.1",
43
43
  "std-env": "^4.2.0",
44
- "tsdown": "^0.22.12",
44
+ "tsdown": "^0.22.14",
45
45
  "typescript": "^6.0.3"
46
46
  }
47
47
  }
@@ -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 };