Skip to content

Commit

Permalink
fix: allow non-JSON ClientConfig (#166)
Browse files Browse the repository at this point in the history
Before this change, non-JSON ClientConfig like the `ResolveStudioUrl` you can
pass to `stega.studioUrl` would be serialised away. Now, we use
`serialize-javascript` to serialise the config into a superset of JSON that
preserves functions.
  • Loading branch information
christianhg authored May 21, 2024
1 parent bc74fd3 commit ed086ff
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
28 changes: 27 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/sanity-astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
},
"license": "MIT",
"devDependencies": {
"@types/serialize-javascript": "^5.0.4",
"astro": "^4.0.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.5",
"serialize-javascript": "^6.0.2",
"vite": "^4.5.0",
"vite-plugin-dts": "^3.7.0"
},
Expand All @@ -60,7 +62,7 @@
"sanity"
],
"dependencies": {
"@sanity/client": "^6.10.0",
"@sanity/client": "^6.4.12",
"@sanity/ui": "^1.8.3",
"sanity": "*"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/sanity-astro/src/vite-plugin-sanity-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ClientConfig } from "@sanity/client";
import type { DeepPartial } from "astro/dist/type-utils";
import serialize from "serialize-javascript";
import type { PluginOption } from "vite";

const virtualModuleId = "sanity:client";
Expand All @@ -18,7 +19,7 @@ export function vitePluginSanityClient(config: ClientConfig) {
return `
import { createClient } from "@sanity/client";
export const sanityClient = createClient(
${JSON.stringify(config)}
${serialize(config)}
);
`;
}
Expand Down

0 comments on commit ed086ff

Please sign in to comment.