Skip to content

Commit 6b38c32

Browse files
committed
Try ts-proto
1 parent b043b02 commit 6b38c32

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
with:
3232
version: "3.1.45"
3333
actions-cache-folder: "emsdk-cache"
34+
- name: Install Protoc
35+
uses: arduino/setup-protoc@v2
36+
with:
37+
version: "24.x"
3438
- run: npm ci
3539
- name: Cache libpg_query build
3640
uses: actions/cache@v3

package-lock.json

Lines changed: 69 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/libpg-query-wasm/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@
3838
"build": "npm run build:libpg_query && npm run build:wasm && npm run build:protobuf && npm run build:ts",
3939
"build:clean": "npm run clean && npm run build",
4040
"build:libpg_query": "(cd libpg_query && sed -i.bak 's/AR = ar rs/AR = emar rs/' Makefile && emmake make build)",
41-
"build:protobuf": "cp libpg_query/protobuf/pg_query.proto dist/ && npm run build:protobuf:js && npm run build:protobuf:js:post && npm run build:protobuf:ts",
41+
"build:protobuf": "npm run build:protobuf:copy && npm run build:protobuf:ts",
42+
"build:protobuf:copy": "cp libpg_query/protobuf/pg_query.proto dist/",
4243
"build:protobuf:js": "pbjs -t static-module -w es6 -o dist/pg_query.js dist/pg_query.proto",
4344
"build:protobuf:js:post": "sed -i.bak 's|^import.*|import $protobuf from \"protobufjs/minimal.js\"|' dist/pg_query.js && rm -f dist/pg_query.js.bak",
44-
"build:protobuf:ts": "pbts -o dist/pg_query.d.ts dist/pg_query.js",
45+
"build:protobuf:ts": "protoc --plugin ../../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/ts-proto --ts_proto_opt=esModuleInterop=true --ts_proto_opt=importSuffix=.js -I dist pg_query.proto",
4546
"build:ts": "tsc",
4647
"build:wasm": "npm run emcc -- -o dist/bindings.mjs",
4748
"clean": "npm run clean:package && npm run clean:libpg_query",
@@ -56,6 +57,7 @@
5657
"protobufjs": "~7.2.5"
5758
},
5859
"devDependencies": {
59-
"protobufjs-cli": "^1.1.2"
60+
"protobufjs-cli": "^1.1.2",
61+
"ts-proto": "^1.158.0"
6062
}
6163
}

packages/libpg-query-wasm/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import module, { ModuleError } from "./bindings-wrapper.js";
2-
import { pg_query } from "../dist/pg_query.js";
2+
import * as pg_query from "./ts-proto/pg_query.js";
33

44
export { pg_query };
55

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.ts

0 commit comments

Comments
 (0)