Do NOT add Storybook to peerDependencies - Nx Angular (ng-packagr)

102 Views Asked by At

Background:

I have an Nx workspace with a single Angular library (and its e2e application). The library exports UI Components as separate entry points as well as assets (e.g. stylesheets) via [email protected].

My source folder's peerDependencies have two @fontsource/... entries and nothing else.

Storybook (v6.5) is added to the workspace's and NOT the library(!)'s package.json as a devDependency. My tsconfig.lib.ts (and by extension the tsconfig.lib.prod.ts) excludes **/*.stories.ts.

Problem:

One of the .stories.ts files has the following code: import type { Args, StoryContext } from '@storybook/csf';

When listing peer dependencies compile-time, this should be ignored for two reasons:

  1. It is explicitly imported as type; and
  2. It is explicitly ignored in the relevant tsconfig.

Yet, when my library builds, @storybook/csf is added to the compiled peerDependencies. If I delete the import statement above, @storybook/csf is NOT added to the compiled peerDependencies.

Question:

Can somebody explain how I can prevent Storybook modules from becoming peer dependencies without

  • deleting their (type) imports from my stories' code? and without
  • deleting .stories.ts files before building and publishing the library?

Thanks!

0

There are 0 best solutions below