@nx/webpack 19.2.0-alpha.2 → 19.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 +4 -4
- package/src/executors/webpack/webpack.impl.js +0 -6
- package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +4 -4
- package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +19 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +2 -3
- package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +1 -0
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.d.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "19.2.0-
|
|
3
|
+
"version": "19.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": {
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"webpack-dev-server": "^4.9.3",
|
|
65
65
|
"webpack-node-externals": "^3.0.0",
|
|
66
66
|
"webpack-subresource-integrity": "^5.1.0",
|
|
67
|
-
"@nx/devkit": "19.2.0-
|
|
68
|
-
"@nx/js": "19.2.0-
|
|
69
|
-
"@nrwl/webpack": "19.2.0-
|
|
67
|
+
"@nx/devkit": "19.2.0-beta.0",
|
|
68
|
+
"@nx/js": "19.2.0-beta.0",
|
|
69
|
+
"@nrwl/webpack": "19.2.0-beta.0"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
@@ -6,7 +6,6 @@ const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
|
|
|
6
6
|
const rxjs_1 = require("rxjs");
|
|
7
7
|
const operators_1 = require("rxjs/operators");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
10
9
|
const run_webpack_1 = require("./lib/run-webpack");
|
|
11
10
|
const fs_1 = require("../../utils/fs");
|
|
12
11
|
const resolve_user_defined_webpack_config_1 = require("../../utils/webpack/resolve-user-defined-webpack-config");
|
|
@@ -83,11 +82,6 @@ async function* webpackExecutor(_options, context) {
|
|
|
83
82
|
};
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
|
-
if (!options.buildLibsFromSource && context.targetName) {
|
|
87
|
-
const { dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName);
|
|
88
|
-
options.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, context.root, metadata.root, dependencies);
|
|
89
|
-
process.env.NX_TSCONFIG_PATH = options.tsConfig;
|
|
90
|
-
}
|
|
91
85
|
// Delete output path before bundling
|
|
92
86
|
if (options.deleteOutputPath && options.outputPath) {
|
|
93
87
|
(0, fs_1.deleteOutputDir)(context.root, options.outputPath);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Compiler } from 'webpack';
|
|
1
|
+
import { Compiler, type Configuration, type WebpackOptionsNormalized } from 'webpack';
|
|
2
|
+
import { NormalizedNxAppWebpackPluginOptions } from '../nx-webpack-plugin/nx-app-webpack-plugin-options';
|
|
2
3
|
export declare class NxTsconfigPathsWebpackPlugin {
|
|
3
4
|
private options;
|
|
4
|
-
constructor(options:
|
|
5
|
-
tsConfig: string;
|
|
6
|
-
});
|
|
5
|
+
constructor(options: NormalizedNxAppWebpackPluginOptions);
|
|
7
6
|
apply(compiler: Compiler): void;
|
|
7
|
+
handleBuildLibsFromSource(config: Partial<WebpackOptionsNormalized | Configuration>, options: any): void;
|
|
8
8
|
}
|
|
@@ -4,6 +4,8 @@ exports.NxTsconfigPathsWebpackPlugin = void 0;
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
8
|
+
const webpack_nx_build_coordination_plugin_1 = require("../webpack-nx-build-coordination-plugin");
|
|
7
9
|
class NxTsconfigPathsWebpackPlugin {
|
|
8
10
|
constructor(options) {
|
|
9
11
|
this.options = options;
|
|
@@ -11,6 +13,8 @@ class NxTsconfigPathsWebpackPlugin {
|
|
|
11
13
|
throw new Error(`Missing "tsConfig" option. Set this option in your Nx webpack plugin.`);
|
|
12
14
|
}
|
|
13
15
|
apply(compiler) {
|
|
16
|
+
// If we are not building libs from source, we need to remap paths so tsconfig may be updated.
|
|
17
|
+
this.handleBuildLibsFromSource(compiler.options, this.options);
|
|
14
18
|
const extensions = new Set([
|
|
15
19
|
...['.ts', '.tsx', '.mjs', '.js', '.jsx'],
|
|
16
20
|
...(compiler.options?.resolve?.extensions ?? []),
|
|
@@ -27,5 +31,20 @@ class NxTsconfigPathsWebpackPlugin {
|
|
|
27
31
|
mainFields: ['module', 'main'],
|
|
28
32
|
}));
|
|
29
33
|
}
|
|
34
|
+
handleBuildLibsFromSource(config, options) {
|
|
35
|
+
if (!options.buildLibsFromSource && options.targetName) {
|
|
36
|
+
const remappedTarget = options.targetName === 'serve' ? 'build' : options.targetName;
|
|
37
|
+
const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(undefined, options.projectGraph, options.root, options.projectName, remappedTarget, options.configurationName);
|
|
38
|
+
options.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, options.root, target.data.root, dependencies);
|
|
39
|
+
if (options.targetName === 'serve') {
|
|
40
|
+
const buildableDependencies = dependencies
|
|
41
|
+
.filter((dependency) => dependency.node.type === 'lib')
|
|
42
|
+
.map((dependency) => dependency.node.name)
|
|
43
|
+
.join(',');
|
|
44
|
+
const buildCommand = `nx run-many --target=build --projects=${buildableDependencies}`;
|
|
45
|
+
config.plugins.push(new webpack_nx_build_coordination_plugin_1.WebpackNxBuildCoordinationPlugin(buildCommand));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
30
49
|
}
|
|
31
50
|
exports.NxTsconfigPathsWebpackPlugin = NxTsconfigPathsWebpackPlugin;
|
|
@@ -168,9 +168,7 @@ function applyNxIndependentConfig(options, config) {
|
|
|
168
168
|
}
|
|
169
169
|
function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
170
170
|
const tsConfig = options.tsConfig ?? (0, js_1.getRootTsConfigPath)();
|
|
171
|
-
const plugins = [
|
|
172
|
-
new nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin({ tsConfig }),
|
|
173
|
-
];
|
|
171
|
+
const plugins = [];
|
|
174
172
|
const executorContext = {
|
|
175
173
|
projectName: options.projectName,
|
|
176
174
|
targetName: options.targetName,
|
|
@@ -178,6 +176,7 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
|
178
176
|
configurationName: options.configurationName,
|
|
179
177
|
root: options.root,
|
|
180
178
|
};
|
|
179
|
+
plugins.push(new nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin({ ...options, tsConfig }));
|
|
181
180
|
if (!options?.skipTypeChecking) {
|
|
182
181
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
183
182
|
plugins.push(new ForkTsCheckerWebpackPlugin({
|
|
@@ -56,6 +56,7 @@ function normalizeOptions(options) {
|
|
|
56
56
|
? normalizeAssets(combinedPluginAndMaybeExecutorOptions.assets, devkit_1.workspaceRoot, sourceRoot, projectNode.data.root)
|
|
57
57
|
: [],
|
|
58
58
|
baseHref: combinedPluginAndMaybeExecutorOptions.baseHref ?? '/',
|
|
59
|
+
buildLibsFromSource: combinedPluginAndMaybeExecutorOptions.buildLibsFromSource ?? true,
|
|
59
60
|
commonChunk: combinedPluginAndMaybeExecutorOptions.commonChunk ?? true,
|
|
60
61
|
compiler: combinedPluginAndMaybeExecutorOptions.compiler ?? 'babel',
|
|
61
62
|
configurationName,
|
|
@@ -58,6 +58,10 @@ export interface NxAppWebpackPluginOptions {
|
|
|
58
58
|
* Set <base href> for the resulting index.html.
|
|
59
59
|
*/
|
|
60
60
|
baseHref?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Build the libraries from source. Default is `true`.
|
|
63
|
+
*/
|
|
64
|
+
buildLibsFromSource?: boolean;
|
|
61
65
|
commonChunk?: boolean;
|
|
62
66
|
/**
|
|
63
67
|
* The compiler to use. Default is `babel` and requires a `.babelrc` file.
|