Giter Site home page Giter Site logo

Comments (8)

emikil avatar emikil commented on June 1, 2024 1

nx graph --file="/tmp/output.json" will export a json file you can use instead of workspace.json
perhaps it should be cached and invalidated only if the file structure has changed.

Since nx is a solution for mono-repos we can make an assumption that the directory is managed with git so cache invalidation will take place only when git shows that something has changed

from nx-completion.

edbzn avatar edbzn commented on June 1, 2024 1

Hi there, I added support for the optional workspace.json file. Try it and let me know if you have any issues.

from nx-completion.

edbzn avatar edbzn commented on June 1, 2024

Now that the workspace definition file (workspace.json) is optional, how can we list all the projects, do we have to recursively traverse folders and look for project.json? I need to investigate because this solution is not viable.

from nx-completion.

ryangrahamnc avatar ryangrahamnc commented on June 1, 2024

I think globbing for ./*/project.json and ./*/*/project.json might be the only way besides manually keeping track of what exists in a cache file.

Here's a dry-run for creating a new app:

$ npx nx g @nrwl/node:app asdf-app --dry-run                  

>  NX  Generating @nrwl/node:application

CREATE apps/asdf-app/src/app/.gitkeep
CREATE apps/asdf-app/src/assets/.gitkeep
CREATE apps/asdf-app/src/environments/environment.prod.ts
CREATE apps/asdf-app/src/environments/environment.ts
CREATE apps/asdf-app/src/main.ts
CREATE apps/asdf-app/tsconfig.app.json
CREATE apps/asdf-app/tsconfig.json
CREATE apps/asdf-app/project.json
CREATE apps/asdf-app/.eslintrc.json
CREATE apps/asdf-app/jest.config.ts
CREATE apps/asdf-app/tsconfig.spec.json

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

Notice how nothing is touched outside of the new apps/asdf-app dir.

Creating a lib updates the root tsconfig.base.json:

$ npx nx g @nrwl/js:lib asdf-lib --dry-run                    

>  NX  Generating @nrwl/js:library

CREATE libs/asdf-lib/README.md
CREATE libs/asdf-lib/package.json
CREATE libs/asdf-lib/src/index.ts
CREATE libs/asdf-lib/src/lib/asdf-lib.spec.ts
CREATE libs/asdf-lib/src/lib/asdf-lib.ts
CREATE libs/asdf-lib/tsconfig.json
CREATE libs/asdf-lib/tsconfig.lib.json
CREATE libs/asdf-lib/project.json
UPDATE tsconfig.base.json
CREATE libs/asdf-lib/.eslintrc.json
CREATE libs/asdf-lib/jest.config.ts
CREATE libs/asdf-lib/tsconfig.spec.json

And that's to set a reference to the lib in the tsconfig paths obj, which probably cant be trusted, since the user can edit it to add their own custom ones too:

"paths": {
    "asdf-lib": ["libs/asdf-lib/src/index.ts"],
}

from nx-completion.

edbzn avatar edbzn commented on June 1, 2024

@ryangrahamnc good point, using base tsconfig is not reliable, we have to look for nested project.json, but what if there's no project.json? this file is optional so we have to look for both package.json and project.json, that's much more complex than before (considering that doing this with Zsh will be a nightmare).

from nx-completion.

kopach avatar kopach commented on June 1, 2024

@edbzn, note with new release of nx, workspace.json is now deprecated
Here is v15.7.0 migrations.json file https://github.com/nrwl/nx/blob/8165459568e5bdfadf3f11ab7fe5e7eb044be06c/packages/workspace/src/generators/convert-to-nx-project/convert-to-nx-project.ts#L33 which removes workspace.json from repo https://github.com/nrwl/nx/blob/8165459568e5bdfadf3f11ab7fe5e7eb044be06c/packages/workspace/src/generators/convert-to-nx-project/convert-to-nx-project.ts#L33

So, this issue becomes critical now, IMO

And here is console output after upgrade

 >  NX   workspace.json is ignored

   Nx no longer reads configuration from workspace.json.
   Run "nx g @nrwl/workspace:fix-configuration" to split workspace.json into individual project.json files

from nx-completion.

danherd avatar danherd commented on June 1, 2024

Great work - thanks!

from nx-completion.

kopach avatar kopach commented on June 1, 2024

Thanks. It works. It feels a bit slower now, though. Also, even if I would keep workspace.json in root of the project just to make nx-completion use it and be faster – nx-completion seems to ignore it. Not a big problem though.

from nx-completion.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.