Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node: Remove compiled JavaScript from repository and compile TypeScript code on NPM prepare script on demand when installed via git #954

Merged
merged 36 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cd6099e
Node: Compile TypeScript code on postinstall
ibc Nov 11, 2022
36ebdd3
Really remove /node/lib/
ibc Nov 11, 2022
6e0c4f2
Make Windows happy
ibc Nov 11, 2022
fbfd970
.gitignore: cosmetic
ibc Nov 11, 2022
896fea1
Update CHANGELOG.md
ibc Nov 11, 2022
912d4d9
fix npm-scripts.js
ibc Nov 11, 2022
cdef1a9
npm-scripts.js: fix lint
ibc Nov 11, 2022
535e8e9
Update files in package.json
ibc Nov 15, 2022
60a7d55
package.json: include node/tsconfig.json in files
ibc Nov 15, 2022
32dc5b6
Merge branch 'v3' into compile-typescript-in-npm-postinstall
ibc Nov 15, 2022
922883a
package.json: move dependencies defining TS types from devDependencie…
ibc Nov 15, 2022
dc112b1
Merge branch 'v3' into compile-typescript-in-npm-postinstall
ibc Nov 15, 2022
3077769
npm-scripts.js: Make 'test:node' task compile TS to JS
ibc Nov 15, 2022
5dccfbb
Merge branch 'v3' into compile-typescript-in-npm-postinstall
ibc Nov 15, 2022
7e62ea2
Merge branch 'v3' into compile-typescript-in-npm-postinstall
ibc Nov 15, 2022
5b0ecc1
Merge branch 'v3' into compile-typescript-in-npm-postinstall
ibc Nov 17, 2022
af81f3a
- Add package-lock.json.
ibc Nov 17, 2022
38789bf
Update CHANGELOG
ibc Nov 17, 2022
5dd182c
Uninstall typescript libs after building
ibc Nov 17, 2022
a44253a
Add --no-save
ibc Nov 17, 2022
a2cafbe
Add prepack NPM script
ibc Nov 17, 2022
d9251b0
test a thing
ibc Nov 17, 2022
18b1e14
test 2
ibc Nov 17, 2022
2f7001d
revert tests
ibc Nov 17, 2022
f6a37ba
postinstall
ibc Nov 17, 2022
c60508a
improvements
ibc Nov 17, 2022
9a4b45a
cosmetic
ibc Nov 17, 2022
591399c
fix .github/workflows/mediasoup-node.yaml
ibc Nov 17, 2022
79b9baa
Use prepare instead of prepack
ibc Nov 17, 2022
95fa080
Improve npm-scripts.js by adding functions
ibc Nov 17, 2022
bfd6560
Make npm-scripts.js better
ibc Nov 18, 2022
18b7b27
Improve copy
ibc Nov 18, 2022
a962fde
Address feedback:
ibc Nov 18, 2022
f291104
fix lint
ibc Nov 18, 2022
1e457ea
Address feedback 2
ibc Nov 18, 2022
7eb25a7
cosmetic
ibc Nov 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Tell GitHub to ignore some folders when detecting the project language.
art/* linguist-vendored=true
doc/* linguist-vendored=true
node/lib/* linguist-vendored=true
node/test/* linguist-vendored=true
rust/benches/* linguist-vendored=true
rust/examples/* linguist-vendored=true
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/mediasoup-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ jobs:
- run: npm install
- run: npm run lint:node
if: runner.os == 'Linux'
- run: npm run typescript:build
- run: npm run test:node
29 changes: 15 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@
!/worker/subprojects/*.wrap

## Node.
/node_modules/
/node_modules
/node/lib

## Rust.
/Cargo.lock
/rust/examples-frontend/*/node_modules/
/rust/examples-frontend/*/node_modules
/rust/examples-frontend/*/package-lock.json
/target/
/target

## Worker.
/worker/out/
/worker/scripts/node_modules/
/worker/out
/worker/scripts/node_modules
# Vistual Studio generated Stuff.
/worker/**/Debug/
/worker/**/Release/
/worker/.vs/
/worker/**/Debug
/worker/**/Release
/worker/.vs
# clang-fuzzer stuff is too big.
/worker/deps/clang-fuzzer/
/worker/deps/clang-fuzzer
# Ignore all fuzzer generated test inputs.
/worker/fuzzer/new-corpus/*
!/worker/fuzzer/new-corpus/.placeholder

## Others.
/coverage/
/NO_GIT/
/coverage
/NO_GIT
*.swp
*.swo
.DS_Store/
.DS_Store
# Vistual Studio Code stuff.
/.vscode/
/.vscode
# JetBrains IDE stuff.
/.idea/
/.idea
5 changes: 4 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
package-lock=false
# Generate package-lock.json.
package-lock=true
# For bad node/npm version to throw actual error.
engine-strict=true
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### NEXT

* Node: Remove compiled JavaScript from repository and compile TypeScript code on NPM `prepare` script on demand when installed via git (PR #954).
* `Worker`: Add `RTC::Shared` singleton for RTC entities (PR #953).


Expand Down
70 changes: 49 additions & 21 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Compiles mediasoup TypeScript code (`lib` folder) JavaScript and places it into

Compiles mediasoup TypeScript code (`lib` folder) JavaScript, places it into the `lib` directory an watches for changes in the TypeScript files.


### `npm run worker:build`

Builds the `mediasoup-worker` binary. It invokes `make`below.


### `npm run lint`

Runs both `npm run lint:node` and `npm run lint:worker`.
Expand Down Expand Up @@ -57,41 +63,30 @@ Runs [Catch2](https://github.com/catchorg/Catch2) test units located at `worker/
Same as `npm run test:node` but it also opens a browser window with JavaScript coverage results.


## Makefile
### `npm run install-deps:node`

The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks:
Installs NPM dependencies and updates `package-lock.json`.


### `make` or `make mediasoup-worker`
### `npm run install-clang-tools`

Builds the `mediasoup-worker` binary at `worker/out/Release/`.
Installs clang tools needed for local development.

If the "MEDIASOUP_MAX_CORES" environment variable is set, the build process will use that number of CPU cores. Otherwise it will auto-detect the number of cores in the machine.

"MEDIASOUP_BUILDTYPE" environment variable controls build types, `Release` and `Debug` are presets optimized for those use cases.
Other build types are possible too, but they are not presets and will require "MESON_ARGS" use to customize build configuration.
Check the meaning of useful macros in the `worker/include/Logger.hpp` header file if you want to enable tracing or other debug information.

Binary is built at `worker/out/MEDIASOUP_BUILDTYPE/build`.
## Makefile

In order to instruct the mediasoup Node.js module to use the `Debug` mediasoup-worker binary, an environment variable must be set before running the Node.js application:
The `worker` folder contains a `Makefile` for the mediasoup-worker C++ subproject. It includes the following tasks:

```bash
$ MEDIASOUP_BUILDTYPE=Debug node myapp.js
```

If the "MEDIASOUP_WORKER_BIN" environment variable is set, mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary:
### `make` or `make mediasoup-worker`

```bash
$ MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
```
Alias of ``make mediasoup-worker` below.


### `make libmediasoup-worker`
### `make meson-ninja`

Builds the `libmediasoup-worker` static library at `worker/out/Release/`.
Installs `meson` and `ninja`.

`MEDIASOUP_MAX_CORES` and `MEDIASOUP_BUILDTYPE` environment variables from above still apply for static library build.

### `make clean`

Expand Down Expand Up @@ -128,6 +123,39 @@ $ make update-wrap-file SUBPROJECT=openssl
```


### `make mediasoup-worker`

Builds the `mediasoup-worker` binary at `worker/out/Release/`.

If the "MEDIASOUP_MAX_CORES" environment variable is set, the build process will use that number of CPU cores. Otherwise it will auto-detect the number of cores in the machine.

"MEDIASOUP_BUILDTYPE" environment variable controls build types, `Release` and `Debug` are presets optimized for those use cases.
Other build types are possible too, but they are not presets and will require "MESON_ARGS" use to customize build configuration.
Check the meaning of useful macros in the `worker/include/Logger.hpp` header file if you want to enable tracing or other debug information.

Binary is built at `worker/out/MEDIASOUP_BUILDTYPE/build`.

In order to instruct the mediasoup Node.js module to use the `Debug` mediasoup-worker binary, an environment variable must be set before running the Node.js application:

```bash
$ MEDIASOUP_BUILDTYPE=Debug node myapp.js
```

If the "MEDIASOUP_WORKER_BIN" environment variable is set, mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary:

```bash
$ MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
```



### `make libmediasoup-worker`

Builds the `libmediasoup-worker` static library at `worker/out/Release/`.

`MEDIASOUP_MAX_CORES` and `MEDIASOUP_BUILDTYPE` environment variables from above still apply for static library build.


### `make xcode`

Builds a Xcode project for the mediasoup-worker subproject.
Expand Down
36 changes: 0 additions & 36 deletions node/lib/ActiveSpeakerObserver.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion node/lib/ActiveSpeakerObserver.d.ts.map

This file was deleted.

44 changes: 0 additions & 44 deletions node/lib/ActiveSpeakerObserver.js

This file was deleted.

55 changes: 0 additions & 55 deletions node/lib/AudioLevelObserver.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion node/lib/AudioLevelObserver.d.ts.map

This file was deleted.

56 changes: 0 additions & 56 deletions node/lib/AudioLevelObserver.js

This file was deleted.

Loading