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

[repo] add first pass of Nx support #7334

Closed
wants to merge 1 commit into from

Conversation

trumbitta
Copy link
Contributor

What do you think about starting to streamline and tidying the repo up a bit, enabling awesome features, unlocking speed and best practices without thinking twice about configuration files, with mostly automated toolchain and dependency updates, and extensibility via plugins (official, community, custom)?

Do you fancy a free dependency graph, a yarn command away?

image

See what just happened: https://nx.dev/l/r/migration/adding-to-monorepo#real-world-examples-of-using-add-nx-to-monorepo

Description

This enables basic Nx improvements like, quoting from the output of the automagic command I used:

  • Computation caching and code change analysis are enabled.
  • Run yarn nx run-many --target=build --all --parallel to run the build script for every project in the monorepo.
  • Run it again to replay the cached computation.
  • Run nx dep-graph to see the structure of the monorepo.
  • Learn more at https://nx.dev/migration/adding-to-monorepo

Nx Cloud is also awesome, but I didn't enabled it at this moment.
Learn more about Nx Cloud at https://nx.app/

Next steps: leveraging the dep graph, starting to transform each project into proper Nx projects.

The move to Nx also opens the door to: Prettier, ESLint with very good presets, EditorConfig, and more. All of them preconfigured with great defaults. Also meaning there will be a solid foundation to attack some of the technical debt I'm starting to notice in the dashboard app (but I'm sure some of it must be hiding also in other parts of the repo :D ).

How to test

Please, help me understand if everything still works as usual!
Ignore Nx and use the repo as usual, to check if the automagic tool broke something!

Other than that, do the following:

  • Open in Gitpod
  • Run yarn nx dep-graph
  • Open in browser
  • Bask in the glory of the dependency graph (there might be missing things, but they will pop back up when the move to Nx is complete)

And the following:

  • Run yarn nx run-many --target=build --all --parallel to run the build script for every project in the monorepo.
  • Alternatively, run yarn nx build @gitpod/dashboard to only build the dashboard (or choose another project)
  • Run it again to replay the cached computation.
  • Imagine what does this mean when Nx Cloud is enabled and configured so that every developer (including the CI server) gets the instant result if they didn't change anything before launching a build (or a test, or a lint, or whatever once the move to Nx is complete).

Release Notes

[repo] Add basic support for Nx

This enables basic Nx improvements like, quoting from the CLI:

  - Computation caching and code change analysis are enabled.
  - Run "yarn nx run-many --target=build --all --parallel" to run the build script for every project in the monorepo.
  - Run it again to replay the cached computation.
  - Run "nx dep-graph" to see the structure of the monorepo.
  - Learn more at https://nx.dev/migration/adding-to-monorepo

Nx Cloud is also awesome, but I didn't enabled it at this moment.
Learn more at https://nx.app/

Next steps: leveraging the dep graph, starting to transform each project into proper Nx projects.
@roboquat
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign princerachit after the PR has been reviewed.
You can assign the PR to them by writing /assign @princerachit in a comment when ready.

No associated issue. Update pull-request body to add a reference to an issue, or get approval with /approve no-issue

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@iQQBot
Copy link
Contributor

iQQBot commented Dec 21, 2021

Hi @trumbitta Thanks for your contribute! 🎉

@stale
Copy link

stale bot commented Jan 1, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the meta: stale This issue/PR is stale and will be closed soon label Jan 1, 2022
@trumbitta
Copy link
Contributor Author

trumbitta commented Jan 1, 2022

Please good bot, keep it open 🙏

@stale stale bot removed the meta: stale This issue/PR is stale and will be closed soon label Jan 1, 2022
@csweichel
Copy link
Contributor

Our build system already provides dependency trees (leeway describe tree resp. leeway describe dependencies --serve=:8080) ... not quite the same quality, but good enough :)

I'm not sure I've understood what nx does. Why would we want to add it to the repo?

@trumbitta
Copy link
Contributor Author

trumbitta commented Jan 10, 2022

Thanks for the reply @csweichel 🙏 the most important goal I had for this PR was to get the conversation going 😄

Nx is a tool for managing (build, lint, test, release, etc) monorepos. Founded by Jeff Cross and Viktor Savkin, two former devs at Google in the Angular team. It's maintained by all the folks at Nrwl, their consultant studio, and a thriving community.

From what I'm reading about leeway, it does more or less what leeway does.

Nx is language agnostic, extensible via a plugin system, works with yarn, npm, and more.
The commands are always the same regardless of the framework or language. E.g. when developing, to launch the dashboard app you'd run nx run dashboard:serve, to run a backend service you'd run nx run backend-service:serve and so on and so forth vs the current situation where you have to discover how to run each app in the monorepo. This is a huge win for DevX (cc @loujaybee about that).
Configuration is also streamlined and "always the same", and it has the concept of "environment" (remember this is always language agnostic) vs the current situation where for example before running the dashboard app in development you have to read the README and edit your local craco.config.js. With Nx you'd simply have a configuration tied to the development environment and everything would just work. And if you need more confs for the same environment you can have those too: nx run dashboard:serve:my-other-conf.
Nx has dozens of generators to streamline everyday work, create new apps, libs, move things around, etc. Each plugin provides its own generators.
Test, lint, build configurations are already there and they are very good from the start while staying customizable.
Updating to a new release (roughly once per month) is usually automagic: Nx provides migrations for every official plugin and the rest is usually well documented. In 3+ years I had to change something by hand only twice though, and for updating code in large monorepos writing your own migrations using an AST tool is supported and encouraged.
Nx curates the package versions of the most important JS/TS packages it provides (e.g. react is curated and provided by the react plugin, and always compatible with the typescript version of the monorepo, etc) so that they are always compatible with each other without devs having to spend time to pick and choose compatible versions.
The Go plugin is one of the most appreciated community plugins.

Of course there's more, AMA :)

@csweichel
Copy link
Contributor

As of today we're not looking to adopt a new build system/monorepo management tool. Our current one works well for our needs.

Thank you for getting in touch/pointing out nx. If our needs change, we'll certainly keep it in mind :)

@csweichel csweichel closed this Jan 10, 2022
@gtsiolis
Copy link
Contributor

gtsiolis commented Jan 10, 2022

Thanks @trumbitta for giving this a go! I agree with @csweichel here but please do not let this discourage you from contributing to other areas of the product. 🧁

@trumbitta
Copy link
Contributor Author

trumbitta commented Jan 10, 2022

Thanks @csweichel and @gtsiolis 🙏

Of course I knew such a PR was a long shot. I'll continue contributing as long as I can, and I'll be there when you decide to switch to Nx 😸

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

Successfully merging this pull request may close these issues.

5 participants