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

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

Closed
1 of 4 tasks
botre opened this issue Dec 8, 2023 · 18 comments · Fixed by #20699
Closed
1 of 4 tasks

Comments

@botre
Copy link

botre commented Dec 8, 2023

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

@botre botre added the type: bug label Dec 8, 2023
@TriPSs
Copy link
Contributor

TriPSs commented Dec 9, 2023

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
})

@jaysoo
Copy link
Member

jaysoo commented Dec 11, 2023

There was a migration back in 15.6 for this. We'll add it again for 17.2.x just in case it wasn't done.

@redplane
Copy link

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
})

You are right.
I had the same issue and my fix was:

  • Go to the
  • Create a file named: webpack.config.js
  • Open file <project folder>/project.json
  • Add "webpackConfig": "apps/apis/webpack.config.js" into targets.build

More information can be seen at: https://nx.dev/recipes/webpack/webpack-config-setup

@0xRapid
Copy link

0xRapid commented Dec 11, 2023

Happened to me in Windows. I think the solution is not to have to create something, but to make a migration that solves it

@jaysoo
Copy link
Member

jaysoo commented Dec 11, 2023

The migration will basically create the file mentioned above. We removed support for webpack builds that don't specify a webpack config file.

@TriPSs
Copy link
Contributor

TriPSs commented Dec 11, 2023

@jaysoo there is still "partial" support as when you put isolatedConfig off it will still fallback, even though that is broken.

@jaysoo
Copy link
Member

jaysoo commented Dec 11, 2023

We're moving away from that, and it'll be gone by Nx 18 (around June 2024). But yes it is supposed to still work.

@jaysoo
Copy link
Member

jaysoo commented Dec 11, 2023

Released in 17.2.1

@MichaelKaaden
Copy link

In my case, the "executor" was already "@nx/webpack:webpack". Since the migration expects it to be "@nrwl/webpack:webpack" instead, it didn't run.

@KeithGillette
Copy link

[email protected] did not fix this issue for us when attempting to migrate from [email protected]. Our executor is @nrwl/webpack:webpack but that was not changed to @nx/webpack:webpack and no new webpack.config.js was created in the project folder. The migrations.json generated by nx migrate latest is:

{
  "migrations": [
    {
      "version": "17.1.0-beta.2",
      "description": "Move jest executor options to nx.json targetDefaults",
      "implementation": "./src/migrations/update-17-1-0/move-options-to-target-defaults",
      "package": "@nx/jest",
      "name": "move-options-to-target-defaults"
    },
    {
      "cli": "nx",
      "version": "17.1.0-beta.5",
      "requires": {
        "@angular/core": ">=17.0.0"
      },
      "description": "Update the @angular/cli package version to ~17.0.0.",
      "factory": "./src/migrations/update-17-1-0/update-angular-cli",
      "package": "@nx/angular",
      "name": "update-angular-cli-version-17-0-0"
    },
    {
      "cli": "nx",
      "version": "17.1.0-beta.5",
      "requires": {
        "@angular/core": ">=17.0.0"
      },
      "description": "Rename 'browserTarget' to 'buildTarget'.",
      "factory": "./src/migrations/update-17-1-0/browser-target-to-build-target",
      "package": "@nx/angular",
      "name": "rename-browser-target-to-build-target"
    },
    {
      "cli": "nx",
      "version": "17.1.0-beta.5",
      "requires": {
        "@angular/core": ">=17.0.0"
      },
      "description": "Replace usages of '@nguniversal/builders' with '@angular-devkit/build-angular'.",
      "factory": "./src/migrations/update-17-1-0/replace-nguniversal-builders",
      "package": "@nx/angular",
      "name": "replace-nguniversal-builders"
    },
    {
      "cli": "nx",
      "version": "17.1.0-beta.5",
      "requires": {
        "@angular/core": ">=17.0.0"
      },
      "description": "Replace usages of '@nguniversal/' packages with '@angular/ssr'.",
      "factory": "./src/migrations/update-17-1-0/replace-nguniversal-engines",
      "package": "@nx/angular",
      "name": "replace-nguniversal-engines"
    },
    {
      "cli": "nx",
      "version": "17.1.0-beta.5",
      "requires": {
        "@angular/core": ">=17.0.0"
      },
      "description": "Replace the deep imports from 'zone.js/dist/zone' and 'zone.js/dist/zone-testing' with 'zone.js' and 'zone.js/testing'.",
      "factory": "./src/migrations/update-17-1-0/update-zone-js-deep-import",
      "package": "@nx/angular",
      "name": "update-zone-js-deep-import"
    },
    {
      "cli": "nx",
      "version": "17.2.0-beta.2",
      "description": "Rename '@nx/angular:webpack-dev-server' executor to '@nx/angular:dev-server'",
      "factory": "./src/migrations/update-17-2-0/rename-webpack-dev-server",
      "package": "@nx/angular",
      "name": "rename-webpack-dev-server-executor"
    },
    {
      "version": "17.1.0-beta.1",
      "description": "Updates for @typescript-utils/utils v6.9.1+",
      "implementation": "./src/migrations/update-17-1-0/update-typescript-eslint",
      "package": "@nx/linter",
      "name": "update-typescript-eslint"
    },
    {
      "version": "17.2.0-beta.0",
      "description": "Simplify eslintFilePatterns",
      "implementation": "./src/migrations/update-17-2-0/simplify-eslint-patterns",
      "package": "@nx/linter",
      "name": "simplify-eslint-patterns"
    },
    {
      "version": "17.0.0",
      "description": "Angular v17 introduces a new control flow syntax that uses the @ and } characters. This migration replaces the existing usages with their corresponding HTML entities.",
      "factory": "./migrations/block-template-entities/bundle",
      "package": "@angular/core",
      "name": "block-template-entities"
    },
    {
      "version": "17.0.0",
      "description": "CompilerOption.useJit and CompilerOption.missingTranslation are unused under Ivy. This migration removes their usage",
      "factory": "./migrations/compiler-options/bundle",
      "package": "@angular/core",
      "name": "migration-v17-compiler-options"
    },
    {
      "version": "17.0.0",
      "description": "Updates `TransferState`, `makeStateKey`, `StateKey` imports from `@angular/platform-browser` to `@angular/core`.",
      "factory": "./migrations/transfer-state/bundle",
      "package": "@angular/core",
      "name": "migration-transfer-state"
    },
    {
      "version": "17.0.0-0",
      "description": "Updates the Angular CDK to v17",
      "factory": "./ng-update/index#updateToV17",
      "package": "@angular/cdk",
      "name": "migration-v17"
    }
  ]
}

@TriPSs
Copy link
Contributor

TriPSs commented Dec 12, 2023

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

@jacqueslareau
Copy link

Upgraded to [email protected] from [email protected] and no migration detected.

@jaysoo
Copy link
Member

jaysoo commented Dec 12, 2023

We're cutting a new patch with @nx scope as well. For migrations, you can manually pass --from=nx@<ver> if you don't see the migration. Perhaps due to the versions installed, Nx did not pick up new migrations.

@luisfelipediaz
Copy link

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

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

@KeithGillette
Copy link

KeithGillette commented Dec 13, 2023

Neither 17.2.3 nor 17.2.4 picked up the migration, with or without [email protected] (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).

@Lorenz-A-Mueller
Copy link

Thanks so much for the helpful answers!
Just to clarify (because I just stumbled over that), both the isoldatedConfig and webpackConfig properties go into targets.build.options

@TriPSs
Copy link
Contributor

TriPSs commented Dec 13, 2023

@Lorenz-A-Mueller yes.

Copy link

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 Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants