The current implementation of @neodx/vfs relies on granular change tracking, which works well in typical cases.
However, I've found that this approach has significant limitations and lacks the potential for future growth.
For instance, the following scenarios are blocked:
Symbolic links support due to its chaining nature and our lack of it.
Cleaning up parent directories with future writes underneath them due to the lack of a steps concept.
Illustration of the real issue (from the docs)
Unfortunately, the following code will not work as expected:
async function reinitWorkingDir(vfs: Vfs) {
// 1. Cleanup working dir
await vfs.delete('.');
// 2. Write some initial files
await vfs.write('index.ts', `export const foo = 'bar';`);
}
Instead of the deletion of the working directory, our current implementation will "forget" about it because of child file writes.
We plan to fix this in the nearest future.
Currently, you can use the following workarounds:
// Variant A - scan and delete all files directly
async function reinitWorkingDir(vfs: Vfs) {
// 1. Delete all files and directories
await concurrently(await vfs.glob('**/*'), vfs.delete);
// 2. Write some initial files
await vfs.write('index.ts', `export const foo = 'bar';`);
}
// Variant B - use `apply` method right after the deletion
async function reinitWorkingDir(vfs: Vfs) {
// 1. Cleanup working dir
await vfs.delete('.');
await vfs.apply();
// 2. Write some initial files
await vfs.write('index.ts', `export const foo = 'bar';`);
}
The current implementation of
@neodx/vfs
relies on granular change tracking, which works well in typical cases. However, I've found that this approach has significant limitations and lacks the potential for future growth. For instance, the following scenarios are blocked:Illustration of the real issue (from the docs)
Unfortunately, the following code will not work as expected:
Instead of the deletion of the working directory, our current implementation will "forget" about it because of child file writes.
We plan to fix this in the nearest future. Currently, you can use the following workarounds: