Skip to content

PromptScript API


Function: compile()

compile(files, entryPath, options): Promise\<CompileResult>

Defined in: browser-compiler/src/index.ts:134

Compile PromptScript files in the browser.

This is the main entry point for browser-based compilation. It creates a virtual file system from the provided files and runs the full compilation pipeline.

Parameters

files

Map of file paths to contents

Map\<string, string> | Record\<string, string>

entryPath

string

Path to the entry file (e.g., "project.prs")

options

CompileOptions = {}

Compilation options

Returns

Promise\<CompileResult>

Compilation result with outputs for all formatters

Example

const files = new Map([
  ['project.prs', '@meta { id: "demo" syntax: "1.0.0" }'],
]);

const result = await compile(files, 'project.prs');

if (result.success) {
  // Get Claude output
  const claudeOutput = result.outputs.get('CLAUDE.md');
  console.log(claudeOutput?.content);
}