tocbot: Added ESM version breaks storybook build

Hello, we are using Storybook in our library, which has tocbot as a dependency. After minor upgrade of Storybook, it no longer builds. Investigation revealed that after adding ESM version, storybook build in our library was broken: Error: No "exports" main defined in ./node_modules/tocbot/package.json Storybook version is 7.6.17, which has tocbot as a dependency at ^4.20.0.

Workaround for now is to override tocbot version.

About this issue

  • Original URL
  • State: open
  • Created 2 months ago
  • Reactions: 3
  • Comments: 22 (7 by maintainers)

Most upvoted comments

@zhangzhenxi0316 tocbot@4.27.5 is published with that change. Let me know if that helps. Thanks!

Hi @Josh-Walker-GM, I pushed a fix to add those exports back, can you try tocbot@4.27.4?

image hi @tscanlin , I encountered this problem as shown above image i think u need set default import config in package.json like this image After I manually added default exports, the build went normally. The strange thing is that whether I export the esmodule product or the common js product, it can be built successfully in the end.

I can confirm, that the latest version works for me too 😃 thanks for so fast fixes!

With Bun, you can override until Storybook updates:

...
"overrides": {
    "tocbot": "4.27.13"
  }

Make sure to remove node_modules and reinstall

There should be no need for this, as they have it defined as ^4.20. so it is upgraded to latest 4.2* version automatically (at least with npm)

With Bun, you can override until Storybook updates:

...
"overrides": {
    "tocbot": "4.27.13"
  }

Make sure to remove node_modules and reinstall

@tscanlin It looks like the latest version resolves our issue. Thanks for the resolution!

@tscanlin Here is an example that demonstrates the issue in storybook: https://stackblitz.com/edit/github-7s5dz5?file=.storybook%2Fmain.ts The @storybook/blocks is the storybook add-on in which we are seeing the issue.

@tscanlin image hi~,please check package.json config, The default parameter needs to be at the bottom of the export configuration thanks

@tscanlin It’s used by Storybook so I’m not too sure. But tocbot@4.27.5 solved the issue 🥳. Thank you!

Looks like that’s fixed it for us. Thanks for the incredibly quick turn around!