Skip to content

Commit a34b167

Browse files
committed
Add documentation
1 parent 67c3fd4 commit a34b167

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ Unlike `VM`, `NodeVM` allows you to require modules in the same way that you wou
144144
* `require.context` - `host` (default) to require modules in the host and proxy them into the sandbox. `sandbox` to load, compile, and require modules in the sandbox. Except for `events`, built-in modules are always required in the host and proxied into the sandbox.
145145
* `require.import` - An array of modules to be loaded into NodeVM on start.
146146
* `require.resolve` - An additional lookup function in case a module wasn't found in one of the traditional node lookup paths.
147+
* `require.customRequire` - Use instead of the `require` function to load modules from the host.
148+
* `require.strict` - `false` to disable loading modules in strict mode (default: `true`).
147149
* `nesting` - **WARNING**: Allowing this is a security risk as scripts can create a NodeVM which can require any host module. `true` to enable VMs nesting (default: `false`).
148150
* `wrapper` - `commonjs` (default) to wrap script into CommonJS wrapper, `none` to retrieve value returned by the script.
149151
* `argv` - Array to be passed to `process.argv`.

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export interface VMRequire {
2424
resolve?: (moduleName: string, parentDirname: string) => string | undefined;
2525
/** Custom require to require host and built-in modules. */
2626
customRequire?: (id: string) => any;
27+
/** Load modules in strict mode. (default: true) */
28+
strict?: boolean;
2729
}
2830

2931
/**

lib/nodevm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class NodeVM extends VM {
184184
* @param {resolveCallback} [options.require.resolve] - An additional lookup function in case a module wasn't
185185
* found in one of the traditional node lookup paths.
186186
* @param {customRequire} [options.require.customRequire=require] - Custom require to require host and built-in modules.
187+
* @param {boolean} [option.require.strict=true] - Load required modules in strict mode.
187188
* @param {boolean} [options.nesting=false] -
188189
* <b>WARNING: Allowing this is a security risk as scripts can create a NodeVM which can require any host module.</b>
189190
* Allow nesting of VMs.

0 commit comments

Comments
 (0)