lifeiscontent / storybook-addon-next-router

Addon to use Next.js Router in Storybook
MIT License
108 stars 22 forks source link

storybook fails to start because of tslib #29

Closed xistz closed 3 years ago

xistz commented 3 years ago

Thank you creating the addon. The addon fails to start if npm is used as the package manager. The issue seems to be with tslib and how npm/yarn manages package versions. The issue can be reproduced in this repository

https://github.com/xistz/next-storybook-addon-next-router

steps taken to create the respective directories

error message from when starting storybook in the npm directory

Screenshot 2021-07-20 at 9 20 12
dohomi commented 3 years ago

I experience the same issue, is there a workaround? I receive this error with yarn v2:

ERR! Error: storybook-addon-next-router tried to access tslib, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

And npm does fail with the error above.

xistz commented 3 years ago

I am not familiar with dependency resolution but I managed to work around it by running npm i -D tslib@2.3.0

lifeiscontent commented 3 years ago

@xistz I can remove tslib, but that would make the code larger, pretty sure other libraries that are written with TS can take advantage of tslib which will ultimately result in a smaller bundle size for you.

xistz commented 3 years ago

@lifeiscontent After a bit more investigation, I realised the issue could have also arose because my other packages were depending on an older version of tslib which didn't have __spreadArray. Whenever those packages get updated, it will be probably be resolved.

Until then, manually installing tslib is a workaround so I think it should be fine to leave it in.

Thanks for your help!