Skip to content

Generator Nx21 + Workspace + Project References #31266

Discussion options

You must be logged in to vote

After reviewing the source code of some of the provided generators, I was able to identify the function that handles this and gain a better understanding of how it works:
https://github.com/nrwl/nx/blob/master/packages/js/src/generators/library/library.ts#L116C3-L116C70

It seems that we don’t actually need an extra function for this. In our custom generator, we can simply add the library to the package.json's workspaces property via updateJson (provided by @nx/devkit). Finally, at the end of the generator, we can execute the following to create the correct reference in the .lock file:

return () => { 
   installPackagesTask(tree); 
};

It looks like I’ve answered my own question 😅 I won’t …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SombreroElGringo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant