ni / javascript-styleguide

JavaScript and TypeScript Style Guide
MIT License
9 stars 9 forks source link

Monorepo migration #59

Closed rajsite closed 2 years ago

rajsite commented 3 years ago

Overview

This PR migrates the repository from a single package repository to a monorepo with multiple packages. One of the primary benefits is projects can install only dependencies they require with npm 7. With npm 7 peerDependencies are installed by default so, for example, projects using only JS or TS will end up installing many unneeded angular dependencies before this change.

The user experience is also improved as users do not need to manually evaluate which dependencies are required by their projects. Fixes #41.

Implementation

The repo creates three new public packages:

The previous @ni/eslint-config package will be marked deprecated with a message redirecting users to the github for new packages. The new packages' major versions will start at (current package major version +1) to avoid confusion.

The smoke tests are each migrated to their own private packages and more faithfully represent a deployed configuration.

User impact

One major change is that due to the behavior change of peerDependencies in npm 7, the documentation now describes a simplified workflow for managing the lint packages. Users on npm 7 only need to install their specific package, for example @ni/eslint-config-javascript and all peerDependencies are guaranteed to be installed.

So the recommendation when using npm 7 will be to only include the exact package you need and rely on npm cli and the generated lock file for the project to handle the dependency tree. Users will not be encouraged to manually add the peerDependencies of the package they install to their own package.json dependencies (unless they are using npm 6 or below).

This isn't common practice yet but I expect the pattern to be more pervasive as npm 7 usage increases.

rajsite commented 3 years ago

Failed to bowl and stroll :P I can pick-it up after returning. Alternatively if someone wants to merge it they have to do the work to create new packages under the ni org and assign them permissions etc before they can be published. Can work with Fred or Mark if feeling ambitious.

We may want a minor push to main of the Angular README updates in-case someone does try and integrate with the exisiting package before the monorepo transition. @TrevorKarjanis