@nx/webpack 20.0.0-beta.4 → 20.0.0-beta.6

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/migrations.json CHANGED
@@ -1,11 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "update-16-0-0-add-nx-packages": {
4
- "cli": "nx",
5
- "version": "16.0.0-beta.1",
6
- "description": "Replace @nrwl/webpack with @nx/webpack",
7
- "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
- },
9
3
  "update-17-2-1-webpack-config-setup": {
10
4
  "cli": "nx",
11
5
  "version": "17.2.1-beta.0",
@@ -20,24 +14,6 @@
20
14
  }
21
15
  },
22
16
  "packageJsonUpdates": {
23
- "16.3.0": {
24
- "version": "16.3.0-beta.8",
25
- "packages": {
26
- "@svgr/webpack": {
27
- "version": "^8.0.1",
28
- "alwaysAddToPackageJson": false
29
- }
30
- }
31
- },
32
- "16.4.1": {
33
- "version": "16.4.1-beta.0",
34
- "packages": {
35
- "webpack": {
36
- "version": "^5.80.0",
37
- "alwaysAddToPackageJson": false
38
- }
39
- }
40
- },
41
17
  "19.6.0": {
42
18
  "version": "19.6.0-beta.1",
43
19
  "packages": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "20.0.0-beta.4",
3
+ "version": "20.0.0-beta.6",
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": {
@@ -69,9 +69,8 @@
69
69
  "webpack-dev-server": "^5.0.4",
70
70
  "webpack-node-externals": "^3.0.0",
71
71
  "webpack-subresource-integrity": "^5.1.0",
72
- "@nx/devkit": "20.0.0-beta.4",
73
- "@nx/js": "20.0.0-beta.4",
74
- "@nrwl/webpack": "20.0.0-beta.4"
72
+ "@nx/devkit": "20.0.0-beta.6",
73
+ "@nx/js": "20.0.0-beta.6"
75
74
  },
76
75
  "publishConfig": {
77
76
  "access": "public"
@@ -7,10 +7,12 @@ const init_1 = require("../init/init");
7
7
  const has_plugin_1 = require("../../utils/has-plugin");
8
8
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
9
9
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
10
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
10
11
  function configurationGenerator(tree, options) {
11
12
  return configurationGeneratorInternal(tree, { addPlugin: false, ...options });
12
13
  }
13
14
  async function configurationGeneratorInternal(tree, options) {
15
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'webpack', 'configuration');
14
16
  const tasks = [];
15
17
  const nxJson = (0, devkit_1.readNxJson)(tree);
16
18
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -4,12 +4,14 @@ exports.webpackInitGenerator = webpackInitGenerator;
4
4
  exports.webpackInitGeneratorInternal = webpackInitGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  const plugin_1 = require("../../plugins/plugin");
8
9
  const versions_1 = require("../../utils/versions");
9
10
  function webpackInitGenerator(tree, schema) {
10
11
  return webpackInitGeneratorInternal(tree, { addPlugin: false, ...schema });
11
12
  }
12
13
  async function webpackInitGeneratorInternal(tree, schema) {
14
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'webpack', 'init');
13
15
  const nxJson = (0, devkit_1.readNxJson)(tree);
14
16
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
15
17
  nxJson.useInferencePlugins !== false;
@@ -15,17 +15,20 @@ function mapRemotes(remotes, remoteEntryExt, determineRemoteUrl, isRemoteGlobal
15
15
  const mappedRemotes = {};
16
16
  for (const remote of remotes) {
17
17
  if (Array.isArray(remote)) {
18
- mappedRemotes[remote[0]] = handleArrayRemote(remote, remoteEntryExt, isRemoteGlobal);
18
+ const remoteName = normalizeRemoteName(remote[0]);
19
+ mappedRemotes[remoteName] = handleArrayRemote(remote, remoteEntryExt, isRemoteGlobal);
19
20
  }
20
21
  else if (typeof remote === 'string') {
21
- mappedRemotes[remote] = handleStringRemote(remote, determineRemoteUrl, isRemoteGlobal);
22
+ const remoteName = normalizeRemoteName(remote);
23
+ mappedRemotes[remoteName] = handleStringRemote(remoteName, determineRemoteUrl, isRemoteGlobal);
22
24
  }
23
25
  }
24
26
  return mappedRemotes;
25
27
  }
26
28
  // Helper function to deal with remotes that are arrays
27
29
  function handleArrayRemote(remote, remoteEntryExt, isRemoteGlobal) {
28
- const [remoteName, remoteLocation] = remote;
30
+ let [remoteName, remoteLocation] = remote;
31
+ remoteName = normalizeRemoteName(remoteName);
29
32
  const remoteLocationExt = (0, path_1.extname)(remoteLocation);
30
33
  // If remote location already has .js or .mjs extension
31
34
  if (['.js', '.mjs'].includes(remoteLocationExt)) {
@@ -63,7 +66,8 @@ function mapRemotesForSSR(remotes, remoteEntryExt, determineRemoteUrl) {
63
66
  const mappedRemotes = {};
64
67
  for (const remote of remotes) {
65
68
  if (Array.isArray(remote)) {
66
- const [remoteName, remoteLocation] = remote;
69
+ let [remoteName, remoteLocation] = remote;
70
+ remoteName = normalizeRemoteName(remoteName);
67
71
  const remoteLocationExt = (0, path_1.extname)(remoteLocation);
68
72
  mappedRemotes[remoteName] = `${remoteName}@${['.js', '.mjs'].includes(remoteLocationExt)
69
73
  ? remoteLocation
@@ -72,8 +76,12 @@ function mapRemotesForSSR(remotes, remoteEntryExt, determineRemoteUrl) {
72
76
  : remoteLocation}/remoteEntry.${remoteEntryExt}`}`;
73
77
  }
74
78
  else if (typeof remote === 'string') {
75
- mappedRemotes[remote] = `${remote}@${determineRemoteUrl(remote)}`;
79
+ const remoteName = normalizeRemoteName(remote);
80
+ mappedRemotes[remoteName] = `${remoteName}@${determineRemoteUrl(remote)}`;
76
81
  }
77
82
  }
78
83
  return mappedRemotes;
79
84
  }
85
+ function normalizeRemoteName(remote) {
86
+ return remote.replace(/-/g, '_');
87
+ }
@@ -78,7 +78,10 @@ function recursivelyCollectSecondaryEntryPointsFromDirectory(pkgName, pkgVersion
78
78
  }
79
79
  function collectPackagesFromExports(pkgName, pkgVersion, exports, collectedPackages) {
80
80
  for (const [relativeEntryPoint, exportOptions] of Object.entries(exports)) {
81
- if (exportOptions?.['default']?.search(/\.(js|mjs|cjs)$/)) {
81
+ const defaultExportOptions = typeof exportOptions?.['default'] === 'string'
82
+ ? exportOptions?.['default']
83
+ : exportOptions?.['default']?.['default'];
84
+ if (defaultExportOptions?.search(/\.(js|mjs|cjs)$/)) {
82
85
  let entryPointName = (0, devkit_1.joinPathFragments)(pkgName, relativeEntryPoint);
83
86
  if (entryPointName.endsWith('.json')) {
84
87
  entryPointName = (0, path_1.dirname)(entryPointName);
@@ -222,8 +222,12 @@ function addStringDependencyToSharedConfig(sharedConfig, dependency, projectGrap
222
222
  sharedConfig[dependency] = config;
223
223
  }
224
224
  else {
225
- throw new Error(`The specified dependency "${dependency}" in the additionalShared configuration does not exist in the project graph. ` +
226
- `Please check your additionalShared configuration and make sure you are including valid workspace projects or npm packages.`);
225
+ const pkgJsonPath = require.resolve(`${dependency}/package.json`);
226
+ if (!pkgJsonPath) {
227
+ throw new Error(`Could not find package ${dependency} when applying it as a shared package. Are you sure it has been installed?`);
228
+ }
229
+ const pkgJson = (0, devkit_1.readJsonFile)(pkgJsonPath);
230
+ const config = getNpmPackageSharedConfig(dependency, pkgJson.version);
227
231
  }
228
232
  }
229
233
  function getEmptySharedLibrariesConfig() {
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function replacePackage(tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = replacePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
6
- async function replacePackage(tree) {
7
- await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/webpack', '@nx/webpack');
8
- await (0, devkit_1.formatFiles)(tree);
9
- }