Skip to content

feat(wasm): expose MemoryFileSystem via WASM API #6428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 30, 2025

Conversation

siketyan
Copy link
Member

Summary

Added MemoryFileSystem to the WASM API.
Now we can access the memory filesystem from outside, insert or remove files.

As a bonus, GritQL plugins are now supported to be called on WASM builds.

Test Plan

Manually tested with playground

@siketyan siketyan requested review from a team June 19, 2025 17:55
@siketyan siketyan self-assigned this Jun 19, 2025
@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core A-Project Area: project A-LSP Area: language server protocol L-Grit Language: GritQL labels Jun 19, 2025
@siketyan siketyan force-pushed the feat/wasm-filesystem branch from ae191aa to fd626c3 Compare June 19, 2025 17:56
Copy link

codspeed-hq bot commented Jun 19, 2025

CodSpeed Performance Report

Merging #6428 will not alter performance

Comparing siketyan:feat/wasm-filesystem (3b59955) with main (09ba0ab)

Summary

✅ 115 untouched benchmarks

@siketyan siketyan marked this pull request as draft June 19, 2025 18:23
@siketyan siketyan force-pushed the feat/wasm-filesystem branch from fd626c3 to 284db91 Compare June 19, 2025 18:25
let base_dir = if cfg!(target_family = "wasm") {
PathBuf::from("/")
} else {
std::env::current_dir()?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::env::current_dir() was called inside Absolutize::absolutize_from implicity and caused "not supported on this platform" error.

@siketyan siketyan force-pushed the feat/wasm-filesystem branch 2 times, most recently from eebdc18 to 8688a0f Compare June 19, 2025 18:31
@siketyan siketyan closed this Jun 19, 2025
@siketyan siketyan reopened this Jun 19, 2025
@siketyan siketyan force-pushed the feat/wasm-filesystem branch from 8688a0f to 7e251b5 Compare June 21, 2025 05:55
Copy link

changeset-bot bot commented Jun 21, 2025

🦋 Changeset detected

Latest commit: b9f403f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@siketyan siketyan force-pushed the feat/wasm-filesystem branch from 7e251b5 to 42ce884 Compare June 21, 2025 07:34
@siketyan siketyan marked this pull request as ready for review June 27, 2025 16:22
@@ -97,7 +97,7 @@ impl MemoryFileSystem {
}

/// Create or update a file in the filesystem
pub fn insert(&mut self, path: Utf8PathBuf, content: impl Into<Vec<u8>>) {
pub fn insert(&self, path: Utf8PathBuf, content: impl Into<Vec<u8>>) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed excess mutability from here and the diff has many of removing mut keywords 😢

@siketyan siketyan force-pushed the feat/wasm-filesystem branch from 13408f9 to ecada68 Compare June 27, 2025 16:26
Comment on lines +47 to +50
#[wasm_bindgen(js_name = remove)]
pub fn remove(&self, path: &str) {
self.inner.remove(Utf8Path::new(path));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also export an "update" function? Genuinely asking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no, we can use insert to update a file

@siketyan siketyan merged commit 4b501d3 into biomejs:main Jun 30, 2025
28 checks passed
@github-actions github-actions bot mentioned this pull request Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Core Area: core A-LSP Area: language server protocol A-Project Area: project L-Grit Language: GritQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy