@nodescript/core
Version:
Visual programming language for Browser and Node
29 lines • 766 B
JavaScript
import { CompilerJob } from './CompilerJob.js';
/**
* Compiles a graph into a ESM module containing `compute` function.
*
* A compiled graph can be computed as follows:
*
* ```
* const { compute } = await import(code);
* const ctx = new GraphEvalContext(...);
* await compute(params, ctx);
* ```
*/
export class GraphCompiler {
compileEsm(graphView, options = {}) {
const job = new CompilerJob(graphView, {
comments: false,
introspect: false,
emitNodeMap: false,
emitAll: false,
...options,
});
job.run();
return {
code: job.getEmittedCode(),
moduleSpec: job.getModuleSpec(),
};
}
}
//# sourceMappingURL=GraphCompiler.js.map