Fork me on GitHub
#cljs-dev
<
2017-10-31
>
p-himik18:10:23

Initially I posted in #clojurescript but this may be more relevant here. I'm trying to use https://github.com/souporserious/react-measure in my project. I specified the dependency using :npm-deps, and everything is fine up to the moment when I actually try to render the wrapped component:

Uncaught TypeError: _resizeObserverPolyfill2$$module$home$p_himik$dev$git$musicxmlcheck_test$node_modules$react_measure$lib$with_content_rect.default is not a constructor
The check of the objects quickly shows that it's being wrapped by _interopRequireDefault into {default: ...} two times:
_resizeObserverPolyfill2$$module$home$p_himik$dev$git$musicxmlcheck_test$node_modules$react_measure$lib$with_content_rect: Object
default:
  default: λ[callback]
Has anyone seen anything like it?

juhoteperi18:10:06

default properties are also from Babel, to help the module being used from ES6 modules

p-himik18:10:24

So react-measure was built with Babel and uploaded to NPM, but resize-observer-polyfill was not built and was just uploaded?

p-himik18:10:50

I have to mention that I know nothing in the modern JS except for some CLJS.

juhoteperi18:10:53

hmh, maybe Closure doesn't understand that __esModule check on interop require call

p-himik18:10:28

The name mangling for resize-observer-polyfill didn't create any __esModule mentions.

juhoteperi18:10:29

resize-observer-polyfill also has built files under dist/

p-himik18:10:55

Yeah, but there's just export default index;

juhoteperi18:10:12

there is ~infinite number of Babel configurations 😕

p-himik18:10:49

But in this case how does that even work for the author of react-measure and all other users of this library?

juhoteperi18:10:19

I don't know, Closure is special case, it might work on browser or node

juhoteperi18:10:17

or hmm... I think it is not used, package.json has main, jsnext:main and module entries, I'm not certain which Cljs/Closure uses