Modern build system for OpenCore Framework TypeScript projects with full decorator support (FiveM, RedM and RageMP)
This may be outdated, the latest information is recommended at opencorejs.dev
| Topic | Description |
|---|---|
| FiveM Runtime | FiveM server vs client runtime details |
| Configuration | Full configuration reference and examples |
| Commands | CLI commands and usage |
| Feature | Description |
|---|---|
| Parallel Compilation | Multi-core builds with configurable worker pools for maximum performance |
| Full TypeScript Support | Decorators, metadata reflection, and modern ES2020+ features |
| Simple Configuration | Embedded build toolchain with sensible defaults, no setup required, a single typed config file |
| Hot Reload | File watching with incremental compilation for rapid development |
| Project Layout | Core, satellite resources, and standalone scripts with proper dependency management |
| Runtime-Aware Builds | Build defaults and output layout adapt to the selected adapter |
| Official Templates | Clone production-ready templates directly from the OpenCore repository |
| Project Scaffolding | Generate features, resources, and standalone scripts with a single command |
npm install -g @open-core/cligo install github.com/newcore-network/opencore-cli@latestgit clone https://github.com/newcore-network/opencore-cli
cd opencore-cli
go build -o opencore .| Command | Description |
|---|---|
opencore init [name] |
Initialize a new project with interactive wizard |
opencore build |
Build all resources for production |
opencore completion |
Completion files config to set in your zsh, bash etc |
opencore create <type> |
Create scaffolding (feature, resource, standalone) |
opencore adapter check |
Validate external adapter contract coverage |
opencore clone <template> |
Clone an official template |
opencore dev |
Start development mode with file watching |
opencore doctor |
Validate project configuration |
opencore update |
self-update CLI |
opencore --version |
Display CLI version |
opencore --h |
Help |
For CI runners (for example GitHub Actions) and non-interactive shells, use plain output:
opencore build --output=plainYou can also disable automatic update checks in CI logs:
OPENCORE_DISABLE_UPDATE_CHECK=1 opencore build --output=plainChoose a release channel when you want to validate prereleases before stable rollout:
opencore update --channel stable
opencore update --channel beta
OPENCORE_UPDATE_CHANNEL=beta opencore buildFor npm installations, use dist-tags directly:
npm install -g @open-core/cli
npm install -g @open-core/cli@betaopencore init my-server
cd my-server
pnpm install
opencore devFor a RageMP project:
opencore init my-ragemp-server --adapter ragemp
cd my-ragemp-server
pnpm install
opencore buildIf you don't have pnpm installed, you can use:
npm installOr yarn (modern/berry):
yarn installYou can also force a package manager:
opencore init my-server --usePackageManager=pnpm
opencore init my-server --usePackageManager=yarn
opencore init my-server --usePackageManager=npmGenerate scaffolding for different project components:
# Create a feature in the core
opencore create feature banking
# Create a feature inside a specific resource
opencore create feature chat -r myresource
# Create a satellite resource (depends on core)
opencore create resource admin --with-client --with-nui
# Create a standalone resource (no dependencies)
opencore create standalone utils --with-client| Subcommand | Flags | Description |
|---|---|---|
feature [name] |
-r, --resource <name> |
Create feature in core (default) or inside a resource |
resource [name] |
--with-client, --with-nui |
Create satellite resource in resources/ |
standalone [name] |
--with-client, --with-nui |
Create standalone resource in standalone/ |
The -r flag allows creating features inside existing resources:
opencore create feature banking # creates in core/src/features/banking/
opencore create feature banking -r admin # creates in resources/admin/src/server/features/banking/Download official templates from the opencore-templates repository:
# List all available templates
opencore clone --list
# List templates from a development branch
opencore clone --list --branch develop
# Clone a template to resources/
opencore clone chat
# Clone a template from a development branch
opencore clone chat --branch develop
# Force using GitHub API instead of git sparse-checkout
opencore clone admin --api| Flag | Description |
|---|---|
-l, --list |
List all available templates from the repository |
-b, --branch <name> |
Repository branch to use when listing or cloning templates (default: master) |
--api |
Force download via GitHub API (skips git sparse-checkout) |
The clone command automatically selects the best download method:
- Uses git sparse-checkout if git >= 2.25 is available (faster)
- Falls back to GitHub API for older git versions or when git is unavailable
Validate external adapter packages such as @open-core/fivem-adapter or @open-core/ragemp-adapter against the framework contract baseline:
# inside an adapter repository
opencore adapter check
# fail on optional parity gaps too
opencore adapter check --strict
# machine-readable output
opencore adapter check --jsonWhat it checks:
- Compares the adapter's registered server/client bindings with the framework's default adapter baseline
- Detects missing required contracts and reports optional parity gaps as warnings by default
- Understands transport helpers like
bindMessagingTransport(...)so the report reflects actual runtime coverage
This command is designed for adapter maintainers, not regular game projects.
Reference:
- CLI usage: ./docs/commands.md
- Adapter overview: opencorejs.dev/docs/adapters
- Framework contracts: opencorejs.dev/docs/contracts/introduction
Full documentation: docs/configuration.md
Projects are configured via opencore.config.ts:
import { defineConfig } from '@open-core/cli'
import { FiveMClientAdapter } from '@open-core/fivem-adapter/client'
import { FiveMServerAdapter } from '@open-core/fivem-adapter/server'
export default defineConfig({
name: 'my-server',
destination: '/path/to/fxserver/resources',
adapter: {
server: FiveMServerAdapter(),
client: FiveMClientAdapter(),
},
core: {
path: './core',
resourceName: 'core',
},
resources: {
include: ['./resources/*'],
},
build: {
minify: true,
parallel: true,
},
})The adapter is the central runtime switch:
FiveMkeeps the standard resource layout andfxmanifest.luaRageMPbuilds server output for Node 14 and splits output intopackages/andclient_packages/opencore doctorshows the configured runtime and adapter status
Views are now handled in one of two modes:
vite: recommended for React, Vue, Svelte, Astro, Tailwind, PostCSS, Sass, and any modern frontend stackvanilla: minimal HTML/CSS/JS/TS views compiled directly by the CLI
The CLI also exposes createOpenCoreViteConfig from @open-core/cli/vite so shared root Vite configs stay small.
Example:
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { createOpenCoreViteConfig } from '@open-core/cli/vite'
export default createOpenCoreViteConfig({
plugins: [react(), tailwindcss()],
build: {
target: 'chrome97',
},
})Per-view package.json scripts are optional and useful only for local development. opencore build does not depend on them.
For older Chromium targets, keep PostCSS in the project root and let the helper auto-resolve it.
| Property | Type | Default | Description |
|---|---|---|---|
name |
string |
- | Project identifier |
destination |
string |
- | FiveM server deployment path (mandatory) |
core |
CoreConfig |
- | Core resource configuration (required) |
resources |
ResourcesConfig |
- | Satellite resources configuration |
standalone |
StandaloneConfig |
- | Independent resources configuration |
modules |
string[] |
- | OpenCore modules to include |
build |
BuildConfig |
- | Global build settings |
dev |
DevConfig |
- | Development server settings |
The central resource containing the framework runtime, dependency injection container, and shared services.
- Initializes OpenCore Framework
- Provides dependency injection container
- Exports shared services and utilities
- Bundles all dependencies
Domain-specific modules that extend core functionality. They import from @open-core/framework which resolves to core exports at runtime.
- External dependency on
@open-core/framework - Optimized for smaller bundle sizes
- Runtime dependency on core resource
Independent modules with no core dependency. Set compile: false for Lua/JS resources that should be copied without transformation.
- No external dependencies
- All dependencies bundled
- Independent deployment
The CLI embeds a complete build toolchain based on esbuild with SWC for TypeScript decorator support.
Build Pipeline:
- SWC Transformation: TypeScript to JavaScript with decorators
- esbuild Bundling: JavaScript to optimized bundles
- FiveM Optimization: Neutral platform targeting, export patching
- Size Analysis: Bundle size tracking and reporting
Full documentation: docs/fivem-runtime.md
FiveM has three distinct runtime environments:
| Feature | Server | Client | Views (NUI) |
|---|---|---|---|
| Runtime | Node.js | Neutral JS | Web Browser |
| Platform | node |
neutral |
browser |
| Node.js APIs | Available | NOT available | NOT available |
| Web APIs | NOT available | NOT available | Available |
| FiveM APIs | Available | Available | Via callbacks |
| GTA Natives | NOT available | Available | NOT available |
| External pkgs | Supported | NOT supported | N/A |
Server: Full Node.js runtime with all APIs.
Client: Neutral JS - FiveM APIs + GTA natives only. All deps MUST be bundled.
Views: Embedded Chromium browser with some version limitations.
For advanced use cases, specify a custom compiler per resource:
core: {
path: './core',
customCompiler: './scripts/custom-build.js',
}Custom compilers receive the following interface:
node custom-build.js single <type> <path> <outDir> '<options-json>'New projects use a single default layout:
project/
├── core/
│ └── src/
│ ├── client.ts
│ ├── server.ts
│ └── features/
├── resources/
├── standalones/
└── views/
The CLI resolves the right entry files during build, and feature scaffolding in core always targets core/src/features/.
git clone https://github.com/newcore-network/opencore-cli
cd opencore-cli
go mod download
go test ./...
go build -o opencore .opencore-cli/
├── internal/
│ ├── commands/ # CLI command handlers
│ ├── builder/ # Build system with parallel compilation
│ ├── config/ # TypeScript configuration parser
│ ├── templates/ # Project scaffolding templates
│ └── ui/ # Terminal interfaces
├── npm/ # NPM package wrapper
└── main.go # Entry point
| Requirement | Version |
|---|---|
| Go | 1.21+ (for building the CLI) |
| Node.js | 18+ (for TypeScript compilation) |
| Package Manager | pnpm (recommended) or npm |
| Platform | Windows, Linux, macOS |
Build performance on a typical project with 10 resources:
| Configuration | Build Time | Memory Usage |
|---|---|---|
| Sequential | 2.3s | 45MB |
| Parallel (4 cores) | 0.8s | 120MB |
| Parallel (8 cores) | 0.5s | 200MB |
MPL-2.0. See LICENSE for details.