Skip to content

Commit

Permalink
fix: workaround for Svelte SSR generation
Browse files Browse the repository at this point in the history
  • Loading branch information
fbasso authored and quentinderoubaix committed Feb 26, 2024
1 parent 3245b7c commit 043869b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion svelte/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
}
},
"dependencies": {
"@agnos-ui/core": ""
"@agnos-ui/core": "",
"esm-env": "^1.0.0"
},
"peerDependencies": {
"@amadeus-it-group/tansu": "*",
Expand Down
10 changes: 9 additions & 1 deletion svelte/headless/src/Slot.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script lang="ts">
import {BROWSER} from 'esm-env';
import type {SlotContent, SlotSvelteComponent} from './types';
import {isSvelteComponent} from './utils/widget';
import {useSvelteSlot} from './types';
import {isSvelteComponent} from './utils/widget';
type Props = $$Generic<object>; // eslint-disable-line no-undef
// cf https://github.com/ota-meshi/eslint-plugin-svelte/issues/348
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand All @@ -11,6 +12,13 @@
};
export let slotContent: SlotContent<Props> = null;
export let props: Props;
// Workaround for a svelte issue that prevents code generation for SSR/slot
// To be removed when https://github.com/sveltejs/svelte/issues/9137 is fixed
if (!BROWSER) {
// @ts-expect-error Setting the global variable `props`, which is not defined in the SSR Svelte-kit compilation
globalThis['props'] = props;
}
</script>

{#if slotContent === useSvelteSlot}
Expand Down

0 comments on commit 043869b

Please sign in to comment.