Commit 6689848
Add check for .env.local and module bindings generations to only write on changes (#3604)
# Description of Changes
The `spacetime dev` and `spacetime generate` commands always overwrite
the `.env.local` and `module_bindings` files, even if the contents are
identical. This can be a nuisance if your client is watching for changes
and reloading, as `spacetime dev` will modify both of those at different
times in the process.
This change will first read the contents of the files and see if a write
is necessary.
For writing `.env.local` as part of `spacetime dev`, the file contents
were already read so no real impact should exist.
For `module_bindings`, I've done some initial profiling with 181
generated typescript files and separately 161 rust files and noticed no
performance impact.
# API and ABI breaking changes
None
# Expected complexity level and risk
1
# Testing
I've ran this code on a project that generates 181 source files for
typescript and 161 for rust. It correctly writes files when changes have
been made and leaves the files unmodified if no changes are made.
For review testing, I would recommend running both with and without my
change on a much more complex project if it's available. I would think
not writing the contents of each file would mitigate the cost to read
most of the time, but perhaps in certain project makeup scenarios and
storage performance characteristics, this could possible be marginally
slower sometimes, though I have not observed that to be the case.
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>1 parent e30d503 commit 6689848
2 files changed
+7
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
326 | 327 | | |
327 | 328 | | |
328 | 329 | | |
| |||
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
346 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
347 | 350 | | |
348 | 351 | | |
349 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
204 | 206 | | |
205 | 207 | | |
206 | 208 | | |
| |||
0 commit comments