From 22cec78331a86bf1d6d2c26fa6d05ac4bbaef93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojtech=20Ma=C5=A1ek?= Date: Thu, 12 Dec 2024 18:01:43 +0100 Subject: [PATCH] docs(bundling): correct esbuild options nesting (#28748) Fixes: - [x] correct nesting of options in ESBuild docs --------- Co-authored-by: Colum Ferry --- .../packages/esbuild/executors/esbuild.json | 2 +- packages/esbuild/docs/esbuild-examples.md | 48 ++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/docs/generated/packages/esbuild/executors/esbuild.json b/docs/generated/packages/esbuild/executors/esbuild.json index 8d99541b38..85224fdb53 100644 --- a/docs/generated/packages/esbuild/executors/esbuild.json +++ b/docs/generated/packages/esbuild/executors/esbuild.json @@ -208,7 +208,7 @@ } }, "additionalProperties": true, - "examplesFile": "`/project.json`:\n\n```jsonc\n{\n //...\n \"targets\": {\n //...\n \"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\"\n }\n }\n }\n}\n```\n\n```bash\nnx build \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 --format=cjs\nnx build --format=esm,cjs\nnx build # defaults to es# defaults to esm\n```\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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": "`/project.json`:\n\n```jsonc\n{\n //...\n \"targets\": {\n //...\n \"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\"\n }\n }\n }\n}\n```\n\n```bash\nnx build \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 --format=cjs\nnx build --format=esm,cjs\nnx build # defaults to es# defaults to esm\n```\n\n```json\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n \"main\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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\": \"\",\n \"tsConfig\": \"/tsconfig.app.json\",\n \"outputPath\": \"dist/\",\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.", diff --git a/packages/esbuild/docs/esbuild-examples.md b/packages/esbuild/docs/esbuild-examples.md index 198f628072..8c0f8f77f7 100644 --- a/packages/esbuild/docs/esbuild-examples.md +++ b/packages/esbuild/docs/esbuild-examples.md @@ -38,10 +38,11 @@ nx build # defaults to es# defaults to esm "build": { "executor": "@nx/esbuild:esbuild", "options": { - "main": "", - "tsConfig": "/tsconfig.app.json", - "outputPath": "dist/", - "format": ["esm", "cjs"] + "main": "", + "tsConfig": "/tsconfig.app.json", + "outputPath": "dist/", + "format": ["esm", "cjs"] + } } ``` @@ -56,10 +57,11 @@ You can also use `*` wildcard to match assets. "build": { "executor": "@nx/esbuild:esbuild", "options": { - "main": "", - "tsConfig": "/tsconfig.app.json", - "outputPath": "dist/", - "external": ["lodash", "*.png"] + "main": "", + "tsConfig": "/tsconfig.app.json", + "outputPath": "dist/", + "external": ["lodash", "*.png"] + } } ``` @@ -72,10 +74,11 @@ Type checking is the slowest part of the build. You may want to skip type checki "build": { "executor": "@nx/esbuild:esbuild", "options": { - "main": "", - "tsConfig": "/tsconfig.app.json", - "outputPath": "dist/", - "skipTypeCheck": true + "main": "", + "tsConfig": "/tsconfig.app.json", + "outputPath": "dist/", + "skipTypeCheck": true + } } ``` @@ -88,16 +91,17 @@ Additional [esbuild options](https://esbuild.github.io/api/) can be passed using "build": { "executor": "@nx/esbuild:esbuild", "options": { - "main": "", - "tsConfig": "/tsconfig.app.json", - "outputPath": "dist/", - "esbuildOptions": { - "legalComments": "inline" - "banner": { - ".js": "// banner" - }, - "footer": { - ".js": "// footer" + "main": "", + "tsConfig": "/tsconfig.app.json", + "outputPath": "dist/", + "esbuildOptions": { + "legalComments": "inline" + "banner": { + ".js": "// banner" + }, + "footer": { + ".js": "// footer" + } } } }