draw2d icon indicating copy to clipboard operation
draw2d copied to clipboard

Using the library with require.

Open shaielc opened this issue 4 years ago • 2 comments

Just saw this : https://github.com/freegroup/draw2d/issues/97#issuecomment-609397867

And wanted to know: A. What is causing this issue? B. Is there a plan to change that in the future?

shaielc avatar Apr 06 '20 15:04 shaielc

the reason for that is, that I must create JS Objects from a string like "draw2d.shape.basic.Rectangle" during the loading of a JSON file. For that reason the draw2d must be available i the global space and not inside any protected area like it is if I use require or import.

https://github.com/freegroup/draw2d/blob/master/src/io/json/Reader.js#L146

It would be fine to change this....but I have no idea how to deal with it.

freegroup avatar Apr 06 '20 18:04 freegroup

Seems like requiring as draw2d should work though.

besides there should be a better solution than eval. i'll look into it.

EDIT: found a solution using object-resolve-path submitting a pull request

EDIT: https://github.com/freegroup/draw2d/pull/99

shaielc avatar Apr 07 '20 10:04 shaielc