Nx: Repackaging for Nx 8.0

Created on 15 Apr 2019  路  19Comments  路  Source: nrwl/nx

Plan for Nx 8.0 Package Structure

We are making some changes to our packaging structure for Nx 8.0 and wanted to have a public plan so everyone knew what the upcoming changes will be and understands why they are happening. Please let us know if you have questions or concerns.

Background

Nx is a general purpose tool that allows you to develop Angular applications, React applications, Web Components, Node applications. All of these are currently implemented by two large packages: @nrwl/schematics and @nrwl/builders.

Problem

Adding functionality to our monolithic packages makes it hard to extend Nx from the outside and also provide catered experiences to specific audiences. While a team which uses Angular and a team which uses React can both use Nx today, they are both using the lowest common multiple of the options which makes the tool more complex for both teams. Same is true about our node support.

Solution

Repackage the existing functionality into domain-specific packages. For instance, jest functionality will be contained in @nrwl/jest.

Dev Experience

A workspace will still be created the same way using create-nx-workspace. We will add the ability to select capabilities when creating a new workspace. Capabilities can be added later on via ng add. For example, to add support for NestJS to an existing workspace: ng add @nrwl/nest. All the functionality available today will be available after the repackaging.

Packaging Structure

  • @nrwl/workspace

    • This will be the core of Nx

    • Analyzing dependencies between projects

    • Building affected projects

    • Generating a workspace

    • Generating a workspace-schematic

  • @nrwl/angular
  • @nrwl/react
  • @nrwl/web
  • @nrwl/jest
  • @nrwl/cypress
  • @nrwl/node
  • @nrwl/express
  • @nrwl/nest

Migration

We will upgrade existing workspaces without breaking them. We will look at the package.json dependencies to bring in the new packages automatically.

Implementation Plan

We will have a long-running beta for Nx 8.0. We estimate that this refactoring will be complete before May 2019. Meanwhile, we will stop adding features to Nx 7. We may still release patches if necessary.

feature

Most helpful comment

Or just @nrwl/workspace!

All 19 comments

will Angular CLI 8.0.0-beta-x support targeted for nx 8.0 or will be add to nx 7.8.x ?

CLI 8.0 support is also be targetted for Nx 8.0. We will repackage first and then migrate to the new Architect API. As far as I know, the new Architect API is the only breaking change in CLI 8.0 so far.

This sounds great!
@nrwl/ng-workspace perhaps should be @nrwl/nx-workspace, i.e., following the convention of create-nx-workspace?
Does @nrwl/web refer to Web Components?

Or just @nrwl/workspace!

Renamed to @nrwl/workspace :)

@emilio-martinez
@nrwl/web refers to the following:

  • Web Builders (Build + Serve)
  • Vanilla Schematics (Web Components)

sounds good. If you need someone to test the beta, happy to help :)

We will update the documentation accordingly, and find a way to show dependencies between each package.

would be great if solve #1098 before 8.0 release :D

@FrozenPandaz would love to test this out if everything's getting to be in a good testing place! Is the latest beta representative of the current master?

Any plan Apollo Client integrate with Nx?

@emilio-martinez Yes @nrwl/workspace@next has this. Please try it out and let us know what you find!

@perjerz3434 No concrete plans at the moment but we would love to have Apollo setup perhaps through Nest. The integration there is really nice and we use it in Angular Console.

@FrozenPandaz could we get a quick "How To" for switching from nrwl/nx to nrwl/workspace, or however it's going to move. I would like to start testing some of my tooling with angular-cli 8 and angular 8 as the release is just around the corner.

I haven't tried this as of yet, but i'm guessing i should be able to ng update @nrwl/schematics@next possibly?

@FrozenPandaz How far is NX 8 being ready? We have an issue with node-sass which has been resolved in version 8

"@angular-devkit/build-angular": "~0.800.0",
"@angular-devkit/build-ng-packagr": "~0.800.0", 

@Jordan-Hall guess it's out 馃槈
https://blog.nrwl.io/nxs-new-look-in-v8-25d7325260d

Sorry, I know it's a bit late for the suggestion. But for @nrwl/web wouldn't it be better to move the builders to individual packages e.g. @nrwl/react would have its own builder?

@Jordan-Hall if I'm understanding what you're saying correctly, that's exactly what the change was for Nx 8, i.e., @nrwl/react has it's own builder separate from the other distributed packages

Thanks for the suggestion!

@Jordan-Hall @emilio-martinez

@nrwl/react actually uses the @nrwl/web builders. We did not want to duplicate the code across both packages. I think the benefit in duplicating the code would be so that @nrwl/react users can save a download but @nrwl/web is pretty light and most of their dependencies can be hoisted if you're using yarn. We can also address that as a separate issue.

Closing this issue because we released Nx 8 with the repackaging.

This is a guide outlining how to move from Nx 7 to Nx 8.
https://nx.dev/guides/nx7-to-nx8

Is there a way to exclude cypress when creating a react application? I've tried creating an empty workspace as shown above, but when I add a react application is adds the cypress library by default.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieldanielecki picture danieldanielecki  路  3Comments

Koslun picture Koslun  路  3Comments

Svancara picture Svancara  路  3Comments

dereklin picture dereklin  路  3Comments

vimalraj-a picture vimalraj-a  路  3Comments