@nx/webpack 0.0.0-pr-29156-c171bae → 0.0.0-pr-29314-e664f92
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 +3 -3
- package/src/executors/webpack/lib/normalize-options.js +2 -0
- package/src/executors/webpack/schema.d.ts +1 -0
- package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +9 -2
- package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.d.ts +4 -0
- package/src/plugins/plugin.js +21 -5
- package/src/utils/config.js +1 -0
- package/src/utils/webpack/read-webpack-options.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/webpack",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29314-e664f92",
|
|
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": {
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"webpack-dev-server": "^5.0.4",
|
|
66
66
|
"webpack-node-externals": "^3.0.0",
|
|
67
67
|
"webpack-subresource-integrity": "^5.1.0",
|
|
68
|
-
"@nx/devkit": "0.0.0-pr-
|
|
69
|
-
"@nx/js": "0.0.0-pr-
|
|
68
|
+
"@nx/devkit": "0.0.0-pr-29314-e664f92",
|
|
69
|
+
"@nx/js": "0.0.0-pr-29314-e664f92"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
@@ -4,9 +4,11 @@ exports.normalizeOptions = normalizeOptions;
|
|
|
4
4
|
exports.normalizePluginPath = normalizePluginPath;
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const normalize_options_1 = require("../../../plugins/nx-webpack-plugin/lib/normalize-options");
|
|
7
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
8
|
function normalizeOptions(options, root, projectRoot, sourceRoot) {
|
|
8
9
|
const normalizedOptions = {
|
|
9
10
|
...options,
|
|
11
|
+
useTsconfigPaths: !(0, ts_solution_setup_1.isUsingTsSolutionSetup)(),
|
|
10
12
|
root,
|
|
11
13
|
projectRoot,
|
|
12
14
|
sourceRoot,
|
|
@@ -14,6 +14,7 @@ const get_terser_ecma_version_1 = require("./get-terser-ecma-version");
|
|
|
14
14
|
const compiler_loaders_1 = require("./compiler-loaders");
|
|
15
15
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
16
16
|
const nodeExternals = require("webpack-node-externals");
|
|
17
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
17
18
|
const IGNORED_WEBPACK_WARNINGS = [
|
|
18
19
|
/The comment file/i,
|
|
19
20
|
/could not find any license/i,
|
|
@@ -176,8 +177,14 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
|
|
|
176
177
|
configurationName: options.configurationName,
|
|
177
178
|
root: options.root,
|
|
178
179
|
};
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
const isUsingTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
181
|
+
options.useTsconfigPaths ??= !isUsingTsSolution;
|
|
182
|
+
// If the project is using ts solutions setup, the paths are not in tsconfig and we should not use the plugin's paths.
|
|
183
|
+
if (options.useTsconfigPaths) {
|
|
184
|
+
plugins.push(new nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin({ ...options, tsConfig }));
|
|
185
|
+
}
|
|
186
|
+
// New TS Solution already has a typecheck target
|
|
187
|
+
if (!options?.skipTypeChecking && !isUsingTsSolution) {
|
|
181
188
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
182
189
|
plugins.push(new ForkTsCheckerWebpackPlugin({
|
|
183
190
|
typescript: {
|
|
@@ -202,6 +202,10 @@ export interface NxAppWebpackPluginOptions {
|
|
|
202
202
|
* List of TypeScript Compiler Transformers Plugins.
|
|
203
203
|
*/
|
|
204
204
|
transformers?: TransformerEntry[];
|
|
205
|
+
/**
|
|
206
|
+
* Use tsconfig-paths-webpack-plugin to resolve modules using paths in the tsconfig file.
|
|
207
|
+
*/
|
|
208
|
+
useTsconfigPaths?: boolean;
|
|
205
209
|
/**
|
|
206
210
|
* Generate a separate vendor chunk for 3rd party packages.
|
|
207
211
|
*/
|
package/src/plugins/plugin.js
CHANGED
|
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
6
6
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
9
|
const fs_1 = require("fs");
|
|
9
10
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
10
11
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
@@ -33,8 +34,9 @@ exports.createNodesV2 = [
|
|
|
33
34
|
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `webpack-${optionsHash}.hash`);
|
|
34
35
|
const targetsCache = readTargetsCache(cachePath);
|
|
35
36
|
const normalizedOptions = normalizeOptions(options);
|
|
37
|
+
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
36
38
|
try {
|
|
37
|
-
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache), configFilePaths, normalizedOptions, context);
|
|
39
|
+
return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache, isTsSolutionSetup), configFilePaths, normalizedOptions, context);
|
|
38
40
|
}
|
|
39
41
|
finally {
|
|
40
42
|
writeTargetsToCache(cachePath, targetsCache);
|
|
@@ -46,10 +48,10 @@ exports.createNodes = [
|
|
|
46
48
|
async (configFilePath, options, context) => {
|
|
47
49
|
devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
|
|
48
50
|
const normalizedOptions = normalizeOptions(options);
|
|
49
|
-
return createNodesInternal(configFilePath, normalizedOptions, context, {});
|
|
51
|
+
return createNodesInternal(configFilePath, normalizedOptions, context, {}, (0, ts_solution_setup_1.isUsingTsSolutionSetup)());
|
|
50
52
|
},
|
|
51
53
|
];
|
|
52
|
-
async function createNodesInternal(configFilePath, options, context, targetsCache) {
|
|
54
|
+
async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup) {
|
|
53
55
|
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
54
56
|
// Do not create a project if package.json and project.json isn't there.
|
|
55
57
|
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
@@ -58,7 +60,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
58
60
|
return {};
|
|
59
61
|
}
|
|
60
62
|
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
|
|
61
|
-
targetsCache[hash] ??= await createWebpackTargets(configFilePath, projectRoot, options, context);
|
|
63
|
+
targetsCache[hash] ??= await createWebpackTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup);
|
|
62
64
|
const { targets, metadata } = targetsCache[hash];
|
|
63
65
|
return {
|
|
64
66
|
projects: {
|
|
@@ -70,7 +72,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
70
72
|
},
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
|
-
async function createWebpackTargets(configFilePath, projectRoot, options, context) {
|
|
75
|
+
async function createWebpackTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup) {
|
|
74
76
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
75
77
|
const webpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)((0, path_1.join)(context.workspaceRoot, configFilePath), (0, js_1.getRootTsConfigPath)(), true);
|
|
76
78
|
const webpackOptions = await (0, read_webpack_options_1.readWebpackOptions)(webpackConfig);
|
|
@@ -157,6 +159,20 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
|
|
|
157
159
|
spa: true,
|
|
158
160
|
},
|
|
159
161
|
};
|
|
162
|
+
if (isTsSolutionSetup) {
|
|
163
|
+
targets[options.buildTargetName].syncGenerators = [
|
|
164
|
+
'@nx/js:typescript-sync',
|
|
165
|
+
];
|
|
166
|
+
targets[options.serveTargetName].syncGenerators = [
|
|
167
|
+
'@nx/js:typescript-sync',
|
|
168
|
+
];
|
|
169
|
+
targets[options.previewTargetName].syncGenerators = [
|
|
170
|
+
'@nx/js:typescript-sync',
|
|
171
|
+
];
|
|
172
|
+
targets[options.serveStaticTargetName].syncGenerators = [
|
|
173
|
+
'@nx/js:typescript-sync',
|
|
174
|
+
];
|
|
175
|
+
}
|
|
160
176
|
return { targets, metadata: {} };
|
|
161
177
|
}
|
|
162
178
|
function normalizeOutputPath(outputPath, projectRoot) {
|
package/src/utils/config.js
CHANGED