Skip to content

Commit 4a66102

Browse files
committed
doc: address Joyee's documentation review feedback
- Change "Instead of" to "In addition to" for node:sea API since both the sea API and VFS work together - Replace duplicated supported ops list in SEA docs with cross-reference to VFS documentation - Move useVfs precondition to Loading modules section header - Clarify code caching limitation is due to incomplete implementation, not a technical impossibility
1 parent 43ed8d4 commit 4a66102

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

doc/api/single-executable-applications.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ See documentation of the [`sea.getAsset()`][], [`sea.getAssetAsBlob()`][],
180180

181181
> Stability: 1 - Experimental
182182
183-
Instead of using the `node:sea` API to access individual assets, you can use
183+
In addition to using the `node:sea` API to access individual assets, you can use
184184
the Virtual File System (VFS) to access bundled assets through standard `fs`
185185
APIs. To enable VFS, set `"useVfs": true` in the SEA configuration. When
186186
enabled, the VFS is automatically initialized and mounted at `/sea`. All
@@ -205,42 +205,37 @@ if (fs.existsSync('/sea/optional.json')) {
205205
}
206206
```
207207

208-
The VFS supports the following `fs` operations on bundled assets:
209-
210-
* `readFileSync()` / `readFile()` / `promises.readFile()`
211-
* `statSync()` / `stat()` / `promises.stat()`
212-
* `lstatSync()` / `lstat()` / `promises.lstat()`
213-
* `readdirSync()` / `readdir()` / `promises.readdir()`
214-
* `existsSync()`
215-
* `realpathSync()` / `realpath()` / `promises.realpath()`
216-
* `accessSync()` / `access()` / `promises.access()`
217-
* `openSync()` / `open()` - for reading
218-
* `createReadStream()`
208+
The VFS supports all common `fs` operations for reading files and directories.
209+
Since the SEA VFS is read-only, write operations are not supported. See the
210+
[VFS documentation][] for the full list of supported and unsupported operations.
219211

220212
#### Loading modules from VFS in SEA
221213

222-
You can use `require()` directly with absolute VFS paths:
223-
224-
```cjs
225-
// Require bundled modules directly
226-
const myModule = require('/sea/lib/mymodule.js');
227-
const utils = require('/sea/utils/helpers.js');
228-
```
229-
230214
When `useVfs` is enabled, `require()` in the injected main script uses the
231215
registered module hooks to load modules from the virtual file system. This
232216
supports both absolute VFS paths and relative requires (e.g.,
233-
`require('./helper.js')` from a VFS module).
217+
`require('./helper.js')` from a VFS module), as well as `node_modules` package
218+
lookups.
219+
220+
```cjs
221+
// Require bundled modules using relative paths
222+
const myModule = require('./lib/mymodule.js');
223+
const utils = require('./utils/helpers.js');
224+
225+
// Absolute VFS paths also work
226+
const config = require('/sea/config.json');
227+
```
234228

235229
When `useVfs` is enabled, `__filename` and `__dirname` in the injected main
236230
script reflect VFS paths (e.g., `/sea/main.js`) instead of
237231
[`process.execPath`][].
238232

239233
#### Code caching limitations
240234

241-
The `useCodeCache` option in the SEA configuration does not apply to modules
242-
loaded from the VFS. Consider bundling the application to enable code caching
243-
and do not rely on module loading in VFS.
235+
The `useCodeCache` option in the SEA configuration does not currently apply to
236+
modules loaded from the VFS. This is a current limitation due to incomplete
237+
implementation, not a technical impossibility. Consider bundling the application
238+
to enable code caching and do not rely on module loading in VFS.
244239

245240
#### Native addon limitations
246241

@@ -721,6 +716,7 @@ to help us document them.
721716
[Mach-O]: https://en.wikipedia.org/wiki/Mach-O
722717
[PE]: https://en.wikipedia.org/wiki/Portable_Executable
723718
[Using native addons in the injected main script]: #using-native-addons-in-the-injected-main-script
719+
[VFS documentation]: vfs.md
724720
[Windows SDK]: https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
725721
[`process.execPath`]: process.md#processexecpath
726722
[`require()`]: modules.md#requireid

doc/api/vfs.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ files exist only in memory.
164164
### Code caching in SEA
165165

166166
When using VFS with Single Executable Applications, the `useCodeCache` option
167-
in the SEA configuration does not apply to modules loaded from the VFS.
168-
Consider bundling the application to enable code caching and do not rely on
169-
module loading in VFS.
167+
in the SEA configuration does not currently apply to modules loaded from the
168+
VFS. This is a current limitation due to incomplete implementation, not a
169+
technical impossibility. Consider bundling the application to enable code
170+
caching and do not rely on module loading in VFS.
170171

171172
## `vfs.create([provider][, options])`
172173

0 commit comments

Comments
 (0)