DEV Community

Cover image for πŸ’ Cherry-Picked Nx v18.2 Updates
jogelin
jogelin

Posted on • Updated on • Originally published at jgelin.Medium

πŸ’ Cherry-Picked Nx v18.2 Updates

Release Note 18.2 (2024–03–28)

https://github.com/nrwl/nx/releases/tag/18.2.0

[Angular] Support Angular 17.3

As usual, Nx is up to date with the latest version of Angular!

What’s new in Angular 17.3? | Ninja Squad

Angular 17.3 is out!

favicon blog.ninja-squad.com

Meet Angular’s new output() API. Angular v17.3 introduces the improved… | by Paul Gschwendtner | Mar, 2024 | Angular Blog

Angular v17.3 introduces the improved API for declaring outputs as a developer preview.

favicon blog.angular.io

[Core] Scope Nx Plugin Project Crystal πŸ’›πŸ’›πŸ’›

feat(core): add ability to scope plugins #22379

Current Behavior

There is no way to users to filter where plugins are applied. Only by the plugin author.

This means that errors thrown make the plugin unusable and more modifications to the project graph are made than desired.

Expected Behavior

Plugins can be scoped via include and exclude which are both lists of file patterns.

{
  plugins: [
    {
      plugin: '@nx/jest/plugin',
      include: ['packages/**/*'],
      exclude: ['e2e/**/*']
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

This will scope running the plugin to processing only those config files.

Related Issue(s)

Fixes #

In my previous article, β€œβ›” Target Exclusions in Nx Project Crystal,” I introduced alternatives for excluding certain projects from specific plugins.

For instance, you might not want a test target in an e2e project simply because there’s a jest.config.ts file present.

Now, an official method is available for excluding or including plugins for a specific project. Within your nx.json file, you can now specify the exclude or include options:

{
  "plugins": [
    {
      "plugin": "@nx/jest/plugin",
      "options": {
        "targetName": "test",
        "exclude": ["my-lib-e2e/**/*"]
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

[Gradle] New Gradle Integration

@nx/gradle | Nx

The Nx Plugin for Gradle allows Gradle tasks to be run through Nx

favicon nx.dev

You can now leverage the new Gradle integration with the @nx/gradle:init generator. To initialize, simply run:

nx g @nx/gradle:init
Enter fullscreen mode Exit fullscreen mode

This initialization will also add the @nx/gradle/plugin to your nx.json:

{
  "plugins": [
    {
      "plugin": "@nx/gradle/plugin",
      "options": {
        "testTargetName": "build",
        "classesTargetName": "test",
        "buildTargetName": "classes"
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

This plugin will:

  • Integrate your Gradle projects into the Nx Dependency Tree by scanning all Gradle configurations.

  • Discover your projects by scanning the Gradle configuration matching the pattern **/build.{gradle.kts,gradle}, and then assign the targets build, test, and classes.

[Cypress] New target open-cypress is added by the @nx/cypress/plugin

feat(testing): infer open-cypress task #22556

Infer a new task named open-cypress, which runs the command cypress open from the project root.

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #22389

If you’re working with Nx Project Crystal and have a Cypress project that includes a cypress.config.* file, the @nx/cypress/plugin will automatically add related targets to your project.

A new target, open-cypress, will now be added to your project configuration:

"open-cypress": {
  "command": "cypress open",
  "options": {
    "cwd": ".",
  },
Enter fullscreen mode Exit fullscreen mode

You have the flexibility to use a different name by specifying the new plugin option openTargetName:

{
  "plugins": [
    {
      "plugin": "@nx/cypress/plugin",
      "options": {
        "targetName": "e2e",
        "ciTargetName": "e2e-ci",
        "componentTestingTargetName": "component-test",
        "openTargetName": "open-cypress" // <-- NEW
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Looking for some help? 🀝
**Connect with me on Twitter β€’ LinkedIn β€’ Github

Top comments (0)