opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.67k stars 875 forks source link

Remove unnecessary `resolutions` from package.json #1298

Open tmarkley opened 2 years ago

tmarkley commented 2 years ago

There are many leftover resolutions from past fixes that are no longer relevant/necessary after recent changes. We need to attempt to remove as many manual resolutions as possible to clean up our dependencies. Some of them are bringing in libraries that are no longer in the dependency tree.

The following resolutions require additional changes/upgrades:

@types/node: @microsoft/api-documenter ansi-regex: many upstream dependencies, see #1084 async: @elastic/makelogs, grunt-contrib-clean, ejs, webpack-dev-server d3-color: @elastic/charts glob-parent: eslint, chokidar, webpack, mocha, chromedriver, parcy/cli, and more hoist-non-react-statics: react-intl json-schema: webpack #1118 kind-of: is-number, define-property, micromatch, @types/globby loader-utils: webpack #1118 node-jose: @elastic/request-crypto nth-check: css-select, cheerio, typescript, enzyme trim: eui, react-markdown, jimp typescript: osd, eui unset-value: webpack #1118

tmarkley commented 2 years ago

The following resolutions require additional changes/upgrades:

@types/node: @microsoft/api-documenter front-matter: sass-lint glob-parent: eslint, chokidar, webpack, mocha, chromedriver, parcy/cli, and more hoist-non-react-statics: react-intl kind-of: is-number, define-property, micromatch, @types/globby merge: sass-lint minimist: sass-lint node-jose: @elastic/request-crypto trim: eui, react-markdown, jimp typescript: osd, eui

tmarkley commented 2 years ago

Async (after addressing #1440):

$ yarn why async
yarn why v1.22.17
[1/4] Why do we have the module "async"...?
[2/4] Initialising dependency graph...
warning Resolution field "typescript@4.0.2" is incompatible with requested version "typescript@~4.5.2"
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "async@3.2.3"
info Has been hoisted to "async"
info Reasons this module exists
   - "workspace-aggregator-c0722a78-ad95-4f99-ae26-c77d29b69f1b" depends on it
   - Hoisted from "_project_#getos#async"
   - Hoisted from "_project_#archiver#async"
info Disk size without dependencies: "1.08MB"
info Disk size with unique dependencies: "1.08MB"
info Disk size with transitive dependencies: "1.08MB"
info Number of shared dependencies: 0
=> Found "@elastic/makelogs#async@1.5.2"
info This module exists because "_project_#@elastic#makelogs" depends on it.
info Disk size without dependencies: "180KB"
info Disk size with unique dependencies: "180KB"
info Disk size with transitive dependencies: "180KB"
info Number of shared dependencies: 0
=> Found "@osd/ui-framework#async@2.6.3"
info Reasons this module exists
   - "_project_#@osd#ui-framework#grunt-contrib-clean" depends on it
   - Hoisted from "_project_#@osd#ui-framework#grunt-contrib-clean#async"
   - in the nohoist list ["/_project_/**/@types/*","/_project_/**/@types/*/**","/_project_/**/grunt-*","/_project_/**/grunt-*/**","/_project_/@elastic/eui/rehype-react","/_project_/@elastic/eui/remark-rehype","/_project_/@elastic/eui/remark-rehype/**"]
info Disk size without dependencies: "852KB"
info Disk size with unique dependencies: "5.71MB"
info Disk size with transitive dependencies: "5.71MB"
info Number of shared dependencies: 1
=> Found "grunt#async@3.2.3"
info Reasons this module exists
   - "_project_#grunt#grunt-legacy-util" depends on it
   - Hoisted from "_project_#grunt#grunt-legacy-util#async"
   - in the nohoist list ["/_project_/**/@types/*","/_project_/**/@types/*/**","/_project_/**/grunt-*","/_project_/**/grunt-*/**","/_project_/@elastic/eui/rehype-react","/_project_/@elastic/eui/remark-rehype","/_project_/@elastic/eui/remark-rehype/**"]
info Disk size without dependencies: "1.08MB"
info Disk size with unique dependencies: "1.08MB"
info Disk size with transitive dependencies: "1.08MB"
info Number of shared dependencies: 0
=> Found "jake#async@0.9.2"
info This module exists because "_project_#@osd#plugin-generator#ejs#jake" depends on it.
info Disk size without dependencies: "120KB"
info Disk size with unique dependencies: "120KB"
info Disk size with transitive dependencies: "120KB"
info Number of shared dependencies: 0
=> Found "portfinder#async@2.6.3"
info This module exists because "_project_#@osd#ui-framework#webpack-dev-server#portfinder" depends on it.
info Disk size without dependencies: "852KB"
info Disk size with unique dependencies: "5.71MB"
info Disk size with transitive dependencies: "5.71MB"
info Number of shared dependencies: 1
Done in 1.11s.
$ npm ls async
opensearch-dashboards@2.0.0 /home/ubuntu/ws/OpenSearch-Dashboards
├─┬ @elastic/makelogs@6.1.0
│ └── async@1.5.2 
├─┬ @osd/plugin-generator@1.0.0 -> /home/ubuntu/ws/OpenSearch-Dashboards/packages/osd-plugin-generator
│ └─┬ ejs@3.1.6
│   └─┬ jake@10.8.4
│     └── async@0.9.2 
├─┬ archiver@5.3.0
│ └── async@3.2.3 
├─┬ getos@3.2.1
│ └── async@3.2.3  deduped
└─┬ grunt@1.4.1
  └─┬ grunt-legacy-util@2.0.1
    └── async@3.2.3 
tmarkley commented 1 year ago

Details for unset-value

After removing the manual resolution:

$ yarn why unset-value
yarn why v1.22.15
[1/4] Why do we have the module "unset-value"...?
[2/4] Initialising dependency graph...
warning Resolution field "typescript@4.0.2" is incompatible with requested version "typescript@~4.5.2"
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "unset-value@1.0.0"
info Reasons this module exists
   - "_project_#braces#snapdragon#base#cache-base" depends on it
   - Hoisted from "_project_#braces#snapdragon#base#cache-base#unset-value"
info Disk size without dependencies: "88KB"
info Disk size with unique dependencies: "128KB"
info Disk size with transitive dependencies: "208KB"
info Number of shared dependencies: 6
=> Found "@types/globby#unset-value@1.0.0"
info Reasons this module exists
   - "_project_#@types#globby#fast-glob#micromatch#snapdragon#base#cache-base" depends on it
   - Hoisted from "_project_#@types#globby#fast-glob#micromatch#snapdragon#base#cache-base#unset-value"
   - in the nohoist list ["/_project_/**/@types/*","/_project_/**/@types/*/**","/_project_/**/grunt-*","/_project_/**/grunt-*/**","/_project_/@elastic/eui/rehype-react","/_project_/@elastic/eui/remark-rehype","/_project_/@elastic/eui/remark-rehype/**"]
info Disk size without dependencies: "96KB"
info Disk size with unique dependencies: "136KB"
info Disk size with transitive dependencies: "216KB"
info Number of shared dependencies: 6
=> Found "@osd/optimizer#unset-value@1.0.0"
info Reasons this module exists
   - "_project_#@osd#optimizer#@types#watchpack#chokidar#braces#snapdragon#base#cache-base" depends on it
   - Hoisted from "_project_#@osd#optimizer#@types#watchpack#chokidar#braces#snapdragon#base#cache-base#unset-value"
   - in the nohoist list ["/_project_/**/@types/*","/_project_/**/@types/*/**","/_project_/**/grunt-*","/_project_/**/grunt-*/**","/_project_/@elastic/eui/rehype-react","/_project_/@elastic/eui/remark-rehype","/_project_/@elastic/eui/remark-rehype/**"]
info Disk size without dependencies: "96KB"
info Disk size with unique dependencies: "136KB"
info Disk size with transitive dependencies: "216KB"
info Number of shared dependencies: 6
=> Found "@osd/pm#unset-value@1.0.0"
info Reasons this module exists
   - "_project_#@osd#pm#@types#globby#fast-glob#micromatch#snapdragon#base#cache-base" depends on it
   - Hoisted from "_project_#@osd#pm#@types#globby#fast-glob#micromatch#snapdragon#base#cache-base#unset-value"
   - in the nohoist list ["/_project_/**/@types/*","/_project_/**/@types/*/**","/_project_/**/grunt-*","/_project_/**/grunt-*/**","/_project_/@elastic/eui/rehype-react","/_project_/@elastic/eui/remark-rehype","/_project_/@elastic/eui/remark-rehype/**"]
info Disk size without dependencies: "96KB"
info Disk size with unique dependencies: "136KB"
info Disk size with transitive dependencies: "216KB"
info Number of shared dependencies: 6
Done in 1.33s.

$ npm list unset-value
opensearch-dashboards@3.0.0 /workspaces/OpenSearch-Dashboards
├─┬ @osd/eslint-plugin-eslint@1.0.0 -> /workspaces/OpenSearch-Dashboards/packages/osd-eslint-plugin-eslint
│ └─┬ micromatch@3.1.10
│   └─┬ snapdragon@0.8.2
│     └─┬ base@0.11.2
│       └─┬ cache-base@1.0.1
│         └── unset-value@1.0.0 
└─┬ @types/globby@8.0.0
  └─┬ fast-glob@2.2.7
    └─┬ micromatch@3.1.10
      └─┬ snapdragon@0.8.2
        └─┬ base@0.11.2
          └─┬ cache-base@1.0.1
            └── unset-value@1.0.0 

After upgrading globby and removing the micromatch dependency:

$ yarn why unset-value
yarn why v1.22.15
[1/4] Why do we have the module "unset-value"...?
[2/4] Initialising dependency graph...
warning Resolution field "typescript@4.0.2" is incompatible with requested version "typescript@~4.5.2"
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "unset-value@1.0.0"
info Reasons this module exists
   - "_project_#braces#snapdragon#base#cache-base" depends on it
   - Hoisted from "_project_#braces#snapdragon#base#cache-base#unset-value"
info Disk size without dependencies: "88KB"
info Disk size with unique dependencies: "128KB"
info Disk size with transitive dependencies: "208KB"
info Number of shared dependencies: 6
=> Found "@osd/optimizer#unset-value@1.0.0"
info Reasons this module exists
   - "_project_#@osd#optimizer#@types#watchpack#chokidar#braces#snapdragon#base#cache-base" depends on it
   - Hoisted from "_project_#@osd#optimizer#@types#watchpack#chokidar#braces#snapdragon#base#cache-base#unset-value"
   - in the nohoist list ["/_project_/**/@types/*","/_project_/**/@types/*/**","/_project_/**/grunt-*","/_project_/**/grunt-*/**","/_project_/@elastic/eui/rehype-react","/_project_/@elastic/eui/remark-rehype","/_project_/@elastic/eui/remark-rehype/**"]
info Disk size without dependencies: "96KB"
info Disk size with unique dependencies: "136KB"
info Disk size with transitive dependencies: "216KB"
info Number of shared dependencies: 6
Done in 1.41s.

$ npm list unset-value
opensearch-dashboards@3.0.0 /workspaces/OpenSearch-Dashboards
└─┬ @osd/eslint-import-resolver-opensearch-dashboards@2.0.0 -> /workspaces/OpenSearch-Dashboards/packages/osd-eslint-import-resolver-opensearch-dashboards
  └─┬ webpack@4.46.0
    └─┬ micromatch@3.1.10
      └─┬ snapdragon@0.8.2
        └─┬ base@0.11.2
          └─┬ cache-base@1.0.1
            └── unset-value@1.0.0 

Thus, the webpack upgrade is blocking this.

joshuarrrr commented 1 year ago

@tmarkley Can you provide a little more context on this issue to make it more actionable for other potential contributors?

There are many leftover resolutions from past fixes that are no longer relevant/necessary after recent changes

What's the best way to identify these? What was your process for generating the list?

We need to attempt to remove as many manual resolutions as possible to clean up our dependencies. Some of them are bringing in libraries that are no longer in the dependency tree.

Can you explain a little more about what the potential consequences, risks, or problems with these resolutions? Having a clear description of the impact makes it easier to prioritize.

Finally, can you outline the general steps that an interested contributor should take to remove or resolve one of these resolutions?