Title: [Feature Request]: Standardized Abstract File System Interface (`this.fs`) · Issue #593 · unjs/unplugin · GitHub
Open Graph Title: [Feature Request]: Standardized Abstract File System Interface (`this.fs`) · Issue #593 · unjs/unplugin
X Title: [Feature Request]: Standardized Abstract File System Interface (`this.fs`) · Issue #593 · unjs/unplugin
Description: Describe the feature Currently, many modern bundlers can operate in non-Node.js environments (e.g., Browsers, Edge Workers, or WASM-based runtimes). Examples include Rollup, Rolldown (through WASM), Rspack (through WASM) and Vite (v7-, c...
Open Graph Description: Describe the feature Currently, many modern bundlers can operate in non-Node.js environments (e.g., Browsers, Edge Workers, or WASM-based runtimes). Examples include Rollup, Rolldown (through WASM)...
X Description: Describe the feature Currently, many modern bundlers can operate in non-Node.js environments (e.g., Browsers, Edge Workers, or WASM-based runtimes). Examples include Rollup, Rolldown (through WASM)...
Opengraph URL: https://github.com/unjs/unplugin/issues/593
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feature Request]: Standardized Abstract File System Interface (`this.fs`)","articleBody":"### Describe the feature\n\nCurrently, many modern bundlers can operate in non-Node.js environments (e.g., Browsers, Edge Workers, or WASM-based runtimes). Examples include [Rollup](https://rollupjs.org/browser/), Rolldown (through [WASM](https://www.npmjs.com/package/@rolldown)), Rspack (through [WASM](https://rspack.rs/api/javascript-api/browser)) and Vite (v7-, [community](https://divriots.com/blog/vite-in-the-browser)).\n\nIn these environments, the standard `node:fs` module is unavailable. This creates a significant hurdle for plugins that need to access the file system (e.g., reading `tsconfig.json`, `package.json`, or checking file existence within the `load` or `transform` hooks). Since `unplugin` aims to provide a unified interface, it would be highly beneficial to abstract file system access to ensure plugins remain environment-agnostic.\n\n### Current Landscape\n\nSeveral major bundlers already provide an abstract FS interface through the plugin context:\n\n| Bundler | Abstract FS Support | Notes |\n| :--- | :--- | :--- |\n| **Rollup** | ✅ [`this.fs`](https://rollupjs.org/plugin-development/#this-fs) | [User-configurable](https://rollupjs.org/browser/#using-an-in-memory-file-system) via `fs` option |\n| **Rolldown** | ✅ [`this.fs`](https://rolldown.rs/reference/Interface.PluginContext#fs) | FS is configurable via an exposed `memfs` instance in browser build |\n| **Vite** | ✅ Supported | [Compatible](https://vite.dev/guide/api-plugin#rolldown-plugin-compatibility) with Rollup/Rolldown context |\n| **Webpack** | ✅ [`this.fs`](https://webpack.js.org/api/loaders/#thisfs) | [User-configurable](https://webpack.js.org/api/node/#custom-file-systems) via `inputFileSystem` |\n| **Rspack** | ✅ [`this.fs`](https://rspack.rs/api/loader-api/context#thisfs) | [Experimental](https://rspack.rs/config/experiments#experimentsuseinputfilesystem) support via `inputFileSystem` |\n| **Farm** | ❌ No | |\n| **Esbuild** | ❌ No | WASM build exists, but no native FS abstraction for plugins |\n| **Bun** | ❌ No | |\n\n### Proposed Solution\n\nI propose that `unplugin` introduces a standardized `fs` object to the plugin context (e.g., `this.fs` or via the hook arguments).\n\nThis interface should ideally mimic a subset of the `node:fs` API (like `readFile`, `stat`, `lstat`) that the underlying bundler provides. For bundlers that do not yet support an abstract FS, `unplugin` could provide a transparent fallback to `node:fs` when running in Node.js.\n\n### Benefit\n\n- **Portability**: Plugins will work out-of-the-box in Web-based IDEs (like StackBlitz), WASM-powered tools, and standard Node.js environments.\n- **Consistency**: Developers won't need to write conditional logic to check if they are in a Node.js environment before performing simple I/O tasks.\n\n\n### Additional information\n\n- [ ] Would you be willing to help implement this feature?","author":{"url":"https://github.com/guyutongxue","@type":"Person","name":"guyutongxue"},"datePublished":"2026-04-11T07:56:12Z","url":"https://github.com/unjs/unplugin/issues/593"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:02b7b053-e12c-8ed2-fc63-fae784d79ca3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A16C:1AEC58:D15FA2:1184A8B:6B0052AF |
| html-safe-nonce | 23250223e308c30d5eaed3cff42cc9e1a08888ed53bb4899d37e946fb84b50d5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTZDOjFBRUM1ODpEMTVGQTI6MTE4NEE4Qjo2QjAwNTJBRiIsInZpc2l0b3JfaWQiOiI1NDAwNzQ3MTU5NzU2NzU1NjMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c6dbd1a7f4af4d935d530a4b144189c40fa498833dc027176488fd890068d58a |
| hovercard-subject-tag | issue:4243649756 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/unjs/unplugin/593/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5ff3b95fd756a94c056e0eae7b3f3db8146cd28ebed716d25f9b543e8f93d04c/unjs/unplugin/issues/593 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5ff3b95fd756a94c056e0eae7b3f3db8146cd28ebed716d25f9b543e8f93d04c/unjs/unplugin/issues/593 |
| og:image:alt | Describe the feature Currently, many modern bundlers can operate in non-Node.js environments (e.g., Browsers, Edge Workers, or WASM-based runtimes). Examples include Rollup, Rolldown (through WASM)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | guyutongxue |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/unjs/unplugin git https://github.com/unjs/unplugin.git |
| octolytics-dimension-user_id | 80154025 |
| octolytics-dimension-user_login | unjs |
| octolytics-dimension-repository_id | 385261169 |
| octolytics-dimension-repository_nwo | unjs/unplugin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 385261169 |
| octolytics-dimension-repository_network_root_nwo | unjs/unplugin |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width