You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating from Nx 16 to Nx 17, my custom generator that internally utilizes "@nx/react:library" has started experiencing an issue. Specifically, the problem arises when I attempt to read the project configuration with readProjectConfiguration(tree, projectName) immediately following the generator's execution. This results in a Cannot find configuration for 'folder-my-example' error. My generator operates by passing predefined values and making file adjustments after running the Nx generator. This issue is particularly troublesome as it disrupts the normal workflow that was functional in Nx 16.
Unusual Finding During Debugging
While debugging by directly tweaking the '@nx/react' generator in 'node_modules,' I encountered an oddity: the project name wasn't correctly recognized in Nx's projects map. Specifically, using 'importPath' incorrectly set the path as the project 'name,' leading to retrieval issues. Similarly, incorporating '/' in the project name didn't convert to hyphens ('-') as in prior Nx versions, disrupting standard name formatting and recognition. This issue was evident during the debugging process, as seen in the provided screenshot.
I manually modified the file in node_modules, adding some console.log statements for debugging purposes.
Expected Behavior
The expected behavior is for the custom generator to seamlessly integrate with the updates in Nx 17, just as it did with Nx 16. The readProjectConfiguration function should correctly retrieve the configuration for the newly created project without throwing an error, regardless of whether the project name includes a folder path (e.g., 'folder/my-example').
GitHub Repo
No response
Steps to Reproduce
Use Nx 17.
Run a custom generator that internally uses "@nx/react:library", create library for "folder/my-example" project and tries to read the project configuration after execution.
Observe the error Cannot find configuration for 'folder-my-example' when the project name includes a folder path.
Additional context
Upon diving into the Nx source code, I noticed that this issue seems specific to '@nx/react'. In contrast, the '@nx/js' library, which follows the same approach, does not exhibit this problem.
As a further attempt to resolve the issue, I tried providing the "projectNameAndRootFormat" explicitly, suspecting the problem might be related to how the 'derived' configuration handles project names with parent folders. Notably, if I avoid using a parent folder in the name (e.g., using no-folder-my-example), the project is created without any issues.
The text was updated successfully, but these errors were encountered:
Performing the same test using @nx/js:library instead of @nx/react:library leads to a different outcome. Here, the project is found, and everything works correctly. The screenshot shows this contrast, using the same debug method and commands from the issue.
Another observation relates to the package.json. When "@nx/react:library" (publishable) creates the package.json using the importPath, it appears to treat this import path as the project name within Nx's project context. Currently, I have pnpm workspaces set up for the libs folder to facilitate publishing using changesets.
The critical note here is: if I disable pnpm workspaces, everything starts working again. That is, the project is correctly identified by its name "shared-abc" instead of "@web/shared-abc". However, what's peculiar is that with "@nx/js:library", despite simulating the same behavior and generating an identical package.json with the importPath as the name, this issue doesn't manifest. This remains true whether pnpm workspaces is enabled or disabled.
This suggests some inconsistency or unexpected interaction in the way "@nx/react:library" is handling project naming and its relationship with package.json and pnpm workspaces.
Current Behavior
After updating from Nx 16 to Nx 17, my custom generator that internally utilizes "@nx/react:library" has started experiencing an issue. Specifically, the problem arises when I attempt to read the project configuration with
readProjectConfiguration(tree, projectName)
immediately following the generator's execution. This results in aCannot find configuration for 'folder-my-example'
error. My generator operates by passing predefined values and making file adjustments after running the Nx generator. This issue is particularly troublesome as it disrupts the normal workflow that was functional in Nx 16.Unusual Finding During Debugging
While debugging by directly tweaking the '@nx/react' generator in 'node_modules,' I encountered an oddity: the project name wasn't correctly recognized in Nx's projects map. Specifically, using 'importPath' incorrectly set the path as the project 'name,' leading to retrieval issues. Similarly, incorporating '/' in the project name didn't convert to hyphens ('-') as in prior Nx versions, disrupting standard name formatting and recognition. This issue was evident during the debugging process, as seen in the provided screenshot.
I manually modified the file in node_modules, adding some console.log statements for debugging purposes.
Expected Behavior
The expected behavior is for the custom generator to seamlessly integrate with the updates in Nx 17, just as it did with Nx 16. The
readProjectConfiguration
function should correctly retrieve the configuration for the newly created project without throwing an error, regardless of whether the project name includes a folder path (e.g., 'folder/my-example').GitHub Repo
No response
Steps to Reproduce
Cannot find configuration for 'folder-my-example'
when the project name includes a folder path.Nx Report
Failure Logs
No response
Package Manager Version
pnpm 7.32.0
Operating System
Additional Information
Additional context
Upon diving into the Nx source code, I noticed that this issue seems specific to '@nx/react'. In contrast, the '@nx/js' library, which follows the same approach, does not exhibit this problem.
As a further attempt to resolve the issue, I tried providing the "projectNameAndRootFormat" explicitly, suspecting the problem might be related to how the 'derived' configuration handles project names with parent folders. Notably, if I avoid using a parent folder in the name (e.g., using
no-folder-my-example
), the project is created without any issues.The text was updated successfully, but these errors were encountered: