Skip to main content

Module modules

Module modules 

Source
Expand description

Module loader rooted at the script_root sandbox.

Scripts can import other JS files via ES module syntax:

import { helper } from './helpers.js';
import data from './fixtures/users.js';

All import paths are:

  1. Resolved relative to the importing module’s directory (or the sandbox root for inline scripts with no base).
  2. Validated against the PathSandbox just like fs.readFile — absolute paths, .. components, and symlink escapes are rejected.
  3. Loaded from disk via rquickjs’s built-in ScriptLoader (.js by default; .mjs also accepted).

Bare specifiers (e.g. import lodash from 'lodash') are rejected — there is no node_modules resolution on purpose, the sandbox is self-contained.

Structs§

SandboxLoader
Loader wrapper that accepts only paths the SandboxResolver produced.
SandboxResolver
Path-sanitising resolver that maps ES module specifiers to absolute paths inside the sandbox root.