repl-sdk

raw JSON →
1.6.0 verified Fri May 01 auth: no javascript

repl-sdk is a runtime compiler library for building fast, extensible REPLs and interactive playgrounds in the browser. Current stable version is 1.6.0, released in April 2026 as part of the ember-repl monorepo. It uses es-module-shims and supports JavaScript, React, Vue, Svelte, Ember, Glimdown, and Mermaid out of the box. Key differentiators: on-demand async compilation (only pay for what you compile for), nested language support within Markdown, and a flexible plugin API for adding custom compilers/renderers. Unlike alternatives like CodeSandbox or RunKit, repl-sdk is designed for embedding in web apps with minimal overhead and full control over the compilation pipeline.

error SyntaxError: Cannot use import statement outside a module
cause Using repl-sdk with a script tag or without type="module".
fix
Add type="module" to your script tag: <script type="module" src="app.js"></script>
error TypeError: replSdk.compile is not a function
cause Trying to call compile() on a non-initialized or promised sdk instance before resolution.
fix
Ensure createReplSdk() is awaited: const sdk = await createReplSdk();
error Module not found: Error: Can't resolve 'es-module-shims'
cause Missing es-module-shims peer dependency.
fix
Install es-module-shims: npm install es-module-shims
error TypeError: Cannot read properties of undefined (reading 'compile')
cause Calling compile on a misconfigured or missing sdk object.
fix
Verify that createReplSdk() resolves and assign it correctly.
breaking ESM-only: repl-sdk does not support CommonJS require(). Attempting to use require() will throw an error.
fix Use ES module import: import { ... } from 'repl-sdk'
breaking buildCompiler replaces Compiler class: The Compiler class export was removed in v1.4.0.
fix Use buildCompiler() instead: import { buildCompiler } from 'repl-sdk'
deprecated Nested language support may not work with all compiler combinations; the API for adding custom compilers is experimental.
fix Refer to documentation for adding custom compilers; expect possible breaking changes in minor versions.
gotcha Async compilation: compile() is async and returns a promise. Forgetting to await will lead to undefined behavior.
fix Always await the compilation result.
npm install repl-sdk
yarn add repl-sdk
pnpm add repl-sdk

Creates a REPL SDK instance, compiles a simple JavaScript expression, and logs the resulting code.

import { createReplSdk } from 'repl-sdk';

async function main() {
  const sdk = await createReplSdk();
  const output = await sdk.compile({
    code: `console.log('Hello, REPL!')`,
    language: 'javascript',
  });
  console.log(output.code);
}

main();