web-infra-dev / rsbuild

The Rspack-based build tool. It's fast, out-of-the-box and extensible.
https://rsbuild.dev/
MIT License
1.09k stars 85 forks source link

[Bug]: importing react-idle-timer causes SyntaxError #2819

Closed TheWeirdDev closed 1 week ago

TheWeirdDev commented 1 week ago

Version

System:
    OS: Linux 6.9 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 10.94 GB / 19.29 GB
    Container: Yes
    Shell: 3.7.1 - /bin/fish
  Browsers:
    Chromium: 126.0.6478.126
  npmPackages:
    @rsbuild/core: 1.0.0-alpha.4 => 1.0.0-alpha.4 
    @rsbuild/plugin-react: 1.0.0-alpha.4 => 1.0.0-alpha.4

Details

Using react-idle-timer in a react project causes SyntaxError:

vendors-node_modules…ack_c-32d00f.js:288 
 Uncaught  SyntaxError: Unexpected token ';' (at vendors-node_modules…32d00f.js:288:21525)

Reproduce link

https://codesandbox.io/p/devbox/wqrg9x

Reproduce Steps

  1. Create a new react ts project using pnpm create rsbuild@latest
  2. Add 'react-idle-timer' as a dependency: pnpm i react-idle-timer
  3. Modify the App component to use idle timer:
    
    import { withIdleTimer } from "react-idle-timer";
    import './App.css';

const App = () => { return (

Rsbuild with React

Start building amazing things with Rsbuild.

); };

export default withIdleTimer(App);


4. Run the dev server: `pnpm run dev`
5. Observe the syntax error message in Chrome DevTools
khangviet1996 commented 1 week ago

I'm facing the same issue. Here is my package.json. My project works fine with version 0.7.10, but when I try to upgrade to the latest version, I encounter this problem. package.json

image

GiancarlosIO commented 1 week ago

Same here. Happens after upgrading rsbuild to latest version

image image

chenjiahan commented 1 week ago

This should related to: https://github.com/web-infra-dev/rspack/issues/7049

@ahabhgk cc

chenjiahan commented 1 week ago

Fixed by Rspack, https://github.com/web-infra-dev/rsbuild/releases/tag/v1.0.0-alpha.6

GiancarlosIO commented 1 week ago

Thanks so much @chenjiahan !!!