@secondlayer/bundler
v0.5.3
Published
Compile a Secondlayer table definition into a deployable artifact.
Readme
@secondlayer/bundler
Bundles a Secondlayer subgraph definition into a single deployable artifact. It compiles a defineSubgraph(...) TypeScript module (and its imports) with esbuild, then extracts the subgraph's name, sources, schema, and handler code ready for deployment.
Used internally by @secondlayer/cli and @secondlayer/mcp when you run secondlayer subgraphs deploy.
Install
bun add @secondlayer/bundlerUsage
import { bundleSubgraphCode } from "@secondlayer/bundler";
const code = await Bun.file("subgraphs/my-contract.ts").text();
const bundle = await bundleSubgraphCode(code);
bundle.name; // subgraph name
bundle.sources; // event filters, keyed by source name
bundle.schema; // declared table schema
bundle.handlerCode; // bundled handler module (string)Bundles larger than SUBGRAPH_BUNDLE_MAX_BYTES (4 MB) throw BundleSizeError.
License
MIT
