The lerna build is very slow, always (+30 minutes)
Asked Answered
L

3

6

I'm just joining a new VueJS / Webpack based on a Lerna code architecture :

package.json
lerna.json
packages/
modules/
plugins/

Approximately each page of the application has been set as a separated module which I find strange and although not an expert I'm not sure this is the correct way of setting up a Lerna architecture.

Nevertheless, the package.json defines the following :

"scripts": {
"bootstrap": "npm install && npm run lerna && npm run app-build",
"lerna": "lerna bootstrap --hoist --nohoist=axios --nohoist=vue-chartist --nohoist=chardist",
"publish": "lerna publish",
"clean": "lerna clean",
"test": "lerna run test --parallel",
"start": "lerna run start --stream --scope=main-module",
"app-build": "lerna run build --stream --scope=main-module",
"doc": "good-doc"}

And the app, although of medium size I would say :

Size of the application with node_modules

Is always very slow (+30 minutes) to build. At each build. The builds are executed like this :

cross-env BACK_URL=back_url npm run bootstrap --hoist

Is there any good pratices to have a quicker build ? Any ideas of what could have been set wrong in my project ? Or maybe this is just normal...

Lyndalynde answered 18/10, 2018 at 14:15 Comment(0)
J
3

I moved from --hoist to use yarn workspaces (https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/).

My problem was not regarding performance but about having the possibility to use the nohoist option (https://yarnpkg.com/blog/2018/02/15/nohoist/). I had some error with a really simple setup because of some react-scripts dependency, so I needed to exclude to modules from hoisting.

Here's my base config:

--> lerna.json
{
  "version": "0.0.0",
  "packages": [
    "packages/*",
  ],
  "npmClient": "yarn",
  "useWorkspaces": true
}

---> package.json
{
  "name": "root",
  "private": true,
  "workspaces": {
    "packages": ["packages/*""],
    "nohoist": ["**/babel-jest", "**/eslint", "**/jest"]
  },
  "devDependencies": {
    "lerna": "^3.4.3"
  }
}
Janey answered 24/10, 2018 at 11:12 Comment(0)
L
0

The slow build was due to my computer + a lot of files to build together I guess. We had lerna implemented as each page of the app was a separated package, which was not really was lerna is made for.

We removed lerna from the infrastructure and we're better off now.

Lyndalynde answered 18/6, 2019 at 13:18 Comment(0)
E
0

I'd say to set "--concurrency 1" to decrease memory usage.

I got better performance with it.

;)

Exiguous answered 12/4, 2022 at 12:46 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Haphtarah

© 2022 - 2024 — McMap. All rights reserved.