docs(bundling): correct esbuild options nesting (#28748)

Fixes:

- [x] correct nesting of options in ESBuild docs

---------

Co-authored-by: Colum Ferry <cferry09@gmail.com>
This commit is contained in:
Vojtech Mašek 2024-12-12 18:01:43 +01:00 committed by GitHub
parent 8bafc3b113
commit 22cec78331
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 23 deletions

View File

@ -208,7 +208,7 @@
}
},
"additionalProperties": true,
"examplesFile": "`<app-root>/project.json`:\n\n```jsonc\n{\n //...\n \"targets\": {\n //...\n \"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\"\n }\n }\n }\n}\n```\n\n```bash\nnx build <app-name>\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"CommonJS output\" %}\n\nThe 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.\n\n```bash\nnx build <app-name> --format=cjs\nnx build <app-name> --format=esm,cjs\nnx build <app-name> # defaults to es# defaults to esm\n```\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"format\": [\"esm\", \"cjs\"]\n}\n```\n\n{% /tab %}\n{% tab label=\"External packages\" %}\n\nYou can avoid packages from being bundled by providing the `external` option with a list of packages to skip.\n\nYou can also use `*` wildcard to match assets.\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"external\": [\"lodash\", \"*.png\"]\n}\n```\n\n{% /tab %}\n{% tab label=\"Skip type checking\" %}\n\nType checking is the slowest part of the build. You may want to skip type checking during build and run it as another job in CI.\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"skipTypeCheck\": true\n}\n```\n\n{% /tab %}\n{% tab label=\"Additional esbuild options\" %}\n\nAdditional [esbuild options](https://esbuild.github.io/api/) can be passed using `esbuildOptions` in your project configuration.\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"esbuildOptions\": {\n \"legalComments\": \"inline\"\n \"banner\": {\n \".js\": \"// banner\"\n },\n \"footer\": {\n \".js\": \"// footer\"\n }\n }\n}\n```\n\n{% /tab %}\n{% tabs %}\n",
"examplesFile": "`<app-root>/project.json`:\n\n```jsonc\n{\n //...\n \"targets\": {\n //...\n \"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\"\n }\n }\n }\n}\n```\n\n```bash\nnx build <app-name>\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"CommonJS output\" %}\n\nThe 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.\n\n```bash\nnx build <app-name> --format=cjs\nnx build <app-name> --format=esm,cjs\nnx build <app-name> # defaults to es# defaults to esm\n```\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"format\": [\"esm\", \"cjs\"]\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"External packages\" %}\n\nYou can avoid packages from being bundled by providing the `external` option with a list of packages to skip.\n\nYou can also use `*` wildcard to match assets.\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"external\": [\"lodash\", \"*.png\"]\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Skip type checking\" %}\n\nType checking is the slowest part of the build. You may want to skip type checking during build and run it as another job in CI.\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"skipTypeCheck\": true\n }\n}\n```\n\n{% /tab %}\n{% tab label=\"Additional esbuild options\" %}\n\nAdditional [esbuild options](https://esbuild.github.io/api/) can be passed using `esbuildOptions` in your project configuration.\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"<app-root>\",\n \"tsConfig\": \"<app-root>/tsconfig.app.json\",\n \"outputPath\": \"dist/<app-root>\",\n \"esbuildOptions\": {\n \"legalComments\": \"inline\"\n \"banner\": {\n \".js\": \"// banner\"\n },\n \"footer\": {\n \".js\": \"// footer\"\n }\n }\n }\n}\n```\n\n{% /tab %}\n{% tabs %}\n",
"presets": []
},
"description": "Bundle a package using EsBuild.",

View File

@ -43,6 +43,7 @@ nx build <app-name> # defaults to es# defaults to esm
"outputPath": "dist/<app-root>",
"format": ["esm", "cjs"]
}
}
```
{% /tab %}
@ -61,6 +62,7 @@ You can also use `*` wildcard to match assets.
"outputPath": "dist/<app-root>",
"external": ["lodash", "*.png"]
}
}
```
{% /tab %}
@ -77,6 +79,7 @@ Type checking is the slowest part of the build. You may want to skip type checki
"outputPath": "dist/<app-root>",
"skipTypeCheck": true
}
}
```
{% /tab %}
@ -101,6 +104,7 @@ Additional [esbuild options](https://esbuild.github.io/api/) can be passed using
}
}
}
}
```
{% /tab %}