TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Crane04/esem/llms.txt
Use this file to discover all available pages before exploring further.
esem-bridge/loader module is a Node.js ESM loader hook that uses the --experimental-loader API to intercept any import specifier beginning with python:. At module resolution time, the hook converts that specifier into a synthetic ES module whose default and named mod exports are live JavaScript proxies backed by the Python bridge. From the perspective of the rest of your code, the import looks and behaves like any other ES module.
Enabling the Loader
Pass the loader to Node.js with the--experimental-loader flag:
esem CLI, which applies this flag automatically:
Import Syntax
Once the loader is active, you can import Python modules using thepython: prefix. Both relative file paths and installed package names are supported:
default export is the module proxy. You can also import the named mod export, which holds the identical proxy:
Loader Hooks
The loader implements two standard Node.js ESM hook functions.resolve(specifier, context, nextResolve)
Intercepts import specifiers. If the specifier starts with python:, the loader strips the prefix, URL-encodes the remaining module path, and returns a synthetic esem:// URL that short-circuits the normal Node.js module resolver:
python: is passed through to the default resolver unchanged.
load(url, context, nextLoad)
Intercepts URLs that begin with esem://. It decodes the module path, then synthesizes an ES module source string on the fly:
ensureWorker() starts the Python subprocess if it is not already running. createModuleProxy() sends a load RPC message to the worker and builds a JavaScript proxy object for each export the Python module exposes.
The
esem run CLI uses this exact loader under the hood — it simply passes
--experimental-loader=<path to loader.js> to the Node.js child process it
spawns. There is no difference between using the CLI and enabling the loader
flag manually.