Elderjs / elderjs

Elder.js is an opinionated static site generator and web framework for Svelte built with SEO in mind.
https://elderguide.com/tech/elderjs/
MIT License
2.12k stars 53 forks source link

1.6.5 Unexpected token l in JSON at position 2 #227

Closed timeshift92 closed 2 years ago

timeshift92 commented 2 years ago

I Have bug, after update elderjs version from 1.6.3 to 1.6.5

stack: 'SyntaxError: Unexpected token l in JSON at position 2\n at JSON.parse ()\n at Object.inlinePreprocessedSvelteComponent (C:\PROJECTS\Uztelecom\uztelecom\node_modules\@elderjs\elderjs\build\partialHydration\inlineSvelteComponent.js:18:89)\n at createReplacementString (C:\PROJECTS\Uztelecom\uztelecom\node_modules\@elderjs\elderjs\build\partialHydration\partialHydration.js:15:36)\n at C:\PROJECTS\Uztelecom\uztelecom\node_modules\@elderjs\elderjs\build\partialHydration\partialHydr…derjs\elderjs\build\partialHydration\partialHydration.js:22:28)\n at markup (C:\PROJECTS\Uztelecom\uztelecom\node_modules\@elderjs\elderjs\build\partialHydration\partialHydration.js:40:32)\n at process_markup (C:\PROJECTS\Uztelecom\uztelecom\node_modules\svelte\compiler.js:31608:30)\n at Object.preprocess (C:\PROJECTS\Uztelecom\uztelecom\node_modules\svelte\compiler.js:31638:37)\n at async C:\PROJECTS\Uztelecom\uztelecom\node_modules\@elderjs\elderjs\build\rollup\rollupPlugin.js:109:31'

s-kris commented 2 years ago

I had the same error when I tried to upgrade to the latest version: Elder.js error in transform. SyntaxError: Unexpected token l in JSON at position 2

Downgraded to version 1.4.0

apop880 commented 2 years ago

I believe this is the same issue I had in https://github.com/Elderjs/elderjs/issues/226.

Basically, if you're including a Svelte component with hydrate-options you probably need to wrap the keys in quotes. If that fixes it for you, let me know and I'll PR a change to the docs - I had first been waiting for either confirmation from @nickreese that that's the right fix or confirmation from someone else that they had the same issue and can fix it the same way I did. :-)