@nx/rspack 20.0.7 → 20.0.8

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": "20.0.7",
4
+ "version": "20.0.8",
5
5
  "type": "commonjs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,9 +24,9 @@
24
24
  "generators": "./generators.json",
25
25
  "executors": "./executors.json",
26
26
  "dependencies": {
27
- "@nx/js": "20.0.7",
28
- "@nx/devkit": "20.0.7",
29
- "@nx/web": "20.0.7",
27
+ "@nx/js": "20.0.8",
28
+ "@nx/devkit": "20.0.8",
29
+ "@nx/web": "20.0.8",
30
30
  "@phenomnomnominal/tsquery": "~5.0.1",
31
31
  "enquirer": "~2.3.6",
32
32
  "express": "^4.19.2",
@@ -101,7 +101,27 @@ function withWeb(opts = {}) {
101
101
  new core_1.rspack.EnvironmentPlugin({
102
102
  NODE_ENV: isProd ? 'production' : 'development',
103
103
  }),
104
+ new core_1.rspack.DefinePlugin(getClientEnvironment(isProd ? 'production' : undefined).stringified),
104
105
  ],
105
106
  };
106
107
  };
107
108
  }
109
+ function getClientEnvironment(mode) {
110
+ // Grab NODE_ENV and NX_PUBLIC_* environment variables and prepare them to be
111
+ // injected into the application via DefinePlugin in webpack configuration.
112
+ const nxPublicKeyRegex = /^NX_PUBLIC_/i;
113
+ const raw = Object.keys(process.env)
114
+ .filter((key) => nxPublicKeyRegex.test(key))
115
+ .reduce((env, key) => {
116
+ env[key] = process.env[key];
117
+ return env;
118
+ }, {});
119
+ // Stringify all values so we can feed into webpack DefinePlugin
120
+ const stringified = {
121
+ 'process.env': Object.keys(raw).reduce((env, key) => {
122
+ env[key] = JSON.stringify(raw[key]);
123
+ return env;
124
+ }, {}),
125
+ };
126
+ return { stringified };
127
+ }