Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pngwn/svelte-worker

POC preprocessor for svelte that auto-workerises reactive declarations.
https://github.com/pngwn/svelte-worker

Last synced: 2 months ago
JSON representation

POC preprocessor for svelte that auto-workerises reactive declarations.

Awesome Lists containing this project

README

        

# svelte-worker

> **POC: DO NOT USE THIS**

A svelte preprocessor that takes a function call that is assigned to a value in a reactive declaration and delegates that work to a web worker.

```svelte

import marked from "marked";

export function parse(source) {
if (!source) return;
return marked(source);
}

import { markdown } from "./markdown.js";

worker: text = parse(markdown);

```

This preprocessor only supports the simple assignment of a call expression (`x = some_func(val)`), it does not support any kind of boolean expression typical of reactive declarations (`x = y && some_func(val)`).

Any function that is delegated to a worker must be exported from the module script. The worker is inlined and not written to a separate file (`new Worker(URL.createObjectURL(new Blob([src])))`). The preprocessor bundles for now but could make use of `type: module` workers, support was only recently added to chrome so this may not be feasible for some time.

There are many questions.

The implementation is very rough.

Do not use this.