stackblitz / core

Online IDE powered by Visual Studio Code ⚡️
https://stackblitz.com
MIT License
10.23k stars 888 forks source link

StackBlitz not respecting peerDependenciesMeta optional property #2624

Open nstuyvesant opened 1 year ago

nstuyvesant commented 1 year ago

Description of Bug

StackBlitz forces the user to install all peerDependencies even if they were marked optional using peerDependenciesMeta in the package.json.

For example, @carbon/styles has the following in its package.json...

  "peerDependenciesMeta": {
    "sass": {
      "optional": true
    }
  }

Steps to Reproduce

For this StackBlitz example, https://stackblitz.com/edit/2njdn4?file=index.js, if you try to delete sass from Dependencies or package.json, StackBlitz will still force you to install sass. As a result, the examples take more time to load because they are loading an unnecessary dependency (given that I am only using CSS from that module and not SCSS).

Expected Behavior

StackBlitz would allow me to delete optional peer dependencies (or not include them in the first place).

Screenshots/Screencast

image

kc0tlh commented 1 year ago

@woodybriggs report on the same issue from #2706:

https://docs.npmjs.com/cli/v7/configuring-npm/package-json#peerdependenciesmeta

peerDependenciesMeta offers the ability for library authors to specify if a peerDependant is optional or not. Currently stackblitz forces installation of peerDependants even if they are marked as optional in peerDependenciesMeta

For a minimal repoduction of this.

Start with: React Typescript Starter

Try add package: @tanstack/react-query

Note after installation message appears: UNMET PEER DEPENDENCIES react-native @ *

"peerDependenciesMeta": { "react-dom": { "optional": true }, "react-native": { "optional": true } }