Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Use NPM >7 and workspaces #55

Closed
boeckMt opened this issue Jan 15, 2021 · 4 comments
Closed

Use NPM >7 and workspaces #55

boeckMt opened this issue Jan 15, 2021 · 4 comments
Labels
enhancement feat: (New feature or request)

Comments

@boeckMt
Copy link
Member

boeckMt commented Jan 15, 2021

Description

To better handle dependencies management try to use NPM 7 workspaces with the monorepo.

// package.json
workspaces": [
    "projects/*",
    "scripts/*"
  ],
...

Dependencies management right now (NPM)

  • there is on package.json in the root of the repo which includes all dependencies used in all the projects
  • each project has its own package.json which includes:
    • peerDependencies to angular and overall used dependencies
    • the direct dependencies of the project and also other @dlr-eoc/projects are listed here as dependencies

Dependencies related to the Build process

Only use npm workspaces is not enough to build all the projects. Projects can also depend on other projects.

  1. To create a build currently we get the list of all projects from angular.json
  2. Then we get its dependencies (with scope @dlr-eoc) from the package.json (by using project.root from angular.json)
  3. To check that all the projects which depend on other projects are listed correctly we use depcheck
  4. Then we build a 'dependencies graph'
  5. To get a legal build execution order we use toposort
  6. To build the projects then we build each project in this order by ng build <project> --prod=true --watch=false
@boeckMt boeckMt added the enhancement feat: (New feature or request) label Jan 15, 2021
@boeckMt
Copy link
Member Author

boeckMt commented Jan 15, 2021

For this we also have to update the github actions to use node 15.x actions/setup-node#213 (comment)

// https://github.com/actions/setup-node
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
  with:
    node-version: '15'

@boeckMt
Copy link
Member Author

boeckMt commented May 26, 2021

@boeckMt
Copy link
Member Author

boeckMt commented Jul 22, 2021

Use Npm Workspaces

Install package in a workspace

  • npm i <p-name> --workspace=projects/<name>

create a new package and add it to the workspace

  • npm init -w ./projects/<name>

@boeckMt
Copy link
Member Author

boeckMt commented Mar 23, 2022

Npm install for the whole workspace

Currently this fails due to the version paceholders we have set

Could not resolve dependency:
npm WARN peer @angular/common@"0.0.0-PLACEHOLDER-VENDOR" from @dlr-eoc/services-layers@0.0.0-PLACEHOLDER
...
npm WARN Could not resolve dependency:
npm WARN peer @angular/core@"0.0.0-PLACEHOLDER-VENDOR" from @dlr-eoc/services-layers@0.0.0-PLACEHOLDER
...
npm WARN Could not resolve dependency:
npm WARN peer rxjs@"0.0.0-PLACEHOLDER-VENDOR" from @dlr-eoc/services-layers@0.0.0-PLACEHOLDER
...

we could try to use the script setVersionsforDependencies and restore it after the install somehow.


possibly related: npm/rfcs#301

@boeckMt boeckMt changed the title Use NPM 7 and workspaces Use NPM >7 and workspaces Mar 23, 2022
@dlr-eoc dlr-eoc locked and limited conversation to collaborators Jan 17, 2023
@boeckMt boeckMt converted this issue into discussion #176 Jan 17, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement feat: (New feature or request)
Projects
None yet
Development

No branches or pull requests

1 participant