@nrwl/esbuild:esbuild
Bundle a package for different platforms. Note: declaration (*.d.ts) file are not currently generated.
Options can be configured in project.json
when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.
<app-root>/project.json
:
1{
2 //...
3 "targets": {
4 //...
5 "build": {
6 "executor": "@nrwl/esbuild:esbuild",
7 "options": {
8 "main": "<app-root>",
9 "tsConfig": "<app-root>/tsconfig.app.json",
10 "outputPath": "dist/<app-root>"
11 }
12 }
13 }
14}
15
nx build <app-name>
Examples
The CommonJS format is required in some environments, such as Electron applications. By default, esbuild
will use the ESM format, which is recommended for Web and Node applications. You may also output to multiple formats.
nx build <app-name> --format=cjs
nx build <app-name> --format=esm,cjs
nx build <app-name> # defaults to es# defaults to esm
1"build": {
2 "executor": "@nrwl/esbuild:esbuild",
3 "options": {
4 "main": "<app-root>",
5 "tsConfig": "<app-root>/tsconfig.app.json",
6 "outputPath": "dist/<app-root>",
7 "format": ["esm", "cjs"]
8}
9