@nx/webpack 20.0.0-beta.5 → 20.0.0-beta.7
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/index.js +1 -1
- package/migrations.json +0 -24
- package/package.json +3 -3
- package/src/executors/webpack/schema.d.ts +1 -1
- package/src/generators/configuration/configuration.js +2 -0
- package/src/generators/init/init.js +2 -0
- package/src/utils/module-federation/remotes.js +13 -5
- package/src/utils/module-federation/secondary-entry-points.js +4 -1
- package/src/utils/module-federation/share.js +6 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "useLegacyNxPlugin", { enumerable: true, get: fun
|
|
|
13
13
|
// Exported for backwards compatibility in case a plugin is using the old name.
|
|
14
14
|
/** @deprecated Use `configurationGenerator` instead. */
|
|
15
15
|
exports.webpackProjectGenerator = configuration_1.configurationGenerator;
|
|
16
|
-
// TODO(
|
|
16
|
+
// TODO(v21): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
|
|
17
17
|
/** @deprecated Use NxAppWebpackPlugin from `@nx/webpack/app-plugin` instead. */
|
|
18
18
|
exports.NxWebpackPlugin = nx_app_webpack_plugin_1.NxAppWebpackPlugin;
|
|
19
19
|
/** @deprecated Use NxTsconfigPathsWebpackPlugin from `@nx/webpack/tsconfig-paths-plugin` instead. */
|
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.
|
|
3
|
+
"version": "20.0.0-beta.7",
|
|
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,8 +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.
|
|
73
|
-
"@nx/js": "20.0.0-beta.
|
|
72
|
+
"@nx/devkit": "20.0.0-beta.7",
|
|
73
|
+
"@nx/js": "20.0.0-beta.7"
|
|
74
74
|
},
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
@@ -47,7 +47,7 @@ export interface WebpackExecutorOptions {
|
|
|
47
47
|
extractLicenses?: boolean;
|
|
48
48
|
fileReplacements?: FileReplacement[];
|
|
49
49
|
generatePackageJson?: boolean;
|
|
50
|
-
// TODO(
|
|
50
|
+
// TODO(v21): Remove this option
|
|
51
51
|
/** @deprecated set webpackConfig and provide an explicit webpack.config.js file (See: https://nx.dev/recipes/webpack/webpack-config-setup) */
|
|
52
52
|
isolatedConfig?: boolean;
|
|
53
53
|
standardWebpackConfigFunction?: boolean;
|
|
@@ -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
|
-
|
|
18
|
+
const remoteName = normalizeRemoteName(remote[0]);
|
|
19
|
+
mappedRemotes[remoteName] = handleArrayRemote(remote, remoteEntryExt, isRemoteGlobal);
|
|
19
20
|
}
|
|
20
21
|
else if (typeof remote === 'string') {
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
226
|
-
|
|
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,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
|
-
}
|