Colum Ferry aefafc55ba
feat(module-federation): alias host and remote generators to consumer and producer (#29190)
## Current Behavior
Our Module Federation support across Angular and React contains Host and
Remote generators.
The module-federation.io docs have started to shift towards Consumer and
Producer terminology for better translation of meanings across
languages.


## Expected Behavior
To stay consistent with official terminology, add aliases for the host
and remote generators to allow for the new terminology. i.e. host ->
consumer, remote -> producer.

Therefore the following are all valid

```shell
nx g host shell --remotes=remote1
nx g host shell --producers=producer1
nx g consumer shell --remotes=remote1
nx g consumer shell --producers=remote1

nx g remote remote1 --host=shell
nx g remote remote1 --consumer=shell
nx g producer producer1 --host=shell
nx g producer producer1 --consumer=shell
```
2024-12-04 16:45:27 +00:00

102 lines
4.9 KiB
JSON

{
"name": "setup-mf",
"factory": "./src/generators/setup-mf/setup-mf",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "GeneratorAngularMFSetup",
"cli": "nx",
"title": "Generate Module Federation Setup for Angular App",
"description": "Create Module Federation configuration files for given Angular Application.",
"type": "object",
"properties": {
"appName": {
"type": "string",
"description": "The name of the application to generate the Module Federation configuration for.",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What app would you like to generate a Module Federation configuration for?",
"x-dropdown": "projects"
},
"mfType": {
"type": "string",
"enum": ["host", "remote"],
"description": "Type of application to generate the Module Federation configuration for.",
"default": "remote"
},
"federationType": {
"type": "string",
"enum": ["static", "dynamic"],
"description": "Use either Static or Dynamic Module Federation pattern for the application.",
"default": "static"
},
"port": {
"type": "number",
"description": "The port at which the remote application should be served."
},
"remotes": {
"type": "array",
"description": "A list of remote application names that the Consumer (host) application should consume.",
"alias": "producers"
},
"host": {
"type": "string",
"description": "The name of the host application that the remote application will be consumed by.",
"alias": "consumer"
},
"routing": {
"type": "boolean",
"description": "Generate a routing setup to allow a Consumer (host) application to route to the Producer (remote) application.",
"x-priority": "important"
},
"skipFormat": {
"type": "boolean",
"description": "Skip formatting the workspace after the generator completes.",
"x-priority": "internal"
},
"skipPackageJson": {
"type": "boolean",
"default": false,
"description": "Do not add dependencies to `package.json`.",
"x-priority": "internal"
},
"skipE2E": {
"type": "boolean",
"default": false,
"description": "Do not set up E2E related config."
},
"e2eProjectName": {
"type": "string",
"description": "The project name of the associated E2E project for the application. This is only required for Cypress E2E projects that do not follow the naming convention `<appName>-e2e`."
},
"prefix": {
"type": "string",
"description": "The prefix to use for any generated component."
},
"standalone": {
"type": "boolean",
"description": "Whether the application is a standalone application.",
"default": true
},
"typescriptConfiguration": {
"type": "boolean",
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
"default": true
},
"setParserOptionsProject": {
"type": "boolean",
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
"default": false
}
},
"required": ["appName", "mfType"],
"additionalProperties": false,
"examplesFile": "## Examples\n\nThe `setup-mf` generator is used to add Module Federation support to existing applications.\n\n{% tabs %}\n\n{% tab label=\"Convert to Host\" %}\nTo convert an existing application to a host application, run the following\n\n```bash\nnx g setup-mf myapp --mfType=host --routing=true\n```\n\n{% /tab %}\n\n{% tab label=\"Convert to Remote\" %}\nTo convert an existing application to a remote application, run the following\n\n```bash\nnx g setup-mf myapp --mfType=remote --routing=true\n```\n\n{% /tab %}\n\n{% tab label=\"Convert to Remote and attach to a host application\" %}\nTo convert an existing application to a remote application and attach it to an existing host application name `myhostapp`, run the following\n\n```bash\nnx g setup-mf myapp --mfType=remote --routing=true --host=myhostapp\n```\n\n{% /tab %}\n\n{% tab label=\"Convert to Host and attach to existing remote applications\" %}\nTo convert an existing application to a host application and attaching existing remote applications named `remote1` and `remote2`, run the following\n\n```bash\nnx g setup-mf myapp --mfType=host --routing=true --remotes=remote1,remote2\n```\n\n{% /tab %}\n\n{% /tabs %}\n",
"presets": []
},
"description": "Generate a Module Federation configuration for a given Angular application.",
"implementation": "/packages/angular/src/generators/setup-mf/setup-mf.ts",
"aliases": [],
"hidden": false,
"path": "/packages/angular/src/generators/setup-mf/schema.json",
"type": "generator"
}