weixin_39646405
weixin_39646405
2021-01-10 12:11

Validation checks

  • Few config validation checks added
  • Info message
  • README.md file updated

该提问来源于开源项目:siddharthkp/bundlesize

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

8条回答

  • weixin_39913422 weixin_39913422 4月前

    Thanks!

    But, this functionality is about to change really soon.(https://github.com/siddharthkp/bundlesize/issues/33)

    I would like to revisit this feature again after that, probably keep all the validation with the config object itself.

    点赞 评论 复制链接分享
  • weixin_39646405 weixin_39646405 4月前

    cool, will look for that config object. Can we have a complete dir check given maxSize of the dir in the config object.

    for eg. I won't like to check for each of my file size instead,

    
    "bundlesize": [
        {
          "path": "./src.js",
          "maxSize": "600B"
        }, {
          "dir": "./src",
          "maxSize": "50Kb"
        }
      ]
    

    or something like this

    
      "bundlesize": {
        "dir": "./dist",
        "maxBundleSize": "25Kb",
        "files": [
          {
            "path": "./index.js",
            "maxSize": "600B"
          }
        ]
      }
    
    

    39

    点赞 评论 复制链接分享
  • weixin_39913422 weixin_39913422 4月前

    I didn't get it. What does maxBundleSize signify?

    js
    "dir": "./dist",
    "maxBundleSize": "25Kb",
    "files": [
      { "path": "./index.js", "maxSize": "600B" }
    ]
    

    Are you saying that the sum of all the individual files should be <25Kb? Or are you saying the generated bundle (webpack/rollup/etc) is < 25Kb?

    点赞 评论 复制链接分享
  • weixin_39646405 weixin_39646405 4月前

    yes, sum of all files sizes in directory or with grouped files size.

    点赞 评论 复制链接分享
  • weixin_39913422 weixin_39913422 4月前

    Do you have a specific use case? This is something that I haven't had the need of yet.

    It's either individual files or the built bundle file.

    点赞 评论 复制链接分享
  • weixin_39646405 weixin_39646405 4月前

    if you consider it mostly for libraries only then it is fine, but if you take a look at web project, for eg. reactjs, one may wants to limit his/her bundled size, which is to load on the browser, he can do it by specifies each file. but it will be more convenient if he/ she has to just specify one dir and max output size. This can also be helpful full for webpack chunks dir, css chunks, and images. like how much you are delivering on browser client.

    点赞 评论 复制链接分享
  • weixin_39913422 weixin_39913422 4月前

    , there are 3 possibilities here:

    1. one bundle file (common for libraries), use them as:
    
    {
       "path": "./dist/lib.js",
       "maxSize": "4Kb"
    }
    
    1. multiple bundle files generated by a tool like webpack (common for applications)

    You might have different limits for different files here. vendor-{hash} should be < 20kB, all chunk files should be < 5kB and all css files less than < 10kB

    
    [
      {
         "path": "./dist/vendor-*.js",
         "maxSize": "20Kb"
      },
      {
         "path": "./dist/chunk-*.js",
         "maxSize": "5Kb"
      },
      {
         "path": "./styles/*.css",
         "maxSize": "10Kb"
      }
    ]
    
    
    1. multiple files distributed by type (typically when making a performance budget)

    This is something that can not be assessed by measuring a folder because bundlesize does not know which file is served on which page.

    Example: home.css is 10kB and about.css is 5kB. These are loaded on their respective pages. It is not useful to have an overall limit on the amount of css that exists on your entire site.

    点赞 评论 复制链接分享
  • weixin_39913422 weixin_39913422 4月前

    Implemented the things you mentioned in the PR in https://github.com/siddharthkp/bundlesize/pull/60, https://github.com/siddharthkp/bundlesize/pull/61 and https://github.com/siddharthkp/bundlesize/pull/62

    点赞 评论 复制链接分享

相关推荐