withConfigSandbox
withConfigSandbox<
R>(options,run):Promise<R>
Defined in: cli/datapad/src/with-config-sandbox/with-config-sandbox.ts:27
Runs run with a throwaway directory prepared for
loadConfigFromContent’s dir, and removes it afterwards (also when
run throws).
The directory is made for a TS/JS config that imports packages:
node_modulesis a symlink tooptions.nodeModules, so those imports resolve as if the config sat next to that directory.- A
package.jsonof{"type":"module"}is written into it. Node decides whether a.ts/.jsfile is ESM or CommonJS from the nearest ancestorpackage.json’stype, defaulting to CommonJS — andtsx’s loader, correctly honouring that, would thenrequire()a pure-ESM dependency such as@theholocron/cli’sdist/index.mjs, which Node rejects outright (“require() of ES Module … not supported”).
The directory lives under the OS temp dir by default rather than inside any
package: read-only deployments (Vercel’s Node.js Functions ship the bundle
read-only under /var/task) can’t create a directory there.
Type Parameters
Section titled “Type Parameters”R
Parameters
Section titled “Parameters”options
Section titled “options”(dir) => Promise<R>
Returns
Section titled “Returns”Promise<R>