@nx/webpack 19.5.0 → 19.5.1
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/webpack",
|
|
3
|
-
"version": "19.5.
|
|
3
|
+
"version": "19.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@babel/core": "^7.23.2",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"@module-federation/sdk": "^0.2.3",
|
|
36
|
+
"@module-federation/enhanced": "^0.2.3",
|
|
36
37
|
"ajv": "^8.12.0",
|
|
37
38
|
"autoprefixer": "^10.4.9",
|
|
38
39
|
"babel-loader": "^9.1.2",
|
|
@@ -66,9 +67,9 @@
|
|
|
66
67
|
"webpack-dev-server": "^4.9.3",
|
|
67
68
|
"webpack-node-externals": "^3.0.0",
|
|
68
69
|
"webpack-subresource-integrity": "^5.1.0",
|
|
69
|
-
"@nx/devkit": "19.5.
|
|
70
|
-
"@nx/js": "19.5.
|
|
71
|
-
"@nrwl/webpack": "19.5.
|
|
70
|
+
"@nx/devkit": "19.5.1",
|
|
71
|
+
"@nx/js": "19.5.1",
|
|
72
|
+
"@nrwl/webpack": "19.5.1"
|
|
72
73
|
},
|
|
73
74
|
"publishConfig": {
|
|
74
75
|
"access": "public"
|
|
@@ -33,6 +33,12 @@ export interface ModuleFederationConfig {
|
|
|
33
33
|
exposes?: Record<string, string>;
|
|
34
34
|
shared?: SharedFunction;
|
|
35
35
|
additionalShared?: AdditionalSharedConfig;
|
|
36
|
+
/**
|
|
37
|
+
* `nxRuntimeLibraryControlPlugin` is a runtime module federation plugin to ensure
|
|
38
|
+
* that shared libraries are resolved from a remote with live reload capabilities.
|
|
39
|
+
* If you run into any issues with loading shared libraries, try disabling this option.
|
|
40
|
+
*/
|
|
41
|
+
disableNxRuntimeLibraryControlPlugin?: boolean;
|
|
36
42
|
}
|
|
37
43
|
export type NxModuleFederationConfigOverride = Omit<moduleFederationPlugin.ModuleFederationPluginOptions, 'exposes' | 'remotes' | 'name' | 'library' | 'shared' | 'filename' | 'remoteType'>;
|
|
38
44
|
export type WorkspaceLibrarySecondaryEntryPoint = {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtimeStore = {
|
|
4
|
+
sharedPackagesFromDev: {},
|
|
5
|
+
};
|
|
6
|
+
if (process.env.NX_MF_DEV_REMOTES) {
|
|
7
|
+
// process.env.NX_MF_DEV_REMOTES is replaced by an array value via DefinePlugin, even though the original value is a stringified array.
|
|
8
|
+
runtimeStore.devRemotes = process.env
|
|
9
|
+
.NX_MF_DEV_REMOTES;
|
|
10
|
+
}
|
|
11
|
+
const nxRuntimeLibraryControlPlugin = function () {
|
|
12
|
+
return {
|
|
13
|
+
name: 'nx-runtime-library-control-plugin',
|
|
14
|
+
beforeInit(args) {
|
|
15
|
+
runtimeStore.name = args.options.name;
|
|
16
|
+
return args;
|
|
17
|
+
},
|
|
18
|
+
resolveShare: (args) => {
|
|
19
|
+
const { shareScopeMap, scope, pkgName, version, GlobalFederation } = args;
|
|
20
|
+
const originalResolver = args.resolver;
|
|
21
|
+
args.resolver = function () {
|
|
22
|
+
if (!runtimeStore.sharedPackagesFromDev[pkgName]) {
|
|
23
|
+
if (!GlobalFederation.__INSTANCES__) {
|
|
24
|
+
return originalResolver();
|
|
25
|
+
}
|
|
26
|
+
else if (!runtimeStore.devRemotes) {
|
|
27
|
+
return originalResolver();
|
|
28
|
+
}
|
|
29
|
+
const devRemoteInstanceToUse = GlobalFederation.__INSTANCES__.find((instance) => instance.options.shared[pkgName] &&
|
|
30
|
+
runtimeStore.devRemotes.find((dr) => instance.name === dr));
|
|
31
|
+
if (!devRemoteInstanceToUse) {
|
|
32
|
+
return originalResolver();
|
|
33
|
+
}
|
|
34
|
+
runtimeStore.sharedPackagesFromDev[pkgName] =
|
|
35
|
+
devRemoteInstanceToUse.name;
|
|
36
|
+
}
|
|
37
|
+
const remoteInstanceName = runtimeStore.sharedPackagesFromDev[pkgName];
|
|
38
|
+
const remoteInstance = GlobalFederation.__INSTANCES__.find((instance) => instance.name === remoteInstanceName);
|
|
39
|
+
try {
|
|
40
|
+
const remotePkgInfo = remoteInstance.options.shared[pkgName].find((shared) => shared.from === remoteInstanceName);
|
|
41
|
+
remotePkgInfo.useIn.push(runtimeStore.name);
|
|
42
|
+
remotePkgInfo.useIn = Array.from(new Set(remotePkgInfo.useIn));
|
|
43
|
+
shareScopeMap[scope][pkgName][version] = remotePkgInfo;
|
|
44
|
+
return remotePkgInfo;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return originalResolver();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return args;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.default = nxRuntimeLibraryControlPlugin;
|