@nx/webpack 16.9.0-beta.1 → 16.9.0-beta.2
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": "16.9.0-beta.
|
|
3
|
+
"version": "16.9.0-beta.2",
|
|
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": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/core": "^7.22.9",
|
|
33
|
-
"@nrwl/webpack": "16.9.0-beta.
|
|
34
|
-
"@nx/devkit": "16.9.0-beta.
|
|
35
|
-
"@nx/js": "16.9.0-beta.
|
|
33
|
+
"@nrwl/webpack": "16.9.0-beta.2",
|
|
34
|
+
"@nx/devkit": "16.9.0-beta.2",
|
|
35
|
+
"@nx/js": "16.9.0-beta.2",
|
|
36
36
|
"autoprefixer": "^10.4.9",
|
|
37
37
|
"babel-loader": "^9.1.2",
|
|
38
38
|
"browserslist": "^4.21.4",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
72
|
"type": "commonjs",
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "e11d538fa2c7266066d554d9405abab8e0a65040"
|
|
74
74
|
}
|
|
@@ -10,7 +10,7 @@ export type WorkspaceLibrary = {
|
|
|
10
10
|
};
|
|
11
11
|
export type SharedWorkspaceLibraryConfig = {
|
|
12
12
|
getAliases: () => Record<string, string>;
|
|
13
|
-
getLibraries: (eager?: boolean) => Record<string, SharedLibraryConfig>;
|
|
13
|
+
getLibraries: (projectRoot: string, eager?: boolean) => Record<string, SharedLibraryConfig>;
|
|
14
14
|
getReplacementPlugin: () => NormalModuleReplacementPlugin;
|
|
15
15
|
};
|
|
16
16
|
export type Remotes = string[] | [remoteName: string, remoteUrl: string][];
|
|
@@ -5,10 +5,10 @@ import { type ProjectGraph } from '@nx/devkit';
|
|
|
5
5
|
* Build an object of functions to be used with the ModuleFederationPlugin to
|
|
6
6
|
* share Nx Workspace Libraries between Hosts and Remotes.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
8
|
+
* @param workspaceLibs - The Nx Workspace Libraries to share
|
|
9
9
|
* @param tsConfigPath - The path to TS Config File that contains the Path Mappings for the Libraries
|
|
10
10
|
*/
|
|
11
|
-
export declare function shareWorkspaceLibraries(
|
|
11
|
+
export declare function shareWorkspaceLibraries(workspaceLibs: WorkspaceLibrary[], tsConfigPath?: string): SharedWorkspaceLibraryConfig;
|
|
12
12
|
/**
|
|
13
13
|
* Build the Module Federation Share Config for a specific package and the
|
|
14
14
|
* specified version of that package.
|
|
@@ -6,15 +6,16 @@ const package_json_1 = require("./package-json");
|
|
|
6
6
|
const typescript_1 = require("./typescript");
|
|
7
7
|
const secondary_entry_points_1 = require("./secondary-entry-points");
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const fs_1 = require("fs");
|
|
9
10
|
/**
|
|
10
11
|
* Build an object of functions to be used with the ModuleFederationPlugin to
|
|
11
12
|
* share Nx Workspace Libraries between Hosts and Remotes.
|
|
12
13
|
*
|
|
13
|
-
* @param
|
|
14
|
+
* @param workspaceLibs - The Nx Workspace Libraries to share
|
|
14
15
|
* @param tsConfigPath - The path to TS Config File that contains the Path Mappings for the Libraries
|
|
15
16
|
*/
|
|
16
|
-
function shareWorkspaceLibraries(
|
|
17
|
-
if (!
|
|
17
|
+
function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TSCONFIG_PATH ?? (0, typescript_1.getRootTsConfigPath)()) {
|
|
18
|
+
if (!workspaceLibs) {
|
|
18
19
|
return getEmptySharedLibrariesConfig();
|
|
19
20
|
}
|
|
20
21
|
const tsconfigPathAliases = (0, typescript_1.readTsPathMappings)(tsConfigPath);
|
|
@@ -23,7 +24,7 @@ function shareWorkspaceLibraries(libraries, tsConfigPath = process.env.NX_TSCONF
|
|
|
23
24
|
}
|
|
24
25
|
const pathMappings = [];
|
|
25
26
|
for (const [key, paths] of Object.entries(tsconfigPathAliases)) {
|
|
26
|
-
const library =
|
|
27
|
+
const library = workspaceLibs.find((lib) => lib.importKey === key);
|
|
27
28
|
if (!library) {
|
|
28
29
|
continue;
|
|
29
30
|
}
|
|
@@ -41,10 +42,41 @@ function shareWorkspaceLibraries(libraries, tsConfigPath = process.env.NX_TSCONF
|
|
|
41
42
|
const webpack = require('webpack');
|
|
42
43
|
return {
|
|
43
44
|
getAliases: () => pathMappings.reduce((aliases, library) => ({ ...aliases, [library.name]: library.path }), {}),
|
|
44
|
-
getLibraries: (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
getLibraries: (projectRoot, eager) => {
|
|
46
|
+
let pkgJson = null;
|
|
47
|
+
if (projectRoot &&
|
|
48
|
+
(0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot, 'package.json'))) {
|
|
49
|
+
pkgJson = (0, devkit_1.readJsonFile)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot, 'package.json'));
|
|
50
|
+
}
|
|
51
|
+
return pathMappings.reduce((libraries, library) => {
|
|
52
|
+
// Check to see if the library version is declared in the app's package.json
|
|
53
|
+
let version = pkgJson?.dependencies?.[library.name];
|
|
54
|
+
if (!version && workspaceLibs.length > 0) {
|
|
55
|
+
const workspaceLib = workspaceLibs.find((lib) => lib.importKey === library.name);
|
|
56
|
+
const libPackageJsonPath = workspaceLib
|
|
57
|
+
? (0, path_1.join)(workspaceLib.root, 'package.json')
|
|
58
|
+
: null;
|
|
59
|
+
if (libPackageJsonPath && (0, fs_1.existsSync)(libPackageJsonPath)) {
|
|
60
|
+
pkgJson = (0, devkit_1.readJsonFile)(libPackageJsonPath);
|
|
61
|
+
if (pkgJson) {
|
|
62
|
+
version = pkgJson.version;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...libraries,
|
|
68
|
+
[library.name]: {
|
|
69
|
+
...(version
|
|
70
|
+
? {
|
|
71
|
+
requiredVersion: version,
|
|
72
|
+
singleton: true,
|
|
73
|
+
}
|
|
74
|
+
: { requiredVersion: false }),
|
|
75
|
+
eager,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}, {});
|
|
79
|
+
},
|
|
48
80
|
getReplacementPlugin: () => new webpack.NormalModuleReplacementPlugin(/./, (req) => {
|
|
49
81
|
if (!req.request.startsWith('.')) {
|
|
50
82
|
return;
|