A plugin for Nx that provides integration with Node.js Single Executable Applications (SEA).
This plugin helps you create Node.js Single Executable Applications (SEA) within your Nx workspace. It automates the process of generating SEA preparation blobs and creating standalone executables that bundle your Node.js application.
- Node.js 20 or higher (SEA feature requirement)
- Nx 20.0.6 or higher
npm install --save-dev @getlarge/nx-node-sea
Create a sea-config.json
file in your project's root directory:
{
"main": "dist/your-app/main.js",
"output": "dist/your-app/main.blob",
"disableExperimentalSEAWarning": false,
"useSnapshot": false,
"useCodeCache": false
}
Add the plugin configuration to your nx.json
file:
{
"plugins": [
{
"plugin": "@getlarge/nx-node-sea",
"options": {
"seaTargetName": "sea-build",
"buildTarget": "build"
}
}
]
}
Note: The
buildTarget
option specifies the target that will be used to build your application before creating the SEA. The default value is"build"
.
nx run your-app:sea-build
This will:
- Build your application using the specified build target
- Generate a SEA preparation blob
- Create a standalone executable
Option | Description | Default |
---|---|---|
buildTarget |
The target to build your application before creating the SEA | "build" |
seaTargetName |
The name of the target that will be created to build the SEA | "sea-build" |
Option | Description | Required |
---|---|---|
main |
Path to the main JavaScript file of your application | Yes |
output |
Path where the SEA blob will be generated | Yes |
disableExperimentalSEAWarning |
Disable warnings about experimental feature | No |
useSnapshot |
Use V8 snapshot for faster startup | No |
useCodeCache |
Use code cache for faster startup | No |
assets |
Record of assets to include in the blob | No |
The plugin automatically handles platform-specific differences for:
- Linux
- macOS (includes code signing)
- Windows
- Node.js Single Executable Applications
- Nx Tasks Pipeline
- Nx Inferred Tasks
- Postject - Used for injecting the blob into the executable
my-app/
├── sea-config.json
├── project.json
└── src/
└── main.ts
The plugin will create a standalone executable in the directory specified in sea-config.json
(output
).
On macOS and Linux, the binary will be named node
. On Windows, it will be named node.exe
.
You can find a complete working example in the node-sea-demo repository.