Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup gro_plugin_gen #504

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'},
},
};
Loading