solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

Invalid JavaScript produced when route data has null prototypes

Open viridia opened this issue 3 years ago • 2 comments

The graphql package generates objects with null prototypes. When these objects are returned from createServerData$, they get serialized as Object.assign(Object.create(null), { ...props... })). Unfortunately, it looks like the code generator is adding an extra right parens ')' after the call to Object.assign(), so this generates a syntax error in the browser.

This only affects the initial HTML; subsequent fetches work fine.

viridia avatar Nov 11 '22 08:11 viridia

I eventually worked around this problem by post-processing the object to covert all the objects in the response to have normal prototypes.

viridia avatar Nov 17 '22 19:11 viridia

Based on the Discord chat from a few weeks ago, I think Ryan might have added a fix for this but I am not sure.

viridia avatar Dec 05 '22 22:12 viridia

I exposed our SolidJS serializer so now we can change how stuff is serialized but I haven't wired it up.

ryansolid avatar Dec 21 '22 22:12 ryansolid

NVM.. I did fix this: https://github.com/ryansolid/dom-expressions/commit/23464e548436e0a59a2fba2113f3877ee2af7b4e

ryansolid avatar Dec 21 '22 22:12 ryansolid