Skip to content

Commit

Permalink
chore: support CJS
Browse files Browse the repository at this point in the history
this PR changes the CI to run two protobuf generators, one for each,
plus another for dts. currently untested.
  • Loading branch information
nbsp committed Nov 13, 2024
1 parent f558b99 commit da89bcb
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 30 deletions.
19 changes: 13 additions & 6 deletions packages/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,32 @@
"name": "@livekit/protocol",
"version": "1.27.1",
"description": "",
"type": "module",
"main": "src/index.js",
"module": "src/index.mjs",
"types": "src/index.d.ts",
"files": [
"src"
],
"exports": {
".": {
"types": "./src/index.d.ts",
"default": "./src/index.js"
"import": "./src/index.mjs",
"require": "./src/index.js"
},
"./*": {
"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.js"
}
},
"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/esm/version.js",
"generate:version:cjs": "genversion --semi src/gen/cjs/version.js",
"generate:version": "pnpm generate:version:esm && pnpm generate:version:cjs",
"generate:proto:esm": "protoc --es_out src/gen/esm --es_opt target=js -I=../../protobufs ../../protobufs/livekit_*.proto",
"generate:proto:cjs": "protoc --es_out src/gen/cjs --es_opt target=js,js_import_style=legacy_commonjs -I=../../protobufs ../../protobufs/livekit_*.proto",
"generate:proto:dts": "mkdir -p src/gen/dts && protoc --es_out src/gen/dts --es_opt target=dts -I=../../protobufs ../../protobufs/livekit_*.proto",
"generate:proto": "pnpm generate:proto:esm && pnpm generate:proto:cjs && pnpm generate:proto:dts",
"build": "pnpm generate:version && pnpm generate:proto"
},
"keywords": [],
Expand Down
1 change: 0 additions & 1 deletion packages/javascript/src/gen/version.d.ts

This file was deleted.

21 changes: 10 additions & 11 deletions packages/javascript/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
export { protoInt64 } from "@bufbuild/protobuf";
export * from "./gen/livekit_agent_dispatch_pb.js";
export * from "./gen/livekit_agent_pb.js";
export * from "./gen/livekit_egress_pb.js";
export * from "./gen/livekit_ingress_pb.js";
export * from "./gen/livekit_metrics_pb.js";
export * from "./gen/livekit_models_pb.js";
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 type * from "./gen/dts/livekit_agent_dispatch_pb.d.ts";
export type * from "./gen/dts/livekit_agent_pb.d.ts";
export type * from "./gen/dts/livekit_egress_pb.d.ts";
export type * from "./gen/dts/livekit_ingress_pb.d.ts";
export type * from "./gen/dts/livekit_metrics_pb.d.ts";
export type * from "./gen/dts/livekit_models_pb.d.ts";
export type * from "./gen/dts/livekit_room_pb.d.ts";
export type * from "./gen/dts/livekit_rtc_pb.d.ts";
export type * from "./gen/dts/livekit_sip_pb.d.ts";
export type * from "./gen/dts/livekit_webhook_pb.d.ts";
39 changes: 27 additions & 12 deletions packages/javascript/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
// @ts-check
export { protoInt64 } from "@bufbuild/protobuf";
export * from "./gen/livekit_agent_dispatch_pb.js";
export * from "./gen/livekit_agent_pb.js";
export * from "./gen/livekit_egress_pb.js";
export * from "./gen/livekit_ingress_pb.js";
export * from "./gen/livekit_metrics_pb.js";
export * from "./gen/livekit_models_pb.js";
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";
const { protoInt64 } = require("@bufbuild/protobuf");
const agentDispatch = require("./gen/esm/livekit_agent_dispatch_pb.js");
const agent = require("./gen/esm/livekit_agent_pb.js");
const egress = require("./gen/esm/livekit_egress_pb.js");
const ingress = require("./gen/esm/livekit_ingress_pb.js");
const metrics = require("./gen/esm/livekit_metrics_pb.js");
const models = require("./gen/esm/livekit_models_pb.js");
const room = require("./gen/esm/livekit_room_pb.js");
const rtc = require("./gen/esm/livekit_rtc_pb.js");
const sip = require("./gen/esm/livekit_sip_pb.js");
const webhook = require("./gen/esm/livekit_webhook_pb.js");
const version = require("./gen/esm/version.js");

module.exports = {
protoInt64,
...agentDispatch,
...agent,
...egress,
...ingress,
...metrics,
...models,
...room,
...rtc,
...sip,
...webhook,
...version,
}
13 changes: 13 additions & 0 deletions packages/javascript/src/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @ts-check
export { protoInt64 } from "@bufbuild/protobuf";
export * from "./gen/esm/livekit_agent_dispatch_pb.js";
export * from "./gen/esm/livekit_agent_pb.js";
export * from "./gen/esm/livekit_egress_pb.js";
export * from "./gen/esm/livekit_ingress_pb.js";
export * from "./gen/esm/livekit_metrics_pb.js";
export * from "./gen/esm/livekit_models_pb.js";
export * from "./gen/esm/livekit_room_pb.js";
export * from "./gen/esm/livekit_rtc_pb.js";
export * from "./gen/esm/livekit_sip_pb.js";
export * from "./gen/esm/livekit_webhook_pb.js";
export * from "./gen/esm/version.js";

0 comments on commit da89bcb

Please sign in to comment.