build-render converts a bundle AST produced by build-ast into a self-contained source string for either a native Oak bundle or a JavaScript bundle. It handles all AST node types and embeds the appropriate runtime preamble and Virtual FS initializer.
This module is part of oak build's internal code-generation pipeline and is not intended for direct use in application code.
buildRender := import('build-render')
{ renderOakBundle: renderOakBundle, renderJSBundle: renderJSBundle } := import('build-render')
Serializes a bundle AST node to Oak source code.
Parameters
bundleNode— the:blockbundle AST fromwrapBundle.vfsFiles— a map of virtual-FS paths to file contents; an empty map omits the VFS initializer.encodeJSON— function to encode a value as a JSON string (typicallyjson.encode).oakNativeRuntime— the native runtime preamble string (fromruntime-native).formatIdent— identifier formatter function (frombuild-ident).abort— called with an error message on unexpected AST node types.
Returns a string containing the complete native Oak bundle source.
source := renderOakBundle(bundleAst, {}, json.encode, OakNativeRuntime, formatIdent, abortFn)
writeFile('out.oak', source)
Serializes a bundle AST node to JavaScript source code.
Parameters
bundleNode— the:blockbundle AST fromwrapBundle.vfsFiles— a map of virtual-FS paths to file contents.encodeJSON— function to encode a value as a JSON string.oakJSRuntime— the JS runtime preamble string (fromruntime-js).formatIdent— identifier formatter withweb? = true.clone— thestd.clonefunction, used internally during rendering.
Returns a string containing the complete JavaScript bundle source.
source := renderJSBundle(bundleAst, {}, json.encode, OakJSRuntime, formatIdentWeb, std.clone)
writeFile('out.js', source)