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

chore: support CJS #883

Merged
merged 15 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
5 changes: 5 additions & 0 deletions .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ jobs:
node-version: 20
cache: "pnpm"

- name: Install rename
run: |
sudo apt-get update
sudo apt-get install rename

- name: Install JS dependencies
run: pnpm install

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
node-version: 20
cache: "pnpm"

- name: Install rename
run: |
sudo apt-get update
sudo apt-get install rename

- name: Install dependencies
run: pnpm install

Expand Down
2 changes: 1 addition & 1 deletion infra/link.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_agent.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_agent_dispatch.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_analytics.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_egress.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_ingress.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_internal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_metrics.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_models.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_room.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_rtc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_sip.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion livekit/livekit_webhook.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/
src/gen
!src/gen/version.d.ts
!src/gen/version.d.ts
18 changes: 13 additions & 5 deletions packages/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@
"description": "",
"type": "module",
nbsp marked this conversation as resolved.
Show resolved Hide resolved
"main": "src/index.js",
"import": "src/index.cjs",
"types": "src/index.d.ts",
"files": [
"src"
],
"exports": {
".": {
"types": "./src/index.d.ts",
"default": "./src/index.js"
"import": "./src/index.js",
"require": "./src/index.cjs"
},
"./*": {
"types": "./src/gen/livekit_*_pb.d.ts",
"default": "./src/gen/livekit_*_pb.js"
"types": "./src/gen/dts/livekit_*_pb.d.ts",
"import": "./src/gen/esm/livekit_*_pb.js",
"require": "./src/gen/cjs/livekit_*_pb.cjs"
}
},
"scripts": {
"generate:version": "genversion --esm --semi src/gen/version.js",
"generate:proto": "protoc --es_out src/gen --es_opt target=js+dts -I=../../protobufs ../../protobufs/livekit_*.proto",
"generate:version:esm": "genversion --esm --semi src/gen/version.mjs",
lukasIO marked this conversation as resolved.
Show resolved Hide resolved
"generate:version:cjs": "genversion --semi src/gen/version.cjs",
"generate:version": "pnpm generate:version:esm && pnpm generate:version:cjs",
"generate:proto:esm": "protoc --es_out src/gen --es_opt target=js -I=../../protobufs ../../protobufs/livekit_*.proto",
"generate:proto:cjs": "protoc --es_out src/gen --es_opt target=js,js_import_style=legacy_commonjs -I=../../protobufs ../../protobufs/livekit_*.proto && rename \"s/js$/cjs/\" src/gen/*.js && sed -i 's/\\.js\")/.cjs\")/' src/gen/*.cjs",
"generate:proto:dts": "protoc --es_out src/gen --es_opt target=dts -I=../../protobufs ../../protobufs/livekit_*.proto",
"generate:proto": "pnpm generate:proto:cjs && pnpm generate:proto:esm && pnpm generate:proto:dts",
"build": "pnpm generate:version && pnpm generate:proto"
},
"keywords": [],
Expand Down
28 changes: 28 additions & 0 deletions packages/javascript/src/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @ts-check
const { protoInt64 } = require("@bufbuild/protobuf");
const agentDispatch = require("./gen/livekit_agent_dispatch_pb.cjs");
const agent = require("./gen/livekit_agent_pb.cjs");
const egress = require("./gen/livekit_egress_pb.cjs");
const ingress = require("./gen/livekit_ingress_pb.cjs");
const metrics = require("./gen/livekit_metrics_pb.cjs");
const models = require("./gen/livekit_models_pb.cjs");
const room = require("./gen/livekit_room_pb.cjs");
const rtc = require("./gen/livekit_rtc_pb.cjs");
const sip = require("./gen/livekit_sip_pb.cjs");
const webhook = require("./gen/livekit_webhook_pb.cjs");
const version = require("./gen/version.cjs");

module.exports = {
protoInt64,
...agentDispatch,
...agent,
...egress,
...ingress,
...metrics,
...models,
...room,
...rtc,
...sip,
...webhook,
version,
}
2 changes: 1 addition & 1 deletion packages/javascript/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export * from "./gen/livekit_room_pb.js";
export * from "./gen/livekit_rtc_pb.js";
export * from "./gen/livekit_sip_pb.js";
export * from "./gen/livekit_webhook_pb.js";
export * from "./gen/version.js";
export * from "./gen/version.mjs";
lukasIO marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion rpc/agent.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/agent_dispatch.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/analytics.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/egress.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/ingress.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/io.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/keepalive.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/participant.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/room.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/roommanager.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/signal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpc/sip.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.