Skip to content

feat(sophora-components): Alternative build setup / clientside-only rendering#343

Merged
sjockers merged 27 commits intomainfrom
feat/sophora-components-clientside-only
Apr 2, 2026
Merged

feat(sophora-components): Alternative build setup / clientside-only rendering#343
sjockers merged 27 commits intomainfrom
feat/sophora-components-clientside-only

Conversation

@sjockers
Copy link
Copy Markdown
Contributor

@sjockers sjockers commented Mar 31, 2026

Use plain Svelte and Vite for rendering generic components in Sophora (Datawrapper switcher, highlight cards) without SvelteKit. Rendering is client-side only – which is fine, because there is no meaningful server-side rendering anyways.

Production demo

Pro:

  • Direct control of how embeds are rendered on the page (also fixes a long-standing issue that prevents rendering multiple embeds on the same page)
  • Fast builds, small bundles
  • No problem with mounting code running multiple times: Mounting code for components is just run once per instance, even when multiple instances of an embed are included. This is due to <script type="module"> only being loaded and evaluated once per document, even when referenced multiple times.

Con:

  • Some HTML boilerplate needed (could be reduced by creating a template file)
  • Minor shimming needed because @swr-data-lab/components builds upon some SvelteKit-only environment variables

Closes #330

@sjockers sjockers requested a review from awesomephant March 31, 2026 15:54
@sjockers
Copy link
Copy Markdown
Contributor Author

sjockers commented Apr 1, 2026

@sjockers sjockers force-pushed the feat/sophora-components-clientside-only branch from 243ef87 to 1ee7fcc Compare April 1, 2026 19:59
@sjockers sjockers force-pushed the feat/sophora-components-clientside-only branch from b84d7b4 to b404424 Compare April 1, 2026 22:03
@sjockers sjockers force-pushed the feat/sophora-components-clientside-only branch from 6ccf03f to 2e02957 Compare April 1, 2026 22:39
@sjockers sjockers force-pushed the feat/sophora-components-clientside-only branch from a0694d5 to 261feaa Compare April 2, 2026 07:54
@sjockers sjockers force-pushed the feat/sophora-components-clientside-only branch 4 times, most recently from c769791 to 144e8a8 Compare April 2, 2026 10:18
@sjockers sjockers force-pushed the feat/sophora-components-clientside-only branch from 144e8a8 to cb8ec47 Compare April 2, 2026 10:23
@sjockers sjockers force-pushed the feat/sophora-components-clientside-only branch from cb8ec47 to 4a41d66 Compare April 2, 2026 10:27
Copy link
Copy Markdown
Collaborator

@awesomephant awesomephant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm following offline discussion and pending changes below

@sjockers sjockers merged commit c164ff0 into main Apr 2, 2026
1 check passed
@sjockers sjockers deleted the feat/sophora-components-clientside-only branch April 2, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatawrapperSwitcher does not work with multiple embeds on one page

2 participants