spring-projects/spring-flo

flo not being set on joint.shapes

acrisci opened this issue · 6 comments

Hi,

I am having a strange issue on one of my environments. It seems to work correctly on my development machine but not my CI machine but I'm not sure why.

My renderer implementation is nearly identical to the demo. But it seems like in the renderer::createNode() function, the flo property is undefined on joint.shapes which naturally leads to this runtime error at this line in the browser:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'Node' of undefined

It seems that the flo member is set directly on the jointjs import. I wonder if it's possible that they are importing two different versions of the library.

Any tips on how to debug this further would be much appreciated.

Is it possible to make the code more resistant to this kind of error by refactoring the code so flo is not set directly on the import?

@acrisci i just ported that stuff as it was... I guess the best fix would be make JS 6 exports for node, link etc jointjs constructs, I'll try to complete this refactoring in the near future.
I wonder if you could try adding import '../shared/shapes' at the top of editor.component.ts. Curious it that would help you.

@acrisci i just ported that stuff as it was... I guess the best fix would be make JS 6 exports for node, link etc jointjs constructs, I'll try to complete this refactoring in the near future.
I wonder if you could try adding import '../shared/shapes' at the top of editor.component.ts. Curious it that would help you.

So looking at the code in the chrome sources tab, it looks like on my build machine it imports jointjs like this:

/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_jointjs__ = __webpack_require__("../../../../jointjs/dist/joint.min.js");

And on my CI machine it imports like this:

/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_jointjs__ = __webpack_require__("../../../../spring-flo/node_modules/jointjs/dist/joint.min.js");

But only in the vendor code. In the main code, it does the first import.

@BoykoAlex I am available to do the refactoring now if you would like.

@acrisci Cool :-) If you have time for it now, please feel free to submit a PR. I won't be able to merge it instantly though, because I'd have to adopt our client app for it, but it will obviously be rather quick (few hours to a day time)