Skip to content

Commit

Permalink
Dual package support without typescript (#907)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Nov 29, 2024
1 parent 4aff238 commit eb1d646
Show file tree
Hide file tree
Showing 10 changed files with 1,576 additions and 614 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-adults-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/protocol": patch
---

Fix treehaking possibility of individual imports
2 changes: 1 addition & 1 deletion .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ jobs:
- name: Add changes
uses: EndBug/add-and-commit@v9
with:
add: '["livekit", "rpc", "infra"]'
add: '["livekit", "rpc", "infra", "packages/javascript/src/gen"]'
default_author: github_actions
message: generated protobuf
5 changes: 3 additions & 2 deletions packages/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
dist/
src/gen
dist
src/gen/*

11 changes: 11 additions & 0 deletions packages/javascript/build.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check

import { defineBuildConfig } from "unbuild";

export default defineBuildConfig({
declaration: true,
sourcemap: true,
rollup: {
emitCJS: true,
},
});
34 changes: 16 additions & 18 deletions packages/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,36 @@
"version": "1.29.2",
"description": "",
"type": "module",
"main": "dist/index.js",
"import": "dist/index.cjs",
"types": "dist/index.d.ts",
"require": "dist/index.cjs",
"files": [
"src",
"dist"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./*": {
"types": "./dist/gen/livekit_*_pb.d.ts",
"import": "./dist/gen/livekit_*_pb.js",
"require": "./dist/gen/livekit_*_pb.cjs"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"main": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"scripts": {
"generate:version": "genversion --esm --semi src/gen/version.ts",
"generate:proto": "mkdir -p src/gen && protoc --es_out src/gen --es_opt target=ts -I=../../protobufs ../../protobufs/livekit_*.proto",
"prebuild": "pnpm generate:version && pnpm generate:proto",
"build": "pnpm prebuild && tsup --onSuccess \"tsc --declaration --emitDeclarationOnly\""
"generate:proto": "mkdir -p src/gen && protoc --es_out src/gen --es_opt target=dts+js -I=../../protobufs ../../protobufs/livekit_*.proto",
"generate:version": "genversion --esm --semi src/gen/version.js",
"build": "pnpm generate:version && pnpm generate:proto && unbuild"
},
"keywords": [],
"author": "LiveKit",
"license": "Apache-2.0",
"devDependencies": {
"@bufbuild/protoc-gen-es": "^1.10.0",
"genversion": "^3.2.0",
"tsup": "^8.3.5",
"typescript": "5.2"
"genversion": "^3.2.0"
},
"dependencies": {
"@bufbuild/protobuf": "^1.10.0"
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions packages/javascript/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @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";
14 changes: 0 additions & 14 deletions packages/javascript/tsconfig.json

This file was deleted.

43 changes: 0 additions & 43 deletions packages/javascript/tsup.config.ts

This file was deleted.

Loading

0 comments on commit eb1d646

Please sign in to comment.