UNPKG

isolated-function

Version:

Run JavaScript from AI agents, plugins, and workflows in a separate Node.js process with strict safety limits.

30 lines (26 loc) 567 B
'use strict' const esbuild = require('esbuild') const MINIFY = (() => { return process.env.ISOLATED_FUNCTIONS_MINIFY === 'false' ? {} : { minifyWhitespace: true, minifyIdentifiers: false, minifySyntax: true } })() module.exports = ({ content, cwd, nodePaths = [] }) => esbuild.build({ stdin: { contents: content, resolveDir: cwd, sourcefile: 'index.js' }, bundle: true, write: false, platform: 'node', legalComments: 'eof', target: 'node24', nodePaths, ...MINIFY })