@nx/rspack 0.0.0-pr-30565-ba2942e → 0.0.0-pr-29464-73fdcbb

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-30565-ba2942e",
4
+ "version": "0.0.0-pr-29464-73fdcbb",
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-30565-ba2942e",
28
- "@nx/devkit": "0.0.0-pr-30565-ba2942e",
29
- "@nx/web": "0.0.0-pr-30565-ba2942e",
30
- "@nx/module-federation": "0.0.0-pr-30565-ba2942e",
27
+ "@nx/js": "0.0.0-pr-29464-73fdcbb",
28
+ "@nx/devkit": "0.0.0-pr-29464-73fdcbb",
29
+ "@nx/web": "0.0.0-pr-29464-73fdcbb",
30
+ "@nx/module-federation": "0.0.0-pr-29464-73fdcbb",
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);
@@ -27,6 +27,16 @@ class NxAppRspackPlugin {
27
27
  if (typeof target === 'string') {
28
28
  this.options.target = target;
29
29
  }
30
+ if (compiler.options.entry &&
31
+ compiler.options.entry['main'] &&
32
+ typeof compiler.options.entry['main'] === 'object' &&
33
+ Object.keys(compiler.options.entry['main']).length === 0) {
34
+ compiler.options.entry = {};
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
+ }
30
40
  (0, apply_base_config_1.applyBaseConfig)(this.options, compiler.options, {
31
41
  useNormalizedEntry: true,
32
42
  });
@@ -101,6 +101,7 @@ async function createRspackTargets(configFilePath, projectRoot, options, context
101
101
  ...(existingValue ? JSON.parse(existingValue) : {}),
102
102
  module: 'CommonJS',
103
103
  moduleResolution: 'Node10',
104
+ customConditions: null,
104
105
  });
105
106
  }
106
107
  targets[options.buildTargetName] = {
@@ -130,7 +131,6 @@ async function createRspackTargets(configFilePath, projectRoot, options, context
130
131
  outputs,
131
132
  };
132
133
  targets[options.serveTargetName] = {
133
- continuous: true,
134
134
  command: `rspack serve`,
135
135
  options: {
136
136
  cwd: projectRoot,
@@ -139,7 +139,6 @@ async function createRspackTargets(configFilePath, projectRoot, options, context
139
139
  },
140
140
  };
141
141
  targets[options.previewTargetName] = {
142
- continuous: true,
143
142
  command: `rspack serve`,
144
143
  options: {
145
144
  cwd: projectRoot,
@@ -148,7 +147,6 @@ async function createRspackTargets(configFilePath, projectRoot, options, context
148
147
  },
149
148
  };
150
149
  targets[options.serveStaticTargetName] = {
151
- continuous: true,
152
150
  executor: '@nx/web:file-server',
153
151
  options: {
154
152
  buildTarget: options.buildTargetName,
@@ -42,7 +42,7 @@ function applyNxIndependentConfig(options, config) {
42
42
  config.node = false;
43
43
  config.mode =
44
44
  // When the target is Node avoid any optimizations, such as replacing `process.env.NODE_ENV` with build time value.
45
- config.target === 'node'
45
+ config.target === 'node' || config.target === 'async-node'
46
46
  ? 'none'
47
47
  : // Otherwise, make sure it matches `process.env.NODE_ENV`.
48
48
  // When mode is development or production, rspack will automatically
@@ -59,13 +59,20 @@ function applyNxIndependentConfig(options, config) {
59
59
  : 'none');
60
60
  // When target is Node, the Webpack mode will be set to 'none' which disables in memory caching and causes a full rebuild on every change.
61
61
  // So to mitigate this we enable in memory caching when target is Node and in watch mode.
62
- config.cache = options.target === 'node' && options.watch ? true : undefined;
62
+ config.cache =
63
+ (options.target === 'node' || options.target === 'async-node') &&
64
+ options.watch
65
+ ? true
66
+ : undefined;
63
67
  config.devtool =
64
68
  options.sourceMap === true ? 'source-map' : options.sourceMap;
65
69
  config.output = {
66
70
  ...(config.output ?? {}),
67
- libraryTarget: config.output?.libraryTarget ??
68
- (options.target === 'node' ? 'commonjs' : undefined),
71
+ libraryTarget: options.target === 'node'
72
+ ? 'commonjs'
73
+ : options.target === 'async-node'
74
+ ? 'commonjs-module'
75
+ : undefined,
69
76
  path: config.output?.path ??
70
77
  (options.outputPath
71
78
  ? // If path is relative, it is relative from project root (aka cwd).
@@ -81,7 +88,7 @@ function applyNxIndependentConfig(options, config) {
81
88
  hashFunction: config.output?.hashFunction ?? 'xxhash64',
82
89
  // Disabled for performance
83
90
  pathinfo: config.output?.pathinfo ?? false,
84
- clean: options.deleteOutputPath,
91
+ clean: config.output?.clean ?? options.deleteOutputPath,
85
92
  };
86
93
  config.watch = options.watch;
87
94
  config.watchOptions = {
@@ -177,8 +184,11 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
177
184
  if (options.useTsconfigPaths) {
178
185
  plugins.push(new nx_tsconfig_paths_rspack_plugin_1.NxTsconfigPathsRspackPlugin({ ...options, tsConfig }));
179
186
  }
180
- // New TS Solution already has a typecheck target
181
- if (!options?.skipTypeChecking && !isUsingTsSolution) {
187
+ // New TS Solution already has a typecheck target but allow it to run during serve
188
+ if ((!options?.skipTypeChecking && !isUsingTsSolution) ||
189
+ (isUsingTsSolution &&
190
+ options?.skipTypeChecking === false &&
191
+ process.env['WEBPACK_SERVE'])) {
182
192
  const { TsCheckerRspackPlugin } = require('ts-checker-rspack-plugin');
183
193
  plugins.push(new TsCheckerRspackPlugin({
184
194
  typescript: {
@@ -263,7 +273,8 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
263
273
  plugins.push(new stats_json_plugin_1.StatsJsonPlugin());
264
274
  }
265
275
  const externals = [];
266
- if (options.target === 'node' && options.externalDependencies === 'all') {
276
+ if ((options.target === 'node' || options.target === 'async-node') &&
277
+ options.externalDependencies === 'all') {
267
278
  const modulesDir = `${options.root}/node_modules`;
268
279
  externals.push(nodeExternals({ modulesDir }));
269
280
  }
@@ -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';