@nrwl/react 13.10.0-rc.0 → 13.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/executors.json +16 -0
  2. package/generators.json +14 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +3 -1
  5. package/index.js.map +1 -1
  6. package/module-federation.d.ts +4 -0
  7. package/module-federation.js +10 -0
  8. package/module-federation.js.map +1 -0
  9. package/package.json +10 -9
  10. package/plugins/webpack.d.ts +2 -1
  11. package/plugins/webpack.js +2 -0
  12. package/plugins/webpack.js.map +1 -1
  13. package/src/executors/mfe-dev-server/compat.d.ts +2 -0
  14. package/src/executors/mfe-dev-server/compat.js +6 -0
  15. package/src/executors/mfe-dev-server/compat.js.map +1 -0
  16. package/src/executors/mfe-dev-server/mfe-dev-server.impl.d.ts +11 -0
  17. package/src/executors/mfe-dev-server/mfe-dev-server.impl.js +86 -0
  18. package/src/executors/mfe-dev-server/mfe-dev-server.impl.js.map +1 -0
  19. package/src/executors/mfe-dev-server/schema.json +82 -0
  20. package/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ +1 -1
  21. package/src/generators/application/lib/find-free-port.d.ts +2 -0
  22. package/src/generators/application/lib/find-free-port.js +18 -0
  23. package/src/generators/application/lib/find-free-port.js.map +1 -0
  24. package/src/generators/application/lib/normalize-options.js +3 -1
  25. package/src/generators/application/lib/normalize-options.js.map +1 -1
  26. package/src/generators/application/schema.d.ts +2 -0
  27. package/src/generators/mfe-host/files/common/src/app/__fileName__.tsx__tmpl__ +29 -0
  28. package/src/generators/mfe-host/files/mfe/mfe.config.js__tmpl__ +6 -0
  29. package/src/generators/mfe-host/files/mfe/src/main.ts__tmpl__ +1 -0
  30. package/src/generators/mfe-host/files/mfe/src/remotes.d.ts__tmpl__ +4 -0
  31. package/src/generators/mfe-host/files/mfe/webpack.config.js__tmpl__ +6 -0
  32. package/src/generators/mfe-host/files/mfe/webpack.config.prod.js__tmpl__ +26 -0
  33. package/src/generators/mfe-host/lib/add-mfe-files.d.ts +5 -0
  34. package/src/generators/mfe-host/lib/add-mfe-files.js +17 -0
  35. package/src/generators/mfe-host/lib/add-mfe-files.js.map +1 -0
  36. package/src/generators/mfe-host/lib/update-mfe-e2e-project.d.ts +3 -0
  37. package/src/generators/mfe-host/lib/update-mfe-e2e-project.js +17 -0
  38. package/src/generators/mfe-host/lib/update-mfe-e2e-project.js.map +1 -0
  39. package/src/generators/mfe-host/mfe-host.d.ts +4 -0
  40. package/src/generators/mfe-host/mfe-host.js +46 -0
  41. package/src/generators/mfe-host/mfe-host.js.map +1 -0
  42. package/src/generators/mfe-host/schema.d.ts +28 -0
  43. package/src/generators/mfe-host/schema.json +155 -0
  44. package/src/generators/mfe-remote/files/mfe/mfe.config.js__tmpl__ +6 -0
  45. package/src/generators/mfe-remote/files/mfe/src/main.ts__tmpl__ +1 -0
  46. package/src/generators/mfe-remote/files/mfe/src/remote-entry.ts__tmpl__ +1 -0
  47. package/src/generators/mfe-remote/files/mfe/webpack.config.js__tmpl__ +6 -0
  48. package/src/generators/mfe-remote/files/mfe/webpack.config.prod.js__tmpl__ +1 -0
  49. package/src/generators/mfe-remote/lib/update-host-with-remote.d.ts +2 -0
  50. package/src/generators/mfe-remote/lib/update-host-with-remote.js +49 -0
  51. package/src/generators/mfe-remote/lib/update-host-with-remote.js.map +1 -0
  52. package/src/generators/mfe-remote/mfe-remote.d.ts +6 -0
  53. package/src/generators/mfe-remote/mfe-remote.js +38 -0
  54. package/src/generators/mfe-remote/mfe-remote.js.map +1 -0
  55. package/src/generators/mfe-remote/schema.d.ts +26 -0
  56. package/src/generators/mfe-remote/schema.json +159 -0
  57. package/src/generators/storybook-configuration/schema.d.ts +1 -0
  58. package/src/generators/storybook-configuration/schema.json +4 -0
  59. package/src/mfe/mfe-ast-utils.d.ts +8 -0
  60. package/src/mfe/mfe-ast-utils.js +96 -0
  61. package/src/mfe/mfe-ast-utils.js.map +1 -0
  62. package/src/mfe/webpack-utils.d.ts +17 -0
  63. package/src/mfe/webpack-utils.js +66 -0
  64. package/src/mfe/webpack-utils.js.map +1 -0
  65. package/src/mfe/with-module-federation.d.ts +14 -0
  66. package/src/mfe/with-module-federation.js +167 -0
  67. package/src/mfe/with-module-federation.js.map +1 -0
  68. package/src/rules/update-mfe-project.d.ts +6 -0
  69. package/src/rules/update-mfe-project.js +14 -0
  70. package/src/rules/update-mfe-project.js.map +1 -0
  71. package/src/utils/versions.js +1 -1
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mfeHostGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nrwl/devkit");
6
+ const application_1 = require("../application/application");
7
+ const normalize_options_1 = require("../application/lib/normalize-options");
8
+ const mfe_remote_1 = require("../mfe-remote/mfe-remote");
9
+ const update_mfe_project_1 = require("../../rules/update-mfe-project");
10
+ const add_mfe_files_1 = require("./lib/add-mfe-files");
11
+ const update_mfe_e2e_project_1 = require("./lib/update-mfe-e2e-project");
12
+ function mfeHostGenerator(host, schema) {
13
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
+ const options = (0, normalize_options_1.normalizeOptions)(host, schema);
15
+ const initTask = yield (0, application_1.default)(host, Object.assign(Object.assign({}, options), {
16
+ // The target use-case for MFE is loading remotes as child routes, thus always enable routing.
17
+ routing: true }));
18
+ const remotesWithPorts = [];
19
+ if (schema.remotes) {
20
+ let remotePort = options.devServerPort + 1;
21
+ for (const remote of schema.remotes) {
22
+ remotesWithPorts.push({ name: remote, port: remotePort });
23
+ yield (0, mfe_remote_1.mfeRemoteGenerator)(host, {
24
+ name: remote,
25
+ style: options.style,
26
+ skipFormat: options.skipFormat,
27
+ unitTestRunner: options.unitTestRunner,
28
+ e2eTestRunner: options.e2eTestRunner,
29
+ linter: options.linter,
30
+ devServerPort: remotePort,
31
+ });
32
+ remotePort++;
33
+ }
34
+ }
35
+ (0, add_mfe_files_1.addMfeFiles)(host, options, remotesWithPorts);
36
+ (0, update_mfe_project_1.updateMfeProject)(host, options);
37
+ (0, update_mfe_e2e_project_1.updateMfeE2eProject)(host, options);
38
+ if (!options.skipFormat) {
39
+ yield (0, devkit_1.formatFiles)(host);
40
+ }
41
+ return initTask;
42
+ });
43
+ }
44
+ exports.mfeHostGenerator = mfeHostGenerator;
45
+ exports.default = mfeHostGenerator;
46
+ //# sourceMappingURL=mfe-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-host.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/mfe-host/mfe-host.ts"],"names":[],"mappings":";;;;AAAA,yCAAiD;AAEjD,4DAA8D;AAC9D,4EAAwE;AACxE,yDAA8D;AAC9D,uEAAkE;AAClE,uDAAkD;AAClD,yEAAmE;AAGnE,SAAsB,gBAAgB,CAAC,IAAU,EAAE,MAAc;;QAC/D,MAAM,OAAO,GAAG,IAAA,oCAAgB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/C,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAoB,EAAC,IAAI,kCAC3C,OAAO;YACV,8FAA8F;YAC9F,OAAO,EAAE,IAAI,IACb,CAAC;QAEH,MAAM,gBAAgB,GAAqC,EAAE,CAAC;QAE9D,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,IAAI,UAAU,GAAG,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;YAC3C,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;gBACnC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;gBAC1D,MAAM,IAAA,+BAAkB,EAAC,IAAI,EAAE;oBAC7B,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,cAAc,EAAE,OAAO,CAAC,cAAc;oBACtC,aAAa,EAAE,OAAO,CAAC,aAAa;oBACpC,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,aAAa,EAAE,UAAU;iBAC1B,CAAC,CAAC;gBACH,UAAU,EAAE,CAAC;aACd;SACF;QAED,IAAA,2BAAW,EAAC,IAAI,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAC7C,IAAA,qCAAgB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,IAAA,4CAAmB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEnC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AArCD,4CAqCC;AAED,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { Linter } from '@nrwl/linter';
2
+ import { SupportedStyles } from '../../../typings';
3
+
4
+ export interface Schema {
5
+ name: string;
6
+ style: SupportedStyles;
7
+ skipFormat: boolean;
8
+ directory?: string;
9
+ tags?: string;
10
+ unitTestRunner: 'jest' | 'none';
11
+ e2eTestRunner: 'cypress' | 'none';
12
+ linter: Linter;
13
+ pascalCaseFiles?: boolean;
14
+ classComponent?: boolean;
15
+ skipWorkspaceJson?: boolean;
16
+ js?: boolean;
17
+ globalCss?: boolean;
18
+ strict?: boolean;
19
+ setParserOptionsProject?: boolean;
20
+ standaloneConfig?: boolean;
21
+ compiler?: 'babel' | 'swc';
22
+ devServerPort?: number;
23
+ remotes?: string[];
24
+ }
25
+
26
+ export interface NormalizedSchema extends Schema {
27
+ appProjectRoot: string;
28
+ }
@@ -0,0 +1,155 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "GeneratorReactMFEHost",
4
+ "cli": "nx",
5
+ "title": "Generate Module Federation Setup for React Host App",
6
+ "description": "Create Module Federation configuration files for given React Host Application.",
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "type": "string",
11
+ "description": "The name of the host application to generate the Module Federation configuration",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "What name would you like to use as the host application?",
17
+ "pattern": "^[a-zA-Z].*$"
18
+ },
19
+ "directory": {
20
+ "description": "The directory of the new application.",
21
+ "type": "string",
22
+ "alias": "dir"
23
+ },
24
+ "style": {
25
+ "description": "The file extension to be used for style files.",
26
+ "type": "string",
27
+ "default": "css",
28
+ "alias": "s",
29
+ "x-prompt": {
30
+ "message": "Which stylesheet format would you like to use?",
31
+ "type": "list",
32
+ "items": [
33
+ {
34
+ "value": "css",
35
+ "label": "CSS"
36
+ },
37
+ {
38
+ "value": "scss",
39
+ "label": "SASS(.scss) [ http://sass-lang.com ]"
40
+ },
41
+ {
42
+ "value": "styl",
43
+ "label": "Stylus(.styl) [ http://stylus-lang.com ]"
44
+ },
45
+ {
46
+ "value": "less",
47
+ "label": "LESS [ http://lesscss.org ]"
48
+ },
49
+ {
50
+ "value": "styled-components",
51
+ "label": "styled-components [ https://styled-components.com ]"
52
+ },
53
+ {
54
+ "value": "@emotion/styled",
55
+ "label": "emotion [ https://emotion.sh ]"
56
+ },
57
+ {
58
+ "value": "styled-jsx",
59
+ "label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
60
+ },
61
+ {
62
+ "value": "none",
63
+ "label": "None"
64
+ }
65
+ ]
66
+ }
67
+ },
68
+ "linter": {
69
+ "description": "The tool to use for running lint checks.",
70
+ "type": "string",
71
+ "enum": ["eslint", "tslint"],
72
+ "default": "eslint"
73
+ },
74
+ "skipFormat": {
75
+ "description": "Skip formatting files.",
76
+ "type": "boolean",
77
+ "default": false
78
+ },
79
+ "skipWorkspaceJson": {
80
+ "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).",
81
+ "type": "boolean",
82
+ "default": false
83
+ },
84
+ "unitTestRunner": {
85
+ "type": "string",
86
+ "enum": ["jest", "none"],
87
+ "description": "Test runner to use for unit tests.",
88
+ "default": "jest"
89
+ },
90
+ "e2eTestRunner": {
91
+ "type": "string",
92
+ "enum": ["cypress", "none"],
93
+ "description": "Test runner to use for end to end (e2e) tests.",
94
+ "default": "cypress"
95
+ },
96
+ "tags": {
97
+ "type": "string",
98
+ "description": "Add tags to the application (used for linting).",
99
+ "alias": "t"
100
+ },
101
+ "pascalCaseFiles": {
102
+ "type": "boolean",
103
+ "description": "Use pascal case component file name (e.g. App.tsx).",
104
+ "alias": "P",
105
+ "default": false
106
+ },
107
+ "classComponent": {
108
+ "type": "boolean",
109
+ "description": "Use class components instead of functional component.",
110
+ "alias": "C",
111
+ "default": false
112
+ },
113
+ "js": {
114
+ "type": "boolean",
115
+ "description": "Generate JavaScript files rather than TypeScript files.",
116
+ "default": false
117
+ },
118
+ "globalCss": {
119
+ "type": "boolean",
120
+ "description": "Default is false. When true, the component is generated with *.css/*.scss instead of *.module.css/*.module.scss",
121
+ "default": false
122
+ },
123
+ "strict": {
124
+ "type": "boolean",
125
+ "description": "Creates an application with strict mode and strict type checking",
126
+ "default": true
127
+ },
128
+ "setParserOptionsProject": {
129
+ "type": "boolean",
130
+ "description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
131
+ "default": false
132
+ },
133
+ "standaloneConfig": {
134
+ "description": "Split the project configuration into <projectRoot>/project.json rather than including it inside workspace.json",
135
+ "type": "boolean"
136
+ },
137
+ "compiler": {
138
+ "type": "string",
139
+ "description": "The compiler to use",
140
+ "enum": ["babel", "swc"],
141
+ "default": "babel"
142
+ },
143
+ "remotes": {
144
+ "type": "array",
145
+ "description": "A list of remote application names that the host application should consume.",
146
+ "default": []
147
+ },
148
+ "devServerPort": {
149
+ "type": "number",
150
+ "description": "The port for the dev server of the remote app."
151
+ }
152
+ },
153
+ "required": ["name"],
154
+ "additionalProperties": false
155
+ }
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ name: '<%= projectName %>',
3
+ exposes: {
4
+ './Module': './src/remote-entry.ts',
5
+ },
6
+ };
@@ -0,0 +1 @@
1
+ import('./bootstrap');
@@ -0,0 +1 @@
1
+ export { default } from './app/app';
@@ -0,0 +1,6 @@
1
+ const withModuleFederation = require('@nrwl/react/module-federation');
2
+ const mfeConfig = require('./mfe.config');
3
+
4
+ module.exports = withModuleFederation({
5
+ ...mfeConfig,
6
+ });
@@ -0,0 +1 @@
1
+ module.exports = require('./webpack.config');
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nrwl/devkit';
2
+ export declare function updateHostWithRemote(host: Tree, hostName: string, remoteName: string): void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateHostWithRemote = void 0;
4
+ const devkit_1 = require("@nrwl/devkit");
5
+ const mfe_ast_utils_1 = require("../../../mfe/mfe-ast-utils");
6
+ const ts = require("typescript");
7
+ function updateHostWithRemote(host, hostName, remoteName) {
8
+ const hostConfig = (0, devkit_1.readProjectConfiguration)(host, hostName);
9
+ const mfeConfigPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'mfe.config.js');
10
+ const remoteDefsPath = (0, devkit_1.joinPathFragments)(hostConfig.sourceRoot, 'remotes.d.ts');
11
+ const appComponentPath = findAppComponentPath(host, hostConfig.sourceRoot);
12
+ if (host.exists(mfeConfigPath)) {
13
+ // find the host project path
14
+ // Update remotes inside ${host_path}/src/remotes.d.ts
15
+ let sourceCode = host.read(mfeConfigPath).toString();
16
+ const source = ts.createSourceFile(mfeConfigPath, sourceCode, ts.ScriptTarget.Latest, true);
17
+ host.write(mfeConfigPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, mfe_ast_utils_1.addRemoteToMfeConfig)(source, remoteName)));
18
+ }
19
+ else {
20
+ // TODO(jack): Point to the nx.dev guide when ready.
21
+ devkit_1.logger.warn(`Could not find MFE configuration at ${mfeConfigPath}. Did you generate this project with "@nrwl/react:mfe-host"?`);
22
+ }
23
+ if (host.exists(remoteDefsPath)) {
24
+ let sourceCode = host.read(remoteDefsPath).toString();
25
+ const source = ts.createSourceFile(mfeConfigPath, sourceCode, ts.ScriptTarget.Latest, true);
26
+ host.write(remoteDefsPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, mfe_ast_utils_1.addRemoteDefinition)(source, remoteName)));
27
+ }
28
+ else {
29
+ devkit_1.logger.warn(`Could not find remote definitions at ${remoteDefsPath}. Did you generate this project with "@nrwl/react:mfe-host"?`);
30
+ }
31
+ if (host.exists(appComponentPath)) {
32
+ let sourceCode = host.read(appComponentPath).toString();
33
+ const source = ts.createSourceFile(mfeConfigPath, sourceCode, ts.ScriptTarget.Latest, true);
34
+ host.write(appComponentPath, (0, devkit_1.applyChangesToString)(sourceCode, (0, mfe_ast_utils_1.addRemoteRoute)(source, (0, devkit_1.names)(remoteName))));
35
+ }
36
+ else {
37
+ devkit_1.logger.warn(`Could not find app component at ${appComponentPath}. Did you generate this project with "@nrwl/react:mfe-host"?`);
38
+ }
39
+ }
40
+ exports.updateHostWithRemote = updateHostWithRemote;
41
+ function findAppComponentPath(host, sourceRoot) {
42
+ const locations = ['app/app.tsx', 'app/App.tsx', 'app.tsx', 'App.tsx'];
43
+ for (const loc of locations) {
44
+ if (host.exists((0, devkit_1.joinPathFragments)(sourceRoot, loc))) {
45
+ return (0, devkit_1.joinPathFragments)(sourceRoot, loc);
46
+ }
47
+ }
48
+ }
49
+ //# sourceMappingURL=update-host-with-remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-host-with-remote.js","sourceRoot":"","sources":["../../../../../../../packages/react/src/generators/mfe-remote/lib/update-host-with-remote.ts"],"names":[],"mappings":";;;AAAA,yCAOsB;AACtB,8DAIoC;AACpC,iCAAiC;AAEjC,SAAgB,oBAAoB,CAClC,IAAU,EACV,QAAgB,EAChB,UAAkB;IAElB,MAAM,UAAU,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5D,MAAM,aAAa,GAA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ACH;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;QACjC,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC;QACxD,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAChC,aAAa,EACb,UAAU,EACV,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACL,CAAC;QACF,IAAI,CAAC,KAAK,CACR,gBAAgB,EAChB,IAAA,6BAAoB,EAClB,UAAU,EACV,IAAA,8BAAc,EAAC,MAAM,EAAE,IAAA,cAAK,EAAC,UAAU,CAAC,CAAC,CAC1C,CACF,CAAC;KACH;SAAM;QACL,eAAM,CAAC,IAAI,CACT,mCAAmC,gBAAgB,8DAA8D,CAClH,CAAC;KACH;AACH,CAAC;AAxED,oDAwEC;AAED,SAAS,oBAAoB,CAAC,IAAU,EAAE,UAAkB;IAC1D,MAAM,SAAS,GAAG,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACvE,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE;QAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,UAAU,EAAE,GAAG,CAAC,CAAC,EAAE;YACnD,OAAO,IAAA,0BAAiB,EAAC,UAAU,EAAE,GAAG,CAAC,CAAC;SAC3C;KACF;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Tree } from '@nrwl/devkit';
2
+ import { NormalizedSchema } from '../application/schema';
3
+ import { Schema } from './schema';
4
+ export declare function addMfeFiles(host: Tree, options: NormalizedSchema): void;
5
+ export declare function mfeRemoteGenerator(host: Tree, schema: Schema): Promise<import("@nrwl/devkit").GeneratorCallback>;
6
+ export default mfeRemoteGenerator;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mfeRemoteGenerator = exports.addMfeFiles = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = require("path");
6
+ const devkit_1 = require("@nrwl/devkit");
7
+ const run_tasks_in_serial_1 = require("@nrwl/workspace/src/utilities/run-tasks-in-serial");
8
+ const normalize_options_1 = require("../application/lib/normalize-options");
9
+ const application_1 = require("../application/application");
10
+ const update_host_with_remote_1 = require("./lib/update-host-with-remote");
11
+ const update_mfe_project_1 = require("../../rules/update-mfe-project");
12
+ function addMfeFiles(host, options) {
13
+ const templateVariables = Object.assign(Object.assign(Object.assign({}, (0, devkit_1.names)(options.name)), options), { tmpl: '' });
14
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `./files/mfe`), options.appProjectRoot, templateVariables);
15
+ }
16
+ exports.addMfeFiles = addMfeFiles;
17
+ function mfeRemoteGenerator(host, schema) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ const options = (0, normalize_options_1.normalizeOptions)(host, schema);
20
+ const initApp = yield (0, application_1.default)(host, options);
21
+ if (schema.host) {
22
+ (0, update_host_with_remote_1.updateHostWithRemote)(host, schema.host, options.name);
23
+ }
24
+ // Module federation requires bootstrap code to be dynamically imported.
25
+ // Renaming original entry file so we can use `import(./bootstrap)` in
26
+ // new entry file.
27
+ host.rename((0, path_1.join)(options.appProjectRoot, 'src/main.tsx'), (0, path_1.join)(options.appProjectRoot, 'src/bootstrap.tsx'));
28
+ addMfeFiles(host, options);
29
+ (0, update_mfe_project_1.updateMfeProject)(host, options);
30
+ if (!options.skipFormat) {
31
+ yield (0, devkit_1.formatFiles)(host);
32
+ }
33
+ return (0, run_tasks_in_serial_1.runTasksInSerial)(initApp);
34
+ });
35
+ }
36
+ exports.mfeRemoteGenerator = mfeRemoteGenerator;
37
+ exports.default = mfeRemoteGenerator;
38
+ //# sourceMappingURL=mfe-remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfe-remote.js","sourceRoot":"","sources":["../../../../../../packages/react/src/generators/mfe-remote/mfe-remote.ts"],"names":[],"m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;CAAA;AAxBD,gDAwBC;AAED,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Linter } from '@nrwl/linter';
2
+
3
+ import { SupportedStyles } from '../../../typings';
4
+
5
+ export interface Schema {
6
+ name: string;
7
+ style: SupportedStyles;
8
+ skipFormat: boolean;
9
+ directory?: string;
10
+ tags?: string;
11
+ unitTestRunner: 'jest' | 'none';
12
+ e2eTestRunner: 'cypress' | 'none';
13
+ linter: Linter;
14
+ pascalCaseFiles?: boolean;
15
+ classComponent?: boolean;
16
+ routing?: boolean;
17
+ skipWorkspaceJson?: boolean;
18
+ js?: boolean;
19
+ globalCss?: boolean;
20
+ strict?: boolean;
21
+ setParserOptionsProject?: boolean;
22
+ standaloneConfig?: boolean;
23
+ compiler?: 'babel' | 'swc';
24
+ host?: string;
25
+ devServerPort?: number;
26
+ }
@@ -0,0 +1,159 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "GeneratorReactMFERemote",
4
+ "cli": "nx",
5
+ "title": "Generate Module Federation Setup for React Remote App",
6
+ "description": "Create Module Federation configuration files for given React Remote Application.",
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "type": "string",
11
+ "description": "The name of the remote application to generate the Module Federation configuration",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "What name would you like to use as the remote application?",
17
+ "pattern": "^[a-zA-Z].*$"
18
+ },
19
+ "directory": {
20
+ "description": "The directory of the new application.",
21
+ "type": "string",
22
+ "alias": "dir"
23
+ },
24
+ "style": {
25
+ "description": "The file extension to be used for style files.",
26
+ "type": "string",
27
+ "default": "css",
28
+ "alias": "s",
29
+ "x-prompt": {
30
+ "message": "Which stylesheet format would you like to use?",
31
+ "type": "list",
32
+ "items": [
33
+ {
34
+ "value": "css",
35
+ "label": "CSS"
36
+ },
37
+ {
38
+ "value": "scss",
39
+ "label": "SASS(.scss) [ http://sass-lang.com ]"
40
+ },
41
+ {
42
+ "value": "styl",
43
+ "label": "Stylus(.styl) [ http://stylus-lang.com ]"
44
+ },
45
+ {
46
+ "value": "less",
47
+ "label": "LESS [ http://lesscss.org ]"
48
+ },
49
+ {
50
+ "value": "styled-components",
51
+ "label": "styled-components [ https://styled-components.com ]"
52
+ },
53
+ {
54
+ "value": "@emotion/styled",
55
+ "label": "emotion [ https://emotion.sh ]"
56
+ },
57
+ {
58
+ "value": "styled-jsx",
59
+ "label": "styled-jsx [ https://www.npmjs.com/package/styled-jsx ]"
60
+ },
61
+ {
62
+ "value": "none",
63
+ "label": "None"
64
+ }
65
+ ]
66
+ }
67
+ },
68
+ "linter": {
69
+ "description": "The tool to use for running lint checks.",
70
+ "type": "string",
71
+ "enum": ["eslint", "tslint"],
72
+ "default": "eslint"
73
+ },
74
+ "routing": {
75
+ "type": "boolean",
76
+ "description": "Generate application with routes.",
77
+ "default": false
78
+ },
79
+ "skipFormat": {
80
+ "description": "Skip formatting files.",
81
+ "type": "boolean",
82
+ "default": false
83
+ },
84
+ "skipWorkspaceJson": {
85
+ "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).",
86
+ "type": "boolean",
87
+ "default": false
88
+ },
89
+ "unitTestRunner": {
90
+ "type": "string",
91
+ "enum": ["jest", "none"],
92
+ "description": "Test runner to use for unit tests.",
93
+ "default": "jest"
94
+ },
95
+ "e2eTestRunner": {
96
+ "type": "string",
97
+ "enum": ["cypress", "none"],
98
+ "description": "Test runner to use for end to end (e2e) tests.",
99
+ "default": "cypress"
100
+ },
101
+ "tags": {
102
+ "type": "string",
103
+ "description": "Add tags to the application (used for linting).",
104
+ "alias": "t"
105
+ },
106
+ "pascalCaseFiles": {
107
+ "type": "boolean",
108
+ "description": "Use pascal case component file name (e.g. App.tsx).",
109
+ "alias": "P",
110
+ "default": false
111
+ },
112
+ "classComponent": {
113
+ "type": "boolean",
114
+ "description": "Use class components instead of functional component.",
115
+ "alias": "C",
116
+ "default": false
117
+ },
118
+ "js": {
119
+ "type": "boolean",
120
+ "description": "Generate JavaScript files rather than TypeScript files.",
121
+ "default": false
122
+ },
123
+ "globalCss": {
124
+ "type": "boolean",
125
+ "description": "Default is false. When true, the component is generated with *.css/*.scss instead of *.module.css/*.module.scss.",
126
+ "default": false
127
+ },
128
+ "strict": {
129
+ "type": "boolean",
130
+ "description": "Creates an application with strict mode and strict type checking.",
131
+ "default": true
132
+ },
133
+ "setParserOptionsProject": {
134
+ "type": "boolean",
135
+ "description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
136
+ "default": false
137
+ },
138
+ "standaloneConfig": {
139
+ "description": "Split the project configuration into <projectRoot>/project.json rather than including it inside workspace.json",
140
+ "type": "boolean"
141
+ },
142
+ "compiler": {
143
+ "type": "string",
144
+ "description": "The compiler to use.",
145
+ "enum": ["babel", "swc"],
146
+ "default": "babel"
147
+ },
148
+ "host": {
149
+ "type": "string",
150
+ "description": "The host / shell application for this remote."
151
+ },
152
+ "devServerPort": {
153
+ "type": "number",
154
+ "description": "The port for the dev server of the remote app."
155
+ }
156
+ },
157
+ "required": ["name"],
158
+ "additionalProperties": false
159
+ }
@@ -9,4 +9,5 @@ export interface StorybookConfigureSchema {
9
9
  linter?: Linter;
10
10
  cypressDirectory?: string;
11
11
  standaloneConfig?: boolean;
12
+ projectBuildConfig?: string;
12
13
  }
@@ -47,6 +47,10 @@
47
47
  "enum": ["eslint", "tslint"],
48
48
  "default": "eslint"
49
49
  },
50
+ "projectBuildConfig": {
51
+ "description": "Provide a custom projectBuildConfig for the Angular executor. If left blank, Nx will use the default.",
52
+ "type": "string"
53
+ },
50
54
  "standaloneConfig": {
51
55
  "description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
52
56
  "type": "boolean"
@@ -0,0 +1,8 @@
1
+ import * as ts from 'typescript';
2
+ import { StringChange } from '@nrwl/devkit';
3
+ export declare function addRemoteToMfeConfig(source: ts.SourceFile, app: string): StringChange[];
4
+ export declare function addRemoteDefinition(source: ts.SourceFile, app: string): StringChange[];
5
+ export declare function addRemoteRoute(source: ts.SourceFile, names: {
6
+ fileName: string;
7
+ className: string;
8
+ }): StringChange[];