re-rxjs / react-rxjs

React bindings for RxJS
https://react-rxjs.org
MIT License
549 stars 19 forks source link

Webpack 4 Build Error #186

Closed iprado78 closed 3 years ago

iprado78 commented 3 years ago

I included react-rxjs in a Next.js POC and it threw an error during build because it ships an esm module with optional chaining:

error - ./node_modules/@react-rxjs/utils/dist/utils.esm.js 66:40
Module parse failed: Unexpected token (66:40)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     let innerSub;
|     let outterSub = source$.subscribe((n) => {
>       innerSub = innerSub || n.get(key)?.subscribe(observer);
|     }, (e) => {
|       observer.error(e);

The underlying problem seems to be the JS parser in webpack 4, and it was solved by changing the configuration of Next.js's build system to use webpack 5.

Do you plan to support building with webpack 4 or generally running the library on older engines?

josepot commented 3 years ago

Hi @iprado78 ,

Sorry that it took me a while to get back to you.

I was under the impression that #179 fixed this :thinking:. So, I want to think that this was happening before v0.8.2 of @react-rxjs/utils? Could you please let us know whether the latest version fixes this issue?

Do you plan to support building with webpack 4 or generally running the library on older engines?

Actually, I'm pretty sure that it used to work fine with webpack 4 out of the box... We were using it on RT, anyways, now it should be fine... And yes, we do support older engines, that's why we also publish a cjs version that's transpiled to ES5. I always thought that it was fair game to use modern features on the esm build, but anyways, hopefully this should do it for now.

iprado78 commented 3 years ago

Thanks, yes, no error with webpack 4 on v0.8.2. We were using v0.7.0.