【问题标题】:The lerna build is very slow, always (+30 minutes)lerna 构建非常缓慢,总是(+30 分钟)
【发布时间】:2018-10-18 14:15:46
【问题描述】:

我刚刚加入了一个基于 Lerna 代码架构的新 VueJS / Webpack:

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

应用程序的每个页面都被设置为一个单独的模块,我觉得这很奇怪,虽然我不是专家,但我不确定这是设置 Lerna 架构的正确方法。

尽管如此,package.json 定义了以下内容:

"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"}

还有应用程序,虽然我想说的是中等大小:

Size of the application with node_modules

构建总是很慢(+30 分钟)。在每个构建中。构建是这样执行的:

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

有没有什么好的做法可以加快构建速度?关于我的项目中可能设置错误的任何想法?或者这只是正常的......

【问题讨论】:

    标签: performance vue.js webpack build lerna


    【解决方案1】:

    我从 --hoist 转移到使用 yarn 工作区 (https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/)。

    我的问题不在于性能,而在于能否使用 nohoist 选项 (https://yarnpkg.com/blog/2018/02/15/nohoist/)。由于一些 react-scripts 依赖性,我在一个非常简单的设置中遇到了一些错误,所以我需要从提升中排除模块。

    这是我的基本配置:

    --> 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"
      }
    }
    

    【讨论】:

      【解决方案2】:

      我猜是因为我的电脑 + 很多文件要一起构建,所以构建缓慢。我们已经实现了 lerna,因为应用程序的每个页面都是一个单独的包,这并不是 lerna 的真正用途。

      我们从基础架构中移除了 lerna,现在情况更好了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-28
        • 2014-03-31
        • 2017-04-18
        • 1970-01-01
        • 2016-01-24
        • 2010-12-10
        • 2022-06-10
        • 2010-10-24
        相关资源
        最近更新 更多