Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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...

like image 751
Ludo Avatar asked Oct 16 '22 11:10

Ludo


1 Answers

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"
  }
}
like image 177
michelepatrassi Avatar answered Oct 19 '22 11:10

michelepatrassi