Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2: Update dependencies #945

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,308 changes: 1,135 additions & 1,173 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@
"copyrightHolder": "Buf Technologies, Inc."
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.2",
"@arethetypeswrong/cli": "^0.15.3",
"@bufbuild/license-header": "^0.0.4",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@types/node": "^22.0.0",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-n": "^17.10.1",
"jest": "^29.7.0",
"prettier": "^3.3.2",
"turbo": "^2.0.5",
"typescript": "^5.5.2"
"prettier": "^3.3.3",
"turbo": "^2.0.9",
"typescript": "^5.5.4"
},
"//": "avoid hoisting of @typescript/vfs, see packages/protoplugin/src/transpile.ts",
"dependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/bundle-size/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ usually do. We repeat this for an increasing number of files.

| code generator | files | bundle size | minified | compressed |
| ------------------- | ----: | ----------: | --------: | ---------: |
| Protobuf-ES | 1 | 125,927 b | 65,653 b | 15,282 b |
| Protobuf-ES | 4 | 128,116 b | 67,161 b | 15,966 b |
| Protobuf-ES | 8 | 130,878 b | 68,932 b | 16,469 b |
| Protobuf-ES | 16 | 141,328 b | 76,913 b | 18,799 b |
| Protobuf-ES | 32 | 169,119 b | 98,931 b | 24,243 b |
| Protobuf-ES | 1 | 126,123 b | 65,653 b | 15,282 b |
| Protobuf-ES | 4 | 128,312 b | 67,161 b | 15,966 b |
| Protobuf-ES | 8 | 131,074 b | 68,932 b | 16,469 b |
| Protobuf-ES | 16 | 141,524 b | 76,913 b | 18,799 b |
| Protobuf-ES | 32 | 169,315 b | 98,931 b | 24,243 b |
| protobuf-javascript | 1 | 334,193 b | 255,820 b | 42,481 b |
| protobuf-javascript | 4 | 360,861 b | 271,092 b | 43,912 b |
| protobuf-javascript | 8 | 382,904 b | 283,409 b | 45,038 b |
Expand Down
4 changes: 2 additions & 2 deletions packages/bundle-size/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"lint": "eslint --max-warnings 0 ."
},
"dependencies": {
"@bufbuild/buf": "^1.29.0",
"@bufbuild/buf": "^1.35.1",
"@bufbuild/protobuf": "2.0.0-beta.3",
"@bufbuild/protoplugin": "2.0.0-beta.3",
"@bufbuild/protoc-gen-es": "2.0.0-beta.3",
"@types/brotli": "^1.3.4",
"brotli": "^1.3.3",
"esbuild": "^0.22.0",
"esbuild": "^0.23.0",
"google-protobuf": "3.21.2"
}
}
4 changes: 2 additions & 2 deletions packages/protobuf-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
},
"type": "module",
"dependencies": {
"@bufbuild/buf": "^1.29.0",
"@bufbuild/buf": "^1.35.1",
"@bufbuild/protobuf": "2.0.0-beta.3",
"@bufbuild/protoc-gen-es": "2.0.0-beta.3",
"typescript": "^5.2.2"
"typescript": "^5.5.4"
}
}
42 changes: 24 additions & 18 deletions packages/protobuf-test/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,48 @@ export async function compileFile(proto: string, name = "input.proto") {

export async function compileEnum(proto: string) {
const file = await compileFile(proto);
const firstEnum = file.enums[0];
assert(firstEnum);
return firstEnum;
if (file.enums.length != 1) {
throw new Error(`expected 1 enum, got ${file.enums.length}`);
}
return file.enums[0];
}

export async function compileMessage(proto: string) {
const file = await compileFile(proto);
const firstMessage = file.messages[0];
assert(firstMessage);
return firstMessage;
if (file.messages.length == 0) {
throw new Error("missing message");
}
return file.messages[0];
}

export async function compileField(proto: string) {
const message = await compileMessage(proto);
const firstField = message.fields[0];
assert(firstField);
return firstField;
if (message.fields.length == 0) {
throw new Error("missing field");
}
return message.fields[0];
}

export async function compileExtension(proto: string) {
const file = await compileFile(proto);
const firstExt = file.extensions[0];
assert(firstExt);
return firstExt;
if (file.extensions.length == 0) {
throw new Error("missing extension");
}
return file.extensions[0];
}

export async function compileService(proto: string) {
const file = await compileFile(proto);
const firstService = file.services[0];
assert(firstService);
return firstService;
if (file.services.length == 0) {
throw new Error("missing service");
}
return file.services[0];
}

export async function compileMethod(proto: string) {
const service = await compileService(proto);
const firstMethod = service.methods[0];
assert(firstMethod);
return firstMethod;
if (service.methods.length == 0) {
throw new Error("missing method");
}
return service.methods[0];
}
3 changes: 1 addition & 2 deletions packages/protobuf-test/src/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ describe("createFileRegistry()", function () {
beforeAll(() => {
testFileReg = createFileRegistry(testFileDescriptorSet);
const a = testFileReg.getFile("a.proto");
assert(a);
assert(a.proto);
assert(a !== undefined);
descFileA = a;
});
test("resolves all dependencies as FileDescriptorProto", function () {
Expand Down
4 changes: 4 additions & 0 deletions packages/protobuf/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,12 +889,14 @@ function newField(
case TYPE_GROUP:
field.listKind = "message";
field.message = reg.getMessage(trimLeadingDot(proto.typeName));
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
assert(field.message);
field.delimitedEncoding = isDelimitedEncoding(proto, parentOrFile);
break;
case TYPE_ENUM:
field.listKind = "enum";
field.enum = reg.getEnum(trimLeadingDot(proto.typeName));
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
assert(field.enum);
break;
default:
Expand All @@ -913,6 +915,7 @@ function newField(
field.fieldKind = "message";
field.message = reg.getMessage(trimLeadingDot(proto.typeName));
assert(
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
field.message,
`invalid FieldDescriptorProto: type_name ${proto.typeName} not found`,
);
Expand Down Expand Up @@ -1083,6 +1086,7 @@ function findOneof(
}
const oneof = allOneofs[proto.oneofIndex];
assert(
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
oneof,
`invalid FieldDescriptorProto: oneof #${proto.oneofIndex} for field #${proto.number} not found`,
);
Expand Down
8 changes: 4 additions & 4 deletions packages/protoplugin-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
},
"license": "Apache-2.0",
"dependencies": {
"@bufbuild/buf": "^1.29.0",
"@bufbuild/buf": "^1.35.1",
"@bufbuild/protobuf": "^2.0.0-beta.3",
"@bufbuild/protoc-gen-es": "^2.0.0-beta.3",
"@bufbuild/protoplugin": "^2.0.0-beta.3",
"typescript": "^5.2.2",
"tsx": "^4.16.0",
"@types/node": "~20.8.6"
"typescript": "^5.5.4",
"tsx": "^4.16.1",
"@types/node": "^22.0.0"
}
}
2 changes: 0 additions & 2 deletions packages/protoplugin-test/src/custom-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ describe("custom options", () => {
`;
test("can be read via extension", async () => {
const opt = (await compileFile(proto)).extensions[0];
assert(opt);
let value: unknown;
await createTestPluginAndRun({
proto: {
Expand All @@ -58,7 +57,6 @@ describe("custom options", () => {
});
test("can be read via getOptions", async () => {
const opt = (await compileFile(proto)).extensions[0];
assert(opt);
let has = false;
let value: unknown;
await createTestPluginAndRun({
Expand Down
21 changes: 12 additions & 9 deletions packages/protoplugin-test/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,24 @@ export async function compileFile(proto: string) {

export async function compileEnum(proto: string) {
const file = await compileFile(proto);
const firstEnum = file.enums[0];
assert(firstEnum);
return firstEnum;
if (file.enums.length != 1) {
throw new Error(`expected 1 enum, got ${file.enums.length}`);
}
return file.enums[0];
}

export async function compileMessage(proto: string) {
const file = await compileFile(proto);
const firstMessage = file.messages[0];
assert(firstMessage);
return firstMessage;
if (file.messages.length == 0) {
throw new Error("missing message");
}
return file.messages[0];
}

export async function compileField(proto: string) {
const message = await compileMessage(proto);
const firstField = message.fields[0];
assert(firstField);
return firstField;
if (message.fields.length == 0) {
throw new Error("missing field");
}
return message.fields[0];
}