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

@nx/js:swc not resolving {projectRoot} for crystal plugins when running nx affected #22940

Closed
4 tasks
gitLinda opened this issue Apr 22, 2024 · 1 comment · Fixed by #23068
Closed
4 tasks
Assignees
Labels

Comments

@gitLinda
Copy link

gitLinda commented Apr 22, 2024

Current Behavior

I have a generic build target in my nx.json that looks like this (using {projectRoot} in the paths):

"build": {
      "executor": "@nx/js:swc",
      "outputs": ["{options.outputPath}"],
      "options": {
        "outputPath": "dist/{projectRoot}",
        "main": "{projectRoot}/src/index.ts",
        "tsConfig": "{projectRoot}/tsconfig.lib.json",
        "assets": [ ... ]
      }
    },

This works fine for everything I have in my repo. Now I started to add my own crystal plugins.
In the "plugins" section of the nx.json:

"plugins": [
    {
      "plugin": "@myorg/foo",
    }
  ]

This @myorg/foo uses the build target from above.
When I run nx run-many --targets build it works fine.
When I run nx affected --targets build it fails with the error:

 NX   Could not load plugin @myorg/foo

LoadPluginError: Could not load plugin @myorg/foo
    at loadNxPluginAsync (/home/linda/IdeaProjects/new/techx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/plugins/loader.js:203:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 1)
    at loadNxPlugins (/home/linda/IdeaProjects/new/techx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/plugins/internal-api.js:51:9)
    at getTouchedProjectsFromProjectGlobChanges (/home/linda/IdeaProjects/new/techx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/affected/locators/project-glob-changes.js:12:23)
    at filterAffected (/home/linda/IdeaProjects/new/techx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/project-graph/affected/affected-project-graph.js:20:26)
    at getAffectedGraphNodes (/home/linda/IdeaProjects/new/techx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/command-line/affected/affected.js:82:11)
    at Object.affected (/home/linda/IdeaProjects/new/techx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/command-line/affected/affected.js:34:22)
    at handleErrors (/home/linda/IdeaProjects/new/techx/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]/node_modules/nx/src/utils/params.js:9:16)

When I overwrite the main option of the build target in the project.json of @myorg/foo to use a fixed path it works fine.

Expected Behavior

The nx affected command can resolve {projectRoot} properly

GitHub Repo

No response

Steps to Reproduce

  1. create a nx workspace
  2. create a plugin
  3. add a crystal plugin to it
  4. use {projectRoot} in path to build

Nx Report

NX   Report complete - copy this into the issue template

Node   : 18.16.0
OS     : linux-x64
pnpm   : 8.10.0

nx                 : 18.3.3
@nx/js             : 18.3.3
@nx/jest           : 18.3.3
@nx/linter         : 18.3.3
@nx/eslint         : 18.3.3
@nx/workspace      : 18.3.3
@nx/devkit         : 18.3.3
@nrwl/devkit       : 18.2.3
@nx/eslint-plugin  : 18.3.3
@nx/playwright     : 18.3.3
@nx/plugin         : 18.3.3
@nx/react          : 18.3.3
@nrwl/tao          : 18.3.3
@nx/vite           : 18.3.3
@nx/web            : 18.3.3
typescript         : 5.4.2

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

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

Successfully merging a pull request may close this issue.

2 participants