title: How to make optional peer dependencies truly optional
body: <p>I have an NPM package that offers two things: Core functionality in form of React hooks and UI components that use these core functionalities.</p>
  <p>My idea originally was to make two packages, one for the core stuff and one for the components. So that if you don't want to use the components out of the box, you could still use the libraries core features. After working on the library I found it to be overkill to make two packages, because the core functionality is basically 2 Hooks with less than 200 lines of code.</p>
  <p>So I went the route to add the UI components dependencies as peer dependencies, and expected that when I mark them as optional, you wouldn't need to install them if you don't need the UI parts. With mark them as optional I mean:</p>
  <pre><code>&quot;peerDependenciesMeta&quot;: {
      &quot;@material-ui/core&quot;: {
        &quot;optional&quot;: true
      },
  }
  </code></pre>
  <p>Now the problem is, even if I don't import the UI parts from my library into a testing project I set up, the App breaks because it is trying to look for the optional dependencies.</p>
  <p>My questions:</p>
  <ul>
  <li>Is this expected behavior?</li>
  <li>Whats optional about these peer dependencies, if the App breaks when the modules my library depends on are not around?</li>
  <li>Are there no options for me other than to make a separate package for the components?</li>
  </ul>
  <p>Hopefully someone can shed some light into the dark for me.</p>