@bufbuild/protoplugin 2.2.1 → 2.2.3

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.
@@ -118,7 +118,32 @@ function transpile(files, transpileJs, transpileDts, jsImportStyle) {
118
118
  throw err;
119
119
  }
120
120
  if (result.emitSkipped) {
121
- throw Error("A problem occurred during transpilation and files were not generated. Contact the plugin author for support.");
121
+ // When compilation fails, this error message is printed to stderr.
122
+ const diagnostics = formatDiagnostics(result.diagnostics);
123
+ throw Error(`A problem occurred during transpilation and files were not generated. Contact the plugin author for support.\n\n${diagnostics}`);
122
124
  }
123
125
  return results;
124
126
  }
127
+ function formatDiagnostics(diagnostics) {
128
+ const sorted = typescript_1.default.sortAndDeduplicateDiagnostics(diagnostics);
129
+ if (sorted.length == 0) {
130
+ return "";
131
+ }
132
+ const first = sorted.slice(0, 3);
133
+ const formatHost = {
134
+ getCanonicalFileName(fileName) {
135
+ return fileName;
136
+ },
137
+ getCurrentDirectory() {
138
+ return ".";
139
+ },
140
+ getNewLine() {
141
+ return "\n";
142
+ },
143
+ };
144
+ let out = typescript_1.default.formatDiagnostics(first, formatHost).trim();
145
+ if (first.length < sorted.length) {
146
+ out += `\n${sorted.length - first.length} more diagnostics elided`;
147
+ }
148
+ return out;
149
+ }
@@ -112,7 +112,32 @@ export function transpile(files, transpileJs, transpileDts, jsImportStyle) {
112
112
  throw err;
113
113
  }
114
114
  if (result.emitSkipped) {
115
- throw Error("A problem occurred during transpilation and files were not generated. Contact the plugin author for support.");
115
+ // When compilation fails, this error message is printed to stderr.
116
+ const diagnostics = formatDiagnostics(result.diagnostics);
117
+ throw Error(`A problem occurred during transpilation and files were not generated. Contact the plugin author for support.\n\n${diagnostics}`);
116
118
  }
117
119
  return results;
118
120
  }
121
+ function formatDiagnostics(diagnostics) {
122
+ const sorted = ts.sortAndDeduplicateDiagnostics(diagnostics);
123
+ if (sorted.length == 0) {
124
+ return "";
125
+ }
126
+ const first = sorted.slice(0, 3);
127
+ const formatHost = {
128
+ getCanonicalFileName(fileName) {
129
+ return fileName;
130
+ },
131
+ getCurrentDirectory() {
132
+ return ".";
133
+ },
134
+ getNewLine() {
135
+ return "\n";
136
+ },
137
+ };
138
+ let out = ts.formatDiagnostics(first, formatHost).trim();
139
+ if (first.length < sorted.length) {
140
+ out += `\n${sorted.length - first.length} more diagnostics elided`;
141
+ }
142
+ return out;
143
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoplugin",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Helps to create your own Protocol Buffers code generators.",
6
6
  "keywords": [
@@ -35,7 +35,7 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@bufbuild/protobuf": "2.2.1",
38
+ "@bufbuild/protobuf": "2.2.3",
39
39
  "@typescript/vfs": "^1.5.2",
40
40
  "typescript": "5.4.5"
41
41
  },