@nx/react 21.3.0-beta.6 → 21.3.0-canary.20250614-db86a35
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/mf/dynamic-federation.js +10 -2
- package/package.json +6 -6
- package/plugins/component-testing/index.js +3 -4
- package/plugins/storybook/index.js +4 -5
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +5 -5
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +6 -6
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +3 -3
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +12 -13
- package/src/generators/application/lib/add-project.js +2 -2
- package/src/generators/component-story/component-story.js +2 -3
- package/src/generators/component-test/component-test.js +4 -6
- package/src/generators/cypress-component-configuration/lib/add-files.js +1 -3
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +3 -3
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +3 -3
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +3 -3
- package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
- package/src/generators/host/lib/add-module-federation-files.js +1 -2
- package/src/generators/library/lib/normalize-options.js +1 -1
- package/src/generators/library/library.js +0 -4
- package/src/generators/library/schema.json +1 -2
- package/src/generators/redux/redux.d.ts +1 -1
- package/src/generators/redux/redux.js +5 -5
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +3 -3
- package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +3 -3
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
- package/src/generators/remote/lib/update-host-with-remote.js +2 -3
- package/src/generators/remote/remote.js +11 -12
- package/src/generators/setup-ssr/setup-ssr.js +3 -4
- package/src/generators/stories/stories.js +5 -5
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/mf/dynamic-federation.js
CHANGED
@@ -4,7 +4,7 @@ exports.setRemoteUrlResolver = setRemoteUrlResolver;
|
|
4
4
|
exports.setRemoteDefinitions = setRemoteDefinitions;
|
5
5
|
exports.setRemoteDefinition = setRemoteDefinition;
|
6
6
|
exports.loadRemoteModule = loadRemoteModule;
|
7
|
-
const
|
7
|
+
const node_path_1 = require("node:path");
|
8
8
|
let remoteUrlDefinitions = {};
|
9
9
|
let resolveRemoteUrl;
|
10
10
|
const remoteModuleMap = new Map();
|
@@ -132,7 +132,15 @@ async function loadRemoteContainer(remoteName) {
|
|
132
132
|
const remoteUrl = remoteUrlDefinitions
|
133
133
|
? remoteUrlDefinitions[remoteName]
|
134
134
|
: await resolveRemoteUrl(remoteName);
|
135
|
-
const
|
135
|
+
const url = new URL(remoteUrl);
|
136
|
+
const ext = (0, node_path_1.extname)(url.pathname);
|
137
|
+
const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);
|
138
|
+
if (needsRemoteEntry) {
|
139
|
+
url.pathname = url.pathname.endsWith('/')
|
140
|
+
? `${url.pathname}remoteEntry.mjs`
|
141
|
+
: `${url.pathname}/remoteEntry.mjs`;
|
142
|
+
}
|
143
|
+
const containerUrl = url.href;
|
136
144
|
const container = await fetchRemoteModule(containerUrl, remoteName);
|
137
145
|
await container.init(__webpack_share_scopes__.default);
|
138
146
|
remoteContainerMap.set(remoteName, container);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/react",
|
3
|
-
"version": "21.3.0-
|
3
|
+
"version": "21.3.0-canary.20250614-db86a35",
|
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": {
|
@@ -38,11 +38,11 @@
|
|
38
38
|
"minimatch": "9.0.3",
|
39
39
|
"picocolors": "^1.1.0",
|
40
40
|
"tslib": "^2.3.0",
|
41
|
-
"@nx/devkit": "21.3.0-
|
42
|
-
"@nx/js": "21.3.0-
|
43
|
-
"@nx/eslint": "21.3.0-
|
44
|
-
"@nx/web": "21.3.0-
|
45
|
-
"@nx/module-federation": "21.3.0-
|
41
|
+
"@nx/devkit": "21.3.0-canary.20250614-db86a35",
|
42
|
+
"@nx/js": "21.3.0-canary.20250614-db86a35",
|
43
|
+
"@nx/eslint": "21.3.0-canary.20250614-db86a35",
|
44
|
+
"@nx/web": "21.3.0-canary.20250614-db86a35",
|
45
|
+
"@nx/module-federation": "21.3.0-canary.20250614-db86a35",
|
46
46
|
"express": "^4.21.2",
|
47
47
|
"http-proxy-middleware": "^3.0.3",
|
48
48
|
"semver": "^7.6.3"
|
@@ -2,9 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.nxComponentTestingPreset = nxComponentTestingPreset;
|
4
4
|
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
|
5
|
-
const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
7
|
-
const
|
6
|
+
const ct_helpers_1 = require("@nx/cypress/src/utils/ct-helpers");
|
8
7
|
const fs_1 = require("fs");
|
9
8
|
const path_1 = require("path");
|
10
9
|
/**
|
@@ -161,7 +160,7 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
161
160
|
const { composePluginsSync } = require('@nx/webpack/src/utils/config');
|
162
161
|
const { withNx } = require('@nx/webpack/src/utils/with-nx');
|
163
162
|
const { withWeb } = require('@nx/webpack/src/utils/with-web');
|
164
|
-
const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root,
|
163
|
+
const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, buildableProjectConfig.sourceRoot);
|
165
164
|
let customWebpack;
|
166
165
|
if (options.webpackConfig) {
|
167
166
|
customWebpack = resolveUserDefinedWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
|
@@ -184,7 +183,7 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
184
183
|
extractLicenses: false,
|
185
184
|
root: devkit_1.workspaceRoot,
|
186
185
|
projectRoot: ctProjectConfig.root,
|
187
|
-
sourceRoot:
|
186
|
+
sourceRoot: ctProjectConfig.sourceRoot,
|
188
187
|
},
|
189
188
|
context,
|
190
189
|
});
|
@@ -2,13 +2,12 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.webpack = exports.core = void 0;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
6
5
|
const config_1 = require("@nx/webpack/src/utils/config");
|
7
|
-
const fs_1 = require("fs");
|
8
6
|
const path_1 = require("path");
|
9
7
|
const webpack_1 = require("webpack");
|
10
|
-
const with_react_1 = require("../with-react");
|
11
8
|
const merge_plugins_1 = require("./merge-plugins");
|
9
|
+
const with_react_1 = require("../with-react");
|
10
|
+
const fs_1 = require("fs");
|
12
11
|
// This is shamelessly taken from CRA and modified for NX use
|
13
12
|
// https://github.com/facebook/create-react-app/blob/4784997f0682e75eb32a897b4ffe34d735912e6c/packages/react-scripts/config/env.js#L71
|
14
13
|
function getClientEnvironment(mode) {
|
@@ -63,7 +62,7 @@ const getProjectData = async (storybookOptions) => {
|
|
63
62
|
? {
|
64
63
|
workspaceRoot: process.env.NX_WORKSPACE_ROOT,
|
65
64
|
projectRoot: projectNode.data.root,
|
66
|
-
sourceRoot:
|
65
|
+
sourceRoot: projectNode.data.sourceRoot,
|
67
66
|
projectNode,
|
68
67
|
}
|
69
68
|
: // Edge-case: missing project node
|
@@ -129,7 +128,7 @@ const webpack = async (storybookWebpackConfig = {}, options) => {
|
|
129
128
|
...options,
|
130
129
|
root: projectData.workspaceRoot,
|
131
130
|
projectRoot: projectData.projectRoot,
|
132
|
-
sourceRoot:
|
131
|
+
sourceRoot: projectData.sourceRoot,
|
133
132
|
fileReplacements: [],
|
134
133
|
sourceMap: true,
|
135
134
|
styles: options.styles ?? [],
|
@@ -2,12 +2,11 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.default = moduleFederationDevServer;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const
|
6
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
7
|
-
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
5
|
+
const dev_server_impl_1 = require("@nx/webpack/src/executors/dev-server/dev-server.impl");
|
8
6
|
const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
|
7
|
+
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
8
|
+
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
9
9
|
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
10
|
-
const dev_server_impl_1 = require("@nx/webpack/src/executors/dev-server/dev-server.impl");
|
11
10
|
const fs_1 = require("fs");
|
12
11
|
const path_1 = require("path");
|
13
12
|
const lib_1 = require("./lib");
|
@@ -24,7 +23,8 @@ async function* moduleFederationDevServer(schema, context) {
|
|
24
23
|
}, context)
|
25
24
|
: (0, dev_server_impl_1.default)(options, context);
|
26
25
|
const p = context.projectsConfigurations.projects[context.projectName];
|
27
|
-
|
26
|
+
const buildOptions = (0, lib_1.getBuildOptions)(options.buildTarget, context);
|
27
|
+
let pathToManifestFile = (0, path_1.join)(context.root, p.sourceRoot, 'assets/module-federation.manifest.json');
|
28
28
|
if (options.pathToManifestFile) {
|
29
29
|
const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
|
30
30
|
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
|
package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js
CHANGED
@@ -2,19 +2,19 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.default = moduleFederationSsrDevServer;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
6
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
7
|
-
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
8
|
-
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
9
5
|
const ssr_dev_server_impl_1 = require("@nx/webpack/src/executors/ssr-dev-server/ssr-dev-server.impl");
|
10
|
-
const fs_1 = require("fs");
|
11
6
|
const path_1 = require("path");
|
7
|
+
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
8
|
+
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
9
|
+
const fs_1 = require("fs");
|
10
|
+
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
12
11
|
const lib_1 = require("./lib");
|
13
12
|
async function* moduleFederationSsrDevServer(ssrDevServerOptions, context) {
|
14
13
|
const options = (0, lib_1.normalizeOptions)(ssrDevServerOptions);
|
15
14
|
let iter = (0, ssr_dev_server_impl_1.default)(options, context);
|
16
15
|
const projectConfig = context.projectsConfigurations.projects[context.projectName];
|
17
|
-
|
16
|
+
const buildOptions = (0, lib_1.getBuildOptions)(options.browserTarget, context);
|
17
|
+
let pathToManifestFile = (0, path_1.join)(context.root, projectConfig.sourceRoot, 'assets/module-federation.manifest.json');
|
18
18
|
if (options.pathToManifestFile) {
|
19
19
|
const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
|
20
20
|
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
|
package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
2
|
-
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
3
|
-
import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
|
4
1
|
import { ModuleFederationStaticServerSchema } from './schema';
|
2
|
+
import { ModuleFederationDevServerOptions } from '../module-federation-dev-server/schema';
|
3
|
+
import { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
4
|
+
import { StaticRemotesConfig } from '@nx/module-federation/src/utils';
|
5
5
|
export declare function startProxies(staticRemotesConfig: StaticRemotesConfig, hostServeOptions: ModuleFederationDevServerOptions, mappedLocationOfHost: string, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
|
6
6
|
pathToCert: string;
|
7
7
|
pathToKey: string;
|
package/src/executors/module-federation-static-server/module-federation-static-server.impl.js
CHANGED
@@ -2,23 +2,22 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.startProxies = startProxies;
|
4
4
|
exports.default = moduleFederationStaticServer;
|
5
|
+
const path_1 = require("path");
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
6
|
-
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
7
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
8
|
-
const utils_1 = require("@nx/module-federation/src/executors/utils");
|
9
|
-
const utils_2 = require("@nx/module-federation/src/utils");
|
10
|
-
const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
|
11
|
-
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
12
|
-
const child_process_1 = require("child_process");
|
13
7
|
const fs_1 = require("fs");
|
8
|
+
const utils_1 = require("@nx/module-federation/src/utils");
|
9
|
+
const utils_2 = require("@nx/module-federation/src/executors/utils");
|
10
|
+
const child_process_1 = require("child_process");
|
14
11
|
const process = require("node:process");
|
15
|
-
const
|
12
|
+
const file_server_impl_1 = require("@nx/web/src/executors/file-server/file-server.impl");
|
13
|
+
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
14
|
+
const wait_for_port_open_1 = require("@nx/web/src/utils/wait-for-port-open");
|
16
15
|
function getBuildAndServeOptionsFromServeTarget(serveTarget, context) {
|
17
16
|
const target = (0, devkit_1.parseTargetString)(serveTarget, context);
|
18
17
|
const serveOptions = (0, devkit_1.readTargetOptions)(target, context);
|
19
18
|
const buildTarget = (0, devkit_1.parseTargetString)(serveOptions.buildTarget, context);
|
20
19
|
const buildOptions = (0, devkit_1.readTargetOptions)(buildTarget, context);
|
21
|
-
let pathToManifestFile = (0, path_1.join)(context.root,
|
20
|
+
let pathToManifestFile = (0, path_1.join)(context.root, context.projectGraph.nodes[context.projectName].data.sourceRoot, 'assets/module-federation.manifest.json');
|
22
21
|
if (serveOptions.pathToManifestFile) {
|
23
22
|
const userPathToManifestFile = (0, path_1.join)(context.root, serveOptions.pathToManifestFile);
|
24
23
|
if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
|
@@ -164,15 +163,15 @@ async function* moduleFederationStaticServer(schema, context) {
|
|
164
163
|
// Get the remotes from the module federation config
|
165
164
|
const p = context.projectsConfigurations.projects[context.projectName];
|
166
165
|
const options = getBuildAndServeOptionsFromServeTarget(schema.serveTarget, context);
|
167
|
-
const moduleFederationConfig = (0,
|
168
|
-
const remotes = (0,
|
166
|
+
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(options.buildOptions.tsConfig, context.root, p.root, 'react');
|
167
|
+
const remotes = (0, utils_1.getRemotes)([], options.serveOptions.skipRemotes, moduleFederationConfig, {
|
169
168
|
projectName: context.projectName,
|
170
169
|
projectGraph: context.projectGraph,
|
171
170
|
root: context.root,
|
172
171
|
}, options.pathToManifestFile);
|
173
|
-
const staticRemotesConfig = (0,
|
172
|
+
const staticRemotesConfig = (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
174
173
|
options.serveOptions.staticRemotesPort ??= remotes.staticRemotePort;
|
175
|
-
const mappedLocationsOfStaticRemotes = await (0,
|
174
|
+
const mappedLocationsOfStaticRemotes = await (0, utils_2.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options.serveOptions);
|
176
175
|
// Build the host
|
177
176
|
const hostUrlSegment = (0, path_1.basename)(options.buildOptions.outputPath);
|
178
177
|
const mappedLocationOfHost = `http${options.serveOptions.ssl ? 's' : ''}://${options.serveOptions.host}:${options.serveOptions.staticRemotesPort}/${hostUrlSegment}`;
|
@@ -89,7 +89,7 @@ function createRspackBuildTarget(options) {
|
|
89
89
|
styles: options.styledModule || !options.hasStyles
|
90
90
|
? []
|
91
91
|
: [
|
92
|
-
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style
|
92
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
|
93
93
|
],
|
94
94
|
scripts: [],
|
95
95
|
configurations: {
|
@@ -151,7 +151,7 @@ function createBuildTarget(options) {
|
|
151
151
|
styles: options.styledModule || !options.hasStyles
|
152
152
|
? []
|
153
153
|
: [
|
154
|
-
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style
|
154
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/styles.${options.style}`),
|
155
155
|
],
|
156
156
|
scripts: [],
|
157
157
|
webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
|
@@ -4,17 +4,16 @@ exports.createComponentStoriesFile = createComponentStoriesFile;
|
|
4
4
|
exports.findPropsAndGenerateFile = findPropsAndGenerateFile;
|
5
5
|
exports.componentStoryGenerator = componentStoryGenerator;
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
7
|
-
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
8
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
9
7
|
const ast_utils_1 = require("../../utils/ast-utils");
|
10
8
|
const component_props_1 = require("../../utils/component-props");
|
9
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
11
10
|
let tsModule;
|
12
11
|
function createComponentStoriesFile(host, { project, componentPath, interactionTests }) {
|
13
12
|
if (!tsModule) {
|
14
13
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
15
14
|
}
|
16
15
|
const proj = (0, devkit_1.getProjects)(host).get(project);
|
17
|
-
const componentFilePath = (0, devkit_1.joinPathFragments)(
|
16
|
+
const componentFilePath = (0, devkit_1.joinPathFragments)(proj.sourceRoot ?? proj.root, componentPath);
|
18
17
|
const componentDirectory = componentFilePath.replace(componentFilePath.slice(componentFilePath.lastIndexOf('/')), '');
|
19
18
|
const isPlainJs = componentFilePath.endsWith('.jsx') || componentFilePath.endsWith('.js');
|
20
19
|
const componentFileName = componentFilePath
|
@@ -2,12 +2,11 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.componentTestGenerator = componentTestGenerator;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
6
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
7
5
|
const path_1 = require("path");
|
8
6
|
const ast_utils_1 = require("../../utils/ast-utils");
|
9
7
|
const component_props_1 = require("../../utils/component-props");
|
10
8
|
const versions_1 = require("../../utils/versions");
|
9
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
11
10
|
let tsModule;
|
12
11
|
async function componentTestGenerator(tree, options) {
|
13
12
|
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
@@ -16,11 +15,10 @@ async function componentTestGenerator(tree, options) {
|
|
16
15
|
// normalize any windows paths
|
17
16
|
options.componentPath = options.componentPath.replace(/\\/g, '/');
|
18
17
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
19
|
-
const
|
20
|
-
|
21
|
-
? (0, path_1.relative)(sourceRoot, options.componentPath)
|
18
|
+
const normalizedPath = options.componentPath.startsWith(projectConfig.sourceRoot)
|
19
|
+
? (0, path_1.relative)(projectConfig.sourceRoot, options.componentPath)
|
22
20
|
: options.componentPath;
|
23
|
-
const componentPath = (0, devkit_1.joinPathFragments)(sourceRoot, normalizedPath);
|
21
|
+
const componentPath = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, normalizedPath);
|
24
22
|
if (tree.exists(componentPath)) {
|
25
23
|
generateSpecsForComponents(tree, componentPath);
|
26
24
|
}
|
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addFiles = addFiles;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
6
5
|
const versions_1 = require("nx/src/utils/versions");
|
7
6
|
const ct_utils_1 = require("../../../utils/ct-utils");
|
8
7
|
const component_test_1 = require("../../component-test/component-test");
|
@@ -33,8 +32,7 @@ async function addFiles(tree, projectConfig, options, found) {
|
|
33
32
|
}
|
34
33
|
if (options.generateTests) {
|
35
34
|
const filePaths = [];
|
36
|
-
|
37
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, sourceRoot, (filePath) => {
|
35
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.sourceRoot, (filePath) => {
|
38
36
|
if ((0, ct_utils_1.isComponent)(tree, filePath)) {
|
39
37
|
filePaths.push(filePath);
|
40
38
|
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin
|
2
|
-
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin
|
3
|
-
import { NxModuleFederationPlugin, NxModuleFederationSSRDevServerPlugin } from '@nx/module-federation/rspack
|
1
|
+
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin';
|
2
|
+
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin';
|
3
|
+
import { NxModuleFederationPlugin, NxModuleFederationSSRDevServerPlugin } from '@nx/module-federation/rspack';
|
4
4
|
import { join } from 'path';
|
5
5
|
|
6
6
|
import browserMfConfig from './module-federation.config';
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin
|
2
|
-
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin
|
3
|
-
import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack
|
1
|
+
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin';
|
2
|
+
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin';
|
3
|
+
import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack';
|
4
4
|
import { ModuleFederationConfig } from '@nx/module-federation';
|
5
5
|
import { join } from 'path';
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin
|
2
|
-
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin
|
3
|
-
import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack
|
1
|
+
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin';
|
2
|
+
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin';
|
3
|
+
import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack';
|
4
4
|
import { join } from 'path';
|
5
5
|
|
6
6
|
import config from './module-federation.config';
|
package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import {composePlugins, withNx} from '@nx/webpack';
|
2
2
|
import {withReact} from '@nx/react';
|
3
|
-
import {withModuleFederationForSSR} from '@nx/module-federation/webpack
|
3
|
+
import {withModuleFederationForSSR} from '@nx/module-federation/webpack';
|
4
4
|
|
5
5
|
import baseConfig from './module-federation.config';
|
6
6
|
|
package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { composePlugins, withNx } from '@nx/webpack';
|
2
2
|
import { withReact } from '@nx/react';
|
3
|
-
import { withModuleFederation } from '@nx/module-federation/webpack
|
3
|
+
import { withModuleFederation } from '@nx/module-federation/webpack';
|
4
4
|
import { ModuleFederationConfig } from '@nx/module-federation';
|
5
5
|
|
6
6
|
import baseConfig from './module-federation.config';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {composePlugins, withNx} from '@nx/webpack';
|
2
2
|
import {withReact} from '@nx/react';
|
3
|
-
import {withModuleFederation} from '@nx/module-federation/webpack
|
3
|
+
import {withModuleFederation} from '@nx/module-federation/webpack';
|
4
4
|
import { ModuleFederationConfig } from '@nx/module-federation';
|
5
5
|
|
6
6
|
import baseConfig from './module-federation.config';
|
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addModuleFederationFiles = addModuleFederationFiles;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
6
5
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
7
6
|
const create_application_files_1 = require("../../application/lib/create-application-files");
|
8
7
|
function addModuleFederationFiles(host, options, defaultRemoteManifest) {
|
@@ -34,7 +33,7 @@ function addModuleFederationFiles(host, options, defaultRemoteManifest) {
|
|
34
33
|
}),
|
35
34
|
};
|
36
35
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
37
|
-
const pathToMFManifest = (0, devkit_1.joinPathFragments)(
|
36
|
+
const pathToMFManifest = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'assets/module-federation.manifest.json');
|
38
37
|
// Module federation requires bootstrap code to be dynamically imported.
|
39
38
|
// Renaming original entry file so we can use `import(./bootstrap)` in
|
40
39
|
// new entry file.
|
@@ -56,7 +56,7 @@ async function normalizeOptions(host, options) {
|
|
56
56
|
if (appProjectType !== 'application') {
|
57
57
|
throw new Error(`appProject expected type of "application" but got "${appProjectType}"`);
|
58
58
|
}
|
59
|
-
const appSourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(appProjectConfig,
|
59
|
+
const appSourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(host, appProjectConfig.sourceRoot, appProjectConfig.root);
|
60
60
|
normalized.appMain =
|
61
61
|
appProjectConfig.targets.build?.options?.main ??
|
62
62
|
findMainEntry(host, appProjectConfig.root);
|
@@ -45,10 +45,6 @@ async function libraryGeneratorInternal(host, schema) {
|
|
45
45
|
!schema.importPath) {
|
46
46
|
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
47
47
|
}
|
48
|
-
if (schema.simpleName !== undefined && schema.simpleName !== false) {
|
49
|
-
// TODO(v22): Remove simpleName as user should be using name.
|
50
|
-
devkit_1.logger.warn(`The "--simpleName" option is deprecated and will be removed in Nx 22. Please use the "--name" option to provide the exact name you want for the library.`);
|
51
|
-
}
|
52
48
|
if (!options.component) {
|
53
49
|
options.style = 'none';
|
54
50
|
}
|
@@ -189,8 +189,7 @@
|
|
189
189
|
"simpleName": {
|
190
190
|
"description": "Don't include the directory in the name of the module of the library.",
|
191
191
|
"type": "boolean",
|
192
|
-
"default": false
|
193
|
-
"x-deprecated": "Use the --name option to provide the exact name instead. This option will be removed in Nx 22."
|
192
|
+
"default": false
|
194
193
|
},
|
195
194
|
"useProjectJson": {
|
196
195
|
"type": "boolean",
|
@@ -1,14 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.reduxGenerator = reduxGenerator;
|
4
|
+
const path = require("path");
|
5
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
6
|
+
const versions_1 = require("../../utils/versions");
|
4
7
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
6
8
|
const js_1 = require("@nx/js");
|
7
9
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
10
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
8
11
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
9
|
-
const path = require("path");
|
10
|
-
const ast_utils_1 = require("../../utils/ast-utils");
|
11
|
-
const versions_1 = require("../../utils/versions");
|
12
12
|
let tsModule;
|
13
13
|
async function reduxGenerator(host, schema) {
|
14
14
|
const options = await normalizeOptions(host, schema);
|
@@ -109,7 +109,7 @@ async function normalizeOptions(host, options) {
|
|
109
109
|
if (appConfig.projectType !== 'application') {
|
110
110
|
throw new Error(`Expected ${options.appProject} to be an application but got ${appConfig.projectType}`);
|
111
111
|
}
|
112
|
-
appProjectSourcePath =
|
112
|
+
appProjectSourcePath = appConfig.sourceRoot;
|
113
113
|
appMainFilePath = path.join(appProjectSourcePath, options.js ? 'main.js' : 'main.tsx');
|
114
114
|
if (!host.exists(appMainFilePath)) {
|
115
115
|
throw new Error(`Could not find ${appMainFilePath} during store configuration`);
|
package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin
|
2
|
-
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin
|
3
|
-
import { NxModuleFederationPlugin, NxModuleFederationSSRDevServerPlugin } from '@nx/module-federation/rspack
|
1
|
+
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin';
|
2
|
+
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin';
|
3
|
+
import { NxModuleFederationPlugin, NxModuleFederationSSRDevServerPlugin } from '@nx/module-federation/rspack';
|
4
4
|
import { join } from 'path';
|
5
5
|
|
6
6
|
import browserMfConfig from './module-federation.config';
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin
|
2
|
-
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin
|
3
|
-
import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack
|
1
|
+
import { NxAppRspackPlugin } from '@nx/rspack/app-plugin';
|
2
|
+
import { NxReactRspackPlugin } from '@nx/rspack/react-plugin';
|
3
|
+
import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack';
|
4
4
|
import { join } from 'path';
|
5
5
|
|
6
6
|
import config from './module-federation.config';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {composePlugins, withNx} from '@nx/webpack';
|
2
2
|
import {withReact} from '@nx/react';
|
3
|
-
import {withModuleFederationForSSR} from '@nx/module-federation/webpack
|
3
|
+
import {withModuleFederationForSSR} from '@nx/module-federation/webpack';
|
4
4
|
|
5
5
|
import baseConfig from "./module-federation.server.config";
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {composePlugins, withNx} from '@nx/webpack';
|
2
2
|
import {withReact} from '@nx/react';
|
3
|
-
import {withModuleFederation} from '@nx/module-federation/webpack
|
3
|
+
import {withModuleFederation} from '@nx/module-federation/webpack';
|
4
4
|
|
5
5
|
import baseConfig from './module-federation.config';
|
6
6
|
|
@@ -2,9 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.updateHostWithRemote = updateHostWithRemote;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
6
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
7
5
|
const ast_utils_1 = require("../../../module-federation/ast-utils");
|
6
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
8
7
|
let tsModule;
|
9
8
|
function updateHostWithRemote(host, hostName, remoteName) {
|
10
9
|
if (!tsModule) {
|
@@ -15,7 +14,7 @@ function updateHostWithRemote(host, hostName, remoteName) {
|
|
15
14
|
if (!host.exists(moduleFederationConfigPath)) {
|
16
15
|
moduleFederationConfigPath = (0, devkit_1.joinPathFragments)(hostConfig.root, 'module-federation.config.ts');
|
17
16
|
}
|
18
|
-
const appComponentPath = findAppComponentPath(host,
|
17
|
+
const appComponentPath = findAppComponentPath(host, hostConfig.sourceRoot);
|
19
18
|
if (host.exists(moduleFederationConfigPath)) {
|
20
19
|
// find the host project path
|
21
20
|
// Update remotes inside ${host_path}/src/remotes.d.ts
|
@@ -2,23 +2,22 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addModuleFederationFiles = addModuleFederationFiles;
|
4
4
|
exports.remoteGenerator = remoteGenerator;
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
6
5
|
const path_1 = require("path");
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
7
|
+
const normalize_options_1 = require("../application/lib/normalize-options");
|
8
|
+
const application_1 = require("../application/application");
|
9
|
+
const update_host_with_remote_1 = require("./lib/update-host-with-remote");
|
10
10
|
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
11
|
+
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
12
|
+
const setup_ssr_for_remote_1 = require("./lib/setup-ssr-for-remote");
|
13
|
+
const setup_tspath_for_remote_1 = require("./lib/setup-tspath-for-remote");
|
14
|
+
const add_remote_to_dynamic_host_1 = require("./lib/add-remote-to-dynamic-host");
|
11
15
|
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
12
16
|
const maybe_js_1 = require("../../utils/maybe-js");
|
17
|
+
const js_1 = require("@nx/js");
|
13
18
|
const versions_1 = require("../../utils/versions");
|
14
|
-
const
|
19
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
15
20
|
const create_application_files_1 = require("../application/lib/create-application-files");
|
16
|
-
const normalize_options_1 = require("../application/lib/normalize-options");
|
17
|
-
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
18
|
-
const add_remote_to_dynamic_host_1 = require("./lib/add-remote-to-dynamic-host");
|
19
|
-
const setup_ssr_for_remote_1 = require("./lib/setup-ssr-for-remote");
|
20
|
-
const setup_tspath_for_remote_1 = require("./lib/setup-tspath-for-remote");
|
21
|
-
const update_host_with_remote_1 = require("./lib/update-host-with-remote");
|
22
21
|
function addModuleFederationFiles(host, options) {
|
23
22
|
const templateVariables = options.bundler === 'rspack'
|
24
23
|
? {
|
@@ -136,7 +135,7 @@ async function remoteGenerator(host, schema) {
|
|
136
135
|
}
|
137
136
|
if (options.host && options.dynamic) {
|
138
137
|
const hostConfig = (0, devkit_1.readProjectConfiguration)(host, schema.host);
|
139
|
-
const pathToMFManifest = (0, devkit_1.joinPathFragments)(
|
138
|
+
const pathToMFManifest = (0, devkit_1.joinPathFragments)(hostConfig.sourceRoot, 'assets/module-federation.manifest.json');
|
140
139
|
(0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.projectName, options.devServerPort, pathToMFManifest);
|
141
140
|
}
|
142
141
|
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
|
@@ -2,11 +2,10 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.setupSsrGenerator = setupSsrGenerator;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
+
const versions_1 = require("../../utils/versions");
|
6
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
5
7
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
6
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
7
8
|
const path_1 = require("path");
|
8
|
-
const ast_utils_1 = require("../../utils/ast-utils");
|
9
|
-
const versions_1 = require("../../utils/versions");
|
10
9
|
let tsModule;
|
11
10
|
function readEntryFile(host, path) {
|
12
11
|
if (!tsModule) {
|
@@ -44,7 +43,7 @@ async function setupSsrGenerator(tree, options) {
|
|
44
43
|
].map((importPath) => {
|
45
44
|
return {
|
46
45
|
importPath,
|
47
|
-
filePath: (0, devkit_1.joinPathFragments)(
|
46
|
+
filePath: (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot || projectConfig.root, `${importPath}.tsx`),
|
48
47
|
};
|
49
48
|
});
|
50
49
|
const appComponentInfo = appImportCandidates.find((candidate) => tree.exists(candidate.filePath));
|
@@ -4,13 +4,13 @@ exports.projectRootPath = projectRootPath;
|
|
4
4
|
exports.containsComponentDeclaration = containsComponentDeclaration;
|
5
5
|
exports.createAllStories = createAllStories;
|
6
6
|
exports.storiesGenerator = storiesGenerator;
|
7
|
+
const component_story_1 = require("../component-story/component-story");
|
8
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
7
9
|
const devkit_1 = require("@nx/devkit");
|
10
|
+
const path_1 = require("path");
|
11
|
+
const minimatch_1 = require("minimatch");
|
8
12
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
9
13
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
10
|
-
const minimatch_1 = require("minimatch");
|
11
|
-
const path_1 = require("path");
|
12
|
-
const ast_utils_1 = require("../../utils/ast-utils");
|
13
|
-
const component_story_1 = require("../component-story/component-story");
|
14
14
|
let tsModule;
|
15
15
|
async function projectRootPath(tree, config) {
|
16
16
|
let projectDir;
|
@@ -32,7 +32,7 @@ async function projectRootPath(tree, config) {
|
|
32
32
|
else {
|
33
33
|
projectDir = '.';
|
34
34
|
}
|
35
|
-
return (0, devkit_1.joinPathFragments)(
|
35
|
+
return (0, devkit_1.joinPathFragments)(config.sourceRoot ?? config.root, projectDir);
|
36
36
|
}
|
37
37
|
function containsComponentDeclaration(tree, componentPath) {
|
38
38
|
if (!tsModule) {
|
package/src/utils/versions.d.ts
CHANGED
@@ -45,7 +45,7 @@ export declare const isbotVersion = "^3.6.5";
|
|
45
45
|
export declare const corsVersion = "~2.8.5";
|
46
46
|
export declare const typesCorsVersion = "~2.8.12";
|
47
47
|
export declare const moduleFederationNodeVersion = "^2.6.26";
|
48
|
-
export declare const moduleFederationEnhancedVersion = "^0.
|
48
|
+
export declare const moduleFederationEnhancedVersion = "^0.9.0";
|
49
49
|
export declare const lessVersion = "3.12.2";
|
50
50
|
export declare const sassVersion = "^1.55.0";
|
51
51
|
export declare const rollupPluginUrlVersion = "^8.0.2";
|
package/src/utils/versions.js
CHANGED
@@ -52,7 +52,7 @@ exports.isbotVersion = '^3.6.5';
|
|
52
52
|
exports.corsVersion = '~2.8.5';
|
53
53
|
exports.typesCorsVersion = '~2.8.12';
|
54
54
|
exports.moduleFederationNodeVersion = '^2.6.26';
|
55
|
-
exports.moduleFederationEnhancedVersion = '^0.
|
55
|
+
exports.moduleFederationEnhancedVersion = '^0.9.0';
|
56
56
|
// style preprocessors
|
57
57
|
exports.lessVersion = '3.12.2';
|
58
58
|
exports.sassVersion = '^1.55.0';
|