This document explains how to build the Node.js bindings for Mapbox GL Native for contributing to the development of the bindings themselves. If you just want to use the module, you can simply install it via npm
; see README.md for installation and usage instructions.
We use CMake:3.18.3 to build Mapbox GL Native for various platforms, including Linux, Android, iOS, macOS and Windows.
The following dependencies are platform-specific to the OS you are using to build the package from source
Linux:
- xvfb
- mesa-utils
- libosmesa6-dev
- libgl1-mesa-glx
- libgl1-mesa-dev
- libegl1-mesa-dev
- libglfw3
- libglfw3-dev
- mesa-common-dev
- libuv1
- libuv1-dev
- libjpeg-dev
- libcurl4-openssl-dev
MacOS:
- glfw3
- gcc@7
Then using Node 10.x run the following commands from the root of this repository tree. It will build Mapbox GL Native targeting your host architecture given that you have all the dependencies installed.
# Update the vendors submodules
git submodule update --init --recursive
# Install the package dependencies
npm install
# Remove the pre-compiled binary from the official repo
rm -rf lib
# Build the c++ addons
cmake . -B build
cmake --build build
# Or, if you want to make it in parallel
cmake . -B build
cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)
If you want to publish you own version of the node package to NPM, you must need to update the package.json to your own configuration, and change the host config to your own repo. See the following link for details about that.
# Link the c++ addons to the node package
./node_modules/.bin/node-pre-gyp package
# Publish the release package to GitHub
export NODE_PRE_GYP_GITHUB_TOKEN=${GITHUB_TOKEN}
./node_modules/.bin/node-pre-gyp-github publish
# Publish the Node package to NPM
npm login
npm publish
To test the Node.js bindings:
npm test
-
How to get the GitHub Access Token?
Look at the official GitHub documentation