Remove unused javascript code based on coverage report

后端 未结 6 697
北海茫月
北海茫月 2021-02-05 07:45

There is a big javascript library (~ 40 000 lines of code) and an application which uses less than 50% of the library\'s code.

There is a test which uti

6条回答
  •  孤城傲影
    2021-02-05 08:12

    In order to automatically remove unused code from bundle, we have:

    1. Tree shaking
    2. Ugliy and Minification tools such as uglifyjs, Terser
    3. Google closure compiler (best results)

    However, in order to find the unused assets, to remove manually, you can use deadfile library: https://m-izadmehr.github.io/deadfile/

    It can simply find unused files, in any JS project.

    Without any config, it supports ES6, JSX, and Vue files:

提交回复
热议问题