-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·41 lines (36 loc) · 1.16 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·41 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
exec 2>&1
set -e
rm -rf dist/ peerjs/
git clone --depth 1 --branch v1.5.5 https://github.com/peers/peerjs peerjs
cd peerjs
git apply ../decoupling.diff
echo "export const version = \"$(node -p "require('./package.json').version")\";" > lib/version.ts
# Replace peerjs's multi-target build config with a single bundle target for react-native
node -e '
const fs = require("fs");
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
for (const field of ["main", "module", "types", "source", "scripts", "targets",
"browser-minified", "browser-unminified", "browser-minified-msgpack"]) {
delete pkg[field];
}
pkg["react-native-peer"] = "output/peerjs.min.js";
pkg.targets = {
"react-native-peer": {
source: "lib/exports.ts",
context: "browser",
outputFormat: "esmodule",
isLibrary: true,
optimize: true,
engines: { browsers: "chrome >= 83" },
},
};
fs.writeFileSync("package.json", JSON.stringify(pkg, null, "\t"));
'
../node_modules/.bin/parcel build --no-source-maps --no-cache
cd ../
mkdir -p dist
cat imports.js peerjs/output/peerjs.min.js > dist/react-native-peer.js
cp index.d.ts dist/
rm -rf peerjs/
echo "Done. dist/react-native-peer.js"