feat(bundling): rename esbuild-project, rollup-project, and webpack-project generators to "configuration" generators for consistency in naming (#18003)
This commit is contained in:
parent
8d5cfcc2b3
commit
24e45d494f
@ -4841,9 +4841,9 @@
|
|||||||
"disableCollapsible": false
|
"disableCollapsible": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "esbuild-project",
|
"id": "configuration",
|
||||||
"path": "/packages/esbuild/generators/esbuild-project",
|
"path": "/packages/esbuild/generators/configuration",
|
||||||
"name": "esbuild-project",
|
"name": "configuration",
|
||||||
"children": [],
|
"children": [],
|
||||||
"isExternal": false,
|
"isExternal": false,
|
||||||
"disableCollapsible": false
|
"disableCollapsible": false
|
||||||
@ -6530,9 +6530,9 @@
|
|||||||
"disableCollapsible": false
|
"disableCollapsible": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "rollup-project",
|
"id": "configuration",
|
||||||
"path": "/packages/rollup/generators/rollup-project",
|
"path": "/packages/rollup/generators/configuration",
|
||||||
"name": "rollup-project",
|
"name": "configuration",
|
||||||
"children": [],
|
"children": [],
|
||||||
"isExternal": false,
|
"isExternal": false,
|
||||||
"disableCollapsible": false
|
"disableCollapsible": false
|
||||||
@ -6986,9 +6986,9 @@
|
|||||||
"disableCollapsible": false
|
"disableCollapsible": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "webpack-project",
|
"id": "configuration",
|
||||||
"path": "/packages/webpack/generators/webpack-project",
|
"path": "/packages/webpack/generators/configuration",
|
||||||
"name": "webpack-project",
|
"name": "configuration",
|
||||||
"children": [],
|
"children": [],
|
||||||
"isExternal": false,
|
"isExternal": false,
|
||||||
"disableCollapsible": false
|
"disableCollapsible": false
|
||||||
|
|||||||
@ -651,13 +651,13 @@
|
|||||||
"path": "/packages/esbuild/generators/init",
|
"path": "/packages/esbuild/generators/init",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
},
|
},
|
||||||
"/packages/esbuild/generators/esbuild-project": {
|
"/packages/esbuild/generators/configuration": {
|
||||||
"description": "Add esbuild configuration to a project.",
|
"description": "Add esbuild configuration to a project.",
|
||||||
"file": "generated/packages/esbuild/generators/esbuild-project.json",
|
"file": "generated/packages/esbuild/generators/configuration.json",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "esbuild-project",
|
"name": "configuration",
|
||||||
"originalFilePath": "/packages/esbuild/src/generators/esbuild-project/schema.json",
|
"originalFilePath": "/packages/esbuild/src/generators/configuration/schema.json",
|
||||||
"path": "/packages/esbuild/generators/esbuild-project",
|
"path": "/packages/esbuild/generators/configuration",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2336,13 +2336,13 @@
|
|||||||
"path": "/packages/rollup/generators/init",
|
"path": "/packages/rollup/generators/init",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
},
|
},
|
||||||
"/packages/rollup/generators/rollup-project": {
|
"/packages/rollup/generators/configuration": {
|
||||||
"description": "Add rollup configuration to a project.",
|
"description": "Add rollup configuration to a project.",
|
||||||
"file": "generated/packages/rollup/generators/rollup-project.json",
|
"file": "generated/packages/rollup/generators/configuration.json",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "rollup-project",
|
"name": "configuration",
|
||||||
"originalFilePath": "/packages/rollup/src/generators/rollup-project/schema.json",
|
"originalFilePath": "/packages/rollup/src/generators/configuration/schema.json",
|
||||||
"path": "/packages/rollup/generators/rollup-project",
|
"path": "/packages/rollup/generators/configuration",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2782,13 +2782,13 @@
|
|||||||
"path": "/packages/webpack/generators/init",
|
"path": "/packages/webpack/generators/init",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
},
|
},
|
||||||
"/packages/webpack/generators/webpack-project": {
|
"/packages/webpack/generators/configuration": {
|
||||||
"description": "Add webpack configuration to a project.",
|
"description": "Add webpack configuration to a project.",
|
||||||
"file": "generated/packages/webpack/generators/webpack-project.json",
|
"file": "generated/packages/webpack/generators/configuration.json",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "webpack-project",
|
"name": "configuration",
|
||||||
"originalFilePath": "/packages/webpack/src/generators/webpack-project/schema.json",
|
"originalFilePath": "/packages/webpack/src/generators/configuration/schema.json",
|
||||||
"path": "/packages/webpack/generators/webpack-project",
|
"path": "/packages/webpack/generators/configuration",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -642,11 +642,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Add esbuild configuration to a project.",
|
"description": "Add esbuild configuration to a project.",
|
||||||
"file": "generated/packages/esbuild/generators/esbuild-project.json",
|
"file": "generated/packages/esbuild/generators/configuration.json",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "esbuild-project",
|
"name": "configuration",
|
||||||
"originalFilePath": "/packages/esbuild/src/generators/esbuild-project/schema.json",
|
"originalFilePath": "/packages/esbuild/src/generators/configuration/schema.json",
|
||||||
"path": "esbuild/generators/esbuild-project",
|
"path": "esbuild/generators/configuration",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -2313,11 +2313,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Add rollup configuration to a project.",
|
"description": "Add rollup configuration to a project.",
|
||||||
"file": "generated/packages/rollup/generators/rollup-project.json",
|
"file": "generated/packages/rollup/generators/configuration.json",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "rollup-project",
|
"name": "configuration",
|
||||||
"originalFilePath": "/packages/rollup/src/generators/rollup-project/schema.json",
|
"originalFilePath": "/packages/rollup/src/generators/configuration/schema.json",
|
||||||
"path": "rollup/generators/rollup-project",
|
"path": "rollup/generators/configuration",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -2754,11 +2754,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Add webpack configuration to a project.",
|
"description": "Add webpack configuration to a project.",
|
||||||
"file": "generated/packages/webpack/generators/webpack-project.json",
|
"file": "generated/packages/webpack/generators/configuration.json",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"name": "webpack-project",
|
"name": "configuration",
|
||||||
"originalFilePath": "/packages/webpack/src/generators/webpack-project/schema.json",
|
"originalFilePath": "/packages/webpack/src/generators/configuration/schema.json",
|
||||||
"path": "webpack/generators/webpack-project",
|
"path": "webpack/generators/configuration",
|
||||||
"type": "generator"
|
"type": "generator"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -45,13 +45,13 @@ This command will install the esbuild plugin if needed, and set `@nx/esbuild:esb
|
|||||||
If you already have a JS project that you want to use esbuild for, run this command:
|
If you already have a JS project that you want to use esbuild for, run this command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nx g esbuild-project mylib
|
nx g @nx/esbuild:configuration mylib
|
||||||
```
|
```
|
||||||
|
|
||||||
This generator validates there isn't an existing `build` target. If you want to overwrite the existing target you can pass the `--skipValidation` option.
|
This generator validates there isn't an existing `build` target. If you want to overwrite the existing target you can pass the `--skipValidation` option.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nx g esbuild-project mylib --skipValidation
|
nx g @nx/esbuild:configuration mylib --skipValidation
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using esbuild
|
## Using esbuild
|
||||||
|
|||||||
@ -206,7 +206,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": true,
|
"additionalProperties": true,
|
||||||
"examplesFile": "`<app-root>/project.json`:\n\n```json\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{% /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",
|
||||||
"presets": []
|
"presets": []
|
||||||
},
|
},
|
||||||
"description": "Bundle a package using EsBuild.",
|
"description": "Bundle a package using EsBuild.",
|
||||||
|
|||||||
@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"name": "configuration",
|
||||||
|
"aliases": ["esbuild-project"],
|
||||||
|
"factory": "./src/generators/configuration/configuration",
|
||||||
|
"schema": {
|
||||||
|
"$schema": "http://json-schema.org/schema",
|
||||||
|
"$id": "NxEsBuildProject",
|
||||||
|
"cli": "nx",
|
||||||
|
"title": "Add esbuild configuration to a project",
|
||||||
|
"description": "Add esbuild configuration to a project.",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"project": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the project.",
|
||||||
|
"$default": { "$source": "argv", "index": 0 },
|
||||||
|
"x-dropdown": "project",
|
||||||
|
"x-prompt": "What is the name of the project to set up a esbuild for?",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"main": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to the workspace root for the main entry file. Defaults to `<project-root>/src/main.ts` or `<project-root>src/index.ts`, whichever is found.",
|
||||||
|
"alias": "entryFile",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"tsConfig": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to the workspace root for the tsconfig file to build with. Defaults to `<project-root>/tsconfig.app.json` or `<project-root>/tsconfig.lib.json`, whichever is found.",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"skipFormat": {
|
||||||
|
"description": "Skip formatting files.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipValidation": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not perform any validation on existing project.",
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"importPath": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The library name used to import it, like `@myorg/my-awesome-lib`."
|
||||||
|
},
|
||||||
|
"platform": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Platform target for outputs.",
|
||||||
|
"enum": ["browser", "node", "neutral"],
|
||||||
|
"default": "node"
|
||||||
|
},
|
||||||
|
"buildTarget": {
|
||||||
|
"description": "The build target to add.",
|
||||||
|
"type": "string",
|
||||||
|
"default": "build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [],
|
||||||
|
"examplesFile": "```bash\nnx g @nx/esbuild:configuration my-package\n```\n\n{% callout type=\"note\" title=\"Overwriting existing build option\" %}\nThe `configuration` generator validates that an existing `build` target isn't already defined for the project. If you are adding esbuild to a project with an existing `build` target, pass the `--skipValidation` option.\n{% /callout %}\n\nYou may also provide a custom main entry file, or a custom tsconfig file if the defaults don't work. By default, the generator will look for a main file matching `src/index.ts` or `src/main.ts`, and a tsconfig file matching `tsconfig.app.json` or `tsconfig.lib.json`.\n\n```bash\nnx g @nx/esbuild:configuration my-package \\\n--main=packages/my-package/src/entry.ts \\\n--tsConfig=packages/my-package/tsconfig.custom.json\n```\n",
|
||||||
|
"presets": []
|
||||||
|
},
|
||||||
|
"description": "Add esbuild configuration to a project.",
|
||||||
|
"hidden": true,
|
||||||
|
"implementation": "/packages/esbuild/src/generators/configuration/configuration.ts",
|
||||||
|
"path": "/packages/esbuild/src/generators/configuration/schema.json",
|
||||||
|
"type": "generator"
|
||||||
|
}
|
||||||
83
docs/generated/packages/rollup/generators/configuration.json
Normal file
83
docs/generated/packages/rollup/generators/configuration.json
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
{
|
||||||
|
"name": "configuration",
|
||||||
|
"aliases": ["rollup-project"],
|
||||||
|
"factory": "./src/generators/configuration/configuration",
|
||||||
|
"schema": {
|
||||||
|
"$schema": "http://json-schema.org/schema",
|
||||||
|
"$id": "NxRollupProject",
|
||||||
|
"cli": "nx",
|
||||||
|
"title": "Add Rollup Configuration to a project",
|
||||||
|
"description": "Add Rollup Configuration to a project.",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"project": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the project.",
|
||||||
|
"$default": { "$source": "argv", "index": 0 },
|
||||||
|
"x-dropdown": "project",
|
||||||
|
"x-prompt": "What is the name of the project to set up a rollup for?",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"compiler": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["babel", "swc", "tsc"],
|
||||||
|
"description": "The compiler to use to build source.",
|
||||||
|
"default": "babel"
|
||||||
|
},
|
||||||
|
"main": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to the workspace root for the main entry file. Defaults to '<projectRoot>/src/main.ts'.",
|
||||||
|
"alias": "entryFile",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"tsConfig": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to the workspace root for the tsconfig file to build with. Defaults to '<projectRoot>/tsconfig.app.json'.",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"skipFormat": {
|
||||||
|
"description": "Skip formatting files.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipValidation": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not perform any validation on existing project.",
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"importPath": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The library name used to import it, like `@myorg/my-awesome-lib`."
|
||||||
|
},
|
||||||
|
"external": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "A list of external modules that will not be bundled (`react`, `react-dom`, etc.).",
|
||||||
|
"items": { "type": "string" }
|
||||||
|
},
|
||||||
|
"rollupConfig": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to workspace root to a custom rollup file that takes a config object and returns an updated config."
|
||||||
|
},
|
||||||
|
"buildTarget": {
|
||||||
|
"description": "The build target to add.",
|
||||||
|
"type": "string",
|
||||||
|
"default": "build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [],
|
||||||
|
"presets": []
|
||||||
|
},
|
||||||
|
"description": "Add rollup configuration to a project.",
|
||||||
|
"hidden": true,
|
||||||
|
"implementation": "/packages/rollup/src/generators/configuration/configuration.ts",
|
||||||
|
"path": "/packages/rollup/src/generators/configuration/schema.json",
|
||||||
|
"type": "generator"
|
||||||
|
}
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"name": "configuration",
|
||||||
|
"aliases": ["webpack-project"],
|
||||||
|
"factory": "./src/generators/configuration/configuration",
|
||||||
|
"schema": {
|
||||||
|
"$schema": "http://json-schema.org/schema",
|
||||||
|
"$id": "NxWebpackProject",
|
||||||
|
"cli": "nx",
|
||||||
|
"title": "Add Webpack Configuration to a project",
|
||||||
|
"description": "Add Webpack Configuration to a project.",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"project": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the project.",
|
||||||
|
"$default": { "$source": "argv", "index": 0 },
|
||||||
|
"x-dropdown": "project",
|
||||||
|
"x-prompt": "What is the name of the project to set up a webpack for?",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"compiler": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["babel", "swc", "tsc"],
|
||||||
|
"description": "The compiler to use to build source.",
|
||||||
|
"default": "swc"
|
||||||
|
},
|
||||||
|
"main": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to the workspace root for the main entry file. Defaults to '<projectRoot>/src/main.ts'.",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"tsConfig": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to the workspace root for the tsconfig file to build with. Defaults to '<projectRoot>/tsconfig.app.json'.",
|
||||||
|
"x-priority": "important"
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Target platform for the build, same as the Webpack config option.",
|
||||||
|
"enum": ["node", "web", "webworker"],
|
||||||
|
"default": "web"
|
||||||
|
},
|
||||||
|
"skipFormat": {
|
||||||
|
"description": "Skip formatting files.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipPackageJson": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not add dependencies to `package.json`.",
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"skipValidation": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Do not perform any validation on existing project.",
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"devServer": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Add a serve target to run a local webpack dev-server",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
|
"webpackConfig": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path relative to workspace root to a custom webpack file that takes a config object and returns an updated config.",
|
||||||
|
"x-priority": "internal"
|
||||||
|
},
|
||||||
|
"babelConfig": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Optionally specify a path relative to workspace root to the babel configuration file of your project.",
|
||||||
|
"x-completion-type": "file"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [],
|
||||||
|
"presets": []
|
||||||
|
},
|
||||||
|
"description": "Add webpack configuration to a project.",
|
||||||
|
"hidden": true,
|
||||||
|
"implementation": "/packages/webpack/src/generators/configuration/configuration.ts",
|
||||||
|
"path": "/packages/webpack/src/generators/configuration/schema.json",
|
||||||
|
"type": "generator"
|
||||||
|
}
|
||||||
@ -45,13 +45,13 @@ This command will install the esbuild plugin if needed, and set `@nx/esbuild:esb
|
|||||||
If you already have a JS project that you want to use esbuild for, run this command:
|
If you already have a JS project that you want to use esbuild for, run this command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nx g esbuild-project mylib
|
nx g @nx/esbuild:configuration mylib
|
||||||
```
|
```
|
||||||
|
|
||||||
This generator validates there isn't an existing `build` target. If you want to overwrite the existing target you can pass the `--skipValidation` option.
|
This generator validates there isn't an existing `build` target. If you want to overwrite the existing target you can pass the `--skipValidation` option.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nx g esbuild-project mylib --skipValidation
|
nx g @nx/esbuild:configuration mylib --skipValidation
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using esbuild
|
## Using esbuild
|
||||||
|
|||||||
@ -353,7 +353,7 @@
|
|||||||
- [esbuild](/packages/esbuild/executors/esbuild)
|
- [esbuild](/packages/esbuild/executors/esbuild)
|
||||||
- [generators](/packages/esbuild/generators)
|
- [generators](/packages/esbuild/generators)
|
||||||
- [init](/packages/esbuild/generators/init)
|
- [init](/packages/esbuild/generators/init)
|
||||||
- [esbuild-project](/packages/esbuild/generators/esbuild-project)
|
- [configuration](/packages/esbuild/generators/configuration)
|
||||||
- [eslint-plugin](/packages/eslint-plugin)
|
- [eslint-plugin](/packages/eslint-plugin)
|
||||||
- [documents](/packages/eslint-plugin/documents)
|
- [documents](/packages/eslint-plugin/documents)
|
||||||
- [Overview](/packages/eslint-plugin/documents/overview)
|
- [Overview](/packages/eslint-plugin/documents/overview)
|
||||||
@ -558,7 +558,7 @@
|
|||||||
- [rollup](/packages/rollup/executors/rollup)
|
- [rollup](/packages/rollup/executors/rollup)
|
||||||
- [generators](/packages/rollup/generators)
|
- [generators](/packages/rollup/generators)
|
||||||
- [init](/packages/rollup/generators/init)
|
- [init](/packages/rollup/generators/init)
|
||||||
- [rollup-project](/packages/rollup/generators/rollup-project)
|
- [configuration](/packages/rollup/generators/configuration)
|
||||||
- [storybook](/packages/storybook)
|
- [storybook](/packages/storybook)
|
||||||
- [documents](/packages/storybook/documents)
|
- [documents](/packages/storybook/documents)
|
||||||
- [Nx Storybook Plugin Overview](/packages/storybook/documents/overview)
|
- [Nx Storybook Plugin Overview](/packages/storybook/documents/overview)
|
||||||
@ -613,7 +613,7 @@
|
|||||||
- [ssr-dev-server](/packages/webpack/executors/ssr-dev-server)
|
- [ssr-dev-server](/packages/webpack/executors/ssr-dev-server)
|
||||||
- [generators](/packages/webpack/generators)
|
- [generators](/packages/webpack/generators)
|
||||||
- [init](/packages/webpack/generators/init)
|
- [init](/packages/webpack/generators/init)
|
||||||
- [webpack-project](/packages/webpack/generators/webpack-project)
|
- [configuration](/packages/webpack/generators/configuration)
|
||||||
- [workspace](/packages/workspace)
|
- [workspace](/packages/workspace)
|
||||||
- [documents](/packages/workspace/documents)
|
- [documents](/packages/workspace/documents)
|
||||||
- [Overview](/packages/workspace/documents/overview)
|
- [Overview](/packages/workspace/documents/overview)
|
||||||
|
|||||||
@ -20,7 +20,7 @@ describe('Rollup Plugin', () => {
|
|||||||
|
|
||||||
// babel (default)
|
// babel (default)
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/rollup:rollup-project ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts`
|
`generate @nx/rollup:configuration ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts`
|
||||||
);
|
);
|
||||||
rmDist();
|
rmDist();
|
||||||
runCLI(`build ${myPkg}`);
|
runCLI(`build ${myPkg}`);
|
||||||
@ -34,7 +34,7 @@ describe('Rollup Plugin', () => {
|
|||||||
|
|
||||||
// swc
|
// swc
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/rollup:rollup-project ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=swc`
|
`generate @nx/rollup:configuration ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=swc`
|
||||||
);
|
);
|
||||||
rmDist();
|
rmDist();
|
||||||
runCLI(`build ${myPkg}`);
|
runCLI(`build ${myPkg}`);
|
||||||
@ -48,7 +48,7 @@ describe('Rollup Plugin', () => {
|
|||||||
|
|
||||||
// tsc
|
// tsc
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/rollup:rollup-project ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=tsc`
|
`generate @nx/rollup:configuration ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=tsc`
|
||||||
);
|
);
|
||||||
rmDist();
|
rmDist();
|
||||||
runCLI(`build ${myPkg}`);
|
runCLI(`build ${myPkg}`);
|
||||||
|
|||||||
@ -19,7 +19,7 @@ describe('Webpack Plugin', () => {
|
|||||||
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
|
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
|
||||||
|
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/webpack:webpack-project ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts`
|
`generate @nx/webpack:configuration ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test `scriptType` later during during.
|
// Test `scriptType` later during during.
|
||||||
@ -52,7 +52,7 @@ module.exports = composePlugins(withNx(), (config) => {
|
|||||||
|
|
||||||
// swc
|
// swc
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/webpack:webpack-project ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=swc`
|
`generate @nx/webpack:configuration ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=swc`
|
||||||
);
|
);
|
||||||
rmDist();
|
rmDist();
|
||||||
runCLI(`build ${myPkg}`);
|
runCLI(`build ${myPkg}`);
|
||||||
@ -66,7 +66,7 @@ module.exports = composePlugins(withNx(), (config) => {
|
|||||||
|
|
||||||
// tsc
|
// tsc
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/webpack:webpack-project ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=tsc`
|
`generate @nx/webpack:configuration ${myPkg} --target=node --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts --compiler=tsc`
|
||||||
);
|
);
|
||||||
rmDist();
|
rmDist();
|
||||||
runCLI(`build ${myPkg}`);
|
runCLI(`build ${myPkg}`);
|
||||||
@ -80,7 +80,7 @@ module.exports = composePlugins(withNx(), (config) => {
|
|||||||
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
|
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
|
||||||
|
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/webpack:webpack-project ${myPkg} --target=node --compiler=babel --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts`
|
`generate @nx/webpack:configuration ${myPkg} --target=node --compiler=babel --tsConfig=libs/${myPkg}/tsconfig.lib.json --main=libs/${myPkg}/src/index.ts`
|
||||||
);
|
);
|
||||||
|
|
||||||
updateFile(
|
updateFile(
|
||||||
|
|||||||
@ -148,6 +148,8 @@ const schemaUrls = {
|
|||||||
'/packages/cypress/generators/configuration',
|
'/packages/cypress/generators/configuration',
|
||||||
'/packages/cypress/generators/cypress-component-configuration':
|
'/packages/cypress/generators/cypress-component-configuration':
|
||||||
'/packages/cypress/generators/component-configuration',
|
'/packages/cypress/generators/component-configuration',
|
||||||
|
'/packages/esbuild/generators/esbuild-project':
|
||||||
|
'/packages/esbuild/generators/configuration',
|
||||||
'/packages/nx-plugin/generators/executor':
|
'/packages/nx-plugin/generators/executor':
|
||||||
'/packages/plugin/generators/executor',
|
'/packages/plugin/generators/executor',
|
||||||
'/packages/nx-plugin/generators/migration':
|
'/packages/nx-plugin/generators/migration':
|
||||||
@ -156,6 +158,10 @@ const schemaUrls = {
|
|||||||
'/packages/nx-plugin/generators/schematic':
|
'/packages/nx-plugin/generators/schematic':
|
||||||
'/packages/plugin/generators/generator',
|
'/packages/plugin/generators/generator',
|
||||||
'/packages/nx-plugin/generators/e2e': '/packages/plugin/executors/e2e',
|
'/packages/nx-plugin/generators/e2e': '/packages/plugin/executors/e2e',
|
||||||
|
'/packages/rollup/generators/rollup-project':
|
||||||
|
'/packages/rollup/generators/configuration',
|
||||||
|
'/packages/webpack/generators/webpack-project':
|
||||||
|
'/packages/webpack/generators/configuration',
|
||||||
'/nx-plugin/executor': '/packages/plugin/generators/executor',
|
'/nx-plugin/executor': '/packages/plugin/generators/executor',
|
||||||
'/nx-plugin/migration': '/packages/plugin/generators/migration',
|
'/nx-plugin/migration': '/packages/plugin/generators/migration',
|
||||||
'/nx-plugin/plugin': '/packages/plugin/generators/plugin',
|
'/nx-plugin/plugin': '/packages/plugin/generators/plugin',
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
```bash
|
```bash
|
||||||
nx g @nx/esbuild:esbuild-project my-package
|
nx g @nx/esbuild:configuration my-package
|
||||||
```
|
```
|
||||||
|
|
||||||
{% callout type="note" title="Overwriting existing build option" %}
|
{% callout type="note" title="Overwriting existing build option" %}
|
||||||
The `esbuild-projet` generator validates that an existing `build` target isn't already defined for the project. If you are adding esbuild to a project with an existing `build` target, pass the `--skipValidation` option.
|
The `configuration` generator validates that an existing `build` target isn't already defined for the project. If you are adding esbuild to a project with an existing `build` target, pass the `--skipValidation` option.
|
||||||
{% /callout %}
|
{% /callout %}
|
||||||
|
|
||||||
You may also provide a custom main entry file, or a custom tsconfig file if the defaults don't work. By default, the generator will look for a main file matching `src/index.ts` or `src/main.ts`, and a tsconfig file matching `tsconfig.app.json` or `tsconfig.lib.json`.
|
You may also provide a custom main entry file, or a custom tsconfig file if the defaults don't work. By default, the generator will look for a main file matching `src/index.ts` or `src/main.ts`, and a tsconfig file matching `tsconfig.app.json` or `tsconfig.lib.json`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nx g @nx/esbuild:esbuild-project my-package \
|
nx g @nx/esbuild:configuration my-package \
|
||||||
--main=packages/my-package/src/entry.ts \
|
--main=packages/my-package/src/entry.ts \
|
||||||
--tsConfig=packages/my-package/tsconfig.custom.json
|
--tsConfig=packages/my-package/tsconfig.custom.json
|
||||||
```
|
```
|
||||||
@ -1,6 +1,6 @@
|
|||||||
`<app-root>/project.json`:
|
`<app-root>/project.json`:
|
||||||
|
|
||||||
```json
|
```jsonc
|
||||||
{
|
{
|
||||||
//...
|
//...
|
||||||
"targets": {
|
"targets": {
|
||||||
|
|||||||
@ -8,9 +8,10 @@
|
|||||||
"description": "Initialize the `@nrwl/esbuild` plugin.",
|
"description": "Initialize the `@nrwl/esbuild` plugin.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
},
|
},
|
||||||
"esbuild-project": {
|
"configuration": {
|
||||||
"factory": "./src/generators/esbuild-project/esbuild-project#esbuildProjectSchematic",
|
"aliases": ["esbuild-project"],
|
||||||
"schema": "./src/generators/esbuild-project/schema.json",
|
"factory": "./src/generators/configuration/configuration#compat",
|
||||||
|
"schema": "./src/generators/configuration/schema.json",
|
||||||
"description": "Add esbuild configuration to a project.",
|
"description": "Add esbuild configuration to a project.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
}
|
}
|
||||||
@ -23,9 +24,10 @@
|
|||||||
"aliases": ["ng-add"],
|
"aliases": ["ng-add"],
|
||||||
"hidden": true
|
"hidden": true
|
||||||
},
|
},
|
||||||
"esbuild-project": {
|
"configuration": {
|
||||||
"factory": "./src/generators/esbuild-project/esbuild-project#esbuildProjectGenerator",
|
"aliases": ["esbuild-project"],
|
||||||
"schema": "./src/generators/esbuild-project/schema.json",
|
"factory": "./src/generators/configuration/configuration",
|
||||||
|
"schema": "./src/generators/configuration/schema.json",
|
||||||
"description": "Add esbuild configuration to a project.",
|
"description": "Add esbuild configuration to a project.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
import { configurationGenerator } from './src/generators/configuration/configuration';
|
||||||
|
export { configurationGenerator };
|
||||||
|
|
||||||
|
// Exported for backwards compatibility in case a plugin is using the old name.
|
||||||
|
/** @deprecated Use `configurationGenerator` instead. */
|
||||||
|
const esbuildProjectGenerator = configurationGenerator;
|
||||||
|
|
||||||
export * from './src/generators/init/init';
|
export * from './src/generators/init/init';
|
||||||
export * from './src/generators/esbuild-project/esbuild-project';
|
|
||||||
export * from './src/utils/versions';
|
export * from './src/utils/versions';
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import {
|
|||||||
writeJson,
|
writeJson,
|
||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
||||||
import esbuildProjectGenerator from './esbuild-project';
|
import configurationGenerator from './configuration';
|
||||||
|
|
||||||
describe('esbuildProjectGenerator', () => {
|
describe('configurationGenerator', () => {
|
||||||
let tree: Tree;
|
let tree: Tree;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -25,7 +25,7 @@ describe('esbuildProjectGenerator', () => {
|
|||||||
tree.write(`mypkg/src/${main}`, 'console.log("main");');
|
tree.write(`mypkg/src/${main}`, 'console.log("main");');
|
||||||
writeJson(tree, `mypkg/${tsConfig}`, {});
|
writeJson(tree, `mypkg/${tsConfig}`, {});
|
||||||
|
|
||||||
await esbuildProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ describe('esbuildProjectGenerator', () => {
|
|||||||
tree.write(`src/main.ts`, 'console.log("main");');
|
tree.write(`src/main.ts`, 'console.log("main");');
|
||||||
writeJson(tree, `tsconfig.app.json`, {});
|
writeJson(tree, `tsconfig.app.json`, {});
|
||||||
|
|
||||||
await esbuildProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ import { esbuildInitGenerator } from '../init/init';
|
|||||||
import { EsBuildExecutorOptions } from '../../executors/esbuild/schema';
|
import { EsBuildExecutorOptions } from '../../executors/esbuild/schema';
|
||||||
import { EsBuildProjectSchema } from './schema';
|
import { EsBuildProjectSchema } from './schema';
|
||||||
|
|
||||||
export async function esbuildProjectGenerator(
|
export async function configurationGenerator(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
options: EsBuildProjectSchema
|
options: EsBuildProjectSchema
|
||||||
) {
|
) {
|
||||||
@ -126,8 +126,6 @@ function getTsConfigFile(tree: Tree, options: EsBuildProjectSchema) {
|
|||||||
return options.tsConfig;
|
return options.tsConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const esbuildProjectSchematic = convertNxGenerator(
|
export const compat = convertNxGenerator(configurationGenerator);
|
||||||
esbuildProjectGenerator
|
|
||||||
);
|
|
||||||
|
|
||||||
export default esbuildProjectGenerator;
|
export default configurationGenerator;
|
||||||
@ -63,5 +63,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [],
|
"required": [],
|
||||||
"examplesFile": "../../../docs/esbuild-project-examples.md"
|
"examplesFile": "../../../docs/configuration-examples.md"
|
||||||
}
|
}
|
||||||
@ -88,11 +88,11 @@ export async function setupBuildGenerator(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'esbuild': {
|
case 'esbuild': {
|
||||||
const { esbuildProjectGenerator } = ensurePackage(
|
const { configurationGenerator } = ensurePackage(
|
||||||
'@nx/esbuild',
|
'@nx/esbuild',
|
||||||
nxVersion
|
nxVersion
|
||||||
);
|
);
|
||||||
const task = await esbuildProjectGenerator(tree, {
|
const task = await configurationGenerator(tree, {
|
||||||
main: mainFile,
|
main: mainFile,
|
||||||
buildTarget: options.buildTarget,
|
buildTarget: options.buildTarget,
|
||||||
project: options.project,
|
project: options.project,
|
||||||
@ -102,8 +102,8 @@ export async function setupBuildGenerator(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'rollup': {
|
case 'rollup': {
|
||||||
const { rollupProjectGenerator } = ensurePackage('@nx/rollup', nxVersion);
|
const { configurationGenerator } = ensurePackage('@nx/rollup', nxVersion);
|
||||||
const task = await rollupProjectGenerator(tree, {
|
const task = await configurationGenerator(tree, {
|
||||||
buildTarget: options.buildTarget,
|
buildTarget: options.buildTarget,
|
||||||
main: mainFile,
|
main: mainFile,
|
||||||
project: options.project,
|
project: options.project,
|
||||||
|
|||||||
@ -8,9 +8,10 @@
|
|||||||
"description": "Initialize the `@nrwl/rollup` plugin.",
|
"description": "Initialize the `@nrwl/rollup` plugin.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
},
|
},
|
||||||
"rollup-project": {
|
"configuration": {
|
||||||
"factory": "./src/generators/rollup-project/rollup-project#rollupProjectSchematic",
|
"aliases": ["rollup-project"],
|
||||||
"schema": "./src/generators/rollup-project/schema.json",
|
"factory": "./src/generators/configuration/configuration#compat",
|
||||||
|
"schema": "./src/generators/configuration/schema.json",
|
||||||
"description": "Add rollup configuration to a project.",
|
"description": "Add rollup configuration to a project.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
}
|
}
|
||||||
@ -23,9 +24,10 @@
|
|||||||
"aliases": ["ng-add"],
|
"aliases": ["ng-add"],
|
||||||
"hidden": true
|
"hidden": true
|
||||||
},
|
},
|
||||||
"rollup-project": {
|
"configuration": {
|
||||||
"factory": "./src/generators/rollup-project/rollup-project#rollupProjectGenerator",
|
"aliases": ["rollup-project"],
|
||||||
"schema": "./src/generators/rollup-project/schema.json",
|
"factory": "./src/generators/configuration/configuration",
|
||||||
|
"schema": "./src/generators/configuration/schema.json",
|
||||||
"description": "Add rollup configuration to a project.",
|
"description": "Add rollup configuration to a project.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
|
import { configurationGenerator } from './src/generators/configuration/configuration';
|
||||||
|
export { configurationGenerator };
|
||||||
|
|
||||||
|
// Exported for backwards compatibility in case a plugin is using the old name.
|
||||||
|
/** @deprecated Use `configurationGenerator` instead. */
|
||||||
|
export const rollupProjectGenerator = configurationGenerator;
|
||||||
|
|
||||||
export * from './src/generators/init/init';
|
export * from './src/generators/init/init';
|
||||||
export * from './src/generators/rollup-project/rollup-project';
|
|
||||||
export type {
|
export type {
|
||||||
AssetGlobPattern,
|
AssetGlobPattern,
|
||||||
Globals,
|
Globals,
|
||||||
|
|||||||
@ -7,9 +7,9 @@ import {
|
|||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
||||||
|
|
||||||
import { rollupProjectGenerator } from './rollup-project';
|
import configurationGenerator from './configuration';
|
||||||
|
|
||||||
describe('rollupProjectGenerator', () => {
|
describe('configurationGenerator', () => {
|
||||||
let tree: Tree;
|
let tree: Tree;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@ -22,7 +22,7 @@ describe('rollupProjectGenerator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should generate files', async () => {
|
it('should generate files', async () => {
|
||||||
await rollupProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ describe('rollupProjectGenerator', () => {
|
|||||||
name: '@acme/mypkg',
|
name: '@acme/mypkg',
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
});
|
});
|
||||||
await rollupProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ describe('rollupProjectGenerator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should support --main option', async () => {
|
it('should support --main option', async () => {
|
||||||
await rollupProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
main: 'libs/mypkg/index.ts',
|
main: 'libs/mypkg/index.ts',
|
||||||
});
|
});
|
||||||
@ -81,7 +81,7 @@ describe('rollupProjectGenerator', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should support --tsConfig option', async () => {
|
it('should support --tsConfig option', async () => {
|
||||||
await rollupProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
tsConfig: 'libs/mypkg/tsconfig.custom.json',
|
tsConfig: 'libs/mypkg/tsconfig.custom.json',
|
||||||
});
|
});
|
||||||
@ -13,7 +13,7 @@ import { rollupInitGenerator } from '../init/init';
|
|||||||
import { RollupExecutorOptions } from '../../executors/rollup/schema';
|
import { RollupExecutorOptions } from '../../executors/rollup/schema';
|
||||||
import { RollupProjectSchema } from './schema';
|
import { RollupProjectSchema } from './schema';
|
||||||
|
|
||||||
export async function rollupProjectGenerator(
|
export async function configurationGenerator(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
options: RollupProjectSchema
|
options: RollupProjectSchema
|
||||||
) {
|
) {
|
||||||
@ -99,8 +99,6 @@ function addBuildTarget(tree: Tree, options: RollupProjectSchema) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default rollupProjectGenerator;
|
export default configurationGenerator;
|
||||||
|
|
||||||
export const rollupProjectSchematic = convertNxGenerator(
|
export const compat = convertNxGenerator(configurationGenerator);
|
||||||
rollupProjectGenerator
|
|
||||||
);
|
|
||||||
@ -73,14 +73,15 @@ async function setupBundler(tree: Tree, options: NormalizedSchema) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (options.bundler === 'webpack') {
|
if (options.bundler === 'webpack') {
|
||||||
const { webpackProjectGenerator } = ensurePackage('@nx/webpack', nxVersion);
|
const { configurationGenerator } = ensurePackage<
|
||||||
await webpackProjectGenerator(tree, {
|
typeof import('@nx/webpack')
|
||||||
|
>('@nx/webpack', nxVersion);
|
||||||
|
await configurationGenerator(tree, {
|
||||||
project: options.projectName,
|
project: options.projectName,
|
||||||
main,
|
main,
|
||||||
tsConfig,
|
tsConfig,
|
||||||
compiler: options.compiler ?? 'babel',
|
compiler: options.compiler ?? 'babel',
|
||||||
devServer: true,
|
devServer: true,
|
||||||
isolatedConfig: true,
|
|
||||||
webpackConfig: joinPathFragments(
|
webpackConfig: joinPathFragments(
|
||||||
options.appProjectRoot,
|
options.appProjectRoot,
|
||||||
'webpack.config.js'
|
'webpack.config.js'
|
||||||
|
|||||||
@ -8,9 +8,10 @@
|
|||||||
"description": "Initialize the `@nrwl/webpack` plugin.",
|
"description": "Initialize the `@nrwl/webpack` plugin.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
},
|
},
|
||||||
"webpack-project": {
|
"configuration": {
|
||||||
"factory": "./src/generators/webpack-project/webpack-project#webpackProjectSchematic",
|
"aliases": ["webpack-project"],
|
||||||
"schema": "./src/generators/webpack-project/schema.json",
|
"factory": "./src/generators/configuration/configuration#compat",
|
||||||
|
"schema": "./src/generators/configuration/schema.json",
|
||||||
"description": "Add webpack configuration to a project.",
|
"description": "Add webpack configuration to a project.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
}
|
}
|
||||||
@ -23,9 +24,10 @@
|
|||||||
"aliases": ["ng-add"],
|
"aliases": ["ng-add"],
|
||||||
"hidden": true
|
"hidden": true
|
||||||
},
|
},
|
||||||
"webpack-project": {
|
"configuration": {
|
||||||
"factory": "./src/generators/webpack-project/webpack-project#webpackProjectGenerator",
|
"aliases": ["webpack-project"],
|
||||||
"schema": "./src/generators/webpack-project/schema.json",
|
"factory": "./src/generators/configuration/configuration",
|
||||||
|
"schema": "./src/generators/configuration/schema.json",
|
||||||
"description": "Add webpack configuration to a project.",
|
"description": "Add webpack configuration to a project.",
|
||||||
"hidden": true
|
"hidden": true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
|
import { configurationGenerator } from './src/generators/configuration/configuration';
|
||||||
|
export { configurationGenerator };
|
||||||
|
|
||||||
|
// Exported for backwards compatibility in case a plugin is using the old name.
|
||||||
|
/** @deprecated Use `configurationGenerator` instead. */
|
||||||
|
export const webpackProjectGenerator = configurationGenerator;
|
||||||
|
|
||||||
export * from './src/utils/create-copy-plugin';
|
export * from './src/utils/create-copy-plugin';
|
||||||
export * from './src/utils/config';
|
export * from './src/utils/config';
|
||||||
export * from './src/generators/init/init';
|
export * from './src/generators/init/init';
|
||||||
export * from './src/generators/webpack-project/webpack-project';
|
|
||||||
export type { WebDevServerOptions } from './src/executors/dev-server/schema';
|
export type { WebDevServerOptions } from './src/executors/dev-server/schema';
|
||||||
export * from './src/executors/dev-server/dev-server.impl';
|
export * from './src/executors/dev-server/dev-server.impl';
|
||||||
export * from './src/executors/webpack/lib/normalize-options';
|
export * from './src/executors/webpack/lib/normalize-options';
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import {
|
|||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
||||||
|
|
||||||
import { webpackProjectGenerator } from './webpack-project';
|
import configurationGenerator from './configuration';
|
||||||
|
|
||||||
describe('webpackProject', () => {
|
describe('webpackProject', () => {
|
||||||
let tree: Tree;
|
let tree: Tree;
|
||||||
@ -20,7 +20,7 @@ describe('webpackProject', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should generate files', async () => {
|
it('should generate files', async () => {
|
||||||
await webpackProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ describe('webpackProject', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should support --main option', async () => {
|
it('should support --main option', async () => {
|
||||||
await webpackProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
main: 'libs/mypkg/index.ts',
|
main: 'libs/mypkg/index.ts',
|
||||||
});
|
});
|
||||||
@ -59,7 +59,7 @@ describe('webpackProject', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should support --tsConfig option', async () => {
|
it('should support --tsConfig option', async () => {
|
||||||
await webpackProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
tsConfig: 'libs/mypkg/tsconfig.custom.json',
|
tsConfig: 'libs/mypkg/tsconfig.custom.json',
|
||||||
});
|
});
|
||||||
@ -79,7 +79,7 @@ describe('webpackProject', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should support --devServer option', async () => {
|
it('should support --devServer option', async () => {
|
||||||
await webpackProjectGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
project: 'mypkg',
|
project: 'mypkg',
|
||||||
devServer: true,
|
devServer: true,
|
||||||
});
|
});
|
||||||
@ -9,12 +9,12 @@ import {
|
|||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
|
|
||||||
import { webpackInitGenerator } from '../init/init';
|
import { webpackInitGenerator } from '../init/init';
|
||||||
import { WebpackProjectGeneratorSchema } from './schema';
|
import { ConfigurationGeneratorSchema } from './schema';
|
||||||
import { WebpackExecutorOptions } from '../../executors/webpack/schema';
|
import { WebpackExecutorOptions } from '../../executors/webpack/schema';
|
||||||
|
|
||||||
export async function webpackProjectGenerator(
|
export async function configurationGenerator(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
options: WebpackProjectGeneratorSchema
|
options: ConfigurationGeneratorSchema
|
||||||
) {
|
) {
|
||||||
const task = await webpackInitGenerator(tree, {
|
const task = await webpackInitGenerator(tree, {
|
||||||
...options,
|
...options,
|
||||||
@ -35,7 +35,7 @@ export async function webpackProjectGenerator(
|
|||||||
|
|
||||||
function checkForTargetConflicts(
|
function checkForTargetConflicts(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
options: WebpackProjectGeneratorSchema
|
options: ConfigurationGeneratorSchema
|
||||||
) {
|
) {
|
||||||
if (options.skipValidation) return;
|
if (options.skipValidation) return;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ function checkForTargetConflicts(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addBuildTarget(tree: Tree, options: WebpackProjectGeneratorSchema) {
|
function addBuildTarget(tree: Tree, options: ConfigurationGeneratorSchema) {
|
||||||
const project = readProjectConfiguration(tree, options.project);
|
const project = readProjectConfiguration(tree, options.project);
|
||||||
const buildOptions: WebpackExecutorOptions = {
|
const buildOptions: WebpackExecutorOptions = {
|
||||||
target: options.target,
|
target: options.target,
|
||||||
@ -132,7 +132,7 @@ module.exports = composePlugins(withNx(), (config) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addServeTarget(tree: Tree, options: WebpackProjectGeneratorSchema) {
|
function addServeTarget(tree: Tree, options: ConfigurationGeneratorSchema) {
|
||||||
const project = readProjectConfiguration(tree, options.project);
|
const project = readProjectConfiguration(tree, options.project);
|
||||||
updateProjectConfiguration(tree, options.project, {
|
updateProjectConfiguration(tree, options.project, {
|
||||||
...project,
|
...project,
|
||||||
@ -153,8 +153,6 @@ function addServeTarget(tree: Tree, options: WebpackProjectGeneratorSchema) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default webpackProjectGenerator;
|
export default configurationGenerator;
|
||||||
|
|
||||||
export const webpackProjectSchematic = convertNxGenerator(
|
export const compat = convertNxGenerator(configurationGenerator);
|
||||||
webpackProjectGenerator
|
|
||||||
);
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
export interface WebpackProjectGeneratorSchema {
|
export interface ConfigurationGeneratorSchema {
|
||||||
project: string;
|
project: string;
|
||||||
main?: string;
|
main?: string;
|
||||||
tsConfig?: string;
|
tsConfig?: string;
|
||||||
Loading…
x
Reference in New Issue
Block a user