Skip to content

Can we make Document.svelte.js a general purpose tool, that can be used outside of Svelte too? #140

@michael

Description

@michael

I'd like to use new Document(schema, serialized_doc) from the migration script in Node. However Document.svelte.js requires Vite and the Svelte compiler in place.

To make Document available outside of the Svelte context, we have a few options:

  • Turn Document.svelte.js into Document.js (removing all svelte-specific code $state $derived etc.)
  • Provide a way to reliably run a "svelte script" (however, I tried vite-node and it has issues as it doesn't exactly replicate the environment of the sveltekit server)
  • Move everything into an API endpoint (/api/migrate), so we always stay in the sveltekit environment
  • Have migrations hooked up into the server boot process (like when you start the server that it runs migrations, this way we would also stay in the sveltekit environment, but it's a bit implicit, if something breaks you might be stuck)

Aside from our migration script, we may want to provide a toolchain for integration into other frameworks (especially just for displaying Svedit documents) and then a Sveltekit-agnostic Document.js would be amazing.

So here's a few ideas:

  • model a "document state POJO" that we can pass from outside to the Document constructor
  • OR create an interface AbstractDocument, that has two implementations: ReactiveDocument (for Svelte and the UI), and Document (for plain Node.js)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions