nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.63k stars 2.36k forks source link

Importing libraries into executors that use tsconfig.paths are not found #10486

Closed Nick-Mazuk closed 1 year ago

Nick-Mazuk commented 2 years ago

Current Behavior

If you import a library into an executor and that library's import statement uses a tsconfig.path rewrite, the file is not found.

The tsconfig.path is likely setup correctly because intellisense works in VS Code, and I've used this same setup outside of nx and it's worked correctly.

Expected Behavior

I should be able import a library using a tsconfig.path import into an executor and it should just work.

Steps to Reproduce

Here's a minimal reproduction: https://github.com/Nick-Mazuk/nx-test-test

To view the error, do the following:

  1. Clone the repository
  2. npm i
  3. nx test b

Failure Logs

Cannot find module '#lib/a'
Require stack:
- /path/to/repo/tools/plugins/ts/executors/test/executor.ts
- /path/to/repo/node_modules/nx/src/config/workspaces.js
- /path/to/repo/node_modules/nx/src/command-line/run.js
- /path/to/repo/node_modules/nx/bin/run-executor.js

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

 >  NX   Ran target test for project b (255ms)

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

Environment

>  NX   Report complete - copy this into the issue template

   Node : 18.1.0
   OS   : darwin arm64
   npm  : 8.8.0

   nx : 14.1.4
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.1.4
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.1.4
   @nrwl/js : Not Found
   @nrwl/linter : 14.1.4
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/workspace : 14.1.4
   typescript : 4.7.2
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
AgentEnder commented 2 years ago

The paths that you are using look a little non-standard. I think this may be an issue with tsconfig-paths not resolving the path correctly.

I'll try to make a reproduction and open an issue for that, but on our side this is working properly when using paths that look like package.json names.

Ghirigoro commented 2 years ago

FWIW I'm also experiencing the same issue but am using more standard path names (e.g. @project/libname)

udnes99 commented 2 years ago

@Ghirigoro Similar to this #9596 ?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] commented 1 year ago

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.