Expand description
Module loading from disk, under a policy.
Scripts import other files via ES module syntax:
import { helper } from './helpers.js';
import data from './fixtures/users.js';An import path is resolved relative to the importing module’s
directory, or to the policy’s root for an inline script with no base,
and read from disk. Bare specifiers (import lodash from 'lodash')
are refused: there is no node_modules resolution here on purpose. A
program that needs one is bundled before it reaches this loader, and
native specifiers never reach it either (the registry’s loader is
chained ahead of this pair).
With ModulePolicy::jail on, a resolution that lands outside the
root – through .., an absolute path, or a symlink – is refused,
so a script confined to a directory cannot pull code from beyond it.
Structs§
- File
Loader - Reads a module the
FileResolverresolved. - File
Resolver - Resolves relative ES module specifiers to absolute paths.
- Module
Policy - Where relative imports resolve from, whether they may leave it, and which native modules exist at all.