Generated types for all files are deleted and never repopulated when sync is run
Describe the bug
I believe the fix for #4973 introduced this bug because it uses rimraf and then write_if_changed to repopulate the cleared types directory. This means that in some cases when svelte-kit sync runs, the entire types directory is removed but no files get re-added because they have not changed.
Stopping the dev process and re-running seems to correctly restore the types (probably because the previous_contents Map referenced by write_if_changed is now cleared).
Reproduction
Have a file with generated types in .svelte-kit/types, run svelte-kit sync, see .svelte-kit/types disappear and not come back.
Logs
No response
System Info
System:
OS: macOS 12.3.1
CPU: (32) x64 Intel(R) Xeon(R) W-3245 CPU @ 3.20GHz
Memory: 35.00 GB / 96.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.1.0 - ~/.asdf/installs/nodejs/18.1.0/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.8.0 - ~/.asdf/plugins/nodejs/shims/npm
Browsers:
Chrome: 101.0.4951.64
Firefox: 90.0.2
Safari: 15.4
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.43
@sveltejs/kit: next => 1.0.0-next.338
svelte: ^3.44.0 => 3.48.0
Severity
annoyance
Additional Information
No response
Repro: https://github.com/tcc-sejohnson/test-sync-removing-types
Created the linked PR to fix. You were right about the cause! :)