@nx/react 0.0.0-pr-29314-bfd9d0c → 0.0.0-pr-29636-b148ccc
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/LICENSE +1 -1
- package/migrations.json +12 -0
- package/package.json +6 -6
- package/plugins/jest.js +6 -11
- package/src/generators/application/lib/add-e2e.js +2 -1
- package/src/generators/host/host.js +2 -1
- package/src/generators/library/lib/determine-entry-fields.d.ts +3 -0
- package/src/generators/library/lib/determine-entry-fields.js +22 -0
- package/src/generators/library/library.js +2 -13
- package/src/generators/remote/remote.js +2 -1
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +11 -6
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +6 -0
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.d.ts +2 -0
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.js +18 -0
- package/src/utils/add-mf-env-to-inputs.d.ts +1 -1
- package/src/utils/add-mf-env-to-inputs.js +8 -11
- package/src/utils/has-rsbuild-plugin.d.ts +1 -1
- package/src/utils/has-rsbuild-plugin.js +5 -5
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
package/LICENSE
CHANGED
package/migrations.json
CHANGED
|
@@ -41,6 +41,18 @@
|
|
|
41
41
|
"version": "20.2.0-beta.2",
|
|
42
42
|
"description": "Update the withModuleFederation import use @nx/module-federation/webpack.",
|
|
43
43
|
"factory": "./src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package"
|
|
44
|
+
},
|
|
45
|
+
"ensure-nx-module-federation-package": {
|
|
46
|
+
"cli": "nx",
|
|
47
|
+
"version": "20.3.0-beta.2",
|
|
48
|
+
"description": "If workspace includes Module Federation projects, ensure the new @nx/module-federation package is installed.",
|
|
49
|
+
"factory": "./src/migrations/update-20-3-0/ensure-nx-module-federation-package"
|
|
50
|
+
},
|
|
51
|
+
"add-mf-env-var-to-target-defaults": {
|
|
52
|
+
"cli": "nx",
|
|
53
|
+
"version": "20.4.0-beta.0",
|
|
54
|
+
"description": "Add NX_MF_DEV_REMOTES to inputs for task hashing when '@nx/webpack:webpack' or '@nx/rspack:rspack' is used for Module Federation.",
|
|
55
|
+
"factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
|
|
44
56
|
}
|
|
45
57
|
},
|
|
46
58
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29636-b148ccc",
|
|
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": "0.0.0-pr-
|
|
42
|
-
"@nx/js": "0.0.0-pr-
|
|
43
|
-
"@nx/eslint": "0.0.0-pr-
|
|
44
|
-
"@nx/web": "0.0.0-pr-
|
|
45
|
-
"@nx/module-federation": "0.0.0-pr-
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-29636-b148ccc",
|
|
42
|
+
"@nx/js": "0.0.0-pr-29636-b148ccc",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-29636-b148ccc",
|
|
44
|
+
"@nx/web": "0.0.0-pr-29636-b148ccc",
|
|
45
|
+
"@nx/module-federation": "0.0.0-pr-29636-b148ccc",
|
|
46
46
|
"express": "^4.19.2",
|
|
47
47
|
"http-proxy-middleware": "^3.0.3"
|
|
48
48
|
},
|
package/plugins/jest.js
CHANGED
|
@@ -16,17 +16,12 @@ module.exports = {
|
|
|
16
16
|
module.exports = {
|
|
17
17
|
__esModule: true,
|
|
18
18
|
default: ${assetFilename},
|
|
19
|
-
ReactComponent:
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
props: Object.assign({}, props, {
|
|
26
|
-
children: ${assetFilename}
|
|
27
|
-
})
|
|
28
|
-
};
|
|
29
|
-
}),
|
|
19
|
+
ReactComponent: function ${componentName}(props) {
|
|
20
|
+
return React.createElement(
|
|
21
|
+
'svg',
|
|
22
|
+
Object.assign({}, props, { children: ${assetFilename} })
|
|
23
|
+
);
|
|
24
|
+
},
|
|
30
25
|
};`,
|
|
31
26
|
};
|
|
32
27
|
}
|
|
@@ -13,7 +13,8 @@ const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaul
|
|
|
13
13
|
async function addE2e(tree, options) {
|
|
14
14
|
const hasNxBuildPlugin = (options.bundler === 'webpack' && (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) ||
|
|
15
15
|
(options.bundler === 'rspack' && (0, has_rspack_plugin_1.hasRspackPlugin)(tree)) ||
|
|
16
|
-
(options.bundler === 'rsbuild' &&
|
|
16
|
+
(options.bundler === 'rsbuild' &&
|
|
17
|
+
(await (0, has_rsbuild_plugin_1.hasRsbuildPlugin)(tree, options.appProjectRoot))) ||
|
|
17
18
|
(options.bundler === 'vite' && (0, has_vite_plugin_1.hasVitePlugin)(tree));
|
|
18
19
|
let e2eWebServerInfo = {
|
|
19
20
|
e2eWebServerAddress: `http://localhost:${options.devServerPort ?? 4200}`,
|
|
@@ -104,9 +104,10 @@ async function hostGenerator(host, schema) {
|
|
|
104
104
|
if (!options.setParserOptionsProject) {
|
|
105
105
|
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
|
|
106
106
|
}
|
|
107
|
-
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
|
|
107
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
|
|
108
108
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion }, {
|
|
109
109
|
'@nx/web': versions_1.nxVersion,
|
|
110
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
110
111
|
});
|
|
111
112
|
tasks.push(installTask);
|
|
112
113
|
if (!options.skipFormat) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.determineEntryFields = determineEntryFields;
|
|
4
|
+
function determineEntryFields(options) {
|
|
5
|
+
if (options.bundler !== 'none') {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
main: options.js ? './src/index.js' : './src/index.ts',
|
|
10
|
+
types: options.js ? './src/index.js' : './src/index.ts',
|
|
11
|
+
exports: {
|
|
12
|
+
'.': options.js
|
|
13
|
+
? './src/index.js'
|
|
14
|
+
: {
|
|
15
|
+
types: './src/index.ts',
|
|
16
|
+
import: './src/index.ts',
|
|
17
|
+
default: './src/index.ts',
|
|
18
|
+
},
|
|
19
|
+
'./package.json': './package.json',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -21,7 +21,7 @@ const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
|
21
21
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
22
22
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
23
23
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
24
|
-
const
|
|
24
|
+
const determine_entry_fields_1 = require("./lib/determine-entry-fields");
|
|
25
25
|
async function libraryGenerator(host, schema) {
|
|
26
26
|
return await libraryGeneratorInternal(host, {
|
|
27
27
|
addPlugin: false,
|
|
@@ -48,16 +48,10 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
48
48
|
});
|
|
49
49
|
tasks.push(initTask);
|
|
50
50
|
if (options.isUsingTsSolutionConfig) {
|
|
51
|
-
const sourceEntry = options.bundler === 'none'
|
|
52
|
-
? options.js
|
|
53
|
-
? './src/index.js'
|
|
54
|
-
: './src/index.ts'
|
|
55
|
-
: undefined;
|
|
56
51
|
(0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
|
|
57
52
|
name: options.importPath,
|
|
58
53
|
version: '0.0.1',
|
|
59
|
-
|
|
60
|
-
types: sourceEntry,
|
|
54
|
+
...(0, determine_entry_fields_1.determineEntryFields)(options),
|
|
61
55
|
nx: {
|
|
62
56
|
name: options.importPath === options.name ? undefined : options.name,
|
|
63
57
|
projectType: 'library',
|
|
@@ -117,11 +111,6 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
117
111
|
const rollupTask = await (0, add_rollup_build_target_1.addRollupBuildTarget)(host, options);
|
|
118
112
|
tasks.push(rollupTask);
|
|
119
113
|
}
|
|
120
|
-
else if (options.bundler === 'none' && options.addPlugin) {
|
|
121
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
122
|
-
(0, plugin_1.ensureProjectIsExcludedFromPluginRegistrations)(nxJson, options.projectRoot);
|
|
123
|
-
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
124
|
-
}
|
|
125
114
|
// Set up test target
|
|
126
115
|
if (options.unitTestRunner === 'jest') {
|
|
127
116
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
@@ -122,10 +122,11 @@ async function remoteGenerator(host, schema) {
|
|
|
122
122
|
const pathToMFManifest = (0, devkit_1.joinPathFragments)(hostConfig.sourceRoot, 'assets/module-federation.manifest.json');
|
|
123
123
|
(0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.projectName, options.devServerPort, pathToMFManifest);
|
|
124
124
|
}
|
|
125
|
-
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
|
|
125
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host, options.bundler);
|
|
126
126
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
127
127
|
'@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
|
|
128
128
|
'@nx/web': versions_1.nxVersion,
|
|
129
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
129
130
|
});
|
|
130
131
|
tasks.push(installTask);
|
|
131
132
|
if (!options.skipFormat) {
|
|
@@ -4,10 +4,11 @@ exports.default = default_1;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
6
6
|
async function default_1(tree) {
|
|
7
|
-
|
|
7
|
+
const bundler = hasModuleFederationProject(tree);
|
|
8
|
+
if (!bundler) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
|
-
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
|
|
11
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree, bundler);
|
|
11
12
|
await (0, devkit_1.formatFiles)(tree);
|
|
12
13
|
}
|
|
13
14
|
function hasModuleFederationProject(tree) {
|
|
@@ -15,10 +16,14 @@ function hasModuleFederationProject(tree) {
|
|
|
15
16
|
for (const project of projects.values()) {
|
|
16
17
|
const targets = project.targets || {};
|
|
17
18
|
for (const [_, target] of Object.entries(targets)) {
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
|
|
20
|
+
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js'))) {
|
|
21
|
+
if (target.executor === '@nx/webpack:webpack') {
|
|
22
|
+
return 'webpack';
|
|
23
|
+
}
|
|
24
|
+
else if (target.executor === '@nx/rspack:rspack') {
|
|
25
|
+
return 'rspack';
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -4,6 +4,7 @@ exports.default = migrateWithMfImport;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
7
8
|
const NX_RSPACK_MODULE_FEDERATION_IMPORT_SELECTOR = 'ImportDeclaration > StringLiteral[value=@nx/react/module-federation], VariableStatement CallExpression:has(Identifier[name=require]) > StringLiteral[value=@nx/react/module-federation]';
|
|
8
9
|
const NEW_IMPORT_PATH = `'@nx/module-federation/webpack'`;
|
|
9
10
|
async function migrateWithMfImport(tree) {
|
|
@@ -31,5 +32,10 @@ async function migrateWithMfImport(tree) {
|
|
|
31
32
|
tree.write(filePath, contents);
|
|
32
33
|
});
|
|
33
34
|
}
|
|
35
|
+
if (projects.size !== 0) {
|
|
36
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
37
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
34
40
|
await (0, devkit_1.formatFiles)(tree);
|
|
35
41
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ensureMfPackage;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
async function ensureMfPackage(tree) {
|
|
8
|
+
const projects = new Set();
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', (options, project, target) => {
|
|
10
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
11
|
+
projects.add(projectConfig.root);
|
|
12
|
+
});
|
|
13
|
+
if (projects.size !== 0) {
|
|
14
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
15
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
export declare function addMfEnvToTargetDefaultInputs(tree: Tree): void;
|
|
2
|
+
export declare function addMfEnvToTargetDefaultInputs(tree: Tree, bundler: 'rspack' | 'webpack'): void;
|
|
@@ -2,27 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function addMfEnvToTargetDefaultInputs(tree) {
|
|
5
|
+
function addMfEnvToTargetDefaultInputs(tree, bundler) {
|
|
6
6
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
-
const
|
|
7
|
+
const executor = bundler === 'rspack' ? '@nx/rspack:rspack' : '@nx/webpack:webpack';
|
|
8
8
|
const mfEnvVar = 'NX_MF_DEV_REMOTES';
|
|
9
9
|
nxJson.targetDefaults ??= {};
|
|
10
|
-
nxJson.targetDefaults[
|
|
11
|
-
nxJson.targetDefaults[
|
|
12
|
-
|
|
13
|
-
'^production',
|
|
14
|
-
];
|
|
15
|
-
nxJson.targetDefaults[webpackExecutor].dependsOn ??= ['^build'];
|
|
10
|
+
nxJson.targetDefaults[executor] ??= {};
|
|
11
|
+
nxJson.targetDefaults[executor].inputs ??= ['production', '^production'];
|
|
12
|
+
nxJson.targetDefaults[executor].dependsOn ??= ['^build'];
|
|
16
13
|
let mfEnvVarExists = false;
|
|
17
|
-
for (const input of nxJson.targetDefaults[
|
|
14
|
+
for (const input of nxJson.targetDefaults[executor].inputs) {
|
|
18
15
|
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
|
19
16
|
mfEnvVarExists = true;
|
|
20
17
|
break;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
if (!mfEnvVarExists) {
|
|
24
|
-
nxJson.targetDefaults[
|
|
21
|
+
nxJson.targetDefaults[executor].inputs.push({ env: mfEnvVar });
|
|
25
22
|
}
|
|
26
|
-
nxJson.targetDefaults[
|
|
23
|
+
nxJson.targetDefaults[executor].cache = true;
|
|
27
24
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
28
25
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function hasRsbuildPlugin(tree: Tree): boolean
|
|
2
|
+
export declare function hasRsbuildPlugin(tree: Tree, projectPath?: string): Promise<boolean>;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasRsbuildPlugin = hasRsbuildPlugin;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const versions_1 = require("./versions");
|
|
6
|
+
async function hasRsbuildPlugin(tree, projectPath) {
|
|
7
|
+
(0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
|
|
8
|
+
const { hasRsbuildPlugin } = await Promise.resolve().then(() => require('@nx/rsbuild/config-utils'));
|
|
9
|
+
return hasRsbuildPlugin(tree, projectPath);
|
|
10
10
|
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export declare const typesExpressVersion = "4.17.17";
|
|
|
35
35
|
export declare const isbotVersion = "^3.6.5";
|
|
36
36
|
export declare const corsVersion = "~2.8.5";
|
|
37
37
|
export declare const typesCorsVersion = "~2.8.12";
|
|
38
|
-
export declare const moduleFederationNodeVersion = "
|
|
39
|
-
export declare const moduleFederationEnhancedVersion = "0.
|
|
38
|
+
export declare const moduleFederationNodeVersion = "^2.6.21";
|
|
39
|
+
export declare const moduleFederationEnhancedVersion = "^0.8.8";
|
|
40
40
|
export declare const lessVersion = "3.12.2";
|
|
41
41
|
export declare const sassVersion = "^1.55.0";
|
|
42
42
|
export declare const rollupPluginUrlVersion = "^8.0.2";
|
package/src/utils/versions.js
CHANGED
|
@@ -40,8 +40,8 @@ exports.typesExpressVersion = '4.17.17';
|
|
|
40
40
|
exports.isbotVersion = '^3.6.5';
|
|
41
41
|
exports.corsVersion = '~2.8.5';
|
|
42
42
|
exports.typesCorsVersion = '~2.8.12';
|
|
43
|
-
exports.moduleFederationNodeVersion = '
|
|
44
|
-
exports.moduleFederationEnhancedVersion = '0.
|
|
43
|
+
exports.moduleFederationNodeVersion = '^2.6.21';
|
|
44
|
+
exports.moduleFederationEnhancedVersion = '^0.8.8';
|
|
45
45
|
// style preprocessors
|
|
46
46
|
exports.lessVersion = '3.12.2';
|
|
47
47
|
exports.sassVersion = '^1.55.0';
|