@effected/bundler 0.1.0 → 0.2.1

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/meta/config.js CHANGED
@@ -17,7 +17,7 @@ function normalizeMetaOptions(meta, env = process.env) {
17
17
  suppressWarnings: meta.tsdoc?.suppressWarnings ?? [],
18
18
  tagDefinitions: meta.tsdoc?.tagDefinitions ?? []
19
19
  },
20
- tsdoctor: meta.tsdoctor
20
+ bundle: meta.bundle
21
21
  };
22
22
  }
23
23
 
package/meta/generate.js CHANGED
@@ -1,12 +1,13 @@
1
- import { TsdoctorEmitError } from "../errors.js";
1
+ import { BundleManifestEmitError } from "../errors.js";
2
2
  import { runApiExtractor } from "./api-extractor.js";
3
- import { TSDOCTOR_MANIFEST_FILENAME, encodeBundleManifest } from "./BundleManifest.js";
3
+ import { composeBundleManifest, ogImageInfoOf } from "./bundle-manifest.js";
4
+ import { RETIRED_MANIFEST_FILENAME } from "./bundle-source.js";
4
5
  import { mergeApiModels } from "./merge-models.js";
5
6
  import { resolveOgCacheSalt, writeGeneratedOgImage } from "./og-image.js";
6
7
  import { scrubDeclarationMapsUnder } from "./scrub-declaration-maps.js";
7
8
  import { resolvePortableTsconfig } from "./tsconfig-resolver.js";
8
9
  import { writeTsdocConfig } from "./tsdoc-config.js";
9
- import { composeTsdoctorManifest, ogImageInfoOf } from "./tsdoctor-manifest.js";
10
+ import { BUNDLE_MANIFEST_FILENAME, encodeBundleManifest } from "@effected/manifest";
10
11
  import { Effect } from "effect";
11
12
  import { copyFileSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
12
13
  import { join, resolve } from "node:path";
@@ -48,6 +49,7 @@ async function generateMeta(options) {
48
49
  const perEntryModels = /* @__PURE__ */ new Map();
49
50
  const intermediateApiJsons = [];
50
51
  let mainEntryDidTsdocMetadata = false;
52
+ let firstFailure;
51
53
  const diagnosticKey = (e) => `${e.code ?? ""}\0${e.text}`;
52
54
  const stripLocation = (e) => ({
53
55
  source: e.source,
@@ -71,21 +73,17 @@ async function generateMeta(options) {
71
73
  const perEntryApiJson = join(outMetaDir, `${safeEntry}.entry.api.json`);
72
74
  intermediateApiJsons.push(perEntryApiJson);
73
75
  const isMain = exportPathFor(entryName) === ".";
74
- const captureRollupOnlyFatal = splitDiagnostics && onMessage !== void 0 && ci !== true;
76
+ const captureRollupOnlyFatal = splitDiagnostics && onMessage !== void 0;
77
+ const isCapturedFatal = (entry) => ci === true ? entry.level === "error" : entry.ciFatal === true;
75
78
  const rollupFatal = [];
76
79
  const runBReported = /* @__PURE__ */ new Set();
77
80
  const captureRollupSuppressed = splitDiagnostics && onSuppressed !== void 0;
78
81
  const rollupSuppressed = [];
79
82
  const runBSuppressed = /* @__PURE__ */ new Set();
80
83
  const runAOnMessage = captureRollupOnlyFatal ? (entry) => {
81
- if (entry.ciFatal === true) rollupFatal.push(entry);
82
- } : ci === true && onMessage !== void 0 ? (entry) => {
83
- if (entry.level === "error") onMessage(stripLocation(entry));
84
+ if (isCapturedFatal(entry)) rollupFatal.push(entry);
84
85
  } : () => {};
85
- const flushRollupSuppressedOnThrow = (err) => {
86
- if (onSuppressed !== void 0) for (const entry of rollupSuppressed) onSuppressed(stripLocation(entry));
87
- throw err;
88
- };
86
+ let runAFailure;
89
87
  try {
90
88
  runApiExtractor({
91
89
  cwd,
@@ -108,12 +106,21 @@ async function generateMeta(options) {
108
106
  }
109
107
  });
110
108
  } catch (err) {
111
- flushRollupSuppressedOnThrow(err);
109
+ if (!splitDiagnostics) throw err;
110
+ runAFailure = { error: err };
112
111
  }
113
112
  if (splitDiagnostics) {
114
113
  const runBOnMessage = captureRollupOnlyFatal && onMessage !== void 0 ? (entry) => {
115
- if (entry.ciFatal === true) runBReported.add(diagnosticKey(entry));
116
- onMessage(entry);
114
+ if (isCapturedFatal(entry) || entry.ciFatal === true) runBReported.add(diagnosticKey(entry));
115
+ if (entry.ciFatal !== true || ci !== true) {
116
+ onMessage(entry);
117
+ return;
118
+ }
119
+ const { ciFatal: _ciFatal, ...escalated } = entry;
120
+ onMessage({
121
+ ...escalated,
122
+ level: "error"
123
+ });
117
124
  } : onMessage;
118
125
  try {
119
126
  runApiExtractor({
@@ -149,9 +156,17 @@ async function generateMeta(options) {
149
156
  onSuppressed(stripLocation(entry));
150
157
  }
151
158
  }
159
+ if (runAFailure !== void 0) {
160
+ firstFailure ??= runAFailure;
161
+ continue;
162
+ }
152
163
  if (isMain) mainEntryDidTsdocMetadata = true;
153
164
  perEntryModels.set(entryName, JSON.parse(readFileSync(perEntryApiJson, "utf-8")));
154
165
  }
166
+ if (firstFailure !== void 0) {
167
+ for (const intermediate of intermediateApiJsons) rmSync(intermediate, { force: true });
168
+ throw firstFailure.error;
169
+ }
155
170
  const finalModel = perEntryModels.size === 1 ? perEntryModels.values().next().value : mergeApiModels({
156
171
  perEntryModels,
157
172
  packageName,
@@ -167,27 +182,28 @@ async function generateMeta(options) {
167
182
  const bundleTsconfig = join(outMetaDir, "tsconfig.json");
168
183
  const portableTsconfig = resolvePortableTsconfig(cwd, tsconfigPath);
169
184
  writeFileSync(bundleTsconfig, `${JSON.stringify(portableTsconfig, null, 2)}\n`, "utf-8");
170
- rmSync(join(outMetaDir, TSDOCTOR_MANIFEST_FILENAME), { force: true });
185
+ rmSync(join(outMetaDir, BUNDLE_MANIFEST_FILENAME), { force: true });
186
+ rmSync(join(outMetaDir, RETIRED_MANIFEST_FILENAME), { force: true });
171
187
  rmSync(join(outMetaDir, "og"), {
172
188
  recursive: true,
173
189
  force: true
174
190
  });
175
191
  let manifestPath;
176
192
  let generatedImageRelative;
177
- if (options.tsdoctor !== void 0) {
193
+ if (options.bundle !== void 0) {
178
194
  const composeInput = {
179
- config: options.tsdoctor.config,
180
- leaf: options.tsdoctor.leaf,
181
- project: options.tsdoctor.project,
195
+ config: options.bundle.config,
196
+ leaf: options.bundle.leaf,
197
+ project: options.bundle.project,
182
198
  packageName,
183
199
  isPrivate: finalPkg.private === true,
184
- targets: options.tsdoctor.targets,
200
+ targets: options.bundle.targets,
185
201
  generatedImage: void 0,
186
202
  repository: manifestRepositoryOf(finalPkg.repository)
187
203
  };
188
- const generate = options.tsdoctor.config?.openGraph?.generate;
204
+ const generate = options.bundle.config?.openGraph?.generate;
189
205
  if (generate !== void 0) {
190
- const cacheSalt = resolveOgCacheSalt(generate, options.tsdoctor.config?.openGraph?.cacheSalt);
206
+ const cacheSalt = resolveOgCacheSalt(generate, options.bundle.config?.openGraph?.cacheSalt);
191
207
  const generated = await writeGeneratedOgImage({
192
208
  generate,
193
209
  info: ogImageInfoOf({
@@ -204,14 +220,14 @@ async function generateMeta(options) {
204
220
  composeInput.generatedImage = generated;
205
221
  generatedImageRelative = generated.path;
206
222
  }
207
- const manifest = composeTsdoctorManifest(composeInput);
223
+ const manifest = composeBundleManifest(composeInput);
208
224
  if (manifest !== void 0) {
209
- const path = join(outMetaDir, TSDOCTOR_MANIFEST_FILENAME);
225
+ const path = join(outMetaDir, BUNDLE_MANIFEST_FILENAME);
210
226
  try {
211
227
  const encoded = await Effect.runPromise(encodeBundleManifest(manifest));
212
228
  writeFileSync(path, `${JSON.stringify(encoded, null, 2)}\n`, "utf-8");
213
229
  } catch (cause) {
214
- throw new TsdoctorEmitError({
230
+ throw new BundleManifestEmitError({
215
231
  packageName,
216
232
  path,
217
233
  cause
@@ -226,8 +242,9 @@ async function generateMeta(options) {
226
242
  copyFileSync(apiJsonPath, join(dest, apiJsonFilename));
227
243
  copyFileSync(bundlePackageJson, join(dest, "package.json"));
228
244
  copyFileSync(bundleTsconfig, join(dest, "tsconfig.json"));
229
- if (manifestPath !== void 0) copyFileSync(manifestPath, join(dest, TSDOCTOR_MANIFEST_FILENAME));
230
- else rmSync(join(dest, TSDOCTOR_MANIFEST_FILENAME), { force: true });
245
+ if (manifestPath !== void 0) copyFileSync(manifestPath, join(dest, BUNDLE_MANIFEST_FILENAME));
246
+ else rmSync(join(dest, BUNDLE_MANIFEST_FILENAME), { force: true });
247
+ rmSync(join(dest, RETIRED_MANIFEST_FILENAME), { force: true });
231
248
  rmSync(join(dest, "og"), {
232
249
  recursive: true,
233
250
  force: true
package/meta/og-image.js CHANGED
@@ -20,7 +20,7 @@ var OgGenerateError = class extends Data.TaggedError("OgGenerateError") {
20
20
  }
21
21
  };
22
22
  /**
23
- * The renderer an `[package.tsdoctor.openGraph] generate` name selects.
23
+ * The renderer an `[package.bundle.openGraph] generate` name selects.
24
24
  *
25
25
  * @remarks
26
26
  * Nothing renders here, but a build asking for an image fails now rather than after its passes when a peer is absent.
package/meta/og-satori.js CHANGED
@@ -90,7 +90,7 @@ function card(info, colors) {
90
90
  };
91
91
  }
92
92
  /**
93
- * Build-time Open Graph image renderers for `[package.tsdoctor.openGraph] generate`.
93
+ * Build-time Open Graph image renderers for `[package.bundle.openGraph] generate`.
94
94
  *
95
95
  * @remarks
96
96
  * `satori()` returns the default card: project name, package name and version, tagline,
@@ -111,7 +111,7 @@ const ogImage = { satori(options = {}) {
111
111
  };
112
112
  const cacheSalt = JSON.stringify({
113
113
  renderer: "@effected/bundler/og#satori",
114
- version: "0.1.0",
114
+ version: "0.2.1",
115
115
  satori: peerVersion("satori"),
116
116
  resvg: peerVersion("@resvg/resvg-js"),
117
117
  colors
package/meta/run-pass.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { resolveNextVersions } from "../changesets/next-versions.js";
2
2
  import { deriveExportPaths } from "../entries/export-paths.js";
3
3
  import { createEntryName } from "../entries/extract.js";
4
- import { TsdoctorEmitError } from "../errors.js";
4
+ import { BundleManifestEmitError } from "../errors.js";
5
5
  import { declarationsDirFor } from "../passes/target-groups.js";
6
+ import { BundleManifestSourceError, loadBundleManifestSources } from "./bundle-source.js";
6
7
  import { normalizeMetaOptions } from "./config.js";
7
8
  import { generateMeta } from "./generate.js";
8
9
  import { OgGenerateError } from "./og-image.js";
9
10
  import { rewriteMetaVersions } from "./optimistic.js";
10
- import { TsdoctorSourceError, loadTsdoctorSources } from "./tsdoctor-source.js";
11
11
  import { join } from "node:path";
12
12
 
13
13
  // src/meta/run-pass.ts
@@ -31,15 +31,15 @@ async function runMetaPass(o) {
31
31
  const resolveNext = o.resolveNextVersions ?? resolveNextVersions;
32
32
  const nextVersions = norm.optimistic ? await resolveNext(o.cwd) : void 0;
33
33
  const manifestTransform = nextVersions ? (m) => rewriteMetaVersions(m, nextVersions.versions, o.packageName) : void 0;
34
- const loadSources = o.loadTsdoctorSources ?? loadTsdoctorSources;
34
+ const loadSources = o.loadBundleManifestSources ?? loadBundleManifestSources;
35
35
  let sources;
36
36
  try {
37
37
  sources = await loadSources(o.cwd);
38
38
  } catch (err) {
39
- if (err instanceof TsdoctorSourceError) for (const g of o.groups) o.collector.recordError(g.id, {
39
+ if (err instanceof BundleManifestSourceError) for (const g of o.groups) o.collector.recordError(g.id, {
40
40
  source: "meta",
41
41
  level: "error",
42
- code: "tsdoctor-source-invalid",
42
+ code: "bundle-manifest-source-invalid",
43
43
  text: err.message,
44
44
  file: err.path
45
45
  });
@@ -48,8 +48,15 @@ async function runMetaPass(o) {
48
48
  if (sources.discoveryFailure !== void 0) for (const g of o.groups) o.collector.recordWarning(g.id, {
49
49
  source: "meta",
50
50
  level: "warn",
51
- code: "tsdoctor-workspace-discovery-failed",
52
- text: `Workspace discovery failed, so tsdoctor.json has no project tier: ${sources.discoveryFailure}`
51
+ code: "bundle-manifest-workspace-discovery-failed",
52
+ text: `Workspace discovery failed, so bundle.json has no project tier: ${sources.discoveryFailure}`
53
+ });
54
+ for (const path of sources.retiredSources ?? []) for (const g of o.groups) o.collector.recordWarning(g.id, {
55
+ source: "meta",
56
+ level: "warn",
57
+ code: "bundle-manifest-retired-source",
58
+ text: `${path} is no longer read; rename it to bundle.json`,
59
+ file: path
53
60
  });
54
61
  for (const g of o.groups) {
55
62
  const targets = (o.targets ?? []).filter((t) => t.group === g.id).map((t) => ({
@@ -70,8 +77,8 @@ async function runMetaPass(o) {
70
77
  tsdoc: norm.tsdoc,
71
78
  ...manifestTransform !== void 0 ? { manifestTransform } : {},
72
79
  ci: o.ci,
73
- tsdoctor: {
74
- config: norm.tsdoctor,
80
+ bundle: {
81
+ config: norm.bundle,
75
82
  leaf: sources.leaf,
76
83
  project: sources.project,
77
84
  targets
@@ -86,10 +93,10 @@ async function runMetaPass(o) {
86
93
  code: "og-generate-failed",
87
94
  text: err.message
88
95
  });
89
- else if (err instanceof TsdoctorEmitError) o.collector.recordError(g.id, {
96
+ else if (err instanceof BundleManifestEmitError) o.collector.recordError(g.id, {
90
97
  source: "meta",
91
98
  level: "error",
92
- code: "tsdoctor-emit-failed",
99
+ code: "bundle-manifest-emit-failed",
93
100
  text: err.message,
94
101
  file: err.path
95
102
  });
@@ -1,6 +1,6 @@
1
+ import { isDeepStrictEqual } from "node:util";
1
2
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
3
  import { join } from "node:path";
3
- import { isDeepStrictEqual } from "node:util";
4
4
  import { StandardTags } from "@microsoft/tsdoc";
5
5
 
6
6
  // src/meta/tsdoc-config.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/bundler",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "description": "The kit's build pipeline: effected.toml config, tsdown JS and declaration passes, API Extractor meta, SEA, GitHub Action bundles and build journals.",
6
6
  "keywords": [
@@ -39,31 +39,32 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@effect/platform-node": "~4.1.2",
42
- "@effected/changesets": "0.1.0",
42
+ "@effected/changesets": "0.3.0",
43
43
  "@effected/config-file": "^0.26.0",
44
44
  "@effected/env": "^0.11.0",
45
45
  "@effected/files": "^0.2.0",
46
46
  "@effected/glob": "^0.20.0",
47
47
  "@effected/images": "^0.9.0",
48
48
  "@effected/jsonc": "^0.24.0",
49
- "@effected/jsonl": "^0.18.0",
50
- "@effected/npm": "^0.31.0",
51
- "@effected/package-json": "^0.31.0",
52
- "@effected/semver": "^0.22.0",
49
+ "@effected/jsonl": "^0.18.1",
50
+ "@effected/manifest": "^0.1.0",
51
+ "@effected/npm": "^0.32.1",
52
+ "@effected/package-json": "^0.31.2",
53
+ "@effected/semver": "^0.23.0",
53
54
  "@effected/toml": "^0.19.1",
54
55
  "@effected/tsconfig-json": "^0.20.2",
55
56
  "@effected/walker": "^0.26.0",
56
- "@effected/workspaces": "^0.44.0",
57
+ "@effected/workspaces": "^0.44.2",
57
58
  "@effected/yaml": "^0.29.0",
58
59
  "@jridgewell/sourcemap-codec": "^1.6.0",
59
60
  "@microsoft/api-extractor": "^7.60.1",
60
61
  "@microsoft/tsdoc": "~0.17.1",
61
62
  "@microsoft/tsdoc-config": "~0.18.3",
62
- "@tsdown/exe": "^0.23.4",
63
+ "@tsdown/exe": "^0.23.7",
63
64
  "jiti": "~2.7.0",
64
- "rolldown": "^1.2.16",
65
+ "rolldown": "^1.3.1",
65
66
  "rolldown-plugin-dts": "^0.30.0",
66
- "tsdown": "^0.23.4"
67
+ "tsdown": "^0.23.7"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "@resvg/resvg-js": "^2.6.2",
@@ -35,7 +35,7 @@ const copyEntriesFor = (entries, outDir) => entries.map((entry) => {
35
35
  * Each group runs TWO passes to the SAME outDir:
36
36
  * 1. JS pass — per-module JS (`unbundle: true`, `dts: false`), with the `emitManifest` plugin
37
37
  * and the `public/` copy. Default `clean: true` gives it a fresh outDir.
38
- * 2. dts pass — bundled declarations only (`unbundle: false`, `dts: { emitDtsOnly: true }`,
38
+ * 2. dts pass — bundled declarations only (`unbundle: false`, `dts: { dtsOnly: true }` (`emitDtsOnly` below rolldown-plugin-dts 0.30),
39
39
  * `clean: false`). No manifest plugin, no copy, no sourcemaps. `clean: false` is load-bearing:
40
40
  * it must NOT wipe the JS the first pass just wrote.
41
41
  *
@@ -138,6 +138,7 @@ async function buildTargetGroups(options) {
138
138
  targetGroup,
139
139
  devManifest: options.devManifest,
140
140
  drop: options.drop,
141
+ ...options.set !== void 0 ? { set: options.set } : {},
141
142
  sourceDir: options.cwd,
142
143
  dual: options.dualExports ?? js.format.includes("cjs"),
143
144
  emitDts: options.emitDts !== false,
@@ -1,9 +1,6 @@
1
- import { Result } from "effect";
2
- import { rmSync } from "node:fs";
3
- import { join, resolve } from "node:path";
1
+ import { Effect, FileSystem, Path, Result } from "effect";
4
2
  import { GlobPattern, GlobPatternOptions } from "@effected/glob";
5
- import { descendSync } from "@effected/walker";
6
- import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
3
+ import { descend } from "@effected/walker";
7
4
 
8
5
  // src/passes/strip-maps.ts
9
6
  /** `.d.ts.map` / `.d.cts.map` at any depth, dot-directories included. */
@@ -23,17 +20,21 @@ const STRIPPABLE_MAPS = Result.getOrThrow(GlobPattern.compileResult("**/*.d.{ts,
23
20
  * vendored tree — only the package's own emitted declarations carry maps worth stripping.
24
21
  * @public
25
22
  */
26
- function removeDeclarationMaps(pkgDir) {
27
- return Result.getOrThrow(descendSync(STRIPPABLE_MAPS, {
28
- cwd: resolve(pkgDir),
23
+ const removeDeclarationMaps = Effect.fnUntraced(function* (pkgDir) {
24
+ const fs = yield* FileSystem.FileSystem;
25
+ const path = yield* Path.Path;
26
+ const root = path.resolve(pkgDir);
27
+ const maps = yield* descend(STRIPPABLE_MAPS, {
28
+ cwd: root,
29
29
  prune: ["node_modules"],
30
- onUnreadable: "skip",
31
- ...nodeWalkerSyncOps
32
- })).map((rel) => {
33
- const full = join(pkgDir, rel);
34
- rmSync(full, { force: true });
35
- return full;
30
+ onUnreadable: "skip"
36
31
  });
37
- }
32
+ const removed = [];
33
+ for (const rel of maps) {
34
+ yield* fs.remove(path.join(root, rel), { force: true });
35
+ removed.push(path.join(pkgDir, rel));
36
+ }
37
+ return removed;
38
+ });
38
39
 
39
40
  export { removeDeclarationMaps };
@@ -1,16 +1,63 @@
1
+ import { createRequire } from "node:module";
2
+ import { Result } from "effect";
3
+ import { readFileSync } from "node:fs";
1
4
  import { join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { SemVer } from "@effected/semver";
2
7
 
3
8
  // src/passes/target-groups.ts
4
9
  /** The `file://` URL of the TypeScript module this package resolves (its own pinned dependency). */
5
10
  const typescriptModuleUrl = () => import.meta.resolve("typescript");
11
+ /** The first rolldown-plugin-dts release that reads `dtsOnly`. */
12
+ const DTS_ONLY_SINCE = "0.30.0";
13
+ /**
14
+ * Choose the declarations-only option key for a rolldown-plugin-dts version.
15
+ *
16
+ * 0.30 and later read `dtsOnly` and warn on `emitDtsOnly`; earlier releases read only
17
+ * `emitDtsOnly` and silently ignore `dtsOnly`, which would turn the declaration pass into a
18
+ * JS-emitting pass. An unknown or unparsable version gets `emitDtsOnly`, which both lines honour.
19
+ *
20
+ * @public
21
+ */
22
+ const dtsOnlyOption = (pluginVersion) => {
23
+ if (pluginVersion !== void 0) {
24
+ const have = SemVer.parseResult(pluginVersion);
25
+ const want = SemVer.parseResult(DTS_ONLY_SINCE);
26
+ if (Result.isSuccess(have) && Result.isSuccess(want) && have.success.gte(want.success)) return { dtsOnly: true };
27
+ }
28
+ return { emitDtsOnly: true };
29
+ };
30
+ /**
31
+ * The version of the rolldown-plugin-dts copy tsdown will load, or `undefined` when it cannot
32
+ * be determined. It is resolved from tsdown's own location, not this package's, because a
33
+ * workspace override can point tsdown at a different copy than this package depends on.
34
+ */
35
+ const resolveDtsPluginVersion = () => {
36
+ try {
37
+ const fromTsdown = createRequire(fileURLToPath(import.meta.resolve("tsdown")));
38
+ const manifest = JSON.parse(readFileSync(fromTsdown.resolve("rolldown-plugin-dts/package.json"), "utf8"));
39
+ return typeof manifest.version === "string" ? manifest.version : void 0;
40
+ } catch {
41
+ return;
42
+ }
43
+ };
44
+ /** Resolved once per process; a build is one process. */
45
+ let dtsPluginVersion;
46
+ const installedDtsPluginVersion = () => {
47
+ dtsPluginVersion ??= { value: resolveDtsPluginVersion() };
48
+ return dtsPluginVersion.value;
49
+ };
6
50
  /**
7
51
  * Build the {@link DtsPassDtsOptions} for a resolved tsconfig path.
8
52
  *
53
+ * @param tsconfig - The resolved tsconfig path.
54
+ * @param pluginVersion - The rolldown-plugin-dts version to target; defaults to the copy tsdown loads.
55
+ *
9
56
  * @public
10
57
  */
11
- const dtsPassDtsOptions = (tsconfig) => ({
58
+ const dtsPassDtsOptions = (tsconfig, pluginVersion = installedDtsPluginVersion()) => ({
12
59
  tsconfig,
13
- emitDtsOnly: true,
60
+ ...dtsOnlyOption(pluginVersion),
14
61
  generator: "tsgo",
15
62
  tsgo: { moduleUrl: typescriptModuleUrl() }
16
63
  });
@@ -109,4 +156,4 @@ function deriveDeclarationsPassOptions(options) {
109
156
  };
110
157
  }
111
158
 
112
- export { declarationsDirFor, deriveDeclarationsPassOptions, deriveDtsPassOptions, deriveTargetGroupOptions, dtsPassDtsOptions, outDirFor };
159
+ export { declarationsDirFor, deriveDeclarationsPassOptions, deriveDtsPassOptions, deriveTargetGroupOptions, dtsOnlyOption, dtsPassDtsOptions, outDirFor };
@@ -1,7 +1,5 @@
1
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";
2
+ import { Clock, Effect, FileSystem, Path, Schema } from "effect";
5
3
 
6
4
  // src/report/issues-artifact.ts
7
5
  /**
@@ -131,25 +129,21 @@ function serializeIssues(issues) {
131
129
  *
132
130
  * @public
133
131
  */
134
- function writeIssuesArtifact(opts) {
135
- const clock = opts.now ?? (() => /* @__PURE__ */ new Date());
132
+ const writeIssuesArtifact = Effect.fnUntraced(function* (opts) {
133
+ const fs = yield* FileSystem.FileSystem;
134
+ const path = yield* Path.Path;
135
+ const generatedAt = opts.now !== void 0 ? opts.now() : new Date(yield* Clock.currentTimeMillis);
136
136
  const issues = flattenIssues(opts.reports, {
137
137
  target: opts.target,
138
- generatedAt: clock().toISOString(),
138
+ generatedAt: generatedAt.toISOString(),
139
139
  buildOk: opts.buildOk,
140
140
  failure: opts.failure
141
141
  });
142
- const outPath = join(opts.cwd, "dist", opts.target, "issues.json");
143
- mkdirSync(dirname(outPath), { recursive: true });
142
+ const outPath = path.join(opts.cwd, "dist", opts.target, "issues.json");
143
+ yield* fs.makeDirectory(path.dirname(outPath), { recursive: true });
144
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
- }
145
+ yield* fs.writeFileString(tmpPath, serializeIssues(issues)).pipe(Effect.andThen(fs.rename(tmpPath, outPath)), Effect.onError(() => fs.remove(tmpPath, { force: true }).pipe(Effect.ignore)));
152
146
  return outPath;
153
- }
147
+ });
154
148
 
155
149
  export { BuildIssuesSchema, PlainDiagnosticSchema, flattenIssues, serializeIssues, writeIssuesArtifact };
package/report/schema.js CHANGED
@@ -5,7 +5,7 @@ import { Schema } from "effect";
5
5
  var ReportTimings = class extends Schema.Class("ReportTimings")({ totalMs: Schema.Number }) {};
6
6
  /**
7
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
8
+ * pass's own sidecar work (`bundle.json` sources, Open Graph generation), or an advisory finding
9
9
  * about the build config itself (`config`, e.g. a `publishConfig.targets` set no final release reaches).
10
10
  *
11
11
  * @public
@@ -1,5 +1,4 @@
1
- import { mkdirSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
1
+ import { Effect, FileSystem, Path } from "effect";
3
2
 
4
3
  // src/targets/binding.ts
5
4
  /**
@@ -7,12 +6,14 @@ import { join } from "node:path";
7
6
  *
8
7
  * @public
9
8
  */
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
- }
9
+ const writeTargetsBinding = Effect.fnUntraced(function* (cwd, resolution) {
10
+ const fs = yield* FileSystem.FileSystem;
11
+ const path = yield* Path.Path;
12
+ const dir = path.join(cwd, "dist", "prod");
13
+ yield* fs.makeDirectory(dir, { recursive: true });
14
+ const file = path.join(dir, "targets.json");
15
+ yield* fs.writeFileString(file, `${JSON.stringify(resolution, null, " ")}\n`);
16
+ return file;
17
+ });
17
18
 
18
19
  export { writeTargetsBinding };