@nx/rspack 20.7.2 → 20.8.0-beta.0
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 +5 -5
- package/src/generators/convert-webpack/convert-webpack.js +23 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/plugins/utils/apply-base-config.js +26 -1
- package/src/plugins/utils/is-lib-buildable.d.ts +7 -0
- package/src/plugins/utils/is-lib-buildable.js +48 -0
- package/src/utils/e2e-web-server-info-utils.d.ts +2 -0
- package/src/utils/e2e-web-server-info-utils.js +25 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rspack",
|
|
3
3
|
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
|
|
4
|
-
"version": "20.
|
|
4
|
+
"version": "20.8.0-beta.0",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"generators": "./generators.json",
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nx/js": "20.
|
|
28
|
-
"@nx/devkit": "20.
|
|
29
|
-
"@nx/web": "20.
|
|
30
|
-
"@nx/module-federation": "20.
|
|
27
|
+
"@nx/js": "20.8.0-beta.0",
|
|
28
|
+
"@nx/devkit": "20.8.0-beta.0",
|
|
29
|
+
"@nx/web": "20.8.0-beta.0",
|
|
30
|
+
"@nx/module-federation": "20.8.0-beta.0",
|
|
31
31
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
32
32
|
"@rspack/core": "^1.1.5",
|
|
33
33
|
"@rspack/dev-server": "^1.0.9",
|
|
@@ -57,6 +57,29 @@ async function default_1(tree, options) {
|
|
|
57
57
|
transformConfigFile(tree, rspackConfigPath);
|
|
58
58
|
}
|
|
59
59
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
60
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
61
|
+
if (nxJson.plugins !== undefined && nxJson.plugins.length > 0) {
|
|
62
|
+
const nonRspackPlugins = nxJson.plugins.filter((plugin) => (typeof plugin !== 'string' && plugin.plugin !== '@nx/rspack/plugin') ||
|
|
63
|
+
(typeof plugin === 'string' && plugin !== '@nx/rspack/plugin'));
|
|
64
|
+
let rspackPlugins = nxJson.plugins.filter((plugin) => (typeof plugin !== 'string' && plugin.plugin === '@nx/rspack/plugin') ||
|
|
65
|
+
(typeof plugin === 'string' && plugin === '@nx/rspack/plugin'));
|
|
66
|
+
if (rspackPlugins.length === 0) {
|
|
67
|
+
rspackPlugins = rspackPlugins.map((plugin) => {
|
|
68
|
+
if (typeof plugin === 'string') {
|
|
69
|
+
return {
|
|
70
|
+
plugin: plugin,
|
|
71
|
+
exclude: [`${project.root}/*`],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...plugin,
|
|
76
|
+
exclude: [...(plugin.exclude ?? []), `${project.root}/*`],
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
nxJson.plugins = [...nonRspackPlugins, ...rspackPlugins];
|
|
80
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
60
83
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
61
84
|
'@rspack/core': versions_1.rspackCoreVersion,
|
|
62
85
|
'@rspack/dev-server': versions_1.rspackDevServerVersion,
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -7,4 +7,5 @@ tslib_1.__exportStar(require("./utils/config"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./utils/with-nx"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./utils/with-react"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./utils/with-web"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./utils/e2e-web-server-info-utils"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./plugins/use-legacy-nx-plugin/use-legacy-nx-plugin"), exports);
|
|
@@ -13,6 +13,7 @@ const nx_tsconfig_paths_rspack_plugin_1 = require("./plugins/nx-tsconfig-paths-r
|
|
|
13
13
|
const get_terser_ecma_version_1 = require("./get-terser-ecma-version");
|
|
14
14
|
const nodeExternals = require("webpack-node-externals");
|
|
15
15
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
16
|
+
const is_lib_buildable_1 = require("./is-lib-buildable");
|
|
16
17
|
const IGNORED_RSPACK_WARNINGS = [
|
|
17
18
|
/The comment file/i,
|
|
18
19
|
/could not find any license/i,
|
|
@@ -276,7 +277,31 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
|
276
277
|
if ((options.target === 'node' || options.target === 'async-node') &&
|
|
277
278
|
options.externalDependencies === 'all') {
|
|
278
279
|
const modulesDir = `${options.root}/node_modules`;
|
|
279
|
-
|
|
280
|
+
const graph = options.projectGraph;
|
|
281
|
+
const projectName = options.projectName;
|
|
282
|
+
const deps = graph?.dependencies?.[projectName] ?? [];
|
|
283
|
+
// Collect non-buildable TS project references so that they are bundled
|
|
284
|
+
// in the final output. This is needed for projects that are not buildable
|
|
285
|
+
// but are referenced by buildable projects. This is needed for the new TS
|
|
286
|
+
// solution setup.
|
|
287
|
+
const nonBuildableWorkspaceLibs = isUsingTsSolution
|
|
288
|
+
? deps
|
|
289
|
+
.filter((dep) => {
|
|
290
|
+
const node = graph.nodes?.[dep.target];
|
|
291
|
+
if (!node || node.type !== 'lib')
|
|
292
|
+
return false;
|
|
293
|
+
const hasBuildTarget = 'build' in (node.data?.targets ?? {});
|
|
294
|
+
if (hasBuildTarget) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
// If there is no build target we check the package exports to see if they reference
|
|
298
|
+
// source files
|
|
299
|
+
return !(0, is_lib_buildable_1.isBuildableLibrary)(node);
|
|
300
|
+
})
|
|
301
|
+
.map((dep) => graph.nodes?.[dep.target]?.data?.metadata?.js?.packageName)
|
|
302
|
+
.filter((name) => !!name)
|
|
303
|
+
: [];
|
|
304
|
+
externals.push(nodeExternals({ modulesDir, allowlist: nonBuildableWorkspaceLibs }));
|
|
280
305
|
}
|
|
281
306
|
else if (Array.isArray(options.externalDependencies)) {
|
|
282
307
|
externals.push(function (ctx, callback) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBuildableLibrary = isBuildableLibrary;
|
|
4
|
+
function isSourceFile(path) {
|
|
5
|
+
return ['.ts', '.tsx', '.mts', '.cts'].some((ext) => path.endsWith(ext));
|
|
6
|
+
}
|
|
7
|
+
function isBuildableExportMap(packageExports) {
|
|
8
|
+
if (!packageExports || Object.keys(packageExports).length === 0) {
|
|
9
|
+
return false; // exports = {} → not buildable
|
|
10
|
+
}
|
|
11
|
+
const isCompiledExport = (value) => {
|
|
12
|
+
if (typeof value === 'string') {
|
|
13
|
+
return !isSourceFile(value);
|
|
14
|
+
}
|
|
15
|
+
if (typeof value === 'object' && value !== null) {
|
|
16
|
+
return Object.entries(value).some(([key, subValue]) => {
|
|
17
|
+
if (key === 'types' ||
|
|
18
|
+
key === 'development' ||
|
|
19
|
+
key === './package.json')
|
|
20
|
+
return false;
|
|
21
|
+
return typeof subValue === 'string' && !isSourceFile(subValue);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
if (packageExports['.']) {
|
|
27
|
+
return isCompiledExport(packageExports['.']);
|
|
28
|
+
}
|
|
29
|
+
return Object.entries(packageExports).some(([key, value]) => key !== '.' && isCompiledExport(value));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check if the library is buildable.
|
|
33
|
+
* @param node from the project graph
|
|
34
|
+
* @returns boolean
|
|
35
|
+
*/
|
|
36
|
+
function isBuildableLibrary(node) {
|
|
37
|
+
if (!node.data.metadata?.js) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const { packageExports, packageMain } = node.data.metadata.js;
|
|
41
|
+
// if we have exports only check this else fallback to packageMain
|
|
42
|
+
if (packageExports) {
|
|
43
|
+
return isBuildableExportMap(packageExports);
|
|
44
|
+
}
|
|
45
|
+
return (typeof packageMain === 'string' &&
|
|
46
|
+
packageMain !== '' &&
|
|
47
|
+
!isSourceFile(packageMain));
|
|
48
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export declare function getRspackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number): Promise<import("@nx/devkit/src/generators/e2e-web-server-info-utils").E2EWebServerDetails>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRspackE2EWebServerInfo = getRspackE2EWebServerInfo;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
|
|
6
|
+
async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride) {
|
|
7
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
8
|
+
let e2ePort = e2ePortOverride ?? 4200;
|
|
9
|
+
if (nxJson.targetDefaults?.['serve'] &&
|
|
10
|
+
nxJson.targetDefaults?.['serve'].options?.port) {
|
|
11
|
+
e2ePort = nxJson.targetDefaults?.['serve'].options?.port;
|
|
12
|
+
}
|
|
13
|
+
return (0, e2e_web_server_info_utils_1.getE2EWebServerInfo)(tree, projectName, {
|
|
14
|
+
plugin: '@nx/rspack/plugin',
|
|
15
|
+
serveTargetName: 'serveTargetName',
|
|
16
|
+
serveStaticTargetName: 'previewTargetName',
|
|
17
|
+
configFilePath,
|
|
18
|
+
}, {
|
|
19
|
+
defaultServeTargetName: 'serve',
|
|
20
|
+
defaultServeStaticTargetName: 'preview',
|
|
21
|
+
defaultE2EWebServerAddress: `http://localhost:${e2ePort}`,
|
|
22
|
+
defaultE2ECiBaseUrl: 'http://localhost:4200',
|
|
23
|
+
defaultE2EPort: e2ePort,
|
|
24
|
+
}, isPluginBeingAdded);
|
|
25
|
+
}
|