@savvy-web/tsdown-plugins 2.4.8 → 2.4.10
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/api-extractor.js +42 -3
- package/package.json +3 -3
package/meta/api-extractor.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { MetaGenerationError } from "../errors.js";
|
|
2
2
|
import { createMessageSuppressor } from "./message-suppressor.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
-
import {
|
|
4
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
5
8
|
import { Extractor, ExtractorConfig, ExtractorLogLevel } from "@microsoft/api-extractor";
|
|
6
9
|
import { TSDocConfigFile } from "@microsoft/tsdoc-config";
|
|
7
10
|
|
|
@@ -10,6 +13,38 @@ const require_ = createRequire(import.meta.url);
|
|
|
10
13
|
/** messageIds that become a hard build error in CI (they corrupt the .api.json). */
|
|
11
14
|
const CI_FATAL_MESSAGE_IDS = /* @__PURE__ */ new Set(["ae-forgotten-export"]);
|
|
12
15
|
/**
|
|
16
|
+
* Derive the extractor-scoped tsconfig for ONE api-extractor run and return its path (#354).
|
|
17
|
+
*
|
|
18
|
+
* The compile tsconfig's `include` covers `src/**` — necessary for the dts-emit pass, poison for
|
|
19
|
+
* the extractor: a hand-authored `src/*.d.ts` shim matched by that glob survives api-extractor's
|
|
20
|
+
* .d.ts root filter, and a self-name import inside it resolves through the SOURCE manifest's
|
|
21
|
+
* `exports` to raw `.ts` sources under `src/`, putting non-declaration files in the Program and
|
|
22
|
+
* firing an unsuppressable `ae-wrong-input-file-type` on every build. The derived config keeps the
|
|
23
|
+
* base's `compilerOptions` (via an absolute-path `extends`) but replaces the input set with exactly
|
|
24
|
+
* what the extractor's Program should hold: the entry `.d.ts` (`files`) plus the `types/*.d.ts`
|
|
25
|
+
* legacy typings — the same effective roots as before minus everything under `src/`.
|
|
26
|
+
*
|
|
27
|
+
* Best-effort, mirroring `writeDtsEmitTsconfig`: a base that does not exist (e.g. a synthetic test
|
|
28
|
+
* path) gets no variant — the original path is returned unchanged. The filename is deterministic
|
|
29
|
+
* per (pid, base, entry) via a content hash (the two joined paths overflow a filename), so repeated
|
|
30
|
+
* calls within a process overwrite the same file; cross-process temp files are left for the OS to
|
|
31
|
+
* reap, consistent with the other tmpdir tsconfig writers.
|
|
32
|
+
*/
|
|
33
|
+
function writeApiExtractorTsconfig(options) {
|
|
34
|
+
const absBase = isAbsolute(options.tsconfigPath) ? options.tsconfigPath : resolve(options.tsconfigPath);
|
|
35
|
+
if (!existsSync(absBase)) return options.tsconfigPath;
|
|
36
|
+
const entryDts = isAbsolute(options.entryDtsPath) ? options.entryDtsPath : resolve(options.cwd, options.entryDtsPath);
|
|
37
|
+
const cfg = {
|
|
38
|
+
extends: absBase,
|
|
39
|
+
files: [entryDts],
|
|
40
|
+
include: [join(options.cwd, "types/*.d.ts")]
|
|
41
|
+
};
|
|
42
|
+
const hash = createHash("sha256").update(`${absBase}\0${entryDts}`).digest("hex").slice(0, 16);
|
|
43
|
+
const path = join(tmpdir(), `tsconfig-api-extractor-${process.pid}-${hash}.json`);
|
|
44
|
+
writeFileSync(path, `${JSON.stringify(cfg, null, " ")}\n`, "utf-8");
|
|
45
|
+
return path;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
13
48
|
* Map an API Extractor message to a collector DiagnosticInput, or undefined if not warn/error.
|
|
14
49
|
*
|
|
15
50
|
* Location (`file`/`line`/`column`) is preserved: diagnostics now come from a per-module declaration
|
|
@@ -40,7 +75,11 @@ function runApiExtractor(options) {
|
|
|
40
75
|
projectFolder: options.cwd,
|
|
41
76
|
mainEntryPointFilePath: options.entryDtsPath,
|
|
42
77
|
enumMemberOrder: "preserve",
|
|
43
|
-
compiler: { tsconfigFilePath:
|
|
78
|
+
compiler: { tsconfigFilePath: writeApiExtractorTsconfig({
|
|
79
|
+
cwd: options.cwd,
|
|
80
|
+
tsconfigPath: options.tsconfigPath,
|
|
81
|
+
entryDtsPath: options.entryDtsPath
|
|
82
|
+
}) },
|
|
44
83
|
docModel: options.emitDocModel === false ? { enabled: false } : {
|
|
45
84
|
enabled: true,
|
|
46
85
|
apiJsonFilePath: options.apiJsonPath,
|
|
@@ -103,4 +142,4 @@ function runApiExtractor(options) {
|
|
|
103
142
|
}
|
|
104
143
|
|
|
105
144
|
//#endregion
|
|
106
|
-
export { mapExtractorMessage, runApiExtractor };
|
|
145
|
+
export { mapExtractorMessage, runApiExtractor, writeApiExtractorTsconfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/tsdown-plugins",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.10",
|
|
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",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"./package.json": "./package.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@changesets/get-release-plan": "^5.0.0
|
|
32
|
+
"@changesets/get-release-plan": "^5.0.0",
|
|
33
33
|
"@effect/platform-node": "4.0.0-beta.107",
|
|
34
34
|
"@effected/npm": "^0.9.0",
|
|
35
35
|
"@effected/package-json": "^0.8.0",
|
|
36
36
|
"@effected/tsconfig-json": "^0.5.0",
|
|
37
|
-
"@effected/workspaces": "^0.
|
|
37
|
+
"@effected/workspaces": "^0.12.0",
|
|
38
38
|
"@microsoft/api-extractor": "^7.58.12",
|
|
39
39
|
"@microsoft/tsdoc": "^0.16.0",
|
|
40
40
|
"@microsoft/tsdoc-config": "^0.18.1",
|