@nx/webpack 23.2.0-beta.11 → 23.2.0-beta.12

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.
@@ -82,6 +82,7 @@ export interface WebpackExecutorOptions {
82
82
  crossOrigin?: 'none' | 'anonymous' | 'use-credentials';
83
83
  deployUrl?: string;
84
84
  extractCss?: boolean;
85
+ cssModuleHashFunction?: string;
85
86
  generateIndexHtml?: boolean;
86
87
  index?: string;
87
88
  postcssConfig?: string;
@@ -265,6 +265,10 @@
265
265
  "type": "boolean",
266
266
  "description": "Extract CSS into a `.css` file."
267
267
  },
268
+ "cssModuleHashFunction": {
269
+ "type": "string",
270
+ "description": "Hash algorithm used to generate CSS module class names. Defaults to `md5`, which FIPS-restricted OpenSSL rejects. Changing it renames generated class names."
271
+ },
268
272
  "subresourceIntegrity": {
269
273
  "type": "boolean",
270
274
  "description": "Enables the use of subresource integrity validation."
@@ -1,4 +1,3 @@
1
- import { getCSSModuleLocalIdent } from '../../../utils/get-css-module-local-ident';
2
1
  import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
3
2
  interface PostcssOptions {
4
3
  (loader: any): any;
@@ -12,7 +11,7 @@ export declare function getCommonLoadersForCssModules(options: NormalizedNxAppWe
12
11
  options: {
13
12
  modules: {
14
13
  mode: string;
15
- getLocalIdent: typeof getCSSModuleLocalIdent;
14
+ getLocalIdent: (ctx: any, localIdentName: any, localName: any, loaderOptions: any) => any;
16
15
  namedExport: boolean;
17
16
  exportLocalsConvention: string;
18
17
  };
@@ -24,7 +24,7 @@ function getCommonLoadersForCssModules(options, includePaths) {
24
24
  options: {
25
25
  modules: {
26
26
  mode: 'local',
27
- getLocalIdent: get_css_module_local_ident_1.getCSSModuleLocalIdent,
27
+ getLocalIdent: (ctx, localIdentName, localName, loaderOptions) => (0, get_css_module_local_ident_1.getCSSModuleLocalIdent)(ctx, localIdentName, localName, loaderOptions, options.cssModuleHashFunction),
28
28
  // css-loader 7 defaults namedExport to true, and to camel-case-only
29
29
  // locals when it is off. Generated components import the default
30
30
  // export and reference class names as authored, so pin both.
@@ -74,6 +74,11 @@ export interface NxAppWebpackPluginOptions {
74
74
  * Set `crossorigin` attribute on the `script` and `link` tags.
75
75
  */
76
76
  crossOrigin?: 'none' | 'anonymous' | 'use-credentials';
77
+ /**
78
+ * Hash algorithm used to generate CSS module class names. Defaults to `md5`,
79
+ * which FIPS-restricted OpenSSL rejects. Changing it renames generated class names.
80
+ */
81
+ cssModuleHashFunction?: string;
77
82
  /**
78
83
  * The deploy path for the application. e.g. `/my-app/`
79
84
  */
@@ -88,6 +88,11 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
88
88
  targets[options.buildTargetName] = {
89
89
  command: `webpack-cli build`,
90
90
  options: { cwd: projectRoot, env: { NODE_ENV: 'production' } },
91
+ configurations: {
92
+ development: {
93
+ env: { NODE_ENV: 'development' },
94
+ },
95
+ },
91
96
  cache: true,
92
97
  dependsOn: [`^${options.buildTargetName}`],
93
98
  inputs: [
@@ -8,7 +8,10 @@ async function getWebpackE2EWebServerInfo(tree, projectName, configFilePath, isP
8
8
  let e2ePort = e2ePortOverride ?? 4200;
9
9
  const servePort = (0, internal_1.readTargetDefaultsForTarget)('serve', nxJson.targetDefaults)
10
10
  ?.options?.port;
11
- if (servePort) {
11
+ // targetDefaults is a workspace-wide fallback, so it fills in only when the caller
12
+ // did not ask for a port. Letting it win over an explicit request would point e2e at
13
+ // a different port than the serve target the generator just wrote.
14
+ if (servePort && e2ePortOverride == null) {
12
15
  e2ePort = servePort;
13
16
  }
14
17
  return (0, internal_1.getE2EWebServerInfo)(tree, projectName, {
@@ -22,5 +25,6 @@ async function getWebpackE2EWebServerInfo(tree, projectName, configFilePath, isP
22
25
  defaultE2EWebServerAddress: `http://localhost:${e2ePort}`,
23
26
  defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
24
27
  defaultE2EPort: e2ePort,
28
+ e2EPortIsExplicit: e2ePortOverride != null,
25
29
  }, isPluginBeingAdded);
26
30
  }
@@ -1 +1 @@
1
- export declare function getCSSModuleLocalIdent(ctx: any, localIdentName: any, localName: any, options: any): any;
1
+ export declare function getCSSModuleLocalIdent(ctx: any, localIdentName: any, localName: any, options: any, hashFunction?: string): any;
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCSSModuleLocalIdent = getCSSModuleLocalIdent;
4
4
  const path_1 = require("path");
5
5
  const loader_utils_1 = require("loader-utils");
6
- function getCSSModuleLocalIdent(ctx, localIdentName, localName, options) {
6
+ function getCSSModuleLocalIdent(ctx, localIdentName, localName, options, hashFunction) {
7
7
  // Use the filename or folder name, based on some uses the index.js / index.module.(css|scss|sass) project style
8
8
  const fileNameOrFolder = ctx.resourcePath.match(/index\.module\.(css|scss|sass)$/)
9
9
  ? '[folder]'
10
10
  : '[name]';
11
11
  // Create a hash based on a the file location and class name. Will be unique across a project, and close to globally unique.
12
- const hash = (0, loader_utils_1.getHashDigest)(path_1.posix.relative(ctx.rootContext, ctx.resourcePath) + localName, 'md5', 'base64', 5);
12
+ const hash = (0, loader_utils_1.getHashDigest)(path_1.posix.relative(ctx.rootContext, ctx.resourcePath) + localName,
13
+ // md5 is unavailable under FIPS-restricted OpenSSL (nx#36829). Env var stays
14
+ // undocumented on purpose - `cssModuleHashFunction` is the documented option.
15
+ hashFunction || process.env.NX_CSS_MODULE_HASH_FUNCTION || 'md5', 'base64', 5);
13
16
  // Use loaderUtils to find the file or folder name
14
17
  const className = (0, loader_utils_1.interpolateName)(ctx, `${fileNameOrFolder}_${localName}__${hash}`, options);
15
18
  // Remove the .module that appears in every classname when based on the file and replace all "." with "_".
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "23.2.0-beta.11",
3
+ "version": "23.2.0-beta.12",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -118,8 +118,8 @@
118
118
  "tslib": "^2.3.0",
119
119
  "webpack-node-externals": "^3.0.0",
120
120
  "webpack-subresource-integrity": "^5.1.0",
121
- "@nx/devkit": "23.2.0-beta.11",
122
- "@nx/js": "23.2.0-beta.11"
121
+ "@nx/devkit": "23.2.0-beta.12",
122
+ "@nx/js": "23.2.0-beta.12"
123
123
  },
124
124
  "peerDependencies": {
125
125
  "webpack": "^5.0.0",
@@ -138,7 +138,7 @@
138
138
  }
139
139
  },
140
140
  "devDependencies": {
141
- "nx": "23.2.0-beta.11"
141
+ "nx": "23.2.0-beta.12"
142
142
  },
143
143
  "publishConfig": {
144
144
  "access": "public"