Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(webpack): fix default compiler option (#22762)
Given a configuration without `options.tsConfig` the `babel` compiler breaks in `createLoaderFromCompiler` where the babel case uses `path.join(options.root, options.tsConfig)` and throws an exception if it's undefined. ## Current Behavior In my case, the root `package.json` generates a dependency in the tree with "empty" options: ``` { root: '/root/of/my/monorepo/monorepo', projectRoot: '', sourceRoot: '', outputFileName: undefined, outputPath: undefined, assets: [], target: 'web', projectName: undefined, targetName: undefined, configurationName: undefined, projectGraph: undefined } ``` which breaks the project graph with this exception: ``` Unable to read angular.json [Failed to process project graph. The "@nx/webpack/plugin" plugin threw an error while creating nodes from src/backend/server/webpack.config.js: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined at new NodeError (node:internal/errors:405:5) at validateString (node:internal/validators:162:11) at Object.join (node:path:1171:7) at createLoaderFromCompiler (/monorepo/node_modules/.pnpm/@nx[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js:50:58) at applyNxDependentConfig (/monorepo/node_modules/.pnpm/@nx[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.js:314:61) at applyBaseConfig (/monorepo/node_modules/.pnpm/@nx[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/lib/apply-base-config.js:36:5) at configure (/monorepo/node_modules/.pnpm/@nx[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/utils/with-nx.js:15:49) at combined (/monorepo/node_modules/.pnpm/@nx[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/utils/config.js:23:28) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async readWebpackOptions (/monorepo/node_modules/.pnpm/@nx[email protected]_@[email protected]_@[email protected]_@[email protected][email protected]_t_auhl3zn4afi4laot7gdsrcezcy/node_modules/@nx/webpack/src/utils/webpack/read-webpack-options.js:17:18)] { name: 'ProjectGraphError' } ``` ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> The default values should fallback properly without throwing an exception for this case. --------- Co-authored-by: Colum Ferry <[email protected]>
- Loading branch information