@savvy-web/tsdown-plugins 0.10.0 → 0.11.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 (2) hide show
  1. package/meta/generate.js +46 -20
  2. package/package.json +1 -1
package/meta/generate.js CHANGED
@@ -31,11 +31,27 @@ async function generateMeta(options) {
31
31
  const perEntryModels = /* @__PURE__ */ new Map();
32
32
  const intermediateApiJsons = [];
33
33
  let mainEntryDidTsdocMetadata = false;
34
+ const diagnosticKey = (e) => `${e.code ?? ""}\0${e.text}`;
35
+ const stripLocation = (e) => ({
36
+ source: e.source,
37
+ level: e.level,
38
+ text: e.text,
39
+ ...e.code !== void 0 ? { code: e.code } : {},
40
+ ...e.ciFatal !== void 0 ? { ciFatal: e.ciFatal } : {}
41
+ });
34
42
  for (const entryName of entryNames) {
35
43
  const modelEntryDts = join(dtsDir, `${entries[entryName]}.d.ts`);
36
44
  const perEntryApiJson = join(outMetaDir, `${entryName.replace(/[\\/]/g, "__")}.entry.api.json`);
37
45
  intermediateApiJsons.push(perEntryApiJson);
38
46
  const isMain = (exportPaths[entryName] ?? (entryName === "index" ? "." : `./${entryName}`)) === ".";
47
+ const captureRollupOnlyFatal = splitDiagnostics && onMessage !== void 0 && ci !== true;
48
+ const rollupFatal = [];
49
+ const runBReported = /* @__PURE__ */ new Set();
50
+ const runAOnMessage = captureRollupOnlyFatal ? (entry) => {
51
+ if (entry.ciFatal === true) rollupFatal.push(entry);
52
+ } : ci === true && onMessage !== void 0 ? (entry) => {
53
+ if (entry.level === "error") onMessage(stripLocation(entry));
54
+ } : () => {};
39
55
  runApiExtractor({
40
56
  cwd,
41
57
  packageJsonPath,
@@ -46,30 +62,40 @@ async function generateMeta(options) {
46
62
  ...isMain && !mainEntryDidTsdocMetadata ? { tsdocMetadataPath } : {},
47
63
  suppressWarnings: tsdoc.suppressWarnings,
48
64
  ...ci !== void 0 ? { ci } : {},
49
- ...splitDiagnostics ? { onMessage: () => {} } : {
65
+ ...splitDiagnostics ? { onMessage: runAOnMessage } : {
50
66
  ...onMessage !== void 0 ? { onMessage } : {},
51
67
  ...onSuppressed !== void 0 ? { onSuppressed } : {}
52
68
  }
53
69
  });
54
- if (splitDiagnostics) try {
55
- runApiExtractor({
56
- cwd,
57
- packageJsonPath,
58
- entryDtsPath: join(aeInputDir, `${entries[entryName]}.d.ts`),
59
- tsconfigPath,
60
- tsdocConfigPath,
61
- apiJsonPath: perEntryApiJson,
62
- emitDocModel: false,
63
- suppressWarnings: tsdoc.suppressWarnings,
64
- ...onMessage !== void 0 ? { onMessage } : {},
65
- ...onSuppressed !== void 0 ? { onSuppressed } : {}
66
- });
67
- } catch (err) {
68
- if (onMessage !== void 0) onMessage({
69
- source: "api-extractor",
70
- level: "warn",
71
- text: `Could not harvest per-module source locations for "${entryName}": ${String(err)}`
72
- });
70
+ if (splitDiagnostics) {
71
+ const runBOnMessage = captureRollupOnlyFatal && onMessage !== void 0 ? (entry) => {
72
+ if (entry.ciFatal === true) runBReported.add(diagnosticKey(entry));
73
+ onMessage(entry);
74
+ } : onMessage;
75
+ try {
76
+ runApiExtractor({
77
+ cwd,
78
+ packageJsonPath,
79
+ entryDtsPath: join(aeInputDir, `${entries[entryName]}.d.ts`),
80
+ tsconfigPath,
81
+ tsdocConfigPath,
82
+ apiJsonPath: perEntryApiJson,
83
+ emitDocModel: false,
84
+ suppressWarnings: tsdoc.suppressWarnings,
85
+ ...runBOnMessage !== void 0 ? { onMessage: runBOnMessage } : {},
86
+ ...onSuppressed !== void 0 ? { onSuppressed } : {}
87
+ });
88
+ } catch (err) {
89
+ if (onMessage !== void 0) onMessage({
90
+ source: "api-extractor",
91
+ level: "warn",
92
+ text: `Could not harvest per-module source locations for "${entryName}": ${String(err)}`
93
+ });
94
+ }
95
+ if (captureRollupOnlyFatal && onMessage !== void 0) for (const entry of rollupFatal) {
96
+ if (runBReported.has(diagnosticKey(entry))) continue;
97
+ onMessage(stripLocation(entry));
98
+ }
73
99
  }
74
100
  if (isMain) mainEntryDidTsdocMetadata = true;
75
101
  perEntryModels.set(entryName, JSON.parse(readFileSync(perEntryApiJson, "utf-8")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/tsdown-plugins",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",