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

Executor nx/webpack:dev-server broken on NX 18 #22288

Closed
1 of 4 tasks
gabrielbryk opened this issue Mar 12, 2024 · 4 comments · Fixed by #22660
Closed
1 of 4 tasks

Executor nx/webpack:dev-server broken on NX 18 #22288

gabrielbryk opened this issue Mar 12, 2024 · 4 comments · Fixed by #22660
Assignees
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug

Comments

@gabrielbryk
Copy link

Current Behavior

The executor is supposed to have options as defined in the schema defined in the documentation. However when I use it, it's not recognizing any of the values provided in options, and instead expects a webpack configuration

Expected Behavior

Works similar to how @nx/webpack:webpack works

GitHub Repo

No response

Steps to Reproduce

Using this target in my project.json

    "dev": {
      "executor": "@nx/webpack:dev-server",
      "defaultConfiguration": "development",
      "options": {
        "buildTarget": "backend:build",
        "hot": true,
        "hmr": true,
        "liveReload": true,
        "webpackConfig": "apps/backend/webpack.config.js"
      },
      "configurations": {
        "development": {
          "buildTarget": "backend:build:development"
        },
        "production": {
          "buildTarget": "backend:build:production",
          "hot": false,
          "hmr": false,
          "liveReload": false
        }
      }
    },

Nx Report

Node   : 20.10.0
OS     : darwin-arm64
pnpm   : 8.15.4

nx (global)        : 18.0.6
nx                 : 18.0.6
@nx/js             : 18.0.6
@nx/jest           : 18.0.6
@nx/linter         : 18.0.6
@nx/eslint         : 18.0.6
@nx/workspace      : 18.0.6
@nx/cypress        : 18.0.6
@nx/eslint-plugin  : 18.0.6
@nx/nest           : 18.0.6
@nx/node           : 18.0.6
@nx/react          : 18.0.6
@nx/vite           : 18.0.6
@nx/web            : 18.0.6
@nx/webpack        : 18.0.6
typescript         : 5.3.3

Failure Logs

nx run backend:dev:backend:build:development


 NX   Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

 - configuration should be an object:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
   -> Options object as provided by the user.

ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration should be an object:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
   -> Options object as provided by the user.

Package Manager Version

No response

Operating System

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

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: bundlers Issues related to webpack, rollup label Mar 15, 2024
@Achder
Copy link

Achder commented Mar 20, 2024

Experiencing the same issue.
I found this in the code:

// Only add the dev server option if user is composable plugin.

// Only add the dev server option if user is composable plugin.
// Otherwise, user should define `devServer` option directly in their webpack config.

Is there maybe a workaround?

@jaysoo
Copy link
Member

jaysoo commented Apr 3, 2024

@Achder @gabrielbryk What is inside the webpack.config.js file?

If someone can link a repro that would help in debugging this issue. We need to add another if-else block to match the @nx/webpack:webpack executor:

} else if (userDefinedWebpackConfig) {
// New behavior, we want the webpack config to export object
return userDefinedWebpackConfig;

Just want to confirm that this is the issue.

@jaysoo
Copy link
Member

jaysoo commented Apr 3, 2024

This PR brings the same feature from @nx/webpack:webpack to @nx/webpack:dev-server. If someone wants to make that patch in their node_modules/, or provide a repro.

Copy link

github-actions bot commented May 4, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: bundlers Issues related to webpack, rollup type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants