Skip to content

Commit

Permalink
docs: add documentation to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdvl committed Aug 12, 2024
1 parent d246d61 commit 65cfec4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/esbuild_plugins/svelte_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const name = "mononykus/svelte";
/** force wrapping the actual component in a synthetic one */
const ssr_island = "?ssr_island";

/** Wrapper component for islands to be hydrated, which serialises props. */
const OneClaw = (
{ path, name, module_src }: {
path: string;
Expand All @@ -33,6 +34,7 @@ const OneClaw = (

const SVELTE_IMPORTS = /(from|import) ['"](?:svelte)(\/?[\w\/-]*)['"]/g;

/** Convert `svelte/*` imports to `npm:[email protected]/*` */
const specifiers = (code: string) =>
code.replaceAll(SVELTE_IMPORTS, `$1 'npm:svelte@${VERSION}$2'`);

Expand Down Expand Up @@ -104,6 +106,7 @@ export const svelte_components = (
});

if (generate === "dom" && path.endsWith(".island.svelte")) {
/** Dynamic function to be inlined in the output. */
const hydrator = (name: string, Component: ComponentType) => {
try {
document.querySelectorAll(
Expand Down

0 comments on commit 65cfec4

Please sign in to comment.