storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
83.95k stars 9.22k forks source link

[Bug]: ESM presets are not loading in Windows #27227

Open bashmish opened 3 months ago

bashmish commented 3 months ago

Describe the bug

If you publish an addon with a preset written in ESM, it's not being loaded on Windows. E.g. we published https://www.npmjs.com/package/@web/storybook-framework-web-components as ESM

Tested on Windows 10 and 11. (It works on macOS though, tested on Sonoma 14.4.1, so seems to be a Windows specific bug)

image

Reproduction link

https://github.com/thepassle/sb-windows-repro

Reproduction steps

git clone https://github.com/thepassle/sb-windows-repro.git cd sb-windows-repo npm i npm start

System

Storybook Environment Info:

  System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Xeon(R) CPU E5-2678 v3 @ 2.50GHz
  Binaries:
    Node: 20.12.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD <----- active
  Browsers:
    Edge: Chromium (125.0.2535.51)
  npmPackages:
    storybook: ^7.0.0 => 7.6.19

Additional context

Preset file is also .mjs, but the Storybook expects package.json exports to define it without extension. Ideally I think the extension should be also part of the public interface, so it's just a file and node should be able to load ".mjs" normally. Right now I think the problem is somewhere in interopRequireDefault, not sure why it's only happening on Windows.

zanfirandra commented 2 months ago

Hello,

Do you have any updates on this? Do you know when a fix will be released?

movrack commented 1 day ago

Facing same issue me and my colleagues... Would appreciate some update :)