xplat v8 - more flexibility and broader options

Nathan Walker

Nathan Walker

Posted Jul 29, Updated Jul 30


The name "xplat" derives from the fact that it provides many tech choices for development in addition to providing optional supporting architecture to scale them in a predictable and uniform way within a monorepo like Nx.

# xplat v8 - more flexibility and broader options [xplat](https://github.com/nstudio/xplat) is a culmination of code sharing ideas and a labor of love guided by past experiences of tech product evolutions as well as perseverance through industry changes. *Ok, but what exactly is it*? They are tools specifically designed for [Nrwl's Nx](https://nx.dev) which add additional app generators not found in Nx today as well as optional supporting architecture which helps scale combinations of platform+framework combinations in a monorepo like Nx. So the name **xplat** derives from the fact that it provides cross platform choices for development in addition to providing an option to scale them in a predictable and uniform way. More precisely xplat is a suite of Angular [schematics](https://angular.io/guide/schematics) much like Nx itself. To best understand the differences you can checkout [xplat and nx](https://nstudio.io/xplat/getting-started/xplat-and-nx). If you are new to xplat we recommend reading about the [Fundamentals](https://nstudio.io/xplat/fundamentals) and if you'd like to give them a spin check out the [Getting Started Guide](https://nstudio.io/xplat/getting-started). Ideas & thoughts which started really years ago via project experiences but in relatively more recent times as a [talk by Jeff Whelpley and myself (Nathan Walker)](https://www.youtube.com/watch?v=EqqNexmu3Ug) has become the way we at nstudio build large projects for not only ourselves internally, but our clients. It has proven to provide the flexibility we have long desired with room to breathe. Plus it gives us increased peace of mind knowing we're not cornered with a certain tech stack allowing us to pivot the codebase if needed. As those who've worked in software for even a few months know changes can happen anytime whether that be internal business decisions affecting the product or industry changes and new technology opportunities. We actively use these tools everyday and are continuing to improve upon them as well as listen closely to community feedback. Speaking of community feedback one suggestion was to be able to use the app generators *without* the xplat supporting architecture layer. In v8 we now allow that via the `--useXplat=false` flag when generating any app. By default all app generators will use the xplat layer since we use these tools everyday and use that option ourselves the most. However if you prefer to use the app generators more a la' carte, just add that flag. Another feedback point was to allow the standard Nx app `--directory` option as that became an option during the time xplat was being developed. For example, this convenient option allows the workspace to group apps inside a `frontend` folder for frontend related apps and a `backend` folder for backend apps like when using Nx's [Nest](https://nx.dev/web/api/nest/schematics/application), [Express](https://nx.dev/web/api/express/schematics/application) or [Node](https://nx.dev/web/api/node/schematics/application) generators. That option can now be used as expected. Also new with v8 is the ability to generate apps with no framework. This means you can generate an Ionic app without Angular for example. When doing so you will actually get an Ionic app built with Stencil. Further you can generate a "vanilla" NativeScript app without Angular in Nx. This means you can generate a {N} app with standard `.xml` files backed by only TypeScript. You could also generate a web app with Nrwl's [@nrwl/web] app generator and could use xplat's Electron generator to wrap that custom elements app. # Repo overhaul xplat was originally developed in a relatively early time period with schematics (~beginning 2018) and since then schematics have matured and evolved. Additionally, Nx has done the same. We have completely overhauled the [xplat open source repo](https://github.com/nstudio/xplat) to match it's Nx neighbor in terms of structure to hopefully make it easier for others who may already contribute to Nx be able to contribute their own additions to xplat since it is designed solely for Nx. ## Why not PR to Nx? Keeping these 2 projects separate is beneficial for a multitude of reasons. It allows various tech stack combinations to try on new directions without affecting it's parent homebase. It also allows the enhancements of the optional supporting architecture layers to evolve with no affect on Nx itself. It can also breathe life into an entirely new direction which the community may want to try in Nx without having to modify Nx itself to do so. Where crossover meets then things could naturally evolve into a contribution to Nx itself and having the repo's more closely match in their structure makes it easier to do so. # What's Next in 8.1 and beyond? We are exploring using [Yarn workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) to improve the package management of the different tech stacks more seamlessly. We have also been looking at using [Lerna](https://lerna.js.org/) as well as combining both. If you have an opinion to share on either of these options or would like to suggest something else, please [share with us here](https://github.com/nstudio/xplat/issues/135). We are also looking into adding [Vue](https://vuejs.org/) and [React](https://reactjs.org/) (*Nx supports React but this would add extra platform+framework combinations*) support which would also allow Ionic+Vue, Ionic+React as well as NativeScript+Vue and NativeScript+React. # Try it out The [Getting Started Guide](https://nstudio.io/xplat/getting-started) is the best place to start. # Nod to Nx Building large and diverse products which can withstand years of change/alterations/maintenance is something that [Nrwl's Nx](https://nx.dev) workspace and monorepo setup is well suited for. This is why we have built xplat as a direct complimentary tool to Nx.