Skip to content

[Bug]: use of isomorphic-unfetch breaks storybook-next build #23700

@martaver

Description

@martaver

Describe the bug

When importing isomorphic-unfetch@5.0.0 (latest) into a Component that is to be displayed in a Story in storybook, the storybook build breaks with:

Module not found: Error: Can't resolve 'unfetch' in '/Users/martaver/Projects/repro/node_modules/isomorphic-unfetch'

and several:

odule build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.

of varying imports.

This might be simply a problem with isomorphic-unfetch, e.g. I know there is a problem with exports in unfetch:
developit/unfetch#162
developit/unfetch#164

However, since the same build error does NOT occur in next's build, I thought I'd flag this for the storybook team, since this suggests that storybook is doing something different in its build to next and I was under the impression that storybook should be utilising the same build configuration as next.

To Reproduce

https://github.com/cleric-sh/repro/tree/next-storybook-isomorphic-unfetch

Note the repro is in branch next-storybook-isomorphic-unfetch!

Run npm run storybook and check out the Button component. It imports isomorphic-unfetch without using it, which causes the aforementioned build errors.

System

Environment Info:

  System:
    OS: macOS 12.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 16.20.1 - ~/.config/nvm/versions/node/v16.20.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.19.4 - ~/.config/nvm/versions/node/v16.20.1/bin/npm
  Browsers:
    Chrome: 115.0.5790.114
    Safari: 15.5
  npmPackages:
    @storybook/addon-essentials: 7.1.1 => 7.1.1 
    @storybook/addon-interactions: 7.1.1 => 7.1.1 
    @storybook/addon-links: 7.1.1 => 7.1.1 
    @storybook/addon-onboarding: ^1.0.8 => 1.0.8 
    @storybook/blocks: 7.1.1 => 7.1.1 
    @storybook/nextjs: 7.1.1 => 7.1.1 
    @storybook/react: 7.1.1 => 7.1.1 
    @storybook/testing-library: ^0.2.0 => 0.2.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions