Skip to content

Commit

Permalink
Merge pull request #88 from whereby/kevinhanna/pan-348-bump-jslib-med…
Browse files Browse the repository at this point in the history
…ia-to-latest-version-in-browser-sdk

remove build step for npm distribution
  • Loading branch information
kevinwhereby authored Oct 19, 2023
2 parents 41fc8a5 + 150fbf5 commit 4d3bccd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 40 deletions.
41 changes: 9 additions & 32 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { build } from "esbuild";
import { replace } from "esbuild-plugin-replace";
import pkg from "./package.json" assert { type: "json" };
const { build } = require("esbuild");
const { replace } = require("esbuild-plugin-replace");
const pkg = require("./package.json");

function makeCdnFilename() {
const major = pkg.version.split(".")[0];
Expand All @@ -14,23 +14,16 @@ function makeCdnFilename() {
return `v${major}${tag}.js`;
}

/**
* we bundle jslib-media because webpack has issues resolving imports from it
*
* we bundle events because webpack tries to `require` it in the bundle which
* causes `Dynamic require of "events" is not supported` when jslib-media imports
* from mediasoup-client
* */
const external = Object.keys(pkg.dependencies)
.concat(Object.keys(pkg.peerDependencies))
.filter((dep) => !dep.match(/jslib-media|events/));

const sharedConfig = {
// embedded CDN
build({
bundle: true,
external,
entryPoints: ["src/lib/embed/index.ts"],
external: undefined,
format: "esm",
minify: process.env.NODE_ENV === "production",
outfile: `dist/${makeCdnFilename()}`,
platform: "browser",
packages: undefined,
plugins: [
replace({
__SDK_VERSION__: pkg.version,
Expand All @@ -42,20 +35,4 @@ const sharedConfig = {
],
target: ["es6"],
treeShaking: process.env.NODE_ENV === "production",
};

// full package
build({
...sharedConfig,
entryPoints: ["src/lib/index.ts"],
outfile: "dist/index.esm.js",
});

// embed with dependencies
build({
...sharedConfig,
external: undefined,
packages: undefined,
entryPoints: ["src/lib/embed/index.ts"],
outfile: `dist/${makeCdnFilename()}`,
});
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
testMatch: ["<rootDir>/src/**/__tests__/**/*.[jt]s?(x)", "<rootDir>/src/**/?(*.)+(spec|test).[jt]s?(x)"],
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@whereby.com/browser-sdk",
"version": "2.0.0-alpha24",
"version": "2.0.0-alpha25",
"description": "Modules for integration Whereby video in web apps",
"author": "Whereby AS",
"license": "MIT",
Expand All @@ -10,23 +10,24 @@
},
"browserslist": "> 0.5%, last 2 versions, not dead",
"source": "src/index.js",
"module": "dist/index.esm.js",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.esm.js"
"import": "./dist/index.js",
"require": "./dist/index.js"
}
},
"type": "module",
"files": [
"dist/**/*.js",
"dist/**/*.d.ts"
],
"types": "dist/index.d.ts",
"scripts": {
"prebuild": "rimraf dist",
"build": "node build.js",
"postbuild": "tsc --emitDeclarationOnly --declaration --project tsconfig.build.json",
"postbuild": "tsc --project tsconfig.build.json",
"build:storybook": "build-storybook",
"dev": "start-storybook -p 6006",
"install:e2e-sample-app": "cd test/sample-app && yarn",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"emitDeclarationOnly": false,
"noEmit": false,
"outDir": "dist",
"removeComments": true
Expand Down

0 comments on commit 4d3bccd

Please sign in to comment.