nx: 17.2.0 @nx/webpack:webpack executor throws isolatedConfig on simple build with node target

Current Behavior

Given the following simple build target:

    "build": {
      "executor": "@nx/webpack:webpack",
      "outputs": ["{options.outputPath}"],
      "options": {
        "outputPath": "dist/apps/backend",
        "main": "apps/backend/src/main.ts",
        "tsConfig": "apps/backend/tsconfig.app.json",
        "target": "node",
        "compiler": "tsc"
      }
    },

I encountered the following error:

> nx run backend:build

{
  outputPath: 'dist/apps/backend',
  main: 'apps/backend/src/main.ts',
  tsConfig: 'apps/backend/tsconfig.app.json',
  target: 'node',
  compiler: 'tsc',
  deleteOutputPath: true,
  outputFileName: 'main.js',
  isolatedConfig: true,
  buildLibsFromSource: true,
  root: '/Users/bjorn/Development/lab-box/mobvious-platform',
  projectRoot: 'apps/backend',
  sourceRoot: 'apps/backend/src',
  webpackConfig: '',
  fileReplacements: [],
  optimization: { scripts: undefined, styles: undefined }
}

 >  NX   Using "isolatedConfig" without a "webpackConfig" is not supported.

   Pass --verbose to see the stacktrace.


 —————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target build for project backend (328ms)
 
    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

Expected Behavior

It should not throw.

GitHub Repo

No response

Steps to Reproduce

Create simple target using webpack, targetting node.

Run the target.

    "build": {
      "executor": "@nx/webpack:webpack",
      "outputs": ["{options.outputPath}"],
      "options": {
        "outputPath": "dist/apps/backend",
        "main": "apps/backend/src/main.ts",
        "tsConfig": "apps/backend/tsconfig.app.json",
        "target": "node",
        "compiler": "tsc"
      }
    },

Nx Report

Node   : 18.18.0
   OS     : darwin-arm64
   yarn   : 1.22.19
   
   nx                 : 17.2.0
   @nx/js             : 17.2.0
   @nx/jest           : 17.2.0
   @nx/linter         : 17.2.0
   @nx/eslint         : 17.2.0
   @nx/workspace      : 17.2.0
   @nx/cypress        : 17.2.0
   @nx/detox          : 17.2.0
   @nx/devkit         : 17.2.0
   @nx/eslint-plugin  : 17.2.0
   @nx/expo           : 17.2.0
   @nx/nest           : 17.2.0
   @nx/node           : 17.2.0
   @nx/react          : 17.2.0
   @nrwl/tao          : 17.2.0
   @nx/web            : 17.2.0
   @nx/webpack        : 17.2.0
   typescript         : 5.2.2

Failure Logs

See above.

Package Manager Version

No response

Operating System

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

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 3
  • Comments: 18 (9 by maintainers)

Most upvoted comments

I think they forgot to add a migration somewhere, adding "webpackConfig": "<directory of your project>/webpack.config.js" with the following config fixes this:

const { composePlugins, withNx } = require('@nx/webpack')

// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
  // Update the webpack config as needed here.
  // e.g. `config.plugins.push(new MyPlugin())`
  return config
})

Neither 17.2.3 nor 17.2.4 picked up the migration, with or without --from=nx@15.6 (which caused other problems), perhaps because our project.json had no targets.build.isolatedConfig property at all. Adding it and setting it to false per @TriPSs removed the Using "isolatedConfig" without a "webpackConfig" is not supported. error on serve but showed the deprecation warning, so I decided to move on and just manually added in the base webpack.config.js and pointed targets.build.options.webpackConfig to it, per Configure webpack on your Nx workspace, as suggested by @TriPSs and @redplane, which prevented the error and deprecation warning (but the latter only if the isolatedConfig property did not exist at all—the warning persists if isolatedConfig: true, even though the current documentation shows that property in project.json).

Upgraded to nx@17.2.1 from nx@17.2.0 and no migration detected.

I tried with --from=nx@<ver> but it doesn’t work, keeps throwing the error:

Using "isolatedConfig" without a "webpackConfig" is not supported.

@KeithGillette with the latest version you can also just put isolatedConfig to false.