Skip to content

Commit

Permalink
cleanup gro_plugin_gen (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn authored Oct 4, 2024
1 parent 65da5e4 commit 4e089c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-phones-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ryanatkn/gro': patch
---

cleanup `gro_plugin_gen`
13 changes: 0 additions & 13 deletions src/lib/gro_plugin_gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export const gro_plugin_gen = ({
root_dirs = [paths.source],
flush_debounce_delay = FLUSH_DEBOUNCE_DELAY,
}: Options = EMPTY_OBJECT): Plugin => {
let generating = false;
let regen = false;
let flushing_timeout: NodeJS.Timeout | undefined;
const queued_files: Set<string> = new Set();
const queue_gen = (gen_file_id: string) => {
Expand All @@ -41,20 +39,9 @@ export const gro_plugin_gen = ({
}
};
const flush_gen_queue = throttle(async () => {
// hacky way to avoid concurrent `gro gen` calls
if (generating) {
regen = true;
return;
}
generating = true;
const files = Array.from(queued_files);
queued_files.clear();
await gen(files);
generating = false;
if (regen) {
regen = false;
void flush_gen_queue();
}
}, flush_debounce_delay);
const gen = (files: string[] = []) => spawn_cli('gro', ['gen', ...files]);

Expand Down
2 changes: 1 addition & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default {
kit: {
adapter: adapter(),
paths: {relative: false}, // use root-absolute paths: https://kit.svelte.dev/docs/configuration#paths
alias: {$routes: 'src/routes', $fixtures: 'src/fixtures'},
alias: {$routes: 'src/routes'},
},
};

0 comments on commit 4e089c2

Please sign in to comment.