SukkaW / nolyfill

Speed up your package installation process, reduce your disk usage, and extend the lifespan of your precious SSD.
MIT License
1.1k stars 15 forks source link

Package detection finds many redundant packages #36

Open wojtekmaj opened 1 year ago

wojtekmaj commented 1 year ago

I have a fairly standard React app. Here are all the deps:


  "dependencies": {
    "@internal/assets": "^3.2.0",
    "@internal/react-toast": "^2.0.0",
    "@internal/react-ui": "^3.0.1",
    "@internal/styles": "^2.0.0",
    "@internal/utils": "^2.2.0",
    "@react-spring/web": "^9.5.0",
    "@sentry/react": "^7.38.0",
    "@wojtekmaj/react-async-button": "^1.3.0",
    "@wojtekmaj/react-hooks": "^1.16.2",
    "@wojtekmaj/react-t": "^0.10.2",
    "core-js": "3",
    "lucide-react": ">=0.130.1 <1",
    "prop-types": "^15.7.2",
    "react": "^17.0.0",
    "react-dom": "^17.0.0",
    "react-helmet-async": "^1.3.0",
    "react-is": "^17.0.0",
    "react-router-dom": "~6.3.0",
    "smoothscroll-polyfill": "^0.4.4",
    "styled-components": "^5.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.19.3",
    "@babel/preset-env": "^7.19.3",
    "@babel/preset-react": "^7.18.6",
    "@babel/preset-typescript": "^7.18.6",
    "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
    "@testing-library/dom": "^8.0.0",
    "@testing-library/jest-dom": "^5.0.0",
    "@testing-library/react": "^12.0.0",
    "@testing-library/user-event": "^14.4.0",
    "@total-typescript/ts-reset": "^0.5.1",
    "@types/babel__core": "^7.20.0",
    "@types/node": "*",
    "@types/react": "^18.2.0",
    "@types/react-dom": "^18.2.0",
    "@types/smoothscroll-polyfill": "^0.3.1",
    "@types/styled-components": "^5.1.26",
    "babel-loader": "^9.1.0",
    "babel-plugin-styled-components": "^2.0.0",
    "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
    "copy-webpack-plugin": "^11.0.0",
    "css-loader": "^6.3.0",
    "eslint": "^8.5.0",
    "eslint-config-wojtekmaj": "^0.9.0",
    "html-webpack-plugin": "^5.1.0",
    "husky": "^8.0.0",
    "jsdom": "^21.1.0",
    "lint-staged": "^14.0.0",
    "mini-css-extract-plugin": "^2.0.0",
    "prettier": "^3.0.0",
    "react-refresh": "^0.14.0",
    "rimraf": "^3.0.0",
    "style-loader": "^3.0.0",
    "ts-node": "^10.9.1",
    "typescript": "^5.1.0",
    "vitest": "^0.34.0",
    "webpack": "^5.88.0",
    "webpack-cli": "^5.0.0",
    "webpack-dev-server": "^4.0.0"
  },

This is the result of yarn dlx nolyfill install in my repository:

    "array-buffer-byte-length": "npm:@nolyfill/array-buffer-byte-length@latest",
    "array-includes": "npm:@nolyfill/array-includes@latest",
    "array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest",
    "array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest",
    "array.prototype.tosorted": "npm:@nolyfill/array.prototype.tosorted@latest",
    "available-typed-arrays": "npm:@nolyfill/available-typed-arrays@latest",
    "deep-equal": "npm:@nolyfill/deep-equal@latest",
    "define-properties": "npm:@nolyfill/define-properties@latest",
    "es-set-tostringtag": "npm:@nolyfill/es-set-tostringtag@latest",
    "function-bind": "npm:@nolyfill/function-bind@latest",
    "function.prototype.name": "npm:@nolyfill/function.prototype.name@latest",
    "get-symbol-description": "npm:@nolyfill/get-symbol-description@latest",
    "globalthis": "npm:@nolyfill/globalthis@latest",
    "gopd": "npm:@nolyfill/gopd@latest",
    "has": "npm:@nolyfill/has@latest",
    "has-property-descriptors": "npm:@nolyfill/has-property-descriptors@latest",
    "has-proto": "npm:@nolyfill/has-proto@latest",
    "has-symbols": "npm:@nolyfill/has-symbols@latest",
    "has-tostringtag": "npm:@nolyfill/has-tostringtag@latest",
    "internal-slot": "npm:@nolyfill/internal-slot@latest",
    "is-arguments": "npm:@nolyfill/is-arguments@latest",
    "is-array-buffer": "npm:@nolyfill/is-array-buffer@latest",
    "is-date-object": "npm:@nolyfill/is-date-object@latest",
    "is-regex": "npm:@nolyfill/is-regex@latest",
    "is-shared-array-buffer": "npm:@nolyfill/is-shared-array-buffer@latest",
    "is-string": "npm:@nolyfill/is-string@latest",
    "is-symbol": "npm:@nolyfill/is-symbol@latest",
    "is-weakref": "npm:@nolyfill/is-weakref@latest",
    "object-is": "npm:@nolyfill/object-is@latest",
    "object-keys": "npm:@nolyfill/object-keys@latest",
    "object.assign": "npm:@nolyfill/object.assign@latest",
    "object.entries": "npm:@nolyfill/object.entries@latest",
    "object.fromentries": "npm:@nolyfill/object.fromentries@latest",
    "object.hasown": "npm:@nolyfill/object.hasown@latest",
    "object.values": "npm:@nolyfill/object.values@latest",
    "regexp.prototype.flags": "npm:@nolyfill/regexp.prototype.flags@latest",
    "safe-regex-test": "npm:@nolyfill/safe-regex-test@latest",
    "side-channel": "npm:@nolyfill/side-channel@latest",
    "string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@latest",
    "string.prototype.trim": "npm:@nolyfill/string.prototype.trim@latest",
    "string.prototype.trimend": "npm:@nolyfill/string.prototype.trimend@latest",
    "string.prototype.trimstart": "npm:@nolyfill/string.prototype.trimstart@latest",
    "typed-array-length": "npm:@nolyfill/typed-array-length@latest",
    "unbox-primitive": "npm:@nolyfill/unbox-primitive@latest",
    "which-boxed-primitive": "npm:@nolyfill/which-boxed-primitive@latest",
    "which-typed-array": "npm:@nolyfill/which-typed-array@latest"

upon carefully reviewing the list, I've noted that many of the packages are not used at all - not anymore, because nolyfill removed the need for them. The final list, resulting with the same lockfile, was:

    "array-includes": "npm:@nolyfill/array-includes@latest",
    "array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest",
    "array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest",
    "array.prototype.tosorted": "npm:@nolyfill/array.prototype.tosorted@latest",
    "has": "npm:@nolyfill/has@latest",
    "object.assign": "npm:@nolyfill/object.assign@latest",
    "object.entries": "npm:@nolyfill/object.entries@latest",
    "object.fromentries": "npm:@nolyfill/object.fromentries@latest",
    "object.hasown": "npm:@nolyfill/object.hasown@latest",
    "object.values": "npm:@nolyfill/object.values@latest",
    "side-channel": "npm:@nolyfill/side-channel@latest",
    "string.prototype.matchall": "npm:@nolyfill/string.prototype.matchall@latest"
SukkaW commented 1 year ago

This is a known issue due to the working mechanics or yarn.lock. yarn.lock lists all dependencies at the top level.

wojtekmaj commented 1 year ago

What do you think about just scanning it twice? Scan - add resolutions - install - scan - remove redundant resolutions? Or at least, make the install command remove redundant packages so that we could manually do just that?