Repository navigation
Conversation
Summary: Mockup for review discussion of meta#5493. Not for landing. - What: `pyrefly_wasm.js` gives the module one preopened directory, `/`, whose files live in JavaScript memory (`files.write`, `files.remove`). The module can only read it. A new `Workspace` (Rust in `lib.rs`, JavaScript class in `pyrefly_wasm.js`) checks a project under a root in that filesystem with ordinary `ModulePath::filesystem` handles. The host edits a file by writing it with `files` and reporting the change with `Workspace.filesChanged`, which calls `Transaction::invalidate_events`, as a file watcher does. - Why: a WASI host that resolves imports through a filesystem can show unsaved buffers to importers without any change to `State`. The host owns the filesystem, so it writes the buffer there and keeps the saved contents itself. This avoids the source overrides of meta#5493 (override on every `ModulePath` variant, a stale `Stdlib` cache for bundled typeshed overrides, keys that silently miss). It also handles a new unsaved file, which an override cannot, because `invalidate_events` with `created` invalidates import resolution. - Cost: each edit counts as a disk change, so `State::generation` increases on each edit. - The `Playground` path does not change: it still uses memory paths and does not touch the filesystem. Differential Revision: D130311987
Contributor
|
@kinto0 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D130311987. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Mockup for review discussion of #5493. Not for landing.
pyrefly_wasm.jsgives the module one preopened directory,/, whose files live in JavaScript memory (files.write,files.remove). The module can only read it. A newWorkspace(Rust inlib.rs, JavaScript class inpyrefly_wasm.js) checks a project under a root in that filesystem with ordinaryModulePath::filesystemhandles. The host edits a file by writing it withfilesand reporting the change withWorkspace.filesChanged, which callsTransaction::invalidate_events, as a file watcher does.State. The host owns the filesystem, so it writes the buffer there and keeps the saved contents itself. This avoids the source overrides of state: load exact module-source overrides before normal sources #5493 (override on everyModulePathvariant, a staleStdlibcache for bundled typeshed overrides, keys that silently miss). It also handles a new unsaved file, which an override cannot, becauseinvalidate_eventswithcreatedinvalidates import resolution.State::generationincreases on each edit.Playgroundpath does not change: it still uses memory paths and does not touch the filesystem.Differential Revision: D130311987