@nx/react 16.9.0-beta.2 → 16.9.0-beta.4
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 +8 -9
- package/plugins/component-testing/index.js +3 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +1 -1
- package/src/module-federation/utils.d.ts +1 -1
- package/src/module-federation/utils.js +11 -5
- package/src/module-federation/with-module-federation.js +11 -0
- package/CHANGELOG.md +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "16.9.0-beta.
|
|
3
|
+
"version": "16.9.0-beta.4",
|
|
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": {
|
|
@@ -31,21 +31,20 @@
|
|
|
31
31
|
"migrations": "./migrations.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nrwl/react": "16.9.0-beta.2",
|
|
35
|
-
"@nx/devkit": "16.9.0-beta.2",
|
|
36
|
-
"@nx/js": "16.9.0-beta.2",
|
|
37
|
-
"@nx/linter": "16.9.0-beta.2",
|
|
38
|
-
"@nx/web": "16.9.0-beta.2",
|
|
39
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
40
35
|
"@svgr/webpack": "^8.0.1",
|
|
41
36
|
"chalk": "^4.1.0",
|
|
42
37
|
"file-loader": "^6.2.0",
|
|
43
38
|
"minimatch": "3.0.5",
|
|
44
|
-
"tslib": "^2.3.0"
|
|
39
|
+
"tslib": "^2.3.0",
|
|
40
|
+
"@nx/devkit": "16.9.0-beta.4",
|
|
41
|
+
"@nx/js": "16.9.0-beta.4",
|
|
42
|
+
"@nx/linter": "16.9.0-beta.4",
|
|
43
|
+
"@nx/web": "16.9.0-beta.4",
|
|
44
|
+
"@nrwl/react": "*"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"type": "commonjs"
|
|
50
|
-
"gitHead": "e11d538fa2c7266066d554d9405abab8e0a65040"
|
|
49
|
+
"type": "commonjs"
|
|
51
50
|
}
|
|
@@ -75,7 +75,7 @@ function nxComponentTestingPreset(pathToConfig, options) {
|
|
|
75
75
|
if (!buildTarget) {
|
|
76
76
|
throw new Error(`Unable to find the 'devServerTarget' executor option in the '${ctTargetName}' target of the '${ctProjectName}' project`);
|
|
77
77
|
}
|
|
78
|
-
webpackConfig = buildTargetWebpack(
|
|
78
|
+
webpackConfig = buildTargetWebpack(ctExecutorContext, buildTarget, ctProjectName);
|
|
79
79
|
}
|
|
80
80
|
catch (e) {
|
|
81
81
|
devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to build a webpack config with the project graph.
|
|
@@ -126,7 +126,8 @@ function withSchemaDefaults(target, context) {
|
|
|
126
126
|
options.generateIndexHtml ??= true;
|
|
127
127
|
return options;
|
|
128
128
|
}
|
|
129
|
-
function buildTargetWebpack(
|
|
129
|
+
function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
130
|
+
const graph = ctx.projectGraph;
|
|
130
131
|
const parsed = (0, devkit_1.parseTargetString)(buildTarget, graph);
|
|
131
132
|
const buildableProjectConfig = graph.nodes[parsed.project]?.data;
|
|
132
133
|
const ctProjectConfig = graph.nodes[componentTestingProjectName]?.data;
|
|
@@ -11,7 +11,7 @@ const child_process_1 = require("child_process");
|
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const tsnode_register_1 = require("@nx/js/src/utils/typescript/tsnode-register");
|
|
13
13
|
function getBuildOptions(buildTarget, context) {
|
|
14
|
-
const target = (0, devkit_1.parseTargetString)(buildTarget, context
|
|
14
|
+
const target = (0, devkit_1.parseTargetString)(buildTarget, context);
|
|
15
15
|
const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
|
|
16
16
|
return {
|
|
17
17
|
...buildOptions,
|
|
@@ -46,12 +46,18 @@ async function getModuleFederationConfig(mfConfig, options = { isServer: false }
|
|
|
46
46
|
};
|
|
47
47
|
(0, module_federation_1.applySharedFunction)(sharedDependencies, mfConfig.shared);
|
|
48
48
|
(0, module_federation_1.applyAdditionalShared)(sharedDependencies, mfConfig.additionalShared, projectGraph);
|
|
49
|
+
// Choose the correct mapRemotes function based on the server state.
|
|
49
50
|
const mapRemotesFunction = options.isServer ? module_federation_1.mapRemotesForSSR : module_federation_1.mapRemotes;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
// Determine the URL function, either from provided options or by using a default.
|
|
52
|
+
const determineRemoteUrlFunction = options.determineRemoteUrl
|
|
53
|
+
? options.determineRemoteUrl
|
|
54
|
+
: getFunctionDeterminateRemoteUrl(options.isServer);
|
|
55
|
+
// Map the remotes if they exist, otherwise default to an empty object.
|
|
56
|
+
let mappedRemotes = {};
|
|
57
|
+
if (mfConfig.remotes && mfConfig.remotes.length > 0) {
|
|
58
|
+
const isLibraryTypeVar = mfConfig.library?.type === 'var';
|
|
59
|
+
mappedRemotes = mapRemotesFunction(mfConfig.remotes, 'js', determineRemoteUrlFunction, isLibraryTypeVar);
|
|
60
|
+
}
|
|
55
61
|
return { sharedLibraries, sharedDependencies, mappedRemotes };
|
|
56
62
|
}
|
|
57
63
|
exports.getModuleFederationConfig = getModuleFederationConfig;
|
|
@@ -12,6 +12,10 @@ async function withModuleFederation(options) {
|
|
|
12
12
|
return (config, ctx) => {
|
|
13
13
|
config.output.uniqueName = options.name;
|
|
14
14
|
config.output.publicPath = 'auto';
|
|
15
|
+
if (options.library?.type === 'var') {
|
|
16
|
+
config.output.scriptType = 'text/javascript';
|
|
17
|
+
config.experiments.outputModule = false;
|
|
18
|
+
}
|
|
15
19
|
config.optimization = {
|
|
16
20
|
runtimeChunk: false,
|
|
17
21
|
};
|
|
@@ -28,6 +32,13 @@ async function withModuleFederation(options) {
|
|
|
28
32
|
shared: {
|
|
29
33
|
...sharedDependencies,
|
|
30
34
|
},
|
|
35
|
+
/**
|
|
36
|
+
* remoteType: 'script' is required for the remote to be loaded as a script tag.
|
|
37
|
+
* remotes will need to be defined as:
|
|
38
|
+
* { appX: 'appX@http://localhost:3001/remoteEntry.js' }
|
|
39
|
+
* { appY: 'appY@http://localhost:3002/remoteEntry.js' }
|
|
40
|
+
*/
|
|
41
|
+
...(options.library?.type === 'var' ? { remoteType: 'script' } : {}),
|
|
31
42
|
}), sharedLibraries.getReplacementPlugin());
|
|
32
43
|
return config;
|
|
33
44
|
};
|