Stephen Rich
Stephen Rich

Reputation: 63

GOJS VUE Vue cli -> Vite migration

I have a large vue 2 project that I am migrating from vue cli to vite and I am down to one dependency that is not working. I use gojs 2.1.51 in my project for many years now but when using the same code and data but using vite instead of vue cli I get

chunk-JHIOXJJP.js?v=d4bd4acf:2020 TypeError: Cannot set property layer of [object Object] which has only a getter
    at Aj (gojs.js?v=507ae5dd:12130:16)
    at Rl (gojs.js?v=507ae5dd:16930:13)
    at Pl (gojs.js?v=507ae5dd:16876:136)
    at Object.initGraph (bizStore.js:133:5)
    at VueComponent.mounted (valueNetwork.vue:165:1)
    at invokeWithErrorHandling (chunk-JHIOXJJP.js?v=d4bd4acf:1991:57)
    at callHook$1 (chunk-JHIOXJJP.js?v=d4bd4acf:2584:7)
    at Object.insert (chunk-JHIOXJJP.js?v=d4bd4acf:6226:11)
    at invokeInsertHook (chunk-JHIOXJJP.js?v=d4bd4acf:4441:31)
    at VueComponent.patch2 [as __patch__] (chunk-JHIOXJJP.js?v=d4bd4acf:4608:5)```

Anytime I try to add a groupTemplateMap
sd.diagram.groupTemplateMap.add(...)

If I switch back to using the vue cli instead of vite it works just fine.  I known there is not a lot of information here to help debug, but I just wanted to know if anyone else has run into issues with gojs and vite or got it to work.

Upvotes: 0

Views: 100

Answers (1)

Stephen Rich
Stephen Rich

Reputation: 63

The issue, if anyone else runs into this, turned out to be a combination of a bad GOJS argument and the way Vite compiles GOJS. Instead of getting a GOJS error, like we do with webpack, I got an exception deep in the minimized GOJS code. The GOJS team was great in helping debug this issue.

From the GOJS team: use method chaining instead of our $/go.GraphObject.make, it should be able to give you more sensible errors.

Upvotes: 0

Related Questions