@@ -180,32 +180,23 @@ See documentation of the [`sea.getAsset()`][], [`sea.getAssetAsBlob()`][],
180180
181181Instead of using the ` node:sea ` API to access individual assets, you can use
182182the Virtual File System (VFS) to access bundled assets through standard ` fs `
183- APIs. The VFS automatically populates itself with all assets defined in the
184- SEA configuration and mounts them at a virtual path (default: ` /sea ` ).
185-
186- To use the VFS with SEA:
183+ APIs. When running as a Single Executable Application, the VFS is automatically
184+ initialized and mounted at ` /sea ` . All assets defined in the SEA configuration
185+ are accessible through this virtual path.
187186
188187``` cjs
189188const fs = require (' node:fs' );
190- const sea = require (' node:sea' );
191-
192- // Get the SEA VFS (returns null if not running as SEA)
193- const vfs = sea .getVfs ();
194189
195- if (vfs) {
196- // Now you can use standard fs APIs to read bundled assets
197- const rawConfig = fs .readFileSync (' /sea/config.json' , ' utf8' );
198- const data = fs .readFileSync (' /sea/data/file.txt' );
199-
200- cons config = JSON .parse (rawconfig);
190+ // Assets are automatically available at /sea when running as SEA
191+ const config = JSON .parse (fs .readFileSync (' /sea/config.json' , ' utf8' ));
192+ const data = fs .readFileSync (' /sea/data/file.txt' );
201193
202- // Directory operations work too
203- const files = fs .readdirSync (' /sea/assets' );
194+ // Directory operations work too
195+ const files = fs .readdirSync (' /sea/assets' );
204196
205- // Check if a bundled file exists
206- if (fs .existsSync (' /sea/optional.json' )) {
207- // ...
208- }
197+ // Check if a bundled file exists
198+ if (fs .existsSync (' /sea/optional.json' )) {
199+ // ...
209200}
210201```
211202
@@ -223,41 +214,16 @@ The VFS supports the following `fs` operations on bundled assets:
223214
224215#### Loading modules from VFS in SEA
225216
226- Once the VFS is initialized with ` sea.getVfs() ` , you can use ` require() ` directly
227- with absolute VFS paths:
217+ You can use ` require() ` directly with absolute VFS paths:
228218
229219``` cjs
230- const sea = require (' node:sea' );
231-
232- // Initialize VFS - this must be called first
233- sea .getVfs ();
234-
235- // Now you can require bundled modules directly
220+ // Require bundled modules directly
236221const myModule = require (' /sea/lib/mymodule.js' );
237222const utils = require (' /sea/utils/helpers.js' );
238223```
239224
240225The SEA's ` require() ` function automatically detects VFS paths (paths starting
241- with the VFS mount point, e.g., ` /sea/ ` ) and loads modules from the virtual
242- file system.
243-
244- #### Custom mount prefix
245-
246- By default, the VFS is mounted at ` /sea ` . You can specify a custom prefix
247- when initializing the VFS:
248-
249- ``` cjs
250- const fs = require (' node:fs' );
251- const sea = require (' node:sea' );
252-
253- const vfs = sea .getSeaVfs ({ prefix: ' /app' });
254-
255- // Assets are now accessible under /app
256- const config = fs .readFileSync (' /app/config.json' , ' utf8' );
257- ```
258-
259- Note: ` sea.getVfs() ` returns a singleton. The ` prefix ` option is only used
260- on the first call; subsequent calls return the same cached instance.
226+ with ` /sea/ ` ) and loads modules from the virtual file system.
261227
262228### Startup snapshot support
263229
0 commit comments