Skip to content

Commit

Permalink
Add rollup config
Browse files Browse the repository at this point in the history
  • Loading branch information
thyal committed Mar 8, 2024
1 parent b74d00f commit 08459da
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 21 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/deploy-release-worflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ jobs:
- name: Setup npmrc
run: echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc

- name: Use Node.js ${{ vars.NODE_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}

- uses: voxmedia/github-action-slack-notify-build@v1
id: slack
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/pr-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ jobs:
- name: Setup npmrc
run: echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc

- name: Use Node.js ${{ vars.NODE_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Install
run: yarn install --frozen-lockfile
Expand Down Expand Up @@ -55,10 +53,8 @@ jobs:
- name: Setup npmrc
run: echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc

- name: Use Node.js ${{ vars.NODE_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}

- name: Install
run: yarn install --frozen-lockfile
Expand Down
5 changes: 0 additions & 5 deletions jsconfig.json

This file was deleted.

15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@
"url": "https://github.com/whereby/jslib-media/issues"
},
"scripts": {
"build": "rm -rf dist && tsc",
"build": "rimraf dist && rollup -c rollup.config.js",
"lint": "eslint src tests",
"test": "npm run lint && npm run test:unit",
"test:unit": "jest",
"test:unit:coverage": "jest --collectCoverage",
"format:fix": "prettier --write './**/*.{js,ts,yml,json}'",
"format:check": "prettier --check './**/*.{js,ts,yml,json}'"
},
"exports": {
".": {
"import": "./dist/index.js"
}
},
"files": [
"dist/**/*.js",
"dist/**/*.d.ts"
],
"dependencies": {
"check-ip": "^1.1.1",
"events": "^3.3.0",
Expand All @@ -40,6 +49,8 @@
"@babel/core": "^7.23.2",
"@babel/eslint-parser": "^7.22.15",
"@babel/preset-env": "^7.23.2",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-replace": "^5.0.5",
"@types/jest": "^29.5.12",
"@types/sdp-transform": "^2.4.9",
"@types/uuid": "^9.0.8",
Expand All @@ -56,6 +67,8 @@
"jest-environment-jsdom": "^29.7.0",
"prettier": "3.2.5",
"process": "^0.11.10",
"rollup": "^4.12.1",
"rollup-plugin-typescript2": "^0.36.0",
"ts-jest": "^29.1.2"
},
"publishConfig": {
Expand Down
41 changes: 41 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const typescript = require("rollup-plugin-typescript2");
const commonjs = require("@rollup/plugin-commonjs");
const replace = require("@rollup/plugin-replace");
const pkg = require("./package.json");
const dotenv = require("dotenv");

dotenv.config({
path: `../../.env`,
});

const peerDependencies = [...Object.keys(pkg.peerDependencies || {})];

const plugins = [
replace({
preventAssignment: true,
// jslib-media uses global.navigator for some gUM calls, replace these
delimiters: [" ", "."],
values: { "global.navigator.mediaDevices": " navigator.mediaDevices." },
}),
commonjs(),
typescript({
tsconfig: "tsconfig.build.json",
}),
];

module.exports = [
// Esm build of lib, to be used with bundlers
{
input: "src/index.ts",

output: [
{
format: "esm", // set ES modules
dir: "dist", // indicate not create a single-file
},
],
plugins,
external: [...peerDependencies],
},
];
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./model";
export * from "./utils";
export * from "./webrtc";
3 changes: 3 additions & 0 deletions src/model/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./connectionStatusConstants";
export * from "./protocol";
export * from "./RtcStream";
10 changes: 10 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export * from "./bandwidthTestUtils";
export * from "./getHandler";
export * from "./ipRegex";
export * from "./Logger";
export * from "./mediaSettings";
export * from "./optimalBitrate";
export * from "./ReconnectManager";
export * from "./ServerSocket";
export * from "./transportSettings";
export * from "./urls";
24 changes: 24 additions & 0 deletions src/webrtc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export * from "./stats/IssueMonitor";
export * from "./stats/PerformanceMonitor";
export * from "./stats/StatsMonitor";
export * from "./stats/StatsMonitor/metrics";
export * from "./stats/StatsMonitor/peerConnectionTracker";
export * from "./BandwidthTester";
export * from "./bugDetector";
export * from "./constants";
export * from "./mediaConstraints";
export * from "./MediaDevices";
export * from "./P2pRtcManager";
export * from "./RtcManagerDispatcher";
export * from "./rtcManagerEvents";
export * from "./rtcrtpsenderHelper";
export * from "./rtcStatsService";
export * from "./sdpModifier";
export * from "./Session";
export * from "./SfuV2Parser";
export * from "./statsHelper";
export * from "./VegaConnection";
export * from "./VegaMediaQualityMonitor";
export * from "./VegaMicAnalyser";
export * from "./VegaMicAnalyserTools";
export * from "./VegaRtcManager";
10 changes: 10 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": false,
"noEmit": false,
"outDir": "dist",
"removeComments": true
},
"exclude": ["src/stories", "src/**/*.spec.ts", "src/lib/__mocks__"]
}
Loading

0 comments on commit 08459da

Please sign in to comment.