@nx/rspack 0.0.0-pr-30516-4c8bfff → 0.0.0-pr-30457-c50183c

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,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": "0.0.0-pr-30516-4c8bfff",
4
+ "version": "0.0.0-pr-30457-c50183c",
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": "0.0.0-pr-30516-4c8bfff",
28
- "@nx/devkit": "0.0.0-pr-30516-4c8bfff",
29
- "@nx/web": "0.0.0-pr-30516-4c8bfff",
30
- "@nx/module-federation": "0.0.0-pr-30516-4c8bfff",
27
+ "@nx/js": "0.0.0-pr-30457-c50183c",
28
+ "@nx/devkit": "0.0.0-pr-30457-c50183c",
29
+ "@nx/web": "0.0.0-pr-30457-c50183c",
30
+ "@nx/module-federation": "0.0.0-pr-30457-c50183c",
31
31
  "@phenomnomnominal/tsquery": "~5.0.1",
32
32
  "@rspack/core": "^1.1.5",
33
33
  "@rspack/dev-server": "^1.0.9",
@@ -31,8 +31,7 @@ function getDevServerOptions(root, serveOptions, buildOptions) {
31
31
  htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
32
32
  },
33
33
  onListening(server) {
34
- const isHttps = server.options.https ||
35
- server.options.server?.type === 'https';
34
+ const isHttps = server.options.server?.type === 'https';
36
35
  devkit_1.logger.info(`NX Web Development Server is listening at ${isHttps ? 'https' : 'http'}://${server.options.host}:${server.options.port}${(0, serve_path_1.buildServePath)(buildOptions)}`);
37
36
  },
38
37
  open: false,
@@ -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,
@@ -57,7 +57,6 @@ async function rspackInitGenerator(tree, schema) {
57
57
  const devDependencies = {
58
58
  '@rspack/core': versions_1.rspackCoreVersion,
59
59
  '@rspack/cli': versions_1.rspackCoreVersion,
60
- '@rspack/plugin-minify': versions_1.rspackPluginMinifyVersion,
61
60
  '@rspack/plugin-react-refresh': versions_1.rspackPluginReactRefreshVersion,
62
61
  'react-refresh': versions_1.reactRefreshVersion,
63
62
  };
package/src/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from './utils/config';
4
4
  export * from './utils/with-nx';
5
5
  export * from './utils/with-react';
6
6
  export * from './utils/with-web';
7
+ export * from './utils/e2e-web-server-info-utils';
7
8
  export * from './plugins/use-legacy-nx-plugin/use-legacy-nx-plugin';
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);
@@ -33,6 +33,10 @@ class NxAppRspackPlugin {
33
33
  Object.keys(compiler.options.entry['main']).length === 0) {
34
34
  compiler.options.entry = {};
35
35
  }
36
+ // Prefer `clean` option from Rspack config over our own.
37
+ if (typeof compiler.options.output.clean !== 'undefined') {
38
+ this.options.deleteOutputPath = false;
39
+ }
36
40
  (0, apply_base_config_1.applyBaseConfig)(this.options, compiler.options, {
37
41
  useNormalizedEntry: true,
38
42
  });
@@ -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,
@@ -88,7 +89,7 @@ function applyNxIndependentConfig(options, config) {
88
89
  hashFunction: config.output?.hashFunction ?? 'xxhash64',
89
90
  // Disabled for performance
90
91
  pathinfo: config.output?.pathinfo ?? false,
91
- clean: options.deleteOutputPath,
92
+ clean: config.output?.clean ?? options.deleteOutputPath,
92
93
  };
93
94
  config.watch = options.watch;
94
95
  config.watchOptions = {
@@ -184,8 +185,11 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
184
185
  if (options.useTsconfigPaths) {
185
186
  plugins.push(new nx_tsconfig_paths_rspack_plugin_1.NxTsconfigPathsRspackPlugin({ ...options, tsConfig }));
186
187
  }
187
- // New TS Solution already has a typecheck target
188
- if (!options?.skipTypeChecking && !isUsingTsSolution) {
188
+ // New TS Solution already has a typecheck target but allow it to run during serve
189
+ if ((!options?.skipTypeChecking && !isUsingTsSolution) ||
190
+ (isUsingTsSolution &&
191
+ options?.skipTypeChecking === false &&
192
+ process.env['WEBPACK_SERVE'])) {
189
193
  const { TsCheckerRspackPlugin } = require('ts-checker-rspack-plugin');
190
194
  plugins.push(new TsCheckerRspackPlugin({
191
195
  typescript: {
@@ -273,7 +277,31 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
273
277
  if ((options.target === 'node' || options.target === 'async-node') &&
274
278
  options.externalDependencies === 'all') {
275
279
  const modulesDir = `${options.root}/node_modules`;
276
- externals.push(nodeExternals({ modulesDir }));
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 }));
277
305
  }
278
306
  else if (Array.isArray(options.externalDependencies)) {
279
307
  externals.push(function (ctx, callback) {
@@ -341,6 +369,8 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
341
369
  tsx: true,
342
370
  },
343
371
  transform: {
372
+ legacyDecorator: true,
373
+ decoratorMetadata: true,
344
374
  react: {
345
375
  runtime: 'automatic',
346
376
  pragma: 'React.createElement',
@@ -0,0 +1,7 @@
1
+ import { type ProjectGraphProjectNode } from '@nx/devkit';
2
+ /**
3
+ * Check if the library is buildable.
4
+ * @param node from the project graph
5
+ * @returns boolean
6
+ */
7
+ export declare function isBuildableLibrary(node: ProjectGraphProjectNode): boolean;
@@ -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
+ }
@@ -99,7 +99,7 @@ function postcssOptionsCreator(options, { includePaths, forCssModules = false, }
99
99
  ? []
100
100
  : [
101
101
  (0, postcss_cli_resources_1.PostcssCliResources)({
102
- baseHref: options.baseHref,
102
+ baseHref: options.baseHref ? options.baseHref : undefined,
103
103
  deployUrl: options.deployUrl,
104
104
  loader,
105
105
  filename: `[name]${hashFormat.file}.[ext]`,
@@ -55,7 +55,7 @@ export interface NxAppRspackPluginOptions {
55
55
  /**
56
56
  * Set <base href> for the resulting index.html.
57
57
  */
58
- baseHref?: string;
58
+ baseHref?: string | false;
59
59
  /**
60
60
  * Build the libraries from source. Default is `true`.
61
61
  */
@@ -63,6 +63,7 @@ export interface NxAppRspackPluginOptions {
63
63
  commonChunk?: boolean;
64
64
  /**
65
65
  * Delete the output path before building.
66
+ * @deprecated Use the `output.clean` option in Rspack. https://rspack.dev/config/output#outputclean
66
67
  */
67
68
  deleteOutputPath?: boolean;
68
69
  /**
@@ -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
+ }
@@ -1,7 +1,6 @@
1
1
  export declare const nxVersion: any;
2
2
  export declare const rspackCoreVersion = "1.2.2";
3
3
  export declare const rspackDevServerVersion = "1.0.9";
4
- export declare const rspackPluginMinifyVersion = "^0.7.5";
5
4
  export declare const rspackPluginReactRefreshVersion = "^1.0.0";
6
5
  export declare const lessLoaderVersion = "~11.1.3";
7
6
  export declare const sassLoaderVersion = "^16.0.4";
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.stylusVersion = exports.lessVersion = exports.nestjsMicroservicesVersion = exports.nestjsPlatformExpressVersion = exports.nestjsCoreVersion = exports.nestjsCommonVersion = exports.reactRefreshVersion = exports.sassEmbeddedVersion = exports.sassLoaderVersion = exports.lessLoaderVersion = exports.rspackPluginReactRefreshVersion = exports.rspackPluginMinifyVersion = exports.rspackDevServerVersion = exports.rspackCoreVersion = exports.nxVersion = void 0;
3
+ exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.stylusVersion = exports.lessVersion = exports.nestjsMicroservicesVersion = exports.nestjsPlatformExpressVersion = exports.nestjsCoreVersion = exports.nestjsCommonVersion = exports.reactRefreshVersion = exports.sassEmbeddedVersion = exports.sassLoaderVersion = exports.lessLoaderVersion = exports.rspackPluginReactRefreshVersion = exports.rspackDevServerVersion = exports.rspackCoreVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.rspackCoreVersion = '1.2.2';
6
6
  exports.rspackDevServerVersion = '1.0.9';
7
- exports.rspackPluginMinifyVersion = '^0.7.5';
8
7
  exports.rspackPluginReactRefreshVersion = '^1.0.0';
9
8
  exports.lessLoaderVersion = '~11.1.3';
10
9
  exports.sassLoaderVersion = '^16.0.4';