Skip to content

Commit

Permalink
⚡ IMPROVE: perf (by generating only when it's needed) (#745)
Browse files Browse the repository at this point in the history
* ⚡ IMPROVE: perf (by generating only when it's needed)

* ✏️ UPDATE: changeset

* Fix typo ;)
  • Loading branch information
jycouet authored Sep 17, 2024
1 parent 0b91638 commit a3d166d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-horses-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-plugin-kit-routes': patch
---

Doesn't generate when +page.svelte is saved (only create or delete)
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body:
- annoyance
- serious, but I can work around it
- blocking an upgrade
- blocking all usage of Houdini
- blocking all usage of KitQL
validations:
required: true

Expand Down
19 changes: 14 additions & 5 deletions packages/vite-plugin-kit-routes/src/lib/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ ${objTypes

// report things
if (shouldLog('post_update_run', options)) {
child.stdout.on('data', (data) => {
child.stderr.on('data', (data) => {
if (data.toString()) {
log.info(data.toString())
}
Expand All @@ -1006,7 +1006,7 @@ ${objTypes

// report errors
if (shouldLog('errors', options)) {
child.stderr.on('data', (data) => {
child.stderr.on('error', (data) => {
const msg = data.toString().replace(/\n$/, '')
if (msg.includes('DEP0040') && msg.includes('punycode')) {
// silent error
Expand Down Expand Up @@ -1046,7 +1046,6 @@ function theEnd(
log.success(`${yellow(options.generated_file_path)} updated`)
}
}

if (atStart && shouldLog('stats', options)) {
let version = ''
try {
Expand Down Expand Up @@ -1127,9 +1126,19 @@ export function kitRoutes<T extends RouteMappings = RouteMappings>(
// Run the thing when any change in a +page.svelte (add, remove, ...)
watchAndRun([
{
name: 'kit-routes-watch',
name: 'kit-routes-watch-svelte-files',
logs: [],
watchKind: ['add', 'unlink'],
watch: ['**/+page.svelte'],
run: async () => {
await run(false, options)
},
},

{
name: 'kit-routes-watch-server-files',
logs: [],
watch: ['**/+page.svelte', '**/+page.server.ts', '**/+server.ts'],
watch: ['**/+page.server.ts', '**/+server.ts'],
run: async () => {
await run(false, options)
},
Expand Down

0 comments on commit a3d166d

Please sign in to comment.