storybookjs / storybook

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

[Bug]: Terser plugin not working with react-native-web on version 7.2.0 #23686

Open rosanche opened 1 year ago

rosanche commented 1 year ago

Describe the bug

When running yarn storybook:build for my project using React Native Web with Storybook, the build fails with a specific issue related to the Terser plugin :

ERR! Unexpected token: punc (.) [main.76e128c5.iframe.bundle.js:1469,10]
ERR!     at js_error (/Users/romainsanchez/Desktop/Blank/neok-app/node_modules/terser/dist/bundle.min.js:549:11)```

```shell
Environment Info:

  System:
    OS: macOS 13.4
    CPU: (8) x64 Apple M2
  Binaries:
    Node: 18.16.0 - /usr/local/opt/node@18/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 9.5.1 - /usr/local/opt/node@18/bin/npm
  Browsers:
    Chrome: 115.0.5790.114
    Safari: 16.5
  npmPackages:
    @storybook/addon-actions: 7.2.0 => 7.2.0 
    @storybook/addon-essentials: 7.2.0 => 7.2.0 
    @storybook/addon-knobs: 7.0.2 => 7.0.2 
    @storybook/addon-links: 7.2.0 => 7.2.0 
    @storybook/addon-react-native-web: 0.0.21 => 0.0.21 
    @storybook/react: 7.2.0 => 7.2.0 
    @storybook/react-native: 6.5.5 => 6.5.5 
    @storybook/react-webpack5: 7.2.0 => 7.2.0

Additional context

I'm currently disabling the Terser plugin as a workaround like this : config.optimization.minimizer = config.optimization.minimizer.filter( (plugin) => plugin.constructor.name !== 'TerserPlugin', );. However the build work but not launching sotrybook, this seems like a bug in @storybook/react-webpack5's webpack config.

Any assistance with resolving this bug or providing a proper workaround would be greatly appreciated.

vanessayuenn commented 1 year ago

@dannyhw any pointers on this? 🙏

dannyhw commented 1 year ago

Can you try the latest version 7.3? I don't really know anything about this terser plugin though, whats its purpose?

dannyhw commented 1 year ago

Can you share a reproduction?