@nx/react 19.0.2 → 19.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "19.0.2",
3
+ "version": "19.0.3",
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, Vitest, Playwright, 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": {
@@ -37,11 +37,11 @@
37
37
  "file-loader": "^6.2.0",
38
38
  "minimatch": "9.0.3",
39
39
  "tslib": "^2.3.0",
40
- "@nx/devkit": "19.0.2",
41
- "@nx/js": "19.0.2",
42
- "@nx/eslint": "19.0.2",
43
- "@nx/web": "19.0.2",
44
- "@nrwl/react": "19.0.2"
40
+ "@nx/devkit": "19.0.3",
41
+ "@nx/js": "19.0.3",
42
+ "@nx/eslint": "19.0.3",
43
+ "@nx/web": "19.0.3",
44
+ "@nrwl/react": "19.0.3"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
@@ -1,4 +1,5 @@
1
1
  import { Configuration, WebpackOptionsNormalized } from 'webpack';
2
+ import { SvgrOptions } from '../../with-react';
2
3
  export declare function applyReactConfig(options: {
3
- svgr?: boolean;
4
+ svgr?: boolean | SvgrOptions;
4
5
  }, config?: Partial<WebpackOptionsNormalized | Configuration>): void;
@@ -5,8 +5,14 @@ function applyReactConfig(options, config = {}) {
5
5
  if (!process.env['NX_TASK_TARGET_PROJECT'])
6
6
  return;
7
7
  addHotReload(config);
8
- if (options.svgr !== false) {
8
+ if (options.svgr !== false || typeof options.svgr === 'object') {
9
9
  removeSvgLoaderIfPresent(config);
10
+ const defaultSvgrOptions = {
11
+ svgo: false,
12
+ titleProp: true,
13
+ ref: true,
14
+ };
15
+ const svgrOptions = typeof options.svgr === 'object' ? options.svgr : defaultSvgrOptions;
10
16
  // TODO(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
11
17
  // It should be:
12
18
  // use: [{
@@ -33,11 +39,7 @@ function applyReactConfig(options, config = {}) {
33
39
  use: [
34
40
  {
35
41
  loader: require.resolve('@svgr/webpack'),
36
- options: {
37
- svgo: false,
38
- titleProp: true,
39
- ref: true,
40
- },
42
+ options: svgrOptions,
41
43
  },
42
44
  {
43
45
  loader: require.resolve('file-loader'),
@@ -1,7 +1,12 @@
1
1
  import type { Configuration } from 'webpack';
2
2
  import type { NxWebpackExecutionContext, WithWebOptions } from '@nx/webpack';
3
+ export interface SvgrOptions {
4
+ svgo?: boolean;
5
+ titleProp?: boolean;
6
+ ref?: boolean;
7
+ }
3
8
  export interface WithReactOptions extends WithWebOptions {
4
- svgr?: false;
9
+ svgr?: boolean | SvgrOptions;
5
10
  }
6
11
  /**
7
12
  * @param {WithReactOptions} pluginOptions
@@ -12,6 +12,7 @@ const normalize_remote_1 = require("./lib/normalize-remote");
12
12
  const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
13
13
  const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
14
14
  const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
15
+ const js_1 = require("@nx/js");
15
16
  async function hostGenerator(host, schema) {
16
17
  return hostGeneratorInternal(host, {
17
18
  projectNameAndRootFormat: 'derived',
@@ -31,6 +32,16 @@ async function hostGeneratorInternal(host, schema) {
31
32
  // TODO(colum): remove when MF works with Crystal
32
33
  addPlugin: false,
33
34
  };
35
+ // Check to see if remotes are provided and also check if --dynamic is provided
36
+ // if both are check that the remotes are valid names else throw an error.
37
+ if (options.dynamic && options.remotes?.length > 0) {
38
+ options.remotes.forEach((remote) => {
39
+ const isValidRemote = (0, js_1.isValidVariable)(remote);
40
+ if (!isValidRemote.isValid) {
41
+ throw new Error(`Invalid remote name provided: ${remote}. ${isValidRemote.message}`);
42
+ }
43
+ });
44
+ }
34
45
  const initTask = await (0, application_1.default)(host, {
35
46
  ...options,
36
47
  // The target use-case is loading remotes as child routes, thus always enable routing.
@@ -13,6 +13,7 @@ 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
15
  const maybe_js_1 = require("../../utils/maybe-js");
16
+ const js_1 = require("@nx/js");
16
17
  function addModuleFederationFiles(host, options) {
17
18
  const templateVariables = {
18
19
  ...(0, devkit_1.names)(options.name),
@@ -56,6 +57,14 @@ async function remoteGeneratorInternal(host, schema) {
56
57
  // TODO(colum): remove when MF works with Crystal
57
58
  addPlugin: false,
58
59
  };
60
+ if (options.dynamic) {
61
+ // Dynamic remotes generate with library { type: 'var' } by default.
62
+ // We need to ensure that the remote name is a valid variable name.
63
+ const isValidRemote = (0, js_1.isValidVariable)(options.name);
64
+ if (!isValidRemote.isValid) {
65
+ throw new Error(`Invalid remote name provided: ${options.name}. ${isValidRemote.message}`);
66
+ }
67
+ }
59
68
  const initAppTask = await (0, application_1.default)(host, {
60
69
  ...options,
61
70
  // Only webpack works with module federation for now.