Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/pngwn/svelte-worker
- Owner: pngwn
- Created: 2020-01-18T13:00:54.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-05T04:35:30.000Z (about 2 years ago)
- Last Synced: 2024-04-24T09:24:08.771Z (8 months ago)
- Language: JavaScript
- Size: 5.47 MB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
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.