@nx/webpack 17.1.1 → 17.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "17.1.1",
3
+ "version": "17.2.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
6
6
  "repository": {
@@ -62,9 +62,9 @@
62
62
  "webpack-dev-server": "^4.9.3",
63
63
  "webpack-node-externals": "^3.0.0",
64
64
  "webpack-subresource-integrity": "^5.1.0",
65
- "@nx/devkit": "17.1.1",
66
- "@nx/js": "17.1.1",
67
- "@nrwl/webpack": "17.1.1"
65
+ "@nx/devkit": "17.2.0-beta.0",
66
+ "@nx/js": "17.2.0-beta.0",
67
+ "@nrwl/webpack": "17.2.0-beta.0"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public"
@@ -1,3 +1,5 @@
1
1
  import { Configuration, WebpackOptionsNormalized } from 'webpack';
2
2
  import { NormalizedNxWebpackPluginOptions } from '../nx-webpack-plugin-options';
3
- export declare function applyBaseConfig(options: NormalizedNxWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>): void;
3
+ export declare function applyBaseConfig(options: NormalizedNxWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>, { useNormalizedEntry, }?: {
4
+ useNormalizedEntry?: boolean;
5
+ }): void;
@@ -20,7 +20,7 @@ const IGNORED_WEBPACK_WARNINGS = [
20
20
  ];
21
21
  const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
22
22
  const mainFields = ['module', 'main'];
23
- function applyBaseConfig(options, config = {}) {
23
+ function applyBaseConfig(options, config = {}, { useNormalizedEntry, } = {}) {
24
24
  const plugins = [
25
25
  new nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin(options),
26
26
  ];
@@ -67,7 +67,12 @@ function applyBaseConfig(options, config = {}) {
67
67
  }
68
68
  config.entry ??= {};
69
69
  entries.forEach((entry) => {
70
- config.entry[entry.name] = { import: entry.import };
70
+ if (useNormalizedEntry) {
71
+ config.entry[entry.name] = { import: entry.import };
72
+ }
73
+ else {
74
+ config.entry[entry.name] = entry.import;
75
+ }
71
76
  });
72
77
  if (options.progress) {
73
78
  plugins.push(new webpack_1.ProgressPlugin({ profile: options.verbose }));
@@ -1,3 +1,5 @@
1
1
  import { Configuration, WebpackOptionsNormalized } from 'webpack';
2
2
  import { NormalizedNxWebpackPluginOptions } from '../nx-webpack-plugin-options';
3
- export declare function applyWebConfig(options: NormalizedNxWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>): void;
3
+ export declare function applyWebConfig(options: NormalizedNxWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>, { useNormalizedEntry, }?: {
4
+ useNormalizedEntry?: boolean;
5
+ }): void;
@@ -12,7 +12,7 @@ const stylesheet_loaders_1 = require("./stylesheet-loaders");
12
12
  const instantiate_script_plugins_1 = require("./instantiate-script-plugins");
13
13
  const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
14
14
  const MiniCssExtractPlugin = require("mini-css-extract-plugin");
15
- function applyWebConfig(options, config = {}) {
15
+ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
16
16
  const plugins = [];
17
17
  const stylesOptimization = typeof options.optimization === 'object'
18
18
  ? options.optimization.styles
@@ -44,7 +44,7 @@ function applyWebConfig(options, config = {}) {
44
44
  if (!options.ssr) {
45
45
  plugins.push(new webpack_1.DefinePlugin((0, get_client_environment_1.getClientEnvironment)(process.env.NODE_ENV).stringified));
46
46
  }
47
- const entry = {};
47
+ const entries = {};
48
48
  const globalStylePaths = [];
49
49
  // Determine hashing format.
50
50
  const hashFormat = (0, hash_format_1.getOutputHashFormat)(options.outputHashing);
@@ -63,11 +63,11 @@ function applyWebConfig(options, config = {}) {
63
63
  (0, normalize_entry_1.normalizeExtraEntryPoints)(options.styles, 'styles').forEach((style) => {
64
64
  const resolvedPath = path.resolve(options.root, style.input);
65
65
  // Add style entry points.
66
- if (entry[style.bundleName]) {
67
- entry[style.bundleName].import.push(resolvedPath);
66
+ if (entries[style.bundleName]) {
67
+ entries[style.bundleName].import.push(resolvedPath);
68
68
  }
69
69
  else {
70
- entry[style.bundleName] = { import: [resolvedPath] };
70
+ entries[style.bundleName] = { import: [resolvedPath] };
71
71
  }
72
72
  // Add global css paths.
73
73
  globalStylePaths.push(resolvedPath);
@@ -272,7 +272,14 @@ function applyWebConfig(options, config = {}) {
272
272
  throw new Error('Entry string is not supported. Use an object.');
273
273
  if (Array.isArray(config.entry))
274
274
  throw new Error('Entry array is not supported. Use an object.');
275
- config.entry = { ...config.entry, ...entry };
275
+ Object.entries(entries).forEach(([entryName, entryData]) => {
276
+ if (useNormalizedEntry) {
277
+ config.entry[entryName] = { import: entryData.import };
278
+ }
279
+ else {
280
+ config.entry[entryName] = entryData.import;
281
+ }
282
+ });
276
283
  config.optimization = {
277
284
  ...config.optimization,
278
285
  minimizer: [...config.optimization.minimizer, ...minimizer],
@@ -31,12 +31,16 @@ class NxWebpackPlugin {
31
31
  if (this.options.deleteOutputPath) {
32
32
  (0, fs_1.deleteOutputDir)(this.options.root, this.options.outputPath);
33
33
  }
34
- (0, apply_base_config_1.applyBaseConfig)(this.options, compiler.options);
34
+ (0, apply_base_config_1.applyBaseConfig)(this.options, compiler.options, {
35
+ useNormalizedEntry: true,
36
+ });
35
37
  if (compiler.options.target) {
36
38
  this.options.target = compiler.options.target;
37
39
  }
38
40
  if (this.options.target === 'web' || this.options.target === 'webworker') {
39
- (0, apply_web_config_1.applyWebConfig)(this.options, compiler.options);
41
+ (0, apply_web_config_1.applyWebConfig)(this.options, compiler.options, {
42
+ useNormalizedEntry: true,
43
+ });
40
44
  }
41
45
  }
42
46
  readExecutorOptions() {
@@ -55,7 +55,7 @@ function getRemotes(devRemotes, skipRemotes, config, context, pathToManifestFile
55
55
  : (0, find_matching_projects_1.findMatchingProjects)([devRemotes], context.projectGraph.nodes));
56
56
  const staticRemotes = knownRemotes.filter((r) => !devServeApps.has(r));
57
57
  const devServeRemotes = knownRemotes.filter((r) => devServeApps.has(r));
58
- const remotePorts = knownRemotes.map((r) => context.projectGraph.nodes[r].data.targets['serve'].options.port);
58
+ const remotePorts = devServeRemotes.map((r) => context.projectGraph.nodes[r].data.targets['serve'].options.port);
59
59
  return {
60
60
  staticRemotes,
61
61
  devRemotes: devServeRemotes,