Ok so you are interested in contributing to Composite, awesome! Feel free to pitch in on whatever interests you and we'll be happy to help you contribute.
Composite is divided into pieces. 3 exactly
- Backend (back folder)
- Frontend (front folder)
- Core (packages/core folder)
The repo is a monorepo managed with npm workspaces
Open a terminal at the root of the project
Run nvm use
If the node version of the project is not install on your machine, you will have to run
nvm install
Create a personal access token (classic)
Then you need to setup an env variable NPM_TOKEN
in order to install github packages
Add this to your .bashrc
/ .zshrc
:
export NPM_TOKEN=github_access_token
Open powershell in administrator and type :
[Environment]::SetEnvironmentVariable("NPM_TOKEN", "YOUR_GITHUB_TOKEN", "User")
In the host file located at C:\Windows\System32\drivers\etc
, open it with an editor.
Add the following lines in the end of your file:
127.0.0.1 api.localhost 127.0.0.1 front.localhost
Open your terminal and type :
sudo nano /etc/hosts
Add the following lines in the end of your file:
127.0.0.1 api.localhost 127.0.0.1 front.localhost
If that doesn't work you need to flush your DNS cache with sudo killall -HUP mDNSResponder
Then you should be able to run this command successfully
npm i
Run this command to build on your machine the packages
make build_packages
Run this command to build the docker containers locally, accordingly with your CPU architecture
make build_containers
make build_database
⚠️ Be careful about the output of this command. Ensure the migration are well applied, if you got an error such as: Error: P1001: Can't reach database server atdb
:5432
, it just mean your database started after we tried to apply the migration. You might have to increase the sleep value define in the make commandbuild_database
, or to start the database in another process before.
In the terminal, cd to ./composite/packages/core and run: ./build.bat
make start
⚠️ Important information to know about watches. If you dig deeper into the docker config, you can see in local development, there are a bunch of volumes mounting, to facilitate watch processes and hot reloading of front and back. Regarding theCore
package, you have to start the watch locally, it's not made inside any docker container. And you actually have to start two different watch processes, one that will compile tocjs
, and the other that will compile toesm
. (Yes it sucks, but it is what it is for now, feel free to improve it)
It's because the backend framework, NestJs does not support esm
yet, so we need to have a cjs version.
And in the same time, because on the frontend, with Three.js, we are using pieces of the library that are outside of the core lib (three/examples/jsm/postprocessing/ShaderPass.js
for example), if the frontend import a cjs version of three.js, this will trigger import of two different instances of the library, which is completely not acceptable.
So basically, frontend consume esm
, backend consume cjs
.
Go at the root of the core package /packages/core
and run these two processes in two different terminal
npm run dev:cjs
npm run dev:esm
make stop