-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(js): provide a new way of generating project name and root directory for libraries #18420
feat(js): provide a new way of generating project name and root directory for libraries #18420
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
22fc6a7
to
4c347f3
Compare
7d6d59f
to
ab4fb04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🎉 - I don't see anything major that needs to be changed, but I think we should really consider checking the generator name. Let me know your thoughts 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize this generator was still kicking around 🤔
@FrozenPandaz do you think we can remove it soon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@meeroslav marked it deprecated for the next version.
#18464
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🎉 - I don't see anything major that needs to be changed, but I think we should really consider checking the generator name. Let me know your thoughts 😄
ab4fb04
to
6c566e4
Compare
6c566e4
to
d3b7eee
Compare
nameDirectoryFormat: options.nameDirectoryFormat, | ||
rootProject: options.rootProject, | ||
}); | ||
options.rootProject = projectDirectory === '.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options.rootProject
would only be used when nameDirectoryFormat
is derived right? So when we remove the derived option, we can also remove rootProject
? 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly. If rootProject
is provided, is considered for both formats. It's only relevant if the directory was not provided though.
If we remove it when derived
is removed, we lose the ability to create what we call a root project. We decided to use the project name as the directory if the directory is not provided for the new way. So, if rootProject
doesn't exist, you can't create a project in the root because you'll always get a folder with the project name.
…ing the js library generator
8292eb5
to
8d98e32
Compare
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
The
@nx/js:library
generator (and all other Nx first-party plugins' project generators) generates the project name, directory, and import path in the following way (rough guidelines):[directory-]name
(directory path separators replaced with-
)[layoutDir/][directory/]name
--importPath
is provided is used[@npmScope/]projectRoot
(projectRoot without the layoutDir)Those rules impose certain limitations:
workspaceLayouts
innx.json
) configured, it will always be used. There's no way to opt out of it for certain projects@my-org/my-pkg
)--importPath
is required to be provided)Expected Behavior
There should be a way to generate exactly what the user provides to the generator. To avoid breaking changes, this will be behind a flag.
The new way is simpler to reason about. There are almost no rules or hidden magic you need to be aware of to understand why things were generated in a certain way. What you provide is what you get.
The only rules that apply are:
--directory
is not provided, the directory will be the project name--importPath
is not provided, it's generated as follows:[@npmScope/]name
Notes about
--project-name-and-root-format
and compatibilityThis is intended to be a non-breaking change. At the same time, we want to make it as visible as possible and prompt for which format to use. The following are some implementation details and context to achieve both things:
--project-name-and-root-format
generator option doesn't have an explicit default value in the schema. The default value is dynamically set or the generator will prompt for the value.derived
(a.k.a. the current behavior)derived
(a.k.a. the current behavior)The above are the rules followed when the option is not provided to the generator. When the option is provided, it is respected as with any other option.
Related Issue(s)
Fixes #