Skip to content
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

Nx 16.8.0+ no longer automatically adds the 'apps' or 'libs' prefix for app/lib generators #180

Closed
simondotm opened this issue Dec 18, 2023 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@simondotm
Copy link
Owner

simondotm commented Dec 18, 2023

See https://nx.dev/deprecated/as-provided-vs-derived

For Nx 17, there are migration options for derived names, but they say from Nx 18 it will be as-provided only.

Apparently we have to provide --directory for workspace structure ourselves now.

Anyone finding this a problem with their projects?

I'm testing the plugin at the moment, and e2e tests are failing but I think the plugin should work ok with this new Nx change, just need to see if the documentation for the plugin may need updating to reflect this.

@simondotm simondotm added the documentation Improvements or additions to documentation label Dec 18, 2023
@timofei-iatsenko
Copy link

Well, i don't exactly understand how it worked before and what the expected result, but right now with Nx 16.10.0 it's not possible to override "app" in the path in any way.

λ nx g @simondotm/nx-firebase:function my-function --app eruptrplatform --dry-run --directory="/my-function" 

>  NX  Generating @simondotm/nx-firebase:function

UPDATE package.json
CREATE apps/my-function/my-function/src/assets/.gitkeep
CREATE apps/my-function/my-function/src/main.ts
CREATE apps/my-function/my-function/tsconfig.app.json
CREATE apps/my-function/my-function/tsconfig.json
CREATE apps/my-function/my-function/project.json
CREATE apps/my-function/my-function/.eslintrc.json
CREATE apps/my-function/my-function/jest.config.ts
CREATE apps/my-function/my-function/tsconfig.spec.json
CREATE apps/my-function/my-function/package.json
CREATE apps/my-function/my-function/readme.md
UPDATE projects/eruptrplatform/project.json
UPDATE firebase.eruptrplatform.json

NOTE: The "dryRun" flag means no changes were made.

Where expected result would be:

CREATE /my-function/src/assets/.gitkeep

The same is true for generating firebase app as well

@timofei-iatsenko
Copy link

Update: it seems NX trying to be smart and do some heuristic over the monorepo. So if you have "app" folder it will create new applications in here. So my previous report valid only if you already have apps / libs folder created.

@simondotm
Copy link
Owner Author

Ok I'm going to close this. My plugin compatibility tests seem ok with Nx versions >=16.8.1
The next plugin release will require a minimum 16.8.1 Nx version, so can be addressed if anyone reports a related issue.

@simondotm
Copy link
Owner Author

simondotm commented Mar 31, 2024

Re-opening this.
Just trying to update plugin to Nx 16.8.1 and having problems with my e2e tests. I don't think the plugin functions & app generators are respecting the new options for generators:

  • --projectNameAndRootFormat should be parsed & used if provided
  • --directory should consider if the nx.json file specifies as-provided or derived and derive the destination based on name/directory accordingly

It doesnt help that the e2e project setup is somewhat opaque about what defaults it sets in the nx.json config.

Previous versions of Nx, plugins could just infer the target folder from workspace layout apps / libs, but now it is much more flexible.

Hopefully theres some tooling for this in @nx/devkit to make my life easier.

@simondotm simondotm reopened this Mar 31, 2024
@simondotm
Copy link
Owner Author

Update: it seems NX trying to be smart and do some heuristic over the monorepo. So if you have "app" folder it will create new applications in here. So my previous report valid only if you already have apps / libs folder created.

@thekip I believe there's some fangled new configs in nx.json that might be influencing this:

  "workspaceLayout": {
    "projectNameAndRootFormat": "derived",
    "appsDir": "apps",
    "libsDir": "libs"
  },

🤔
Nx 16.8 blog post here

@simondotm
Copy link
Owner Author

The default nx.json created by the e2e test framework is just:

  "workspaceLayout": {
    "projectNameAndRootFormat": "as-provided"
  },

I'll probably need to add some e2e tests to make sure we've got functional coverage for all the different workspace variants.

@simondotm
Copy link
Owner Author

This is now implemented in #205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants