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

[Feature Request] Remove `add-module-exports` babel plugin

Open amanmahajan7 opened this issue 7 years ago • 2 comments

add-module-exports plugin mimics babel-5 behavior and adds a magic module.exports = exports['default']; statement if the module only has default export. Although this is convenient but it is not the correct behavior and Babel 6 has removed this hack.

This problem is clearly explained on stackoverflow

https://github.com/59naga/babel-plugin-add-module-exports

Due to this plugin, react-measure default export is undefined when used with TypeScript (at least in my project). If we really need to preserve the old behavior then having multiple bundles (UMD, UMD-legacy, ES6) would be really helpful

Thanks

amanmahajan7 avatar Sep 29 '17 22:09 amanmahajan7

Here is more info https://github.com/Microsoft/TypeScript/issues/5565#issuecomment-155216760

amanmahajan7 avatar Sep 29 '17 22:09 amanmahajan7

Also ran into this error: https://github.com/souporserious/react-measure/issues/37#issuecomment-333237534

Using:

import * as ReactMeasure from "react-measure";
const Measure: any = (ReactMeasure as any).Measure;

to work around the error but I obviously loose type checking.

jrmyio avatar Feb 22 '18 19:02 jrmyio