react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

`build/module` path contains usage of object spread operator

Open dimitriylol opened this issue 6 years ago • 2 comments

In the v4.4.0 there is the usage of object spread operator in build/module/Draggable.js:

      return {
        x: position.x,
        y: position.y,
        prevPropsPosition: { ...position
        }
      };

It breaks webpack compilation if node_modules aren't preprocessed with babel. If that's intentional, please post a comment and close the issue

dimitriylol avatar May 12 '20 18:05 dimitriylol

This is intentional in build/module, it is not present in build/cjs. build/module is intended for modern targets such as Node 12+. Is webpack selecting this automatically and causing problems?

STRML avatar May 12 '20 20:05 STRML

I see what the issue is now: because "browser" was removed in package.json, Webpack is now selecting "module", which is not ES5.

It wasn't clear to me at the time of writing that "module" really needs to be ES5-compliant code in practice, with import/export. That's pretty shocking and unexpected, but I can verify that this happens in real code by setting https://github.com/NeroVanbiervliet/electron-react-webpack-boilerplate/commit/864ed1f0ea9f4436e2a839c314680f205ef4331e to resolve 4.4.0, which causes a syntax error on build due to usage of an old version of Babili, which claims to understand ES6 syntax but doesn't really.

I hope ecosystem support gets to a point where "module"/"jsnext:main" are really usable, but today isn't that day.

I don't really want to inflict this kind of pain (enjoy diagnosing errors like: ERROR in unknown: Unexpected token (2000:4)!) on users of this module just to save a few kB, so I've ripped it out in 4.4.1.

STRML avatar May 12 '20 21:05 STRML