@nx/webpack 24.0.0-beta.2 → 24.0.0-beta.4

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.
Files changed (61) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/internal.d.ts +3 -0
  4. package/dist/internal.js +7 -1
  5. package/dist/ready-check.d.ts +1 -0
  6. package/dist/ready-check.js +9 -0
  7. package/dist/ready-signal.d.ts +1 -0
  8. package/dist/ready-signal.js +5 -0
  9. package/dist/src/executors/dev-server/dev-server.impl.js +38 -30
  10. package/dist/src/generators/configuration/configuration.js +14 -132
  11. package/dist/src/generators/configuration/schema.d.ts +0 -1
  12. package/dist/src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.js +82 -49
  13. package/dist/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.d.ts +1 -0
  14. package/dist/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.js +31 -2
  15. package/dist/src/generators/convert-config-to-webpack-plugin/schema.json +2 -2
  16. package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +5 -4
  17. package/dist/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +13 -5
  18. package/dist/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +8 -14
  19. package/dist/src/generators/init/init.js +45 -54
  20. package/dist/src/generators/init/schema.d.ts +0 -1
  21. package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +11 -0
  22. package/dist/src/migrations/update-24-0-0/inventory.d.ts +9 -0
  23. package/dist/src/migrations/update-24-0-0/inventory.js +53 -0
  24. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.d.ts +10 -0
  25. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.js +60 -0
  26. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.md +98 -0
  27. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
  28. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +36 -0
  29. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +92 -0
  30. package/dist/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +6 -0
  31. package/dist/src/plugins/nx-webpack-plugin/lib/normalize-options.js +29 -24
  32. package/dist/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.d.ts +2 -0
  33. package/dist/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.js +18 -1
  34. package/dist/src/plugins/plugin.js +24 -0
  35. package/dist/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +3 -0
  36. package/dist/src/utils/config.d.ts +8 -12
  37. package/dist/src/utils/config.js +15 -68
  38. package/dist/src/utils/deprecation.d.ts +1 -6
  39. package/dist/src/utils/deprecation.js +4 -27
  40. package/dist/src/utils/dev-server-ready-check.d.ts +48 -0
  41. package/dist/src/utils/dev-server-ready-check.js +325 -0
  42. package/dist/src/utils/dev-server-ready-signal.d.ts +29 -0
  43. package/dist/src/utils/dev-server-ready-signal.js +60 -0
  44. package/dist/src/utils/e2e-web-server-info-utils.d.ts +1 -1
  45. package/dist/src/utils/e2e-web-server-info-utils.js +2 -2
  46. package/dist/src/utils/webpack/read-webpack-options.d.ts +1 -1
  47. package/dist/src/utils/webpack/read-webpack-options.js +4 -4
  48. package/dist/src/utils/with-nx.d.ts +5 -9
  49. package/dist/src/utils/with-nx.js +5 -32
  50. package/dist/src/utils/with-web.d.ts +5 -9
  51. package/dist/src/utils/with-web.js +5 -24
  52. package/executors.json +0 -10
  53. package/migrations.json +13 -0
  54. package/package.json +20 -4
  55. package/dist/src/executors/webpack/lib/run-webpack.d.ts +0 -3
  56. package/dist/src/executors/webpack/lib/run-webpack.js +0 -36
  57. package/dist/src/executors/webpack/schema.json +0 -459
  58. package/dist/src/executors/webpack/webpack.impl.d.ts +0 -13
  59. package/dist/src/executors/webpack/webpack.impl.js +0 -117
  60. package/dist/src/utils/has-plugin.d.ts +0 -2
  61. package/dist/src/utils/has-plugin.js +0 -10
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webpackExecutor = webpackExecutor;
4
- const internal_1 = require("@nx/devkit/internal");
5
- const devkit_1 = require("@nx/devkit");
6
- const js_1 = require("@nx/js");
7
- const internal_2 = require("@nx/js/internal");
8
- const path_1 = require("path");
9
- const rxjs_1 = require("rxjs");
10
- const operators_1 = require("rxjs/operators");
11
- const config_1 = require("../../utils/config");
12
- const resolve_user_defined_webpack_config_1 = require("../../utils/webpack/resolve-user-defined-webpack-config");
13
- const deprecation_1 = require("../../utils/deprecation");
14
- const normalize_options_1 = require("./lib/normalize-options");
15
- const run_webpack_1 = require("./lib/run-webpack");
16
- async function getWebpackConfigs(options, context) {
17
- let userDefinedWebpackConfig = null;
18
- if (options.webpackConfig) {
19
- userDefinedWebpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)(options.webpackConfig, (0, js_1.getRootTsConfigPath)());
20
- if (typeof userDefinedWebpackConfig.then === 'function') {
21
- userDefinedWebpackConfig = await userDefinedWebpackConfig;
22
- }
23
- }
24
- const config = {};
25
- if (typeof userDefinedWebpackConfig === 'function' &&
26
- ((0, config_1.isNxWebpackComposablePlugin)(userDefinedWebpackConfig) ||
27
- !options.standardWebpackConfigFunction)) {
28
- // Old behavior, call the Nx-specific webpack config function that user exports
29
- return await userDefinedWebpackConfig(config, {
30
- options,
31
- context,
32
- configuration: context.configurationName, // backwards compat
33
- });
34
- }
35
- else if (userDefinedWebpackConfig) {
36
- if (typeof userDefinedWebpackConfig === 'function') {
37
- // assume it's an async standard webpack config function
38
- // https://webpack.js.org/configuration/configuration-types/#exporting-a-promise
39
- return await userDefinedWebpackConfig(process.env.NODE_ENV, {});
40
- }
41
- // New behavior, we want the webpack config to export object
42
- return userDefinedWebpackConfig;
43
- }
44
- else {
45
- // Fallback case, if we cannot find a webpack config path
46
- return config;
47
- }
48
- }
49
- async function* webpackExecutor(_options, context) {
50
- (0, deprecation_1.warnWebpackExecutorDeprecation)();
51
- // Default to production build.
52
- process.env['NODE_ENV'] ||= 'production';
53
- const metadata = context.projectsConfigurations.projects[context.projectName];
54
- const sourceRoot = (0, internal_2.getProjectSourceRoot)(metadata);
55
- const options = (0, normalize_options_1.normalizeOptions)(_options, context.root, metadata.root, sourceRoot);
56
- const isScriptOptimizeOn = typeof options.optimization === 'boolean'
57
- ? options.optimization
58
- : options.optimization && options.optimization.scripts
59
- ? options.optimization.scripts
60
- : false;
61
- process.env.NODE_ENV ||= isScriptOptimizeOn
62
- ? 'production'
63
- : 'development';
64
- process.env.NX_BUILD_LIBS_FROM_SOURCE = `${options.buildLibsFromSource}`;
65
- process.env.NX_BUILD_TARGET = (0, devkit_1.targetToTargetString)({
66
- project: context.projectName,
67
- target: context.targetName,
68
- configuration: context.configurationName,
69
- });
70
- if (options.compiler === 'swc') {
71
- try {
72
- require.resolve('swc-loader');
73
- require.resolve('@swc/core');
74
- }
75
- catch {
76
- devkit_1.logger.error(`Missing SWC dependencies: @swc/core, swc-loader. Make sure you install them first.`);
77
- return {
78
- success: false,
79
- options,
80
- };
81
- }
82
- }
83
- if (options.generatePackageJson && metadata.projectType !== 'application') {
84
- devkit_1.logger.warn((0, devkit_1.stripIndents) `The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.
85
- For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/nx-api/eslint-plugin/documents/dependency-checks).`);
86
- }
87
- const configs = await getWebpackConfigs(options, context);
88
- return yield* (0, internal_1.eachValueFrom)((0, rxjs_1.of)(configs).pipe((0, operators_1.mergeMap)((config) => (Array.isArray(config) ? (0, rxjs_1.from)(config) : (0, rxjs_1.of)(config))),
89
- // Run build sequentially and bail when first one fails.
90
- (0, operators_1.mergeScan)((acc, config) => {
91
- if (!acc.hasErrors()) {
92
- // Propagate watch mode from executor options to webpack config.
93
- // Without this, NxAppWebpackPlugin-based configs run in single-run
94
- // mode even when the executor is invoked with watch: true, causing
95
- // @nx/js:node to restart the process after every build.
96
- config.watch = options.watch ?? config.watch;
97
- return (0, run_webpack_1.runWebpack)(config).pipe((0, operators_1.tap)((stats) => {
98
- console.info(stats.toString(config.stats));
99
- }));
100
- }
101
- else {
102
- return (0, rxjs_1.of)();
103
- }
104
- }, { hasErrors: () => false }, 1),
105
- // Collect build results as an array.
106
- (0, operators_1.bufferCount)(Array.isArray(configs) ? configs.length : 1), (0, operators_1.switchMap)(async (results) => {
107
- const success = results.every((result) => Boolean(result) && !result.hasErrors());
108
- // TODO(jack): This should read output from webpack config if provided.
109
- // The outfile is only used by NestJS, where `@nx/js:node` executor requires it to run the file.
110
- return {
111
- success,
112
- outfile: (0, path_1.resolve)(context.root, options.outputPath, options.outputFileName),
113
- options,
114
- };
115
- })));
116
- }
117
- exports.default = webpackExecutor;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function hasPlugin(tree: Tree): boolean;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasPlugin = hasPlugin;
4
- const devkit_1 = require("@nx/devkit");
5
- function hasPlugin(tree) {
6
- const nxJson = (0, devkit_1.readNxJson)(tree);
7
- return !!nxJson.plugins?.some((p) => typeof p === 'string'
8
- ? p === '@nx/webpack/plugin'
9
- : p.plugin === '@nx/webpack/plugin');
10
- }