Not Supported
Pure does not embed a JavaScript engine. Features that require dynamic code evaluation, runtime introspection of the JS engine, or direct V8/JavaScriptCore APIs do not work. This page lists specific unsupported features so you can plan accordingly.
Dynamic code evaluation
Section titled “Dynamic code evaluation”| Feature | Status | Alternative |
|---|---|---|
eval(code) | ❌ | Rewrite as a static function |
new Function(body) | ❌ | Rewrite as a static function |
import(expr) with a variable path | ❌ | Use static import or require() |
require(variable) | ❌ | Use static require('./path') |
vm.runInContext, vm.Script | ❌ | Not applicable |
The compiler resolves all imports statically at compile time. Dynamic import paths (e.g. require(process.env.PLUGIN)) cannot be resolved and will cause a compile error.
Dynamic import() with a constant string literal works:
// ✅ This works — the path is a constantconst mod = await import('./plugins/default.js');
// ❌ This does not work — the path is a variableconst mod = await import(`./plugins/${name}.js`);Node.js modules
Section titled “Node.js modules”| Module | Status |
|---|---|
node:vm | ❌ Requires a JS engine |
node:inspector | ❌ V8-specific |
node:repl | ❌ Requires a JS engine |
node:wasi | ❌ Not implemented |
node:domain | ❌ Deprecated; not implemented |
node:sqlite | ❌ Use better-sqlite3 instead |
Native add-ons
Section titled “Native add-ons”Third-party native add-ons that use the Node-API (N-API / node-addon-api) may work if the binary interface is compatible with Pure’s runtime. Many popular add-ons (e.g. better-sqlite3, sharp) work without modification. Add-ons that use internal V8 headers or Node internals will not work. See npm packages → Native add-ons for details.
Bun-specific APIs
Section titled “Bun-specific APIs”| API | Notes |
|---|---|
Bun.serve() | Use node:http or node:net instead |
Bun.file() | Use node:fs instead |
Bun.build() | Not applicable in Pure |
Bun.password.* | Use node:crypto (pbkdf2, scrypt, argon2 via npm package) |
Bun.sql | Use better-sqlite3 or another npm SQL client |
Bun.redis | Use the redis npm package |
import.meta.dir | Use __dirname |
import.meta.main | Use require.main === module |
__dirname and __filename
Section titled “__dirname and __filename”__dirname and __filename are set to the source file’s directory and path at compile time, not the directory of the running binary. This means:
// Returns the source directory, not where the binary lives at runtimeconsole.log(__dirname);To get the directory of the running binary at runtime, use:
import { dirname } from 'node:path';const binaryDir = dirname(process.execPath);Source maps and stack traces
Section titled “Source maps and stack traces”Stack traces in compiled binaries include source file names and line numbers from the original TypeScript/JavaScript source. The exact format differs from Node.js stack traces — libraries that parse stack trace strings (e.g. source-map-support) may not work correctly.
process.versions
Section titled “process.versions”process.versions.node is not set. Code that branches on process.versions.node may behave differently. Use process.versions.pure to detect a Pure runtime programmatically:
if (process.versions.pure) { // running in a Pure-compiled binary}TypeScript features that are limited
Section titled “TypeScript features that are limited”| Feature | Status |
|---|---|
experimentalDecorators | ✅ Supported (reflect-metadata partially supported) |
emitDecoratorMetadata | ⚠️ Partial — metadata is available but type information is limited |
allowArbitraryExtensions | ✅ Supported |