@nx/webpack 21.1.2 → 21.1.3
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/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p style="text-align: center;">
|
|
2
2
|
<picture>
|
|
3
3
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
-
<img alt="Nx - Smart
|
|
4
|
+
<img alt="Nx - Smart Repos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
5
|
</picture>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
<hr>
|
|
22
22
|
|
|
23
|
-
# Nx: Smart
|
|
23
|
+
# Nx: Smart Repos · Fast Builds
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
An AI-first build platform that connects everything from your editor to CI. Helping you deliver fast, without breaking things.
|
|
26
26
|
|
|
27
27
|
This package is a [Webpack plugin for Nx](https://nx.dev/nx-api/webpack).
|
|
28
28
|
|
|
@@ -64,5 +64,5 @@ npx nx@latest init
|
|
|
64
64
|
- [Blog Posts About Nx](https://nx.dev/blog)
|
|
65
65
|
|
|
66
66
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
67
|
-
width="100%" alt="Nx - Smart
|
|
67
|
+
width="100%" alt="Nx - Smart Repos · Fast Builds"></a></p>
|
|
68
68
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "21.1.
|
|
3
|
+
"version": "21.1.3",
|
|
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": {
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"webpack-dev-server": "^5.2.1",
|
|
67
67
|
"webpack-node-externals": "^3.0.0",
|
|
68
68
|
"webpack-subresource-integrity": "^5.1.0",
|
|
69
|
-
"@nx/devkit": "21.1.
|
|
70
|
-
"@nx/js": "21.1.
|
|
69
|
+
"@nx/devkit": "21.1.3",
|
|
70
|
+
"@nx/js": "21.1.3"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
@@ -21,8 +21,10 @@ const IGNORED_WEBPACK_WARNINGS = [
|
|
|
21
21
|
/could not find any license/i,
|
|
22
22
|
];
|
|
23
23
|
const extensionAlias = {
|
|
24
|
-
'.js': ['.ts', '.js'],
|
|
24
|
+
'.js': ['.ts', '.tsx', '.js', '.jsx'],
|
|
25
25
|
'.mjs': ['.mts', '.mjs'],
|
|
26
|
+
'.cjs': ['.cts', '.cjs'],
|
|
27
|
+
'.jsx': ['.tsx', '.jsx'],
|
|
26
28
|
};
|
|
27
29
|
const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
|
|
28
30
|
const mainFields = ['module', 'main'];
|
|
@@ -281,27 +283,11 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
|
281
283
|
const modulesDir = `${options.root}/node_modules`;
|
|
282
284
|
const graph = options.projectGraph;
|
|
283
285
|
const projectName = options.projectName;
|
|
284
|
-
const deps = graph?.dependencies?.[projectName] ?? [];
|
|
285
286
|
// Collect non-buildable TS project references so that they are bundled
|
|
286
287
|
// in the final output. This is needed for projects that are not buildable
|
|
287
|
-
// but are referenced by buildable projects.
|
|
288
|
-
// solution setup.
|
|
288
|
+
// but are referenced by buildable projects.
|
|
289
289
|
const nonBuildableWorkspaceLibs = isUsingTsSolution
|
|
290
|
-
?
|
|
291
|
-
.filter((dep) => {
|
|
292
|
-
const node = graph.nodes?.[dep.target];
|
|
293
|
-
if (!node || node.type !== 'lib')
|
|
294
|
-
return false;
|
|
295
|
-
const hasBuildTarget = 'build' in (node.data?.targets ?? {});
|
|
296
|
-
if (hasBuildTarget) {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
// If there is no build target we check the package exports to see if they reference
|
|
300
|
-
// source files
|
|
301
|
-
return !(0, utils_1.isBuildableLibrary)(node);
|
|
302
|
-
})
|
|
303
|
-
.map((dep) => graph.nodes?.[dep.target]?.data?.metadata?.js?.packageName)
|
|
304
|
-
.filter((name) => !!name)
|
|
290
|
+
? (0, utils_1.getNonBuildableLibs)(graph, projectName)
|
|
305
291
|
: [];
|
|
306
292
|
externals.push(nodeExternals({ modulesDir, allowlist: nonBuildableWorkspaceLibs }));
|
|
307
293
|
}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ProjectGraph, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
2
|
/**
|
|
3
3
|
* Check if the library is buildable.
|
|
4
4
|
* @param node from the project graph
|
|
5
5
|
* @returns boolean
|
|
6
6
|
*/
|
|
7
7
|
export declare function isBuildableLibrary(node: ProjectGraphProjectNode): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Get all transitive dependencies of a target that are non-buildable libraries.
|
|
10
|
+
* This function traverses the project graph to find all dependencies of a given target,
|
|
11
|
+
* @param graph Graph of the project
|
|
12
|
+
* @param targetName The project name to get dependencies for
|
|
13
|
+
* @param visited Set to keep track of visited nodes to prevent infinite loops in circular dependencies
|
|
14
|
+
* @returns string[] - List of all transitive dependencies that are non-buildable libraries
|
|
15
|
+
*/
|
|
16
|
+
export declare function getAllTransitiveDeps(graph: ProjectGraph, targetName: string, visited?: Set<string>): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Get all non-buildable libraries in the project graph for a given project.
|
|
19
|
+
* This function retrieves all direct and transitive dependencies of a project,
|
|
20
|
+
* filtering out only those that are libraries and not buildable.
|
|
21
|
+
* @param graph Project graph
|
|
22
|
+
* @param projectName The project name to get dependencies for
|
|
23
|
+
* @returns A list of all non-buildable libraries that the project depends on, including transitive dependencies.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNonBuildableLibs(graph: ProjectGraph, projectName: string): string[];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBuildableLibrary = isBuildableLibrary;
|
|
4
|
+
exports.getAllTransitiveDeps = getAllTransitiveDeps;
|
|
5
|
+
exports.getNonBuildableLibs = getNonBuildableLibs;
|
|
4
6
|
function isSourceFile(path) {
|
|
5
7
|
return ['.ts', '.tsx', '.mts', '.cts'].some((ext) => path.endsWith(ext));
|
|
6
8
|
}
|
|
@@ -46,3 +48,76 @@ function isBuildableLibrary(node) {
|
|
|
46
48
|
packageMain !== '' &&
|
|
47
49
|
!isSourceFile(packageMain));
|
|
48
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Get all transitive dependencies of a target that are non-buildable libraries.
|
|
53
|
+
* This function traverses the project graph to find all dependencies of a given target,
|
|
54
|
+
* @param graph Graph of the project
|
|
55
|
+
* @param targetName The project name to get dependencies for
|
|
56
|
+
* @param visited Set to keep track of visited nodes to prevent infinite loops in circular dependencies
|
|
57
|
+
* @returns string[] - List of all transitive dependencies that are non-buildable libraries
|
|
58
|
+
*/
|
|
59
|
+
function getAllTransitiveDeps(graph, targetName, visited = new Set()) {
|
|
60
|
+
if (visited.has(targetName)) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
visited.add(targetName);
|
|
64
|
+
const node = graph.nodes?.[targetName];
|
|
65
|
+
if (!node) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
// Get direct dependencies of this target
|
|
69
|
+
const directDeps = graph.dependencies?.[targetName] || [];
|
|
70
|
+
const transitiveDeps = [];
|
|
71
|
+
for (const dep of directDeps) {
|
|
72
|
+
const depNode = graph.nodes?.[dep.target];
|
|
73
|
+
// Only consider library dependencies
|
|
74
|
+
if (!depNode || depNode.type !== 'lib') {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// Check if this dependency is non-buildable
|
|
78
|
+
const hasBuildTarget = 'build' in (depNode.data?.targets ?? {});
|
|
79
|
+
const isBuildable = hasBuildTarget || isBuildableLibrary(depNode);
|
|
80
|
+
if (!isBuildable) {
|
|
81
|
+
const packageName = depNode.data?.metadata?.js?.packageName;
|
|
82
|
+
if (packageName) {
|
|
83
|
+
transitiveDeps.push(packageName);
|
|
84
|
+
}
|
|
85
|
+
const nestedDeps = getAllTransitiveDeps(graph, dep.target, visited);
|
|
86
|
+
transitiveDeps.push(...nestedDeps);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return transitiveDeps;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get all non-buildable libraries in the project graph for a given project.
|
|
93
|
+
* This function retrieves all direct and transitive dependencies of a project,
|
|
94
|
+
* filtering out only those that are libraries and not buildable.
|
|
95
|
+
* @param graph Project graph
|
|
96
|
+
* @param projectName The project name to get dependencies for
|
|
97
|
+
* @returns A list of all non-buildable libraries that the project depends on, including transitive dependencies.
|
|
98
|
+
*/
|
|
99
|
+
function getNonBuildableLibs(graph, projectName) {
|
|
100
|
+
const deps = graph?.dependencies?.[projectName] ?? [];
|
|
101
|
+
const allNonBuildable = new Set();
|
|
102
|
+
// First, find all direct non-buildable deps and add them App -> library
|
|
103
|
+
const directNonBuildable = deps.filter((dep) => {
|
|
104
|
+
const node = graph.nodes?.[dep.target];
|
|
105
|
+
if (!node || node.type !== 'lib')
|
|
106
|
+
return false;
|
|
107
|
+
const hasBuildTarget = 'build' in (node.data?.targets ?? {});
|
|
108
|
+
if (hasBuildTarget)
|
|
109
|
+
return false;
|
|
110
|
+
return !isBuildableLibrary(node);
|
|
111
|
+
});
|
|
112
|
+
// Add direct non-buildable dependencies
|
|
113
|
+
for (const dep of directNonBuildable) {
|
|
114
|
+
const packageName = graph.nodes?.[dep.target]?.data?.metadata?.js?.packageName;
|
|
115
|
+
if (packageName) {
|
|
116
|
+
allNonBuildable.add(packageName);
|
|
117
|
+
}
|
|
118
|
+
// Get all transitive non-buildable dependencies App -> library1 -> library2
|
|
119
|
+
const transitiveDeps = getAllTransitiveDeps(graph, dep.target);
|
|
120
|
+
transitiveDeps.forEach((pkg) => allNonBuildable.add(pkg));
|
|
121
|
+
}
|
|
122
|
+
return Array.from(allNonBuildable);
|
|
123
|
+
}
|