@nx/webpack 23.0.0-pr.35465.2bc2643 → 23.0.0-rc.1

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 (233) hide show
  1. package/{app-plugin.d.ts → dist/app-plugin.d.ts} +0 -1
  2. package/{index.d.ts → dist/index.d.ts} +0 -4
  3. package/{index.js → dist/index.js} +1 -4
  4. package/dist/internal.d.ts +8 -0
  5. package/dist/internal.js +26 -0
  6. package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
  7. package/{src → dist/src}/executors/dev-server/dev-server.impl.d.ts +0 -1
  8. package/{src → dist/src}/executors/dev-server/dev-server.impl.js +10 -8
  9. package/{src → dist/src}/executors/dev-server/lib/get-dev-server-config.d.ts +0 -1
  10. package/{src → dist/src}/executors/dev-server/lib/serve-path.d.ts +0 -1
  11. package/{src → dist/src}/executors/dev-server/schema.json +1 -0
  12. package/{src → dist/src}/executors/ssr-dev-server/lib/wait-until-server-is-listening.d.ts +0 -1
  13. package/{src → dist/src}/executors/ssr-dev-server/ssr-dev-server.impl.d.ts +0 -1
  14. package/{src → dist/src}/executors/ssr-dev-server/ssr-dev-server.impl.js +2 -2
  15. package/{src → dist/src}/executors/webpack/lib/normalize-options.d.ts +0 -1
  16. package/{src → dist/src}/executors/webpack/lib/normalize-options.js +2 -2
  17. package/{src → dist/src}/executors/webpack/lib/run-webpack.d.ts +1 -2
  18. package/{src → dist/src}/executors/webpack/lib/run-webpack.js +3 -3
  19. package/{src → dist/src}/executors/webpack/schema.d.ts +1 -1
  20. package/{src → dist/src}/executors/webpack/schema.json +1 -0
  21. package/{src → dist/src}/executors/webpack/webpack.impl.d.ts +0 -1
  22. package/{src → dist/src}/executors/webpack/webpack.impl.js +6 -4
  23. package/{src → dist/src}/generators/configuration/configuration.d.ts +0 -1
  24. package/{src → dist/src}/generators/configuration/configuration.js +9 -2
  25. package/{src → dist/src}/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.d.ts +0 -1
  26. package/{src → dist/src}/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.js +5 -3
  27. package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.d.ts +0 -1
  28. package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/normalize-path-options.d.ts +0 -1
  29. package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/utils.d.ts +0 -1
  30. package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/validate-project.d.ts +0 -1
  31. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
  32. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +5 -5
  33. package/{src → dist/src}/generators/convert-to-inferred/utils/ast.d.ts +0 -1
  34. package/{src → dist/src}/generators/convert-to-inferred/utils/build-post-target-transformer.d.ts +0 -1
  35. package/{src → dist/src}/generators/convert-to-inferred/utils/build-post-target-transformer.js +8 -8
  36. package/{src → dist/src}/generators/convert-to-inferred/utils/index.d.ts +0 -1
  37. package/{src → dist/src}/generators/convert-to-inferred/utils/serve-post-target-transformer.d.ts +0 -1
  38. package/{src → dist/src}/generators/convert-to-inferred/utils/serve-post-target-transformer.js +4 -4
  39. package/{src → dist/src}/generators/convert-to-inferred/utils/types.d.ts +1 -2
  40. package/{src → dist/src}/generators/init/init.d.ts +0 -1
  41. package/{src → dist/src}/generators/init/init.js +10 -3
  42. package/{src → dist/src}/generators/init/schema.json +1 -1
  43. package/{src → dist/src}/migrations/update-21-0-0/remove-isolated-config.d.ts +0 -1
  44. package/{src → dist/src}/migrations/update-21-0-0/remove-isolated-config.js +2 -2
  45. package/dist/src/migrations/update-21-0-0/remove-isolated-config.md +37 -0
  46. package/{src → dist/src}/migrations/update-22-0-0/remove-deprecated-options.d.ts +0 -1
  47. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.d.ts +9 -0
  48. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.js +223 -0
  49. package/dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md +25 -0
  50. package/dist/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.d.ts +2 -0
  51. package/dist/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.js +128 -0
  52. package/dist/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.md +54 -0
  53. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
  54. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +225 -0
  55. package/{src → dist/src}/plugins/generate-package-json-plugin.d.ts +0 -1
  56. package/{src → dist/src}/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +0 -1
  57. package/{src → dist/src}/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +5 -5
  58. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +0 -1
  59. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/apply-base-config.js +2 -2
  60. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +0 -1
  61. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/apply-web-config.js +3 -3
  62. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +0 -1
  63. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts +0 -1
  64. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +0 -1
  65. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +0 -1
  66. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/normalize-options.js +2 -2
  67. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +0 -1
  68. package/{src → dist/src}/plugins/nx-webpack-plugin/lib/utils.d.ts +0 -1
  69. package/{src → dist/src}/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.d.ts +1 -2
  70. package/{src → dist/src}/plugins/nx-webpack-plugin/nx-app-webpack-plugin.d.ts +0 -1
  71. package/{src → dist/src}/plugins/plugin.d.ts +3 -4
  72. package/{src → dist/src}/plugins/plugin.js +62 -29
  73. package/{src → dist/src}/plugins/stats-json-plugin.d.ts +0 -1
  74. package/{src → dist/src}/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.d.ts +0 -1
  75. package/{src → dist/src}/plugins/webpack-nx-build-coordination-plugin.d.ts +0 -1
  76. package/{src → dist/src}/plugins/write-index-html-plugin.d.ts +0 -1
  77. package/{src → dist/src}/utils/config.d.ts +12 -1
  78. package/{src → dist/src}/utils/config.js +17 -2
  79. package/{src → dist/src}/utils/create-copy-plugin.d.ts +0 -1
  80. package/dist/src/utils/deprecation.d.ts +8 -0
  81. package/dist/src/utils/deprecation.js +55 -0
  82. package/dist/src/utils/e2e-web-server-info-utils.d.ts +2 -0
  83. package/{src → dist/src}/utils/e2e-web-server-info-utils.js +6 -5
  84. package/{src → dist/src}/utils/ensure-dependencies.d.ts +0 -1
  85. package/{src → dist/src}/utils/ensure-dependencies.js +3 -3
  86. package/{src → dist/src}/utils/fs.d.ts +0 -1
  87. package/{src → dist/src}/utils/get-client-environment.d.ts +0 -1
  88. package/{src → dist/src}/utils/get-css-module-local-ident.d.ts +0 -1
  89. package/{src → dist/src}/utils/has-plugin.d.ts +0 -1
  90. package/{src → dist/src}/utils/hash-format.d.ts +0 -1
  91. package/{src → dist/src}/utils/models.d.ts +0 -1
  92. package/{src → dist/src}/utils/run-webpack.d.ts +0 -1
  93. package/dist/src/utils/versions.d.ts +12 -0
  94. package/dist/src/utils/versions.js +24 -0
  95. package/dist/src/utils/web-babel-loader.d.ts +1 -0
  96. package/{src → dist/src}/utils/web-babel-loader.js +2 -0
  97. package/dist/src/utils/webpack/deprecated-less-loader.js +19 -0
  98. package/{src → dist/src}/utils/webpack/interpolate-env-variables-to-index.d.ts +0 -1
  99. package/{src → dist/src}/utils/webpack/normalize-entry.d.ts +0 -1
  100. package/{src → dist/src}/utils/webpack/package-chunk-sort.d.ts +0 -1
  101. package/{src → dist/src}/utils/webpack/plugins/postcss-cli-resources.d.ts +0 -1
  102. package/{src → dist/src}/utils/webpack/plugins/scripts-webpack-plugin.d.ts +0 -1
  103. package/{src → dist/src}/utils/webpack/read-webpack-options.d.ts +0 -1
  104. package/{src → dist/src}/utils/webpack/resolve-user-defined-webpack-config.d.ts +0 -1
  105. package/{src → dist/src}/utils/webpack/resolve-user-defined-webpack-config.js +4 -6
  106. package/{src → dist/src}/utils/with-nx.d.ts +4 -1
  107. package/{src → dist/src}/utils/with-nx.js +6 -0
  108. package/{src → dist/src}/utils/with-web.d.ts +4 -1
  109. package/{src → dist/src}/utils/with-web.js +6 -0
  110. package/{tsconfig-paths-plugin.d.ts → dist/tsconfig-paths-plugin.d.ts} +0 -1
  111. package/executors.json +6 -6
  112. package/generators.json +8 -8
  113. package/migrations.json +34 -20
  114. package/package.json +85 -16
  115. package/app-plugin.d.ts.map +0 -1
  116. package/index.d.ts.map +0 -1
  117. package/plugin.d.ts.map +0 -1
  118. package/src/executors/dev-server/dev-server.impl.d.ts.map +0 -1
  119. package/src/executors/dev-server/lib/get-dev-server-config.d.ts.map +0 -1
  120. package/src/executors/dev-server/lib/serve-path.d.ts.map +0 -1
  121. package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.d.ts.map +0 -1
  122. package/src/executors/ssr-dev-server/ssr-dev-server.impl.d.ts.map +0 -1
  123. package/src/executors/webpack/lib/normalize-options.d.ts.map +0 -1
  124. package/src/executors/webpack/lib/run-webpack.d.ts.map +0 -1
  125. package/src/executors/webpack/webpack.impl.d.ts.map +0 -1
  126. package/src/generators/configuration/configuration.d.ts.map +0 -1
  127. package/src/generators/convert-config-to-webpack-plugin/convert-config-to-webpack-plugin.d.ts.map +0 -1
  128. package/src/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.d.ts.map +0 -1
  129. package/src/generators/convert-config-to-webpack-plugin/lib/normalize-path-options.d.ts.map +0 -1
  130. package/src/generators/convert-config-to-webpack-plugin/lib/utils.d.ts.map +0 -1
  131. package/src/generators/convert-config-to-webpack-plugin/lib/validate-project.d.ts.map +0 -1
  132. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
  133. package/src/generators/convert-to-inferred/utils/ast.d.ts.map +0 -1
  134. package/src/generators/convert-to-inferred/utils/build-post-target-transformer.d.ts.map +0 -1
  135. package/src/generators/convert-to-inferred/utils/index.d.ts.map +0 -1
  136. package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.d.ts.map +0 -1
  137. package/src/generators/convert-to-inferred/utils/types.d.ts.map +0 -1
  138. package/src/generators/init/init.d.ts.map +0 -1
  139. package/src/migrations/update-21-0-0/remove-isolated-config.d.ts.map +0 -1
  140. package/src/migrations/update-22-0-0/remove-deprecated-options.d.ts.map +0 -1
  141. package/src/plugins/generate-package-json-plugin.d.ts.map +0 -1
  142. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts.map +0 -1
  143. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts.map +0 -1
  144. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts.map +0 -1
  145. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts.map +0 -1
  146. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts.map +0 -1
  147. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts.map +0 -1
  148. package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts.map +0 -1
  149. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts.map +0 -1
  150. package/src/plugins/nx-webpack-plugin/lib/utils.d.ts.map +0 -1
  151. package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.d.ts.map +0 -1
  152. package/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.d.ts.map +0 -1
  153. package/src/plugins/plugin.d.ts.map +0 -1
  154. package/src/plugins/stats-json-plugin.d.ts.map +0 -1
  155. package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.d.ts.map +0 -1
  156. package/src/plugins/webpack-nx-build-coordination-plugin.d.ts.map +0 -1
  157. package/src/plugins/write-index-html-plugin.d.ts.map +0 -1
  158. package/src/utils/config.d.ts.map +0 -1
  159. package/src/utils/create-copy-plugin.d.ts.map +0 -1
  160. package/src/utils/e2e-web-server-info-utils.d.ts +0 -3
  161. package/src/utils/e2e-web-server-info-utils.d.ts.map +0 -1
  162. package/src/utils/ensure-dependencies.d.ts.map +0 -1
  163. package/src/utils/fs.d.ts.map +0 -1
  164. package/src/utils/get-client-environment.d.ts.map +0 -1
  165. package/src/utils/get-css-module-local-ident.d.ts.map +0 -1
  166. package/src/utils/has-plugin.d.ts.map +0 -1
  167. package/src/utils/hash-format.d.ts.map +0 -1
  168. package/src/utils/models.d.ts.map +0 -1
  169. package/src/utils/run-webpack.d.ts.map +0 -1
  170. package/src/utils/versions.d.ts +0 -8
  171. package/src/utils/versions.d.ts.map +0 -1
  172. package/src/utils/versions.js +0 -11
  173. package/src/utils/web-babel-loader.d.ts +0 -1
  174. package/src/utils/web-babel-loader.d.ts.map +0 -1
  175. package/src/utils/webpack/interpolate-env-variables-to-index.d.ts.map +0 -1
  176. package/src/utils/webpack/normalize-entry.d.ts.map +0 -1
  177. package/src/utils/webpack/package-chunk-sort.d.ts.map +0 -1
  178. package/src/utils/webpack/plugins/postcss-cli-resources.d.ts.map +0 -1
  179. package/src/utils/webpack/plugins/scripts-webpack-plugin.d.ts.map +0 -1
  180. package/src/utils/webpack/read-webpack-options.d.ts.map +0 -1
  181. package/src/utils/webpack/resolve-user-defined-webpack-config.d.ts.map +0 -1
  182. package/src/utils/with-nx.d.ts.map +0 -1
  183. package/src/utils/with-web.d.ts.map +0 -1
  184. package/tsconfig-paths-plugin.d.ts.map +0 -1
  185. /package/{LICENSE → dist/LICENSE} +0 -0
  186. /package/{app-plugin.js → dist/app-plugin.js} +0 -0
  187. /package/{plugin.js → dist/plugin.js} +0 -0
  188. /package/{src → dist/src}/executors/dev-server/lib/get-dev-server-config.js +0 -0
  189. /package/{src → dist/src}/executors/dev-server/lib/serve-path.js +0 -0
  190. /package/{src → dist/src}/executors/dev-server/schema.d.ts +0 -0
  191. /package/{src → dist/src}/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +0 -0
  192. /package/{src → dist/src}/executors/ssr-dev-server/schema.d.ts +0 -0
  193. /package/{src → dist/src}/executors/ssr-dev-server/schema.json +0 -0
  194. /package/{src → dist/src}/generators/configuration/schema.d.ts +0 -0
  195. /package/{src → dist/src}/generators/configuration/schema.json +0 -0
  196. /package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/extract-webpack-options.js +0 -0
  197. /package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/normalize-path-options.js +0 -0
  198. /package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/utils.js +0 -0
  199. /package/{src → dist/src}/generators/convert-config-to-webpack-plugin/lib/validate-project.js +0 -0
  200. /package/{src → dist/src}/generators/convert-config-to-webpack-plugin/schema.json +0 -0
  201. /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
  202. /package/{src → dist/src}/generators/convert-to-inferred/utils/ast.js +0 -0
  203. /package/{src → dist/src}/generators/convert-to-inferred/utils/index.js +0 -0
  204. /package/{src → dist/src}/generators/convert-to-inferred/utils/types.js +0 -0
  205. /package/{src → dist/src}/generators/init/schema.d.ts +0 -0
  206. /package/{src → dist/src}/migrations/update-22-0-0/remove-deprecated-options.js +0 -0
  207. /package/{src → dist/src}/plugins/generate-package-json-plugin.js +0 -0
  208. /package/{src → dist/src}/plugins/nx-webpack-plugin/lib/compiler-loaders.js +0 -0
  209. /package/{src → dist/src}/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.js +0 -0
  210. /package/{src → dist/src}/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.js +0 -0
  211. /package/{src → dist/src}/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +0 -0
  212. /package/{src → dist/src}/plugins/nx-webpack-plugin/lib/utils.js +0 -0
  213. /package/{src → dist/src}/plugins/nx-webpack-plugin/nx-app-webpack-plugin-options.js +0 -0
  214. /package/{src → dist/src}/plugins/nx-webpack-plugin/nx-app-webpack-plugin.js +0 -0
  215. /package/{src → dist/src}/plugins/stats-json-plugin.js +0 -0
  216. /package/{src → dist/src}/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +0 -0
  217. /package/{src → dist/src}/plugins/webpack-nx-build-coordination-plugin.js +0 -0
  218. /package/{src → dist/src}/plugins/write-index-html-plugin.js +0 -0
  219. /package/{src → dist/src}/utils/create-copy-plugin.js +0 -0
  220. /package/{src → dist/src}/utils/fs.js +0 -0
  221. /package/{src → dist/src}/utils/get-client-environment.js +0 -0
  222. /package/{src → dist/src}/utils/get-css-module-local-ident.js +0 -0
  223. /package/{src → dist/src}/utils/has-plugin.js +0 -0
  224. /package/{src → dist/src}/utils/hash-format.js +0 -0
  225. /package/{src → dist/src}/utils/models.js +0 -0
  226. /package/{src → dist/src}/utils/run-webpack.js +0 -0
  227. /package/{src → dist/src}/utils/webpack/interpolate-env-variables-to-index.js +0 -0
  228. /package/{src → dist/src}/utils/webpack/normalize-entry.js +0 -0
  229. /package/{src → dist/src}/utils/webpack/package-chunk-sort.js +0 -0
  230. /package/{src → dist/src}/utils/webpack/plugins/postcss-cli-resources.js +0 -0
  231. /package/{src → dist/src}/utils/webpack/plugins/scripts-webpack-plugin.js +0 -0
  232. /package/{src → dist/src}/utils/webpack/read-webpack-options.js +0 -0
  233. /package/{tsconfig-paths-plugin.js → dist/tsconfig-paths-plugin.js} +0 -0
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = rewriteInternalSubpathImports;
4
+ exports.rewriteSubpathImports = rewriteSubpathImports;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
7
+ const FROM_PREFIX = '@nx/webpack/src/';
8
+ const TO_PUBLIC = '@nx/webpack';
9
+ const TO_INTERNAL = '@nx/webpack/internal';
10
+ // Symbols exported from `@nx/webpack`'s public entry (packages/webpack/index.ts).
11
+ // A named import/export of one of these from `@nx/webpack/src/*` is routed to
12
+ // the public `@nx/webpack` entry; everything else goes to `@nx/webpack/internal`.
13
+ const PUBLIC_SYMBOLS = new Set([
14
+ 'AssetGlobPattern',
15
+ 'AsyncNxComposableWebpackPlugin',
16
+ 'FileReplacement',
17
+ 'MergedOptions',
18
+ 'NormalizedWebpackExecutorOptions',
19
+ 'NxComposableWebpackPlugin',
20
+ 'NxWebpackExecutionContext',
21
+ 'NxWebpackPlugin',
22
+ 'WebDevServerOptions',
23
+ 'WebpackExecutorEvent',
24
+ 'WebpackExecutorOptions',
25
+ 'WithNxOptions',
26
+ 'WithWebOptions',
27
+ 'composePlugins',
28
+ 'composePluginsSync',
29
+ 'configurationGenerator',
30
+ 'convertConfigToWebpackPluginGenerator',
31
+ 'createCopyPlugin',
32
+ 'devServerExecutor',
33
+ 'getCSSModuleLocalIdent',
34
+ 'getWebpackE2EWebServerInfo',
35
+ 'isNxWebpackComposablePlugin',
36
+ 'normalizeOptions',
37
+ 'normalizePluginPath',
38
+ 'nxWebpackComposablePlugin',
39
+ 'useLegacyNxPlugin',
40
+ 'webpackExecutor',
41
+ 'webpackInitGenerator',
42
+ 'webpackProjectGenerator',
43
+ 'withNx',
44
+ 'withWeb',
45
+ ]);
46
+ // Methods on `jest` and `vi` that take a module specifier as their first arg.
47
+ const MOCK_HELPER_METHODS = new Set([
48
+ 'mock',
49
+ 'unmock',
50
+ 'doMock',
51
+ 'dontMock',
52
+ 'requireActual',
53
+ 'requireMock',
54
+ 'importActual',
55
+ 'importMock',
56
+ ]);
57
+ let ts;
58
+ async function rewriteInternalSubpathImports(tree) {
59
+ let touchedCount = 0;
60
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
61
+ if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
62
+ return;
63
+ }
64
+ const original = tree.read(filePath, 'utf-8');
65
+ if (!original || !original.includes(FROM_PREFIX)) {
66
+ return;
67
+ }
68
+ const updated = rewriteSubpathImports(original);
69
+ if (updated !== original) {
70
+ tree.write(filePath, updated);
71
+ touchedCount += 1;
72
+ }
73
+ });
74
+ if (touchedCount > 0) {
75
+ devkit_1.logger.info(`Rewrote @nx/webpack/src/* imports in ${touchedCount} file(s) ` +
76
+ `(public symbols to @nx/webpack, internals to @nx/webpack/internal).`);
77
+ }
78
+ await (0, devkit_1.formatFiles)(tree);
79
+ }
80
+ function rewriteSubpathImports(source) {
81
+ ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
82
+ const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
83
+ /* setParentNodes */ true, ts.ScriptKind.TSX);
84
+ const changes = [];
85
+ for (const stmt of sourceFile.statements) {
86
+ if (ts.isImportDeclaration(stmt)) {
87
+ collectImportRewrite(sourceFile, stmt, changes);
88
+ }
89
+ else if (ts.isExportDeclaration(stmt)) {
90
+ collectExportRewrite(sourceFile, stmt, changes);
91
+ }
92
+ }
93
+ collectCallExpressionRewrites(sourceFile, changes);
94
+ return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
95
+ }
96
+ function isSubpathSpecifier(node) {
97
+ return ts.isStringLiteral(node) && node.text.startsWith(FROM_PREFIX);
98
+ }
99
+ function collectImportRewrite(sourceFile, stmt, changes) {
100
+ if (!isSubpathSpecifier(stmt.moduleSpecifier)) {
101
+ return;
102
+ }
103
+ const clause = stmt.importClause;
104
+ // Pure named imports (`import { a, b } from '...'`) can be split by symbol.
105
+ // A default or namespace import grabs the whole module, so it can't be
106
+ // split — route it wholesale to the internal entry.
107
+ if (clause &&
108
+ !clause.name &&
109
+ clause.namedBindings &&
110
+ ts.isNamedImports(clause.namedBindings)) {
111
+ rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, clause.isTypeOnly, clause.namedBindings.elements, 'import', changes);
112
+ return;
113
+ }
114
+ replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
115
+ }
116
+ function collectExportRewrite(sourceFile, stmt, changes) {
117
+ if (!stmt.moduleSpecifier || !isSubpathSpecifier(stmt.moduleSpecifier)) {
118
+ return;
119
+ }
120
+ // `export { a, b } from '...'` can be split; `export * from '...'` cannot.
121
+ if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
122
+ rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, stmt.isTypeOnly, stmt.exportClause.elements, 'export', changes);
123
+ return;
124
+ }
125
+ replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
126
+ }
127
+ /**
128
+ * Partition the named bindings of an import/export declaration into the ones
129
+ * that resolve to `@nx/webpack`'s public entry and the ones that don't. If both
130
+ * groups are non-empty, the single declaration is split into two.
131
+ */
132
+ function rewriteNamedDeclaration(sourceFile, decl, specifier, isTypeOnly, elements, keyword, changes) {
133
+ const publicEls = [];
134
+ const internalEls = [];
135
+ for (const el of elements) {
136
+ // `propertyName` is the original name in `orig as alias`; fall back to
137
+ // `name` for the plain `orig` form.
138
+ const importedName = (el.propertyName ?? el.name).text;
139
+ (PUBLIC_SYMBOLS.has(importedName) ? publicEls : internalEls).push(el);
140
+ }
141
+ if (publicEls.length === 0) {
142
+ replaceSpecifier(sourceFile, specifier, TO_INTERNAL, changes);
143
+ return;
144
+ }
145
+ if (internalEls.length === 0) {
146
+ replaceSpecifier(sourceFile, specifier, TO_PUBLIC, changes);
147
+ return;
148
+ }
149
+ // Mixed — replace the whole declaration with one statement per target.
150
+ const quote = sourceFile.text.charAt(specifier.getStart(sourceFile));
151
+ const start = decl.getStart(sourceFile);
152
+ const end = decl.getEnd();
153
+ const semicolon = sourceFile.text.charAt(end - 1) === ';' ? ';' : '';
154
+ const prefix = isTypeOnly ? `${keyword} type` : keyword;
155
+ const render = (els, target) => `${prefix} { ${els
156
+ .map((el) => el.getText(sourceFile))
157
+ .join(', ')} } from ${quote}${target}${quote}${semicolon}`;
158
+ changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
159
+ type: devkit_1.ChangeType.Insert,
160
+ index: start,
161
+ text: `${render(publicEls, TO_PUBLIC)}\n${render(internalEls, TO_INTERNAL)}`,
162
+ });
163
+ }
164
+ function collectCallExpressionRewrites(sourceFile, changes) {
165
+ const visit = (node) => {
166
+ if (ts.isCallExpression(node) &&
167
+ shouldRewriteCallExpression(node) &&
168
+ node.arguments.length >= 1 &&
169
+ isSubpathSpecifier(node.arguments[0])) {
170
+ // `require(...)`, dynamic `import(...)` and `jest.mock(...)` reference
171
+ // the module as a whole and can't be symbol-split, so they go to the
172
+ // internal entry.
173
+ replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
174
+ }
175
+ else if (ts.isImportTypeNode(node)) {
176
+ // `typeof import('...')` parses as an `ImportTypeNode`, not a
177
+ // CallExpression — its argument is `LiteralTypeNode<StringLiteral>`.
178
+ // The whole module is referenced, so it can't be symbol-split.
179
+ const literal = getImportTypeStringLiteral(node);
180
+ if (literal && literal.text.startsWith(FROM_PREFIX)) {
181
+ replaceSpecifier(sourceFile, literal, TO_INTERNAL, changes);
182
+ }
183
+ }
184
+ ts.forEachChild(node, visit);
185
+ };
186
+ visit(sourceFile);
187
+ }
188
+ function getImportTypeStringLiteral(node) {
189
+ const arg = node.argument;
190
+ if (arg && ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal)) {
191
+ return arg.literal;
192
+ }
193
+ return undefined;
194
+ }
195
+ function shouldRewriteCallExpression(call) {
196
+ const callee = call.expression;
197
+ // `require('...')`
198
+ if (ts.isIdentifier(callee) && callee.text === 'require')
199
+ return true;
200
+ // dynamic `import('...')` (runtime form parses as a CallExpression whose
201
+ // callee is the `import` keyword). The `typeof import('...')` type-position
202
+ // form is an `ImportTypeNode` (handled in `collectCallExpressionRewrites`).
203
+ if (callee.kind === ts.SyntaxKind.ImportKeyword)
204
+ return true;
205
+ // `jest.mock(...)` / `vi.mock(...)` and friends.
206
+ if (ts.isPropertyAccessExpression(callee)) {
207
+ const obj = callee.expression;
208
+ if (ts.isIdentifier(obj) &&
209
+ (obj.text === 'jest' || obj.text === 'vi') &&
210
+ MOCK_HELPER_METHODS.has(callee.name.text)) {
211
+ return true;
212
+ }
213
+ }
214
+ return false;
215
+ }
216
+ function replaceSpecifier(sourceFile, literal, target, changes) {
217
+ const start = literal.getStart(sourceFile);
218
+ const end = literal.getEnd();
219
+ const quote = sourceFile.text.charAt(start);
220
+ changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
221
+ type: devkit_1.ChangeType.Insert,
222
+ index: start,
223
+ text: `${quote}${target}${quote}`,
224
+ });
225
+ }
@@ -15,4 +15,3 @@ export declare class GeneratePackageJsonPlugin implements WebpackPluginInstance
15
15
  private resolveRuntimeDependencies;
16
16
  apply(compiler: Compiler): void;
17
17
  }
18
- //# sourceMappingURL=generate-package-json-plugin.d.ts.map
@@ -6,4 +6,3 @@ export declare class NxTsconfigPathsWebpackPlugin {
6
6
  apply(compiler: Compiler): void;
7
7
  handleBuildLibsFromSource(config: Partial<WebpackOptionsNormalized | Configuration>, options: NormalizedNxAppWebpackPluginOptions): void;
8
8
  }
9
- //# sourceMappingURL=nx-tsconfig-paths-webpack-plugin.d.ts.map
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
7
7
  const devkit_1 = require("@nx/devkit");
8
- const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
9
- const ts_config_1 = require("@nx/js/src/utils/typescript/ts-config");
8
+ const internal_1 = require("@nx/js/internal");
9
+ const js_1 = require("@nx/js");
10
10
  const webpack_nx_build_coordination_plugin_1 = require("../webpack-nx-build-coordination-plugin");
11
11
  class NxTsconfigPathsWebpackPlugin {
12
12
  constructor(options) {
@@ -30,7 +30,7 @@ class NxTsconfigPathsWebpackPlugin {
30
30
  : this.options.tsConfig;
31
31
  compiler.options.resolve.plugins.push(new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
32
32
  configFile,
33
- baseUrl: (0, ts_config_1.resolvePathsBaseUrl)(configFile),
33
+ baseUrl: (0, js_1.resolvePathsBaseUrl)(configFile),
34
34
  extensions: Array.from(extensions),
35
35
  mainFields: ['module', 'main'],
36
36
  }));
@@ -38,8 +38,8 @@ class NxTsconfigPathsWebpackPlugin {
38
38
  handleBuildLibsFromSource(config, options) {
39
39
  if (!options.buildLibsFromSource && options.targetName) {
40
40
  const remappedTarget = options.targetName === 'serve' ? 'build' : options.targetName;
41
- const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(undefined, options.projectGraph, options.root, options.projectName, remappedTarget, options.configurationName);
42
- options.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, options.root, target.data.root, dependencies);
41
+ const { target, dependencies } = (0, internal_1.calculateProjectBuildableDependencies)(undefined, options.projectGraph, options.root, options.projectName, remappedTarget, options.configurationName);
42
+ options.tsConfig = (0, internal_1.createTmpTsConfig)(options.tsConfig, options.root, target.data.root, dependencies);
43
43
  if (options.targetName === 'serve') {
44
44
  const buildableDependencies = dependencies
45
45
  .filter((dependency) => dependency.node.type === 'lib')
@@ -3,4 +3,3 @@ import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-op
3
3
  export declare function applyBaseConfig(options: NormalizedNxAppWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>, { useNormalizedEntry, }?: {
4
4
  useNormalizedEntry?: boolean;
5
5
  }): void;
6
- //# sourceMappingURL=apply-base-config.d.ts.map
@@ -15,7 +15,7 @@ const get_terser_ecma_version_1 = require("./get-terser-ecma-version");
15
15
  const compiler_loaders_1 = require("./compiler-loaders");
16
16
  const TerserPlugin = require("terser-webpack-plugin");
17
17
  const nodeExternals = require("webpack-node-externals");
18
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
18
+ const internal_1 = require("@nx/js/internal");
19
19
  const utils_1 = require("./utils");
20
20
  const IGNORED_WEBPACK_WARNINGS = [
21
21
  /The comment file/i,
@@ -208,7 +208,7 @@ function applyNxDependentConfig(options, config, { useNormalizedEntry } = {}) {
208
208
  configurationName: options.configurationName,
209
209
  root: options.root,
210
210
  };
211
- const isUsingTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
211
+ const isUsingTsSolution = (0, internal_1.isUsingTsSolutionSetup)();
212
212
  options.useTsconfigPaths ??= !isUsingTsSolution;
213
213
  // If the project is using ts solutions setup, the paths are not in tsconfig and we should not use the plugin's paths.
214
214
  if (options.useTsconfigPaths) {
@@ -3,4 +3,3 @@ import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-op
3
3
  export declare function applyWebConfig(options: NormalizedNxAppWebpackPluginOptions, config?: Partial<WebpackOptionsNormalized | Configuration>, { useNormalizedEntry, }?: {
4
4
  useNormalizedEntry?: boolean;
5
5
  }): void;
6
- //# sourceMappingURL=apply-web-config.d.ts.map
@@ -118,7 +118,7 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
118
118
  use: [
119
119
  ...(0, stylesheet_loaders_1.getCommonLoadersForCssModules)(options, includePaths),
120
120
  {
121
- loader: require.resolve('less-loader'),
121
+ loader: path.join(__dirname, '../../../utils/webpack/deprecated-less-loader.js'),
122
122
  options: {
123
123
  lessOptions: {
124
124
  paths: includePaths,
@@ -163,7 +163,7 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
163
163
  use: [
164
164
  ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalCss)(options, includePaths),
165
165
  {
166
- loader: require.resolve('less-loader'),
166
+ loader: path.join(__dirname, '../../../utils/webpack/deprecated-less-loader.js'),
167
167
  options: {
168
168
  sourceMap: !!options.sourceMap,
169
169
  lessOptions: {
@@ -210,7 +210,7 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
210
210
  use: [
211
211
  ...(0, stylesheet_loaders_1.getCommonLoadersForGlobalStyle)(options, includePaths),
212
212
  {
213
- loader: require.resolve('less-loader'),
213
+ loader: path.join(__dirname, '../../../utils/webpack/deprecated-less-loader.js'),
214
214
  options: {
215
215
  sourceMap: !!options.sourceMap,
216
216
  lessOptions: {
@@ -53,4 +53,3 @@ export declare function createLoaderFromCompiler(options: NormalizedNxAppWebpack
53
53
  jsc?: undefined;
54
54
  };
55
55
  };
56
- //# sourceMappingURL=compiler-loaders.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare function getTerserEcmaVersion(projectRoot: string): 2020 | 5;
2
- //# sourceMappingURL=get-terser-ecma-version.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import { WebpackPluginInstance } from 'webpack';
2
2
  import { NormalizedNxAppWebpackPluginOptions } from '../nx-app-webpack-plugin-options';
3
3
  export declare function instantiateScriptPlugins(options: NormalizedNxAppWebpackPluginOptions): WebpackPluginInstance[];
4
- //# sourceMappingURL=instantiate-script-plugins.d.ts.map
@@ -2,4 +2,3 @@ import { AssetGlobPattern, FileReplacement, NormalizedNxAppWebpackPluginOptions,
2
2
  export declare function normalizeOptions(options: NxAppWebpackPluginOptions): NormalizedNxAppWebpackPluginOptions;
3
3
  export declare function normalizeAssets(assets: any[], root: string, sourceRoot: string, projectRoot: string, resolveRelativePathsToProjectRoot?: boolean): AssetGlobPattern[];
4
4
  export declare function normalizeFileReplacements(root: string, fileReplacements: FileReplacement[]): FileReplacement[];
5
- //# sourceMappingURL=normalize-options.d.ts.map
@@ -4,7 +4,7 @@ exports.normalizeOptions = normalizeOptions;
4
4
  exports.normalizeAssets = normalizeAssets;
5
5
  exports.normalizeFileReplacements = normalizeFileReplacements;
6
6
  const devkit_1 = require("@nx/devkit");
7
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
+ const internal_1 = require("@nx/js/internal");
8
8
  const fs_1 = require("fs");
9
9
  const path_1 = require("path");
10
10
  function normalizeOptions(options) {
@@ -49,7 +49,7 @@ function normalizeOptions(options) {
49
49
  // executor options take precedence (especially for overriding with CLI args)
50
50
  originalTargetOptions);
51
51
  }
52
- const sourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(projectNode.data);
52
+ const sourceRoot = (0, internal_1.getProjectSourceRoot)(projectNode.data);
53
53
  if (!combinedPluginAndMaybeExecutorOptions.main) {
54
54
  throw new Error(`Missing "main" option for the entry file. Set this option in your Nx webpack plugin.`);
55
55
  }
@@ -71,4 +71,3 @@ export declare function getCommonLoadersForGlobalStyle(options: NormalizedNxAppW
71
71
  };
72
72
  })[];
73
73
  export {};
74
- //# sourceMappingURL=stylesheet-loaders.d.ts.map
@@ -24,4 +24,3 @@ export declare function getAllTransitiveDeps(graph: ProjectGraph, targetName: st
24
24
  * @returns A list of all non-buildable libraries that the project depends on, including transitive dependencies.
25
25
  */
26
26
  export declare function getNonBuildableLibs(graph: ProjectGraph, projectName: string): (string | RegExp)[];
27
- //# sourceMappingURL=utils.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { ProjectGraph } from '@nx/devkit';
2
- import { AssetGlob } from '@nx/js/src/utils/assets/assets';
2
+ import { AssetGlob } from '@nx/js/internal';
3
3
  export interface AssetGlobPattern {
4
4
  glob: string;
5
5
  input: string;
@@ -271,4 +271,3 @@ export interface NormalizedNxAppWebpackPluginOptions extends NxAppWebpackPluginO
271
271
  outputFileName: string;
272
272
  assets: AssetGlobPattern[];
273
273
  }
274
- //# sourceMappingURL=nx-app-webpack-plugin-options.d.ts.map
@@ -15,4 +15,3 @@ export declare class NxAppWebpackPlugin {
15
15
  constructor(options?: NxAppWebpackPluginOptions);
16
16
  apply(compiler: Compiler): void;
17
17
  }
18
- //# sourceMappingURL=nx-app-webpack-plugin.d.ts.map
@@ -1,4 +1,4 @@
1
- import { CreateDependencies, CreateNodesV2 } from '@nx/devkit';
1
+ import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
2
  export interface WebpackPluginOptions {
3
3
  buildTargetName?: string;
4
4
  serveTargetName?: string;
@@ -11,6 +11,5 @@ export interface WebpackPluginOptions {
11
11
  * @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
12
12
  */
13
13
  export declare const createDependencies: CreateDependencies;
14
- export declare const createNodes: CreateNodesV2<WebpackPluginOptions>;
15
- export declare const createNodesV2: CreateNodesV2<WebpackPluginOptions>;
16
- //# sourceMappingURL=plugin.d.ts.map
14
+ export declare const createNodes: CreateNodes<WebpackPluginOptions>;
15
+ export declare const createNodesV2: CreateNodes<WebpackPluginOptions>;
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
6
- const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
7
6
  const js_1 = require("@nx/js");
8
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
+ const internal_2 = require("@nx/js/internal");
9
8
  const fs_1 = require("fs");
10
9
  const file_hasher_1 = require("nx/src/hasher/file-hasher");
11
10
  const cache_directory_1 = require("nx/src/utils/cache-directory");
12
11
  const path_1 = require("path");
13
12
  const read_webpack_options_1 = require("../utils/webpack/read-webpack-options");
14
13
  const resolve_user_defined_webpack_config_1 = require("../utils/webpack/resolve-user-defined-webpack-config");
15
- const util_1 = require("@nx/js/src/plugins/typescript/util");
16
- function readTargetsCache(cachePath) {
17
- return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
18
- }
19
- function writeTargetsToCache(cachePath, results) {
20
- (0, devkit_1.writeJsonFile)(cachePath, results);
21
- }
22
14
  /**
23
15
  * @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
24
16
  */
@@ -32,30 +24,47 @@ exports.createNodes = [
32
24
  async (configFilePaths, options, context) => {
33
25
  const optionsHash = (0, file_hasher_1.hashObject)(options);
34
26
  const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `webpack-${optionsHash}.hash`);
35
- const targetsCache = readTargetsCache(cachePath);
27
+ const targetsCache = new internal_1.PluginCache(cachePath);
36
28
  const normalizedOptions = normalizeOptions(options);
37
- const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
38
- const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
29
+ const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)();
30
+ const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
31
+ const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
32
+ const lockFileName = (0, js_1.getLockFileName)(packageManager);
39
33
  try {
40
- return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache, isTsSolutionSetup, pmc), configFilePaths, normalizedOptions, context);
34
+ const { entries, preErrors } = await filterWebpackConfigs(configFilePaths, context);
35
+ const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.projectRoot), normalizedOptions, context, entries.map(() => [lockFileName]));
36
+ let results = [];
37
+ let nodeErrors = [];
38
+ try {
39
+ results = await (0, devkit_1.createNodesFromFiles)((configFile, opts, ctx, idx) => createNodesInternal(configFile, opts, ctx, targetsCache, isTsSolutionSetup, pmc, projectHashes[idx]), entries.map((e) => e.configFile), normalizedOptions, context);
40
+ }
41
+ catch (e) {
42
+ if (e instanceof devkit_1.AggregateCreateNodesError) {
43
+ results = e.partialResults ?? [];
44
+ nodeErrors = e.errors;
45
+ }
46
+ else {
47
+ throw e;
48
+ }
49
+ }
50
+ const allErrors = [...preErrors, ...nodeErrors];
51
+ if (allErrors.length > 0) {
52
+ throw new devkit_1.AggregateCreateNodesError(allErrors, results);
53
+ }
54
+ return results;
41
55
  }
42
56
  finally {
43
- writeTargetsToCache(cachePath, targetsCache);
57
+ targetsCache.writeToDisk();
44
58
  }
45
59
  },
46
60
  ];
47
61
  exports.createNodesV2 = exports.createNodes;
48
- async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc) {
62
+ async function createNodesInternal(configFilePath, options, context, targetsCache, isTsSolutionSetup, pmc, hash) {
49
63
  const projectRoot = (0, path_1.dirname)(configFilePath);
50
- // Do not create a project if package.json and project.json isn't there.
51
- const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
52
- if (!siblingFiles.includes('package.json') &&
53
- !siblingFiles.includes('project.json')) {
54
- return {};
64
+ if (!targetsCache.has(hash)) {
65
+ targetsCache.set(hash, await createWebpackTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc));
55
66
  }
56
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
57
- targetsCache[hash] ??= await createWebpackTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc);
58
- const { targets, metadata } = targetsCache[hash];
67
+ const { targets, metadata } = targetsCache.get(hash);
59
68
  return {
60
69
  projects: {
61
70
  [projectRoot]: {
@@ -67,7 +76,7 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
67
76
  };
68
77
  }
69
78
  async function createWebpackTargets(configFilePath, projectRoot, options, context, isTsSolutionSetup, pmc) {
70
- const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
79
+ const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
71
80
  const webpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)((0, path_1.join)(context.workspaceRoot, configFilePath), (0, js_1.getRootTsConfigPath)(), true);
72
81
  const webpackOptions = await (0, read_webpack_options_1.readWebpackOptions)(webpackConfig);
73
82
  const outputs = [];
@@ -79,7 +88,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
79
88
  const targets = {};
80
89
  targets[options.buildTargetName] = {
81
90
  command: `webpack-cli build`,
82
- options: { cwd: projectRoot, args: ['--node-env=production'] },
91
+ options: { cwd: projectRoot, env: { NODE_ENV: 'production' } },
83
92
  cache: true,
84
93
  dependsOn: [`^${options.buildTargetName}`],
85
94
  inputs: 'production' in namedInputs
@@ -89,6 +98,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
89
98
  {
90
99
  externalDependencies: ['webpack-cli'],
91
100
  },
101
+ internal_2.TS_SOLUTION_SETUP_TSCONFIG_INPUT,
92
102
  ]
93
103
  : [
94
104
  'default',
@@ -96,6 +106,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
96
106
  {
97
107
  externalDependencies: ['webpack-cli'],
98
108
  },
109
+ internal_2.TS_SOLUTION_SETUP_TSCONFIG_INPUT,
99
110
  ],
100
111
  outputs,
101
112
  metadata: {
@@ -117,7 +128,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
117
128
  command: `webpack-cli serve`,
118
129
  options: {
119
130
  cwd: projectRoot,
120
- args: ['--node-env=development'],
131
+ env: { NODE_ENV: 'development' },
121
132
  },
122
133
  metadata: {
123
134
  technologies: ['webpack'],
@@ -137,7 +148,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
137
148
  command: `webpack-cli serve`,
138
149
  options: {
139
150
  cwd: projectRoot,
140
- args: ['--node-env=production'],
151
+ env: { NODE_ENV: 'production' },
141
152
  },
142
153
  metadata: {
143
154
  technologies: ['webpack'],
@@ -180,7 +191,7 @@ async function createWebpackTargets(configFilePath, projectRoot, options, contex
180
191
  '@nx/js:typescript-sync',
181
192
  ];
182
193
  }
183
- (0, util_1.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
194
+ (0, internal_2.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
184
195
  return { targets, metadata: {} };
185
196
  }
186
197
  function normalizeOutputPath(outputPath, projectRoot) {
@@ -211,6 +222,28 @@ function normalizeOutputPath(outputPath, projectRoot) {
211
222
  }
212
223
  }
213
224
  }
225
+ async function filterWebpackConfigs(configFiles, context) {
226
+ const preErrors = [];
227
+ const candidates = await Promise.all(configFiles.map(async (configFile) => {
228
+ try {
229
+ const projectRoot = (0, path_1.dirname)(configFile);
230
+ const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
231
+ if (!siblingFiles.includes('package.json') &&
232
+ !siblingFiles.includes('project.json')) {
233
+ return null;
234
+ }
235
+ return { configFile, projectRoot };
236
+ }
237
+ catch (e) {
238
+ preErrors.push([configFile, e]);
239
+ return null;
240
+ }
241
+ }));
242
+ return {
243
+ entries: candidates.filter((c) => c !== null),
244
+ preErrors,
245
+ };
246
+ }
214
247
  function normalizeOptions(options) {
215
248
  return {
216
249
  buildTargetName: options?.buildTargetName ?? 'build',
@@ -2,4 +2,3 @@ import { Compiler } from 'webpack';
2
2
  export declare class StatsJsonPlugin {
3
3
  apply(compiler: Compiler): void;
4
4
  }
5
- //# sourceMappingURL=stats-json-plugin.d.ts.map
@@ -29,4 +29,3 @@ module.exports = async () => ({
29
29
  export declare function useLegacyNxPlugin(fn: (config: Configuration, ctx: NxWebpackExecutionContext) => Promise<Configuration>, executorOptions: NxAppWebpackPluginOptions): Promise<{
30
30
  apply(compiler: Compiler): void;
31
31
  }>;
32
- //# sourceMappingURL=use-legacy-nx-plugin.d.ts.map
@@ -19,4 +19,3 @@ export declare class WebpackNxBuildCoordinationPlugin {
19
19
  private createFileWatcher;
20
20
  }
21
21
  export {};
22
- //# sourceMappingURL=webpack-nx-build-coordination-plugin.d.ts.map
@@ -20,4 +20,3 @@ export declare class WriteIndexHtmlPlugin {
20
20
  private generateSriAttributes;
21
21
  private filterAndMapBuildFiles;
22
22
  }
23
- //# sourceMappingURL=write-index-html-plugin.d.ts.map
@@ -14,10 +14,21 @@ export interface NxComposableWebpackPlugin {
14
14
  export interface AsyncNxComposableWebpackPlugin {
15
15
  (config: Configuration, ctx: NxWebpackExecutionContext): Configuration | Promise<Configuration>;
16
16
  }
17
+ /**
18
+ * @deprecated Will be removed in Nx v24. Use `NxAppWebpackPlugin` from
19
+ * `@nx/webpack/app-plugin` in a standard webpack config and run
20
+ * `nx g @nx/webpack:convert-to-inferred`. See
21
+ * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
22
+ */
17
23
  export declare function composePlugins(...plugins: (NxComposableWebpackPlugin | AsyncNxComposableWebpackPlugin | Promise<NxComposableWebpackPlugin | AsyncNxComposableWebpackPlugin>)[]): ((config: Configuration, ctx: NxWebpackExecutionContext) => Promise<Configuration>) & {
18
24
  nxWebpackComposablePlugin: boolean;
19
25
  };
26
+ /**
27
+ * @deprecated Will be removed in Nx v24. Use `NxAppWebpackPlugin` from
28
+ * `@nx/webpack/app-plugin` in a standard webpack config and run
29
+ * `nx g @nx/webpack:convert-to-inferred`. See
30
+ * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
31
+ */
20
32
  export declare function composePluginsSync(...plugins: NxComposableWebpackPlugin[]): ((config: Configuration, ctx: NxWebpackExecutionContext) => Configuration) & {
21
33
  nxWebpackComposablePlugin: boolean;
22
34
  };
23
- //# sourceMappingURL=config.d.ts.map