@nx/react 18.1.0-beta.0 → 18.1.0-beta.10

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 (56) hide show
  1. package/migrations.json +6 -0
  2. package/package.json +6 -6
  3. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +15 -7
  4. package/src/executors/module-federation-dev-server/schema.json +1 -1
  5. package/src/generators/application/application.js +12 -4
  6. package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
  7. package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +1 -1
  8. package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +33 -0
  9. package/src/generators/application/files/style-tailwind/src/styles.css +1 -0
  10. package/src/generators/application/lib/add-e2e.js +2 -2
  11. package/src/generators/application/lib/add-project.d.ts +0 -1
  12. package/src/generators/application/lib/add-project.js +5 -10
  13. package/src/generators/application/lib/add-routing.d.ts +1 -1
  14. package/src/generators/application/lib/add-routing.js +4 -8
  15. package/src/generators/application/lib/create-application-files.js +9 -4
  16. package/src/generators/application/lib/normalize-options.js +5 -2
  17. package/src/generators/application/lib/update-jest-config.js +2 -1
  18. package/src/generators/application/schema.json +4 -0
  19. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -1
  20. package/src/generators/federate-module/schema.json +2 -1
  21. package/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +33 -0
  22. package/src/generators/host/host.js +5 -1
  23. package/src/generators/host/lib/add-module-federation-files.d.ts +1 -1
  24. package/src/generators/host/lib/add-module-federation-files.js +3 -2
  25. package/src/generators/host/lib/update-module-federation-e2e-project.js +7 -5
  26. package/src/generators/host/schema.json +7 -2
  27. package/src/generators/library/lib/add-rollup-build-target.js +1 -1
  28. package/src/generators/library/lib/normalize-options.js +4 -1
  29. package/src/generators/library/lib/update-app-routes.js +1 -1
  30. package/src/generators/library/library.js +4 -3
  31. package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -1
  32. package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
  33. package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
  34. package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +1 -1
  35. package/src/generators/remote/lib/setup-tspath-for-remote.js +2 -1
  36. package/src/generators/remote/lib/update-host-with-remote.js +10 -1
  37. package/src/generators/remote/remote.js +8 -2
  38. package/src/generators/remote/schema.json +7 -2
  39. package/src/generators/storybook-configuration/configuration.js +4 -1
  40. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +2 -0
  41. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
  42. package/src/rules/update-module-federation-project.d.ts +1 -0
  43. package/src/rules/update-module-federation-project.js +5 -4
  44. package/src/utils/add-mf-env-to-inputs.js +4 -1
  45. package/src/utils/assertion.js +1 -0
  46. package/src/utils/maybe-js.d.ts +3 -0
  47. package/typings/style.d.ts +1 -0
  48. package/src/generators/library/lib/maybe-js.d.ts +0 -2
  49. /package/src/generators/host/files/{module-federation/src/main.ts__tmpl__ → common/src/main.js__tmpl__} +0 -0
  50. /package/src/generators/host/files/{common → common-ts}/src/app/__fileName__.tsx__tmpl__ +0 -0
  51. /package/src/generators/host/files/{module-federation-ts → common-ts}/src/main.ts__tmpl__ +0 -0
  52. /package/src/generators/remote/files/{module-federation/src/main.ts__tmpl__ → common/src/main.js__tmpl__} +0 -0
  53. /package/src/generators/remote/files/{module-federation/src/remote-entry.ts__tmpl__ → common/src/remote-entry.js__tmpl__} +0 -0
  54. /package/src/generators/remote/files/{module-federation-ts → common-ts}/src/main.ts__tmpl__ +0 -0
  55. /package/src/generators/remote/files/{module-federation-ts → common-ts}/src/remote-entry.ts__tmpl__ +0 -0
  56. /package/src/{generators/library/lib → utils}/maybe-js.js +0 -0
package/migrations.json CHANGED
@@ -53,6 +53,12 @@
53
53
  "version": "18.0.0-beta.0",
54
54
  "description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/webpack:webpack' is used for Module Federation.",
55
55
  "factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
56
+ },
57
+ "fix-target-defaults-for-webpack": {
58
+ "cli": "nx",
59
+ "version": "18.1.1-beta.0",
60
+ "description": "Ensure targetDefaults inputs for task hashing when '@nx/webpack:webpack' is used are correct for Module Federation.",
61
+ "factory": "./src/migrations/update-18-1-1/fix-target-defaults-inputs"
56
62
  }
57
63
  },
58
64
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "18.1.0-beta.0",
3
+ "version": "18.1.0-beta.10",
4
4
  "private": false,
5
5
  "description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -36,11 +36,11 @@
36
36
  "chalk": "^4.1.0",
37
37
  "minimatch": "9.0.3",
38
38
  "tslib": "^2.3.0",
39
- "@nx/devkit": "18.1.0-beta.0",
40
- "@nx/js": "18.1.0-beta.0",
41
- "@nx/eslint": "18.1.0-beta.0",
42
- "@nx/web": "18.1.0-beta.0",
43
- "@nrwl/react": "18.1.0-beta.0"
39
+ "@nx/devkit": "18.1.0-beta.10",
40
+ "@nx/js": "18.1.0-beta.10",
41
+ "@nx/eslint": "18.1.0-beta.10",
42
+ "@nx/web": "18.1.0-beta.10",
43
+ "@nrwl/react": "18.1.0-beta.10"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"
@@ -55,7 +55,7 @@ function startStaticRemotesFileServer(staticRemotesConfig, context, options) {
55
55
  }, context);
56
56
  return staticRemotesIter;
57
57
  }
58
- async function startDevRemotes(remotes, context) {
58
+ async function startDevRemotes(remotes, context, options) {
59
59
  const devRemoteIters = [];
60
60
  for (const app of remotes.devRemotes) {
61
61
  const remoteProjectServeTarget = context.projectGraph.nodes[app].data.targets['serve'];
@@ -66,6 +66,10 @@ async function startDevRemotes(remotes, context) {
66
66
  configuration: context.configurationName,
67
67
  }, {
68
68
  watch: true,
69
+ ...(options.host ? { host: options.host } : {}),
70
+ ...(options.ssl ? { ssl: options.ssl } : {}),
71
+ ...(options.sslCert ? { sslCert: options.sslCert } : {}),
72
+ ...(options.sslKey ? { sslKey: options.sslKey } : {}),
69
73
  ...(isUsingModuleFederationDevServerExecutor
70
74
  ? { isInitialHost: false }
71
75
  : {}),
@@ -167,7 +171,7 @@ async function* moduleFederationDevServer(options, context) {
167
171
  }
168
172
  const staticRemotesConfig = parseStaticRemotesConfig(remotes.staticRemotes, context);
169
173
  await buildStaticRemotes(staticRemotesConfig, nxBin, context, options);
170
- const devRemoteIters = await startDevRemotes(remotes, context);
174
+ const devRemoteIters = await startDevRemotes(remotes, context, options);
171
175
  const staticRemotesIter = remotes.staticRemotes.length > 0
172
176
  ? startStaticRemotesFileServer(staticRemotesConfig, context, options)
173
177
  : undefined;
@@ -181,19 +185,23 @@ async function* moduleFederationDevServer(options, context) {
181
185
  return;
182
186
  }
183
187
  try {
188
+ const host = options.host ?? 'localhost';
189
+ const baseUrl = `http${options.ssl ? 's' : ''}://${host}:${options.port}`;
184
190
  const portsToWaitFor = staticRemotesIter
185
191
  ? [options.staticRemotesPort, ...remotes.remotePorts]
186
192
  : [...remotes.remotePorts];
187
193
  await Promise.all(portsToWaitFor.map((port) => (0, wait_for_port_open_1.waitForPortOpen)(port, {
188
194
  retries: 480,
189
195
  retryDelay: 2500,
190
- host: 'localhost',
196
+ host: host,
191
197
  })));
192
- devkit_1.logger.info(`NX All remotes started, server ready at http://localhost:${options.port}`);
193
- next({ success: true, baseUrl: `http://localhost:${options.port}` });
198
+ devkit_1.logger.info(`NX All remotes started, server ready at ${baseUrl}`);
199
+ next({ success: true, baseUrl: baseUrl });
194
200
  }
195
- catch {
196
- throw new Error(`Timed out waiting for remote to start. Check above for any errors.`);
201
+ catch (err) {
202
+ throw new Error(`Failed to start remotes. Check above for any errors.`, {
203
+ cause: err,
204
+ });
197
205
  }
198
206
  finally {
199
207
  done();
@@ -19,7 +19,7 @@
19
19
  "items": {
20
20
  "type": "string"
21
21
  },
22
- "description": "List of remote applications to not automatically serve, either statically or in development mode.",
22
+ "description": "List of remote applications to not automatically serve, either statically or in development mode. This will not remove the remotes from the `module-federation.config` file, and therefore the application may still try to fetch these remotes.\nThis option is useful for when the `host` application is using a `remote` that does not live in the same workspace as the `host`.",
23
23
  "x-priority": "important"
24
24
  },
25
25
  "buildTarget": {
@@ -14,6 +14,7 @@ const devkit_1 = require("@nx/devkit");
14
14
  const init_1 = require("../init/init");
15
15
  const eslint_1 = require("@nx/eslint");
16
16
  const versions_1 = require("../../utils/versions");
17
+ const maybe_js_1 = require("../../utils/maybe-js");
17
18
  const install_common_dependencies_1 = require("./lib/install-common-dependencies");
18
19
  const create_ts_config_1 = require("../../utils/create-ts-config");
19
20
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
@@ -23,6 +24,7 @@ const add_e2e_1 = require("./lib/add-e2e");
23
24
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
24
25
  const js_1 = require("@nx/js");
25
26
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
27
+ const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
26
28
  async function addLinting(host, options) {
27
29
  const tasks = [];
28
30
  if (options.linter === eslint_1.Linter.EsLint) {
@@ -91,6 +93,12 @@ async function applicationGeneratorInternal(host, schema) {
91
93
  }
92
94
  (0, create_application_files_1.createApplicationFiles)(host, options);
93
95
  (0, add_project_1.addProject)(host, options);
96
+ if (options.style === 'tailwind') {
97
+ const twTask = await (0, setup_tailwind_1.setupTailwindGenerator)(host, {
98
+ project: options.projectName,
99
+ });
100
+ tasks.push(twTask);
101
+ }
94
102
  if (options.bundler === 'vite') {
95
103
  const { createOrEditViteConfig, viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
96
104
  // We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
@@ -131,11 +139,11 @@ async function applicationGeneratorInternal(host, schema) {
131
139
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
132
140
  const rspackTask = await configurationGenerator(host, {
133
141
  project: options.projectName,
134
- main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, add_project_1.maybeJs)(options, `src/main.tsx`)),
142
+ main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
135
143
  tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
136
144
  target: 'web',
137
145
  newProject: true,
138
- uiFramework: 'react',
146
+ framework: 'react',
139
147
  });
140
148
  tasks.push(rspackTask);
141
149
  }
@@ -193,8 +201,8 @@ async function applicationGeneratorInternal(host, schema) {
193
201
  devkit_1.logger.warn(`${chalk.bold('styled-jsx')} is not supported by ${chalk.bold('Rspack')}. We've added ${chalk.bold('babel-loader')} to your project, but using babel will slow down your build.`);
194
202
  tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
195
203
  host.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
196
- const { composePlugins, withNx, withWeb } = require('@nx/rspack');
197
- module.exports = composePlugins(withNx(), withWeb(), (config) => {
204
+ const { composePlugins, withNx, withReact } = require('@nx/rspack');
205
+ module.exports = composePlugins(withNx(), withReact(), (config) => {
198
206
  config.module.rules.push({
199
207
  test: /\\.[jt]sx$/i,
200
208
  use: [
@@ -7,7 +7,7 @@
7
7
 
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1" />
9
9
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
10
- <% if (!styledModule && style !== 'none') { %><link rel="stylesheet" href="/src/styles.<%= style %>" /><% } %>
10
+ <% if (!styledModule && style !== 'none') { %><link rel="stylesheet" href="/src/styles.<%= style === 'tailwind' ? 'css' : style %>" /><% } %>
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
@@ -735,7 +735,7 @@ export function NxWelcome({ title }: { title: string }) {
735
735
  You can activate distributed tasks executions and caching by
736
736
  running:
737
737
  </p>
738
- <pre>nx connect-to-nx-cloud</pre>
738
+ <pre>nx connect</pre>
739
739
  <a
740
740
  href="https://nx.app/?utm_source=nx-project"
741
741
  target="_blank"
@@ -0,0 +1,33 @@
1
+ <% if (classComponent) { %>
2
+ import { Component } from 'react';
3
+ <% } if (!minimal) { %>
4
+ import NxWelcome from "./nx-welcome";
5
+ <% } %>
6
+
7
+ <% if (classComponent) { %>
8
+ export class App extends Component {
9
+ render() {
10
+ <% } else { %>
11
+ export function App() {
12
+ <% } %>
13
+ return (
14
+ <div>
15
+ <% if (!minimal) { %>
16
+ <NxWelcome title="<%= projectName %>"/>
17
+ <% } else { %>
18
+ <h1>
19
+ <span> Hello there, </span>
20
+ Welcome <%= projectName %> 👋
21
+ </h1>
22
+ <% } %>
23
+ </div>);
24
+ <% if (classComponent) { %>
25
+ }
26
+ }
27
+ <% } else { %>
28
+ }
29
+ <% } %>
30
+
31
+ export default App;
32
+
33
+ <% if (inSourceTests === true) { %> <%- inSourceVitestTests %> <% } %>
@@ -0,0 +1 @@
1
+ /* You can add global styles to this file, and also import other style files */
@@ -34,7 +34,7 @@ async function addE2e(tree, options) {
34
34
  bundler: options.bundler === 'rspack' ? 'webpack' : options.bundler,
35
35
  skipFormat: true,
36
36
  devServerTarget: `${options.projectName}:serve`,
37
- baseUrl: 'http://localhost:4200',
37
+ baseUrl: `http://localhost:${options.devServerPort ?? 4200}`,
38
38
  jsx: true,
39
39
  rootProject: options.rootProject,
40
40
  webServerCommands: hasNxBuildPlugin
@@ -66,7 +66,7 @@ async function addE2e(tree, options) {
66
66
  linter: options.linter,
67
67
  setParserOptionsProject: options.setParserOptionsProject,
68
68
  webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
69
- webServerAddress: 'http://localhost:4200',
69
+ webServerAddress: `http://localhost:${options.devServerPort ?? 4200}`,
70
70
  rootProject: options.rootProject,
71
71
  addPlugin: options.addPlugin,
72
72
  });
@@ -1,4 +1,3 @@
1
1
  import { NormalizedSchema } from '../schema';
2
2
  import { Tree } from '@nx/devkit';
3
3
  export declare function addProject(host: Tree, options: NormalizedSchema): void;
4
- export declare function maybeJs(options: NormalizedSchema, path: string): string;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.maybeJs = exports.addProject = void 0;
3
+ exports.addProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
6
+ const maybe_js_1 = require("../../../utils/maybe-js");
6
7
  function addProject(host, options) {
7
8
  const project = {
8
9
  root: options.appProjectRoot,
@@ -24,12 +25,6 @@ function addProject(host, options) {
24
25
  });
25
26
  }
26
27
  exports.addProject = addProject;
27
- function maybeJs(options, path) {
28
- return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
29
- ? path.replace(/\.tsx?$/, '.js')
30
- : path;
31
- }
32
- exports.maybeJs = maybeJs;
33
28
  function createBuildTarget(options) {
34
29
  return {
35
30
  executor: '@nx/webpack:webpack',
@@ -42,7 +37,7 @@ function createBuildTarget(options) {
42
37
  : options.projectName),
43
38
  index: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/index.html'),
44
39
  baseHref: '/',
45
- main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/main.tsx`)),
40
+ main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/main.tsx`)),
46
41
  tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
47
42
  assets: [
48
43
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/favicon.ico'),
@@ -66,8 +61,8 @@ function createBuildTarget(options) {
66
61
  production: {
67
62
  fileReplacements: [
68
63
  {
69
- replace: (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/environments/environment.ts`)),
70
- with: (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/environments/environment.prod.ts`)),
64
+ replace: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/environments/environment.ts`)),
65
+ with: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/environments/environment.prod.ts`)),
71
66
  },
72
67
  ],
73
68
  optimization: true,
@@ -1,3 +1,3 @@
1
- import { NormalizedSchema } from '../schema';
2
1
  import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from '../schema';
3
3
  export declare function addRouting(host: Tree, options: NormalizedSchema): import("@nx/devkit").GeneratorCallback;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addRouting = void 0;
4
- const ast_utils_1 = require("../../../utils/ast-utils");
5
- const versions_1 = require("../../../utils/versions");
6
4
  const devkit_1 = require("@nx/devkit");
7
5
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
6
+ const ast_utils_1 = require("../../../utils/ast-utils");
7
+ const versions_1 = require("../../../utils/versions");
8
+ const maybe_js_1 = require("../../../utils/maybe-js");
8
9
  let tsModule;
9
10
  function addRouting(host, options) {
10
11
  if (!options.routing) {
@@ -13,7 +14,7 @@ function addRouting(host, options) {
13
14
  if (!tsModule) {
14
15
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
15
16
  }
16
- const appPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, maybeJs(options, `src/app/${options.fileName}.tsx`));
17
+ const appPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, `src/app/${options.fileName}.tsx`));
17
18
  const appFileContent = host.read(appPath, 'utf-8');
18
19
  const appSource = tsModule.createSourceFile(appPath, appFileContent, tsModule.ScriptTarget.Latest, true);
19
20
  const changes = (0, devkit_1.applyChangesToString)(appFileContent, (0, ast_utils_1.addInitialRoutes)(appPath, appSource));
@@ -24,8 +25,3 @@ function addRouting(host, options) {
24
25
  return () => { };
25
26
  }
26
27
  exports.addRouting = addRouting;
27
- function maybeJs(options, path) {
28
- return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
29
- ? path.replace(/\.tsx?$/, '.js')
30
- : path;
31
- }
@@ -6,9 +6,9 @@ const js_1 = require("@nx/js");
6
6
  const path_1 = require("path");
7
7
  const create_ts_config_1 = require("../../../utils/create-ts-config");
8
8
  const get_in_source_vitest_tests_template_1 = require("../../../utils/get-in-source-vitest-tests-template");
9
- const get_app_tests_1 = require("./get-app-tests");
10
- const add_project_1 = require("./add-project");
9
+ const maybe_js_1 = require("../../../utils/maybe-js");
11
10
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
11
+ const get_app_tests_1 = require("./get-app-tests");
12
12
  function createApplicationFiles(host, options) {
13
13
  let styleSolutionSpecificAppFiles;
14
14
  if (options.styledModule && options.style !== 'styled-jsx') {
@@ -17,6 +17,9 @@ function createApplicationFiles(host, options) {
17
17
  else if (options.style === 'styled-jsx') {
18
18
  styleSolutionSpecificAppFiles = '../files/style-styled-jsx';
19
19
  }
20
+ else if (options.style === 'tailwind') {
21
+ styleSolutionSpecificAppFiles = '../files/style-tailwind';
22
+ }
20
23
  else if (options.style === 'none') {
21
24
  styleSolutionSpecificAppFiles = '../files/style-none';
22
25
  }
@@ -128,11 +131,13 @@ function createNxWebpackPluginOptions(options) {
128
131
  : options.projectName),
129
132
  index: './src/index.html',
130
133
  baseHref: '/',
131
- main: (0, add_project_1.maybeJs)(options, `./src/main.tsx`),
134
+ main: (0, maybe_js_1.maybeJs)(options, `./src/main.tsx`),
132
135
  tsConfig: './tsconfig.app.json',
133
136
  assets: ['./src/favicon.ico', './src/assets'],
134
137
  styles: options.styledModule || !options.hasStyles
135
138
  ? []
136
- : [`./src/styles.${options.style}`],
139
+ : [
140
+ `./src/styles.${options.style !== 'tailwind' ? options.style : 'css'}`,
141
+ ],
137
142
  };
138
143
  }
@@ -26,7 +26,10 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
26
26
  rootProject: options.rootProject,
27
27
  callingGenerator,
28
28
  });
29
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
29
+ const nxJson = (0, devkit_1.readNxJson)(host);
30
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
31
+ nxJson.useInferencePlugins !== false;
32
+ options.addPlugin ??= addPlugin;
30
33
  options.rootProject = appProjectRoot === '.';
31
34
  options.projectNameAndRootFormat = projectNameAndRootFormat;
32
35
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
@@ -35,7 +38,7 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
35
38
  ? options.tags.split(',').map((s) => s.trim())
36
39
  : [];
37
40
  const fileName = options.pascalCaseFiles ? 'App' : 'app';
38
- const styledModule = /^(css|scss|less|none)$/.test(options.style)
41
+ const styledModule = /^(css|scss|less|tailwind|none)$/.test(options.style)
39
42
  ? null
40
43
  : options.style;
41
44
  (0, assertion_1.assertValidStyle)(options.style);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateSpecConfig = void 0;
4
+ const maybe_js_1 = require("../../../utils/maybe-js");
4
5
  const jest_utils_1 = require("../../../utils/jest-utils");
5
6
  const devkit_1 = require("@nx/devkit");
6
7
  function updateSpecConfig(host, options) {
@@ -21,7 +22,7 @@ function updateSpecConfig(host, options) {
21
22
  if (options.unitTestRunner !== 'jest') {
22
23
  return;
23
24
  }
24
- const configPath = `${options.appProjectRoot}/jest.config.${options.js ? 'js' : 'ts'}`;
25
+ const configPath = (0, maybe_js_1.maybeJs)(options, `${options.appProjectRoot}/jest.config.ts`);
25
26
  const originalContent = host.read(configPath, 'utf-8');
26
27
  const content = (0, jest_utils_1.updateJestConfigContent)(originalContent);
27
28
  host.write(configPath, content);
@@ -62,6 +62,10 @@
62
62
  "value": "less",
63
63
  "label": "LESS [ https://lesscss.org ]"
64
64
  },
65
+ {
66
+ "value": "tailwind",
67
+ "label": "tailwind [ https://tailwindcss.com/ ]"
68
+ },
65
69
  {
66
70
  "value": "styled-components",
67
71
  "label": "styled-components [ https://styled-components.com ]"
@@ -19,7 +19,10 @@ exports.cypressComponentConfigGenerator = cypressComponentConfigGenerator;
19
19
  */
20
20
  async function cypressComponentConfigGeneratorInternal(tree, options) {
21
21
  const { componentConfigurationGenerator: baseCyCtConfig } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
22
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
22
+ const nxJson = (0, devkit_1.readNxJson)(tree);
23
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
24
+ nxJson.useInferencePlugins !== false;
25
+ options.addPlugin ??= addPlugin;
23
26
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
24
27
  const installTask = await baseCyCtConfig(tree, {
25
28
  project: options.project,
@@ -69,7 +69,8 @@
69
69
  "e2eTestRunner": {
70
70
  "type": "string",
71
71
  "enum": ["cypress", "playwright", "none"],
72
- "description": "Test runner to use for end to end (e2e) tests.",
72
+ "description": "Test runner to use for end to end (E2E) tests.",
73
+ "x-prompt": "Which E2E test runner would you like to use?",
73
74
  "default": "cypress"
74
75
  },
75
76
  "host": {
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ <% if (!minimal) { %>
3
+ import NxWelcome from "./nx-welcome";
4
+ <% } %>
5
+ import { Link, Route, Routes } from 'react-router-dom';
6
+
7
+ <% if (remotes.length > 0) { %>
8
+ <% remotes.forEach(function(r) { %>
9
+ const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module'));
10
+ <% }); %>
11
+ <% } %>
12
+ export function App() {
13
+ return (
14
+ <React.Suspense fallback={null}>
15
+ <ul>
16
+ <li><Link to="/">Home</Link></li>
17
+ <% remotes.forEach(function(r) { %>
18
+ <li><Link to="/<%=r.fileName%>"><%=r.className%></Link></li>
19
+ <% }); %>
20
+ </ul>
21
+ <Routes>
22
+ <% if (!minimal) { %>
23
+ <Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
24
+ <% } %>
25
+ <% remotes.forEach(function(r) { %>
26
+ <Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
27
+ <% }); %>
28
+ </Routes>
29
+ </React.Suspense>
30
+ );
31
+ }
32
+
33
+ export default App;
@@ -23,7 +23,10 @@ async function hostGeneratorInternal(host, schema) {
23
23
  const tasks = [];
24
24
  const options = {
25
25
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:host')),
26
- typescriptConfiguration: schema.typescriptConfiguration ?? true,
26
+ js: schema.js ?? false,
27
+ typescriptConfiguration: schema.js
28
+ ? false
29
+ : schema.typescriptConfiguration ?? true,
27
30
  dynamic: schema.dynamic ?? false,
28
31
  // TODO(colum): remove when MF works with Crystal
29
32
  addPlugin: false,
@@ -55,6 +58,7 @@ async function hostGeneratorInternal(host, schema) {
55
58
  skipFormat: true,
56
59
  projectNameAndRootFormat: options.projectNameAndRootFormat,
57
60
  typescriptConfiguration: options.typescriptConfiguration,
61
+ js: options.js,
58
62
  dynamic: options.dynamic,
59
63
  host: options.name,
60
64
  });
@@ -1,5 +1,5 @@
1
- import { NormalizedSchema } from '../schema';
2
1
  import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from '../schema';
3
3
  export declare function addModuleFederationFiles(host: Tree, options: NormalizedSchema, defaultRemoteManifest: {
4
4
  name: string;
5
5
  port: number;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addModuleFederationFiles = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const maybe_js_1 = require("../../../utils/maybe-js");
5
6
  function addModuleFederationFiles(host, options, defaultRemoteManifest) {
6
7
  const templateVariables = {
7
8
  ...(0, devkit_1.names)(options.name),
@@ -20,8 +21,8 @@ function addModuleFederationFiles(host, options, defaultRemoteManifest) {
20
21
  // Module federation requires bootstrap code to be dynamically imported.
21
22
  // Renaming original entry file so we can use `import(./bootstrap)` in
22
23
  // new entry file.
23
- host.rename((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/main.tsx'), (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/bootstrap.tsx'));
24
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, `../files/common`), options.appProjectRoot, templateVariables);
24
+ host.rename((0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/main.tsx')), (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/bootstrap.tsx')));
25
+ (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, `../files/${options.js ? 'common' : 'common-ts'}`), options.appProjectRoot, templateVariables);
25
26
  const pathToModuleFederationFiles = options.typescriptConfiguration
26
27
  ? 'module-federation-ts'
27
28
  : 'module-federation';
@@ -5,11 +5,13 @@ const devkit_1 = require("@nx/devkit");
5
5
  function updateModuleFederationE2eProject(host, options) {
6
6
  try {
7
7
  let projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.e2eProjectName);
8
- projectConfig.targets.e2e.options = {
9
- ...projectConfig.targets.e2e.options,
10
- baseUrl: `http://localhost:${options.devServerPort}`,
11
- };
12
- (0, devkit_1.updateProjectConfiguration)(host, options.e2eProjectName, projectConfig);
8
+ if (projectConfig.targets.e2e.executor !== '@nx/playwright:playwright') {
9
+ projectConfig.targets.e2e.options = {
10
+ ...projectConfig.targets.e2e.options,
11
+ baseUrl: `http://localhost:${options.devServerPort}`,
12
+ };
13
+ (0, devkit_1.updateProjectConfiguration)(host, options.e2eProjectName, projectConfig);
14
+ }
13
15
  }
14
16
  catch {
15
17
  // nothing
@@ -49,6 +49,10 @@
49
49
  "value": "less",
50
50
  "label": "LESS [ https://lesscss.org ]"
51
51
  },
52
+ {
53
+ "value": "tailwind",
54
+ "label": "tailwind [ https://tailwindcss.com/ ]"
55
+ },
52
56
  {
53
57
  "value": "styled-components",
54
58
  "label": "styled-components [ https://styled-components.com ]"
@@ -100,7 +104,8 @@
100
104
  "e2eTestRunner": {
101
105
  "type": "string",
102
106
  "enum": ["cypress", "playwright", "none"],
103
- "description": "Test runner to use for end to end (e2e) tests.",
107
+ "description": "Test runner to use for end to end (E2E) tests.",
108
+ "x-prompt": "Which E2E test runner would you like to use?",
104
109
  "default": "cypress"
105
110
  },
106
111
  "tags": {
@@ -170,7 +175,7 @@
170
175
  },
171
176
  "typescriptConfiguration": {
172
177
  "type": "boolean",
173
- "description": "Whether the module federation configuration and webpack configuration files should use TS.",
178
+ "description": "Whether the module federation configuration and webpack configuration files should use TS. When --js is used, this flag is ignored.",
174
179
  "default": true
175
180
  }
176
181
  },
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addRollupBuildTarget = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const maybe_js_1 = require("./maybe-js");
5
+ const maybe_js_1 = require("../../../utils/maybe-js");
6
6
  const versions_1 = require("../../../utils/versions");
7
7
  async function addRollupBuildTarget(host, options) {
8
8
  const tasks = [];
@@ -13,7 +13,10 @@ async function normalizeOptions(host, options) {
13
13
  projectNameAndRootFormat: options.projectNameAndRootFormat,
14
14
  callingGenerator: '@nx/react:library',
15
15
  });
16
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
16
+ const nxJson = (0, devkit_1.readNxJson)(host);
17
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
18
+ nxJson.useInferencePlugins !== false;
19
+ options.addPlugin ??= addPlugin;
17
20
  const fileName = options.simpleName
18
21
  ? projectNames.projectSimpleName
19
22
  : projectNames.projectFileName;
@@ -4,7 +4,7 @@ exports.updateAppRoutes = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const ast_utils_1 = require("../../../utils/ast-utils");
6
6
  const ast_utils_2 = require("../../../utils/ast-utils");
7
- const maybe_js_1 = require("./maybe-js");
7
+ const maybe_js_1 = require("../../../utils/maybe-js");
8
8
  const versions_1 = require("../../../utils/versions");
9
9
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
10
10
  let tsModule;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
4
+ const path_1 = require("path");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
7
+ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
6
8
  const js_1 = require("@nx/js");
7
9
  const versions_1 = require("../../utils/versions");
10
+ const maybe_js_1 = require("../../utils/maybe-js");
8
11
  const component_1 = require("../component/component");
9
12
  const init_1 = require("../init/init");
10
13
  const jest_utils_1 = require("../../utils/jest-utils");
@@ -16,8 +19,6 @@ const create_files_1 = require("./lib/create-files");
16
19
  const create_ts_config_1 = require("../../utils/create-ts-config");
17
20
  const install_common_dependencies_1 = require("./lib/install-common-dependencies");
18
21
  const set_defaults_1 = require("./lib/set-defaults");
19
- const path_1 = require("path");
20
- const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
21
22
  async function libraryGenerator(host, schema) {
22
23
  return await libraryGeneratorInternal(host, {
23
24
  addPlugin: false,
@@ -177,7 +178,7 @@ async function libraryGeneratorInternal(host, schema) {
177
178
  (0, create_ts_config_1.extractTsConfigBase)(host);
178
179
  if (!options.skipTsConfig) {
179
180
  (0, js_1.addTsConfigPath)(host, options.importPath, [
180
- (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
181
+ (0, maybe_js_1.maybeJs)(options, (0, devkit_1.joinPathFragments)(options.projectRoot, './src/index.ts')),
181
182
  ]);
182
183
  }
183
184
  if (!options.skipFormat) {
@@ -4,6 +4,6 @@ module.exports = {
4
4
  library: { type: 'var', name: '<%= projectName %>'},
5
5
  <% } %>
6
6
  exposes: {
7
- './Module': './src/remote-entry.ts',
7
+ './Module': './src/remote-entry.<%= js ? 'js' : 'ts' %>',
8
8
  },
9
9
  };
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  name: '<%= projectName %>',
3
3
  exposes: {
4
- './Module': '<%= appProjectRoot %>/src/remote-entry.ts',
4
+ './Module': '<%= appProjectRoot %>/src/remote-entry.<%= js ? 'js' : 'ts' %>',
5
5
  },
6
6
  };
@@ -3,7 +3,7 @@ import {ModuleFederationConfig} from '@nx/webpack';
3
3
  const config: ModuleFederationConfig = {
4
4
  name: '<%= projectName %>',
5
5
  exposes: {
6
- './Module': '<%= appProjectRoot %>/src/remote-entry.ts',
6
+ './Module': '<%= appProjectRoot %>/src/remote-entry.<%= js ? 'js' : 'ts' %>',
7
7
  },
8
8
  };
9
9
 
@@ -6,7 +6,7 @@ const config: ModuleFederationConfig = {
6
6
  library: { type: 'var', name: '<%= projectName %>'},
7
7
  <% } %>
8
8
  exposes: {
9
- './Module': './src/remote-entry.ts',
9
+ './Module': './src/remote-entry.<%= js ? 'js' : 'ts' %>',
10
10
  },
11
11
  };
12
12
 
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupTspathForRemote = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
+ const maybe_js_1 = require("../../../utils/maybe-js");
6
7
  function setupTspathForRemote(tree, options) {
7
8
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.name);
8
- const exportPath = `./src/remote-entry.ts`;
9
+ const exportPath = (0, maybe_js_1.maybeJs)(options, './src/remote-entry.ts');
9
10
  const exportName = 'Module';
10
11
  (0, js_1.addTsConfigPath)(tree, `${options.name}/${exportName}`, [
11
12
  (0, devkit_1.joinPathFragments)(project.root, exportPath),
@@ -46,7 +46,16 @@ function updateHostWithRemote(host, hostName, remoteName) {
46
46
  }
47
47
  exports.updateHostWithRemote = updateHostWithRemote;
48
48
  function findAppComponentPath(host, sourceRoot) {
49
- const locations = ['app/app.tsx', 'app/App.tsx', 'app.tsx', 'App.tsx'];
49
+ const locations = [
50
+ 'app/app.tsx',
51
+ 'app/App.tsx',
52
+ 'app/app.js',
53
+ 'app/App.js',
54
+ 'app.tsx',
55
+ 'App.tsx',
56
+ 'app.js',
57
+ 'App.js',
58
+ ];
50
59
  for (const loc of locations) {
51
60
  if (host.exists((0, devkit_1.joinPathFragments)(sourceRoot, loc))) {
52
61
  return (0, devkit_1.joinPathFragments)(sourceRoot, loc);
@@ -12,12 +12,14 @@ const setup_ssr_for_remote_1 = require("./lib/setup-ssr-for-remote");
12
12
  const setup_tspath_for_remote_1 = require("./lib/setup-tspath-for-remote");
13
13
  const add_remote_to_dynamic_host_1 = require("./lib/add-remote-to-dynamic-host");
14
14
  const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
15
+ const maybe_js_1 = require("../../utils/maybe-js");
15
16
  function addModuleFederationFiles(host, options) {
16
17
  const templateVariables = {
17
18
  ...(0, devkit_1.names)(options.name),
18
19
  ...options,
19
20
  tmpl: '',
20
21
  };
22
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `./files/${options.js ? 'common' : 'common-ts'}`), options.appProjectRoot, templateVariables);
21
23
  const pathToModuleFederationFiles = options.typescriptConfiguration
22
24
  ? 'module-federation-ts'
23
25
  : 'module-federation';
@@ -45,7 +47,11 @@ async function remoteGeneratorInternal(host, schema) {
45
47
  const tasks = [];
46
48
  const options = {
47
49
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:remote')),
48
- typescriptConfiguration: schema.typescriptConfiguration ?? false,
50
+ // when js is set to true, we want to use the js configuration
51
+ js: schema.js ?? false,
52
+ typescriptConfiguration: schema.js
53
+ ? false
54
+ : schema.typescriptConfiguration ?? true,
49
55
  dynamic: schema.dynamic ?? false,
50
56
  // TODO(colum): remove when MF works with Crystal
51
57
  addPlugin: false,
@@ -63,7 +69,7 @@ async function remoteGeneratorInternal(host, schema) {
63
69
  // Module federation requires bootstrap code to be dynamically imported.
64
70
  // Renaming original entry file so we can use `import(./bootstrap)` in
65
71
  // new entry file.
66
- host.rename((0, path_1.join)(options.appProjectRoot, 'src/main.tsx'), (0, path_1.join)(options.appProjectRoot, 'src/bootstrap.tsx'));
72
+ host.rename((0, path_1.join)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/main.tsx')), (0, path_1.join)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/bootstrap.tsx')));
67
73
  addModuleFederationFiles(host, options);
68
74
  (0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
69
75
  (0, setup_tspath_for_remote_1.setupTspathForRemote)(host, options);
@@ -55,6 +55,10 @@
55
55
  "value": "less",
56
56
  "label": "LESS [ https://lesscss.org ]"
57
57
  },
58
+ {
59
+ "value": "tailwind",
60
+ "label": "tailwind [ https://tailwindcss.com/ ]"
61
+ },
58
62
  {
59
63
  "value": "styled-components",
60
64
  "label": "styled-components [ https://styled-components.com ]"
@@ -106,7 +110,8 @@
106
110
  "e2eTestRunner": {
107
111
  "type": "string",
108
112
  "enum": ["cypress", "playwright", "none"],
109
- "description": "Test runner to use for end to end (e2e) tests.",
113
+ "description": "Test runner to use for end to end (E2E) tests.",
114
+ "x-prompt": "Which E2E test runner would you like to use?",
110
115
  "default": "cypress"
111
116
  },
112
117
  "tags": {
@@ -169,7 +174,7 @@
169
174
  },
170
175
  "typescriptConfiguration": {
171
176
  "type": "boolean",
172
- "description": "Whether the module federation configuration and webpack configuration files should use TS.",
177
+ "description": "Whether the module federation configuration and webpack configuration files should use TS. When --js is used, this flag is ignored.",
173
178
  "default": true
174
179
  }
175
180
  },
@@ -28,7 +28,10 @@ function storybookConfigurationGenerator(host, schema) {
28
28
  }
29
29
  exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
30
30
  async function storybookConfigurationGeneratorInternal(host, schema) {
31
- schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
31
+ const nxJson = (0, devkit_1.readNxJson)(host);
32
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
33
+ nxJson.useInferencePlugins !== false;
34
+ schema.addPlugin ??= addPluginDefault;
32
35
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
33
36
  let uiFramework = '@storybook/react-vite';
34
37
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ async function default_1(tree) {
5
+ if (!hasModuleFederationProject(tree)) {
6
+ return;
7
+ }
8
+ ensureTargetDefaultsContainProductionInputs(tree);
9
+ await (0, devkit_1.formatFiles)(tree);
10
+ }
11
+ exports.default = default_1;
12
+ function ensureTargetDefaultsContainProductionInputs(tree) {
13
+ const nxJson = (0, devkit_1.readNxJson)(tree);
14
+ const webpackExecutor = '@nx/webpack:webpack';
15
+ const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
16
+ nxJson.targetDefaults[webpackExecutor] ??= {};
17
+ nxJson.targetDefaults[webpackExecutor].inputs ??= [
18
+ 'production',
19
+ '^production',
20
+ { env: mfEnvVar },
21
+ ];
22
+ if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('production')) {
23
+ nxJson.targetDefaults[webpackExecutor].inputs.push('production');
24
+ }
25
+ if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('^production')) {
26
+ nxJson.targetDefaults[webpackExecutor].inputs.push('^production');
27
+ }
28
+ let mfEnvVarExists = false;
29
+ for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
30
+ if (typeof input === 'object' && input['env'] === mfEnvVar) {
31
+ mfEnvVarExists = true;
32
+ break;
33
+ }
34
+ }
35
+ if (!mfEnvVarExists) {
36
+ nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
37
+ }
38
+ (0, devkit_1.updateNxJson)(tree, nxJson);
39
+ }
40
+ function hasModuleFederationProject(tree) {
41
+ const projects = (0, devkit_1.getProjects)(tree);
42
+ for (const project of projects.values()) {
43
+ const targets = project.targets || {};
44
+ for (const [_, target] of Object.entries(targets)) {
45
+ if (target.executor === '@nx/webpack:webpack' &&
46
+ (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
47
+ tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
48
+ return true;
49
+ }
50
+ }
51
+ }
52
+ return false;
53
+ }
@@ -1,5 +1,6 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  export declare function updateModuleFederationProject(host: Tree, options: {
3
+ js?: boolean;
3
4
  projectName: string;
4
5
  appProjectRoot: string;
5
6
  devServerPort?: number;
@@ -3,20 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateModuleFederationProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../utils/versions");
6
+ const maybe_js_1 = require("../utils/maybe-js");
6
7
  function updateModuleFederationProject(host, options) {
7
8
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
8
9
  projectConfig.targets.build.options = {
9
10
  ...projectConfig.targets.build.options,
10
- main: `${options.appProjectRoot}/src/main.ts`,
11
- webpackConfig: `${options.appProjectRoot}/webpack.config.${options.typescriptConfiguration ? 'ts' : 'js'}`,
11
+ main: (0, maybe_js_1.maybeJs)(options, `${options.appProjectRoot}/src/main.ts`),
12
+ webpackConfig: `${options.appProjectRoot}/webpack.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
12
13
  };
13
14
  projectConfig.targets.build.configurations.production = {
14
15
  ...projectConfig.targets.build.configurations.production,
15
- webpackConfig: `${options.appProjectRoot}/webpack.config.prod.${options.typescriptConfiguration ? 'ts' : 'js'}`,
16
+ webpackConfig: `${options.appProjectRoot}/webpack.config.prod.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
16
17
  };
17
18
  // If host should be configured to use dynamic federation
18
19
  if (options.dynamic) {
19
- const pathToProdWebpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.prod.config.${options.typescriptConfiguration ? 'ts' : 'js'}`);
20
+ const pathToProdWebpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.prod.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`);
20
21
  if (host.exists(pathToProdWebpackConfig)) {
21
22
  host.delete(pathToProdWebpackConfig);
22
23
  }
@@ -8,7 +8,10 @@ function addMfEnvToTargetDefaultInputs(tree) {
8
8
  const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
9
9
  nxJson.targetDefaults ??= {};
10
10
  nxJson.targetDefaults[webpackExecutor] ??= {};
11
- nxJson.targetDefaults[webpackExecutor].inputs ??= [];
11
+ nxJson.targetDefaults[webpackExecutor].inputs ??= [
12
+ 'production',
13
+ '^production',
14
+ ];
12
15
  let mfEnvVarExists = false;
13
16
  for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
14
17
  if (typeof input === 'object' && input['env'] === mfEnvVar) {
@@ -5,6 +5,7 @@ const VALID_STYLES = [
5
5
  'css',
6
6
  'scss',
7
7
  'less',
8
+ 'tailwind',
8
9
  'styled-components',
9
10
  '@emotion/styled',
10
11
  'styled-jsx',
@@ -0,0 +1,3 @@
1
+ export declare function maybeJs(options: {
2
+ js?: boolean;
3
+ }, path: string): string;
@@ -2,6 +2,7 @@ export type SupportedStyles =
2
2
  | 'css'
3
3
  | 'scss'
4
4
  | 'less'
5
+ | 'tailwind'
5
6
  | 'styled-components'
6
7
  | '@emotion/styled'
7
8
  | 'styled-jsx'
@@ -1,2 +0,0 @@
1
- import { NormalizedSchema } from '../schema';
2
- export declare function maybeJs(options: NormalizedSchema, path: string): string;