Project setup
You will need pnpm, as moonlight uses it for dependency and workspace management.
- Clone the repository.
- Install dependencies with
pnpm i
. - Build the project with
pnpm run build
.- For working on moonlight, a watch mode is available with
pnpm run dev
.
- For working on moonlight, a watch mode is available with
Project structure
moonlight is split into a pnpm workspace. The project is comprised of multiple packages:
core
: core code and utilities responsible for loading extensionsinjector
: the entrypoint for moonlight loaded by the patched Discord client- loads the config and detected extensions from disk and forwards them to the other stages
- loads host modules
- sets up
node-preload
to be ran when the browser window is created
node-preload
: ran before Discord’s code on the Node side- receives the config/detected extensions from
injector
and forwards it toweb-preload
- loads node modules
- loads
web-preload
and forwards some inforation to it
- receives the config/detected extensions from
web-preload
: ran before Discord’s code on the web side- receives the loaded config and detected extensions from
node-preload
- loads extensions and installs their Webpack modules and patches
- receives the loaded config and detected extensions from
core-extensions
: built-in extensions that come with every moonlight install, mostly librariestypes
: types for moonlight’s core, core extensions, and extension manifests/exportsbrowser
: the entrypoint for the browser extension
Build system
moonlight uses esbuild as its build system (build.mjs
). This script is responsible for outputting injector
, node-preload
, and web-preload
into dist
, along with all core extensions.
Other dependencies
moonlight uses some other packages that are not in the monorepo, like LunAST, moonmap, and mappings. When testing local forks, try pnpm link.