index.js - 531.46 KB
-
node_modules/lodash - 531.35 KB
-
lodash.js - 531.35 KB
-
This rule aims to reduce weight of programs by using only needed modules. Many libraries export only one module by default, but some of them are exporting ES modules or submodules. We should use them to select more precisly needed modules and avoid unnecessarily overloading files weight.
Example with the well-known lodash library, if you only need
isEmpty method.
| Full lodash library | Only isEmpty method |
|---|---|
index.js - 531.46 KB
|
index.js - 24.42 KB
|
Examples of non-compliant code for this rule:
// Example with lodash
import lodash from "lodash";
import { isEmpty } from "lodash";
import * as lodash from "lodash";
// Example with underscore
import _ from "underscore";
Examples of compliant code for this rule:
// Example with lodash (uses submodules)
import isEmpty from "lodash/isEmpty";
import intersect from "lodash/intersect";
// Example with underscore (uses esm modules)
import map from "underscore/modules/map.js";