evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a system that compiles MDX content on a server and executes it in a separate process, simulating a server-compile/client-execute architecture.
Create a Node.js application with two main components:
compiler.js)Create a module that:
executor.js)Create a module that:
index.js)Create a main entry point that:
Your solution should successfully handle the following MDX content:
export const title = "Hello World"
# Welcome
This is a **simple** MDX document.
<div className="custom">Custom JSX content</div>File: executor.test.js
Test that MDX content can be compiled and then executed:
// Should compile MDX to executable format
const mdxSource = '# Hello\n\nThis is **MDX**.';
const compiled = await compileForExecution(mdxSource);
// Should execute the compiled code
const result = await executeCompiled(compiled);
// Should have a default export (the component)
assert(result.default !== undefined);
assert(typeof result.default === 'function');File: executor.test.js
Test that synchronous compilation and execution works:
const mdxSource = 'export const value = 42\n\n# Test';
const compiled = compileForExecutionSync(mdxSource);
const result = executeCompiledSync(compiled);
// Should preserve named exports
assert(result.value === 42);File: executor.test.js
Test that named exports from MDX are accessible after execution:
const mdxSource = 'export const author = "Alice"\n\n# Article';
const compiled = await compileForExecution(mdxSource);
const result = await executeCompiled(compiled);
// Named exports should be accessible
assert(result.author === "Alice");Provides MDX compilation and runtime execution capabilities.
Provides JSX runtime support required for MDX execution.
evaluate or evaluateSync functions - the goal is to separate compilation from executioncompiler.js: Compilation serviceexecutor.js: Execution serviceindex.js: Integration exampleexecutor.test.js: Test suite