Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React] [Weback] Cannot run tasks after generated app with webpack and move to nx-enhance #26303

Open
1 of 4 tasks
NicolasBelliard opened this issue May 31, 2024 · 1 comment
Assignees
Labels
scope: react Issues related to React support for Nx type: bug

Comments

@NicolasBelliard
Copy link
Contributor

Current Behavior

Hello!

I created an nx app with cli create-nx-workspace with the following param:

  • stack: react
  • framework: none
  • Integrated monorepo
  • bundler: webpack

Then I updated the wepack config to move to nx-enhance configuration as it is written in the doc here

You can see bellow the following config:

const { composePlugins, withNx } = require('@nx/webpack');
const { withReact } = require('@nx/react');
const { join } = require('path');

// Nx composable plugins for webpack.
module.exports = composePlugins(
  withNx(),
  withReact(),
  (config, { options, context }) => {
    // Update the webpack configuration as needed here.

    config.output = {
      path: join(__dirname, '../../dist/apps/nx-enhance'),
    }
    config.devServer = {
      port: 4200,
    }
    return config;
  }
);

The issue it is when I ran the build or serve I have the following error:

> nx run nx-enhance:build

> webpack-cli build --node-env=production

[webpack-cli] TypeError: Cannot read properties of undefined (reading 'nodes')
    at calculateProjectDependencies (/home/test/dev/nx-enhance/node_modules/@nx/js/src/utils/buildable-libs-utils.js:24:30)
    at calculateProjectBuildableDependencies (/home/test/dev/nx-enhance/node_modules/@nx/js/src/utils/buildable-libs-utils.js:20:12)
    at NxTsconfigPathsWebpackPlugin.handleBuildLibsFromSource (/home/test/dev/nx-enhance/node_modules/@nx/webpack/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js:37:111)
    at NxTsconfigPathsWebpackPlugin.apply (/home/test/dev/nx-enhance/node_modules/@nx/webpack/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js:17:14)
    at createCompiler (/home/test/dev/nx-enhance/node_modules/webpack/lib/webpack.js:78:12)
    at create (/home/test/dev/nx-enhance/node_modules/webpack/lib/webpack.js:145:16)
    at webpack (/home/test/dev/nx-enhance/node_modules/webpack/lib/webpack.js:153:47)
    at WebpackCLI.f [as webpack] (/home/test/dev/nx-enhance/node_modules/webpack/lib/index.js:73:16)
    at WebpackCLI.createCompiler (/home/test/dev/nx-enhance/node_modules/webpack-cli/lib/webpack-cli.js:1785:29)
    at async WebpackCLI.runWebpack (/home/test/dev/nx-enhance/node_modules/webpack-cli/lib/webpack-cli.js:1877:20)
Warning: command "webpack-cli build --node-env=production" exited with non-zero status code


Process finished with exit code 1

I created the following repository if you want to try on your local: https://github.com/NicolasBelliard/nx-enhance-example

Thank you for your help.

Expected Behavior

When I run the command nx run nx-enhance:build I have no error

GitHub Repo

https://github.com/NicolasBelliard/nx-enhance-example

Steps to Reproduce

  1. Clone the project
  2. Run npm i
  3. Run nx serve nx-enhance
  4. You should have an error

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.14.0
OS     : linux-x64
npm    : 10.7.0

nx                 : 19.1.1
@nx/js             : 19.1.1
@nx/jest           : 19.1.1
@nx/linter         : 19.1.1
@nx/eslint         : 19.1.1
@nx/workspace      : 19.1.1
@nx/devkit         : 19.1.1
@nx/eslint-plugin  : 19.1.1
@nx/playwright     : 19.1.1
@nx/react          : 19.1.1
@nrwl/tao          : 19.1.1
@nx/web            : 19.1.1
@nx/webpack        : 19.1.1
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

> nx run nx-enhance:build

> webpack-cli build --node-env=production

[webpack-cli] TypeError: Cannot read properties of undefined (reading 'nodes')
    at calculateProjectDependencies (/home/test/dev/nx-enhance/node_modules/@nx/js/src/utils/buildable-libs-utils.js:24:30)
    at calculateProjectBuildableDependencies (/home/test/dev/nx-enhance/node_modules/@nx/js/src/utils/buildable-libs-utils.js:20:12)
    at NxTsconfigPathsWebpackPlugin.handleBuildLibsFromSource (/home/test/dev/nx-enhance/node_modules/@nx/webpack/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js:37:111)
    at NxTsconfigPathsWebpackPlugin.apply (/home/test/dev/nx-enhance/node_modules/@nx/webpack/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js:17:14)
    at createCompiler (/home/test/dev/nx-enhance/node_modules/webpack/lib/webpack.js:78:12)
    at create (/home/test/dev/nx-enhance/node_modules/webpack/lib/webpack.js:145:16)
    at webpack (/home/test/dev/nx-enhance/node_modules/webpack/lib/webpack.js:153:47)
    at WebpackCLI.f [as webpack] (/home/test/dev/nx-enhance/node_modules/webpack/lib/index.js:73:16)
    at WebpackCLI.createCompiler (/home/test/dev/nx-enhance/node_modules/webpack-cli/lib/webpack-cli.js:1785:29)
    at async WebpackCLI.runWebpack (/home/test/dev/nx-enhance/node_modules/webpack-cli/lib/webpack-cli.js:1877:20)
Warning: command "webpack-cli build --node-env=production" exited with non-zero status code


Process finished with exit code 1

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@NicolasBelliard
Copy link
Contributor Author

Hello @FrozenPandaz
Do you know if we can review this MR: #26430?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: react Issues related to React support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants