Closed jornejongsma closed 2 years ago
Do you see the targets if you run the https://github.com/nrwl/nx-examples repo?
And if you do, can you give me the contents of your package.json file in the project you're seeing the issue in? (Just deps and dev deps)
I see the issue with the workspace.json not pointing to the project files, but I'm not seeing the other issues. I'll fix the codlins for workspace.json asap.
I pushed out a release to fix the code lenses, but I'm not closing this until I get a reply back with the other details about the targets not showing up, etc.
Yes, I'm back again, today we had Pentecost Monday, which is a public holiday here in The Netherlands.
So, what I did: First I updated to v17.18.1 and installed nx-examples repo, and everything works as expected, great! Then I opened one of my repos and that took a few moments before it picked up the right target links; After that opened another workspace repo, that did not seem to work completely: workspace.json regained its links, but not in the project.json's. Although, the 'Generate & Run Target' panel showed all the targets, but in the Project panel the executors for every project didn't work... So it did not work everywhere the way it should.
So having the latest version now installed, I wanted to see what would happen when I removed node_modules and re-installed all dependencies again. I made an overview:
version | without node_modules | freshly installing node_modules | normal update to next version |
---|---|---|---|
v17.17.0 | works fine! *1 | yep, woks | - |
v17.18.0 | NOT working | workspace.json not working*2 | worskpace.json stopped 3* |
v17.18.1 | only workspace.json | only after reloading VSC | workdspace.json works again *4 |
1. For as far as things can work without node_modules, all links are showing up. 2. Only workspace.json did not work, but..! Starting fresh with npx create-nx-workspace, nothing works! And this was my experience that after a while slowly other existing workspaces also started to stop working! 3. Two days ago, not only workspace.json did not work, but after a while every link/target stopped working, but somehow I can't reproduce that situation at the moment. 4. Well, everything works again, but that workspace freshly installed with 17.18.0 needed (seemed to have) to re-install node_modules, and even after restarting VSC, it took several minutes before all panels finally worked as they should.
Conclusion: When starting a fresh environment with v17.18.0 will give people a hard time with this extension. Also updating after that to the 17.18.1 patch might not instantly work as it should. A fresh project clone does work right away with v17.18.1 (really strange to see that it seems to make a difference to have a fresh clone or a simply reinstalled node_modules) Is there some caching going there?
What it looks like when it's not working:
What's the package.json contents in the workspace that doesn't work?
{
"name": "jj-mono",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"start": "nx serve",
"build": "nx build",
"test": "nx test"
},
"repository": {
"type": "git",
"url": "https://github.com/jornejongsma/jj-mono"
},
"private": true,
"devDependencies": {
"@nrwl/cli": "14.1.9",
"@nrwl/cypress": "14.1.9",
"@nrwl/devkit": "14.1.9",
"@nrwl/eslint-plugin-nx": "14.1.9",
"@nrwl/jest": "14.1.9",
"@nrwl/js": "14.1.9",
"@nrwl/linter": "14.1.9",
"@nrwl/nx-plugin": "^14.1.9",
"@nrwl/react": "^14.1.9",
"@nrwl/web": "14.1.9",
"@nrwl/workspace": "14.1.9",
"@testing-library/react": "13.1.1",
"@types/jest": "27.4.1",
"@types/node": "16.11.7",
"@types/react": "18.0.8",
"@types/react-dom": "18.0.3",
"@typescript-eslint/eslint-plugin": "~5.18.0",
"@typescript-eslint/parser": "~5.18.0",
"babel-jest": "27.5.1",
"cypress": "^9.1.0",
"eslint": "~8.12.0",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-cypress": "^2.10.3",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-react": "7.29.4",
"eslint-plugin-react-hooks": "4.5.0",
"jest": "27.5.1",
"nx": "14.1.9",
"prettier": "^2.5.1",
"react-test-renderer": "18.1.0",
"ts-jest": "27.1.4",
"ts-node": "9.1.1",
"tslib": "^2.0.0",
"typescript": "~4.6.2"
},
"dependencies": {
"core-js": "^3.6.5",
"react": "18.1.0",
"react-dom": "18.1.0",
"regenerator-runtime": "0.13.7",
"tslib": "^2.3.0"
}
}
Hmm, I completely missed that you mentioned you had Windows. I'm going to have to boot that up and check up on it. Sorry for the inconvenience this is causing you!
I have seen this intermittently on Mac as well. Quitting and re-launching VSCode seems to resolve it.
Could have to do with pnp
As a workaround copy the package.json of the nx dependenxy from .yarn to node_modules/nx/package.json
For me it started working again.
Why not
__non_webpack_require__('nx/package.json');
???
hmm.. good catch! I'll change that implementation to be more inline with our other places.
@jornejongsma sorry, but I'm not able to reproduce this with any of the workspaces I have on Windows. Can you provide a reproduction or even your workspace?
@Cammisuli did you try with yarn berry in pnp mode?
Nx itself doesn't really support yarn berry. (Only the core works well with it).
So reproduction repos using yarn berry would be greatly appreciated 😅
I found the underlying cause, will push out a new version asap. Thanks for your patience!
Thanks for helping us out!
Can confirm it is working for me now yarn 3.2.1 with pnp node 16.15.1. Thanks again!
Yes, it's working for me too. Although, when you've installed a new plugin, you must reload VSC to make newly generated targets work for that plugin.
For instance, after installing @nrwl/react the generators will appear in the NX console . So generating an app with it, the new apps will appear in the projects-pannel too, but these apps won't show their execution targets before a reload of VSC.
Oh, I noticed something else, maybe another issue:
When creating a new execution target in a project.json, it automatically creates a new command link inside that json, but it does not update the execution targets in the Projects panel. Only after running that command in the terminal, it might update that list with the new target. (I actually don't know what triggered an update, not a VSC reload, but eventually, it did)
And when you'd remove a target from a project.json it won't update that Projects panel, so older unused commands stay in that list. Hitting that refresh button or restarting VSC didn't update any changes.
Yea, that's something I need to handle better. Recently we switched to use the project graph apis, and i default to use cache every time. I might remove the check for the cache, and try and regenerate things all the time. But I also have to make sure that this function call is used a lot and need to optimize it a bit.
I have it on my next thing to fix this week.
Current Behavior
When opening the CLI extension it cannot find the project targets anymore; It does not expose the execution targets in the 'Generate & Run Target; In the workspace.json it does not show the links to every project; And in all project.json files it does not add project target to the commands.
Expected Behavior
In the Projects panel, it should show all execution commands; In Generate & Run Target panel it should also show all available execution commands.
Version 17.17.0 did work as expected, the current version 17.18.0 is not working for me.
Steps to Reproduce
Just open a repo, when the latest update is coming through, maybe reload vs-code, and you will probably see that it stops working
Environment
Version: 1.67.2 (user setup) Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5 Date: 2022-05-17T18:15:52.058Z Electron: 17.4.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Windows_NT x64 10.0.19043