Skip to content

Node Compatibility Reference

Sloppy is not a Node runtime. Node compatibility is an explicit registry of supported, partial, stubbed, and unsupported builtins that resolve to Sloppy stdlib-backed shim modules.

The registry lets compatible pure-JavaScript packages build without giving packages unrestricted access to Node internals.

Status Values

StatusMeaning
supportedThe shim exposes the documented subset for that builtin and does not require a native Node API.
partialSome useful members are implemented through Sloppy Core or pure JS; missing members throw clear errors.
stubbedThe builtin is recognized for diagnostics but does not provide useful runtime behavior yet.
unsupportedImports fail at build time with SLOPPYC_E_UNSUPPORTED_NODE_BUILTIN.

Current Registry

SpecifierStatusBacking moduleNotes
node:path, pathsupportedsloppy/node/pathPOSIX-style path helpers plus win32/posix helper objects.
node:events, eventssupportedsloppy/node/eventsBasic EventEmitter methods.
node:url, urlsupportedsloppy/node/urlRe-exports URL and URLSearchParams when the JS environment provides them.
node:querystring, querystringsupportedsloppy/node/querystringBasic parse and stringify.
node:buffer, bufferpartialsloppy/node/bufferBuffer.from, Buffer.alloc, zero-filled allocUnsafe, isBuffer, isEncoding, byteLength, concat, compare, equals, slice/subarray, write, basic unsigned integer reads/writes, and UTF-8/hex/base64/base64url conversion. No full Node buffer identity.
node:console, consolepartialsloppy/node/consoleReuses the Sloppy program console object where present.
node:constants, constantspartialsloppy/node/constantsSmall file-mode constants used by pure-JS feature detection.
node:util, utilpartialsloppy/node/utilMinimal inspect, format, promisify, callbackify, inherits, and type helpers.
node:timers, timerspartialsloppy/node/timersMaps to available global timers where present; missing timer globals fail clearly.
node:fs, fspartialsloppy/node/fsCallback helpers and promises backed by sloppy/fs. The sync subset (readFileSync, existsSync, statSync) consults the sealed bundled asset map and throws SLOPPY_E_NODE_SYNC_FS_UNSEALED for paths outside that policy; watchers and arbitrary sync filesystem APIs are not implemented.
node:fs/promises, fs/promisespartialsloppy/node/fs/promisesreadFile, writeFile, appendFile, copyFile, rename, stat, mkdir, readdir, rm, unlink, access, readlink, and symlink where Sloppy filesystem policy allows them. lstat, mkdtemp, and realpath throw explicit unsupported errors until matching runtime primitives exist.
node:os, ospartialsloppy/node/osMinimal platform/environment helpers backed by sloppy/os where possible.
node:process, processpartialsloppy/node/processplatform, arch, overlay-writable env, cwd(), argv, nextTick, Sloppy version/versions, exitCode, monotonic hrtime/uptime, EventEmitter-style on/addListener/removeListener/emit, browser: false, and minimal stdio objects.
node:crypto, cryptopartialsloppy/node/cryptorandomBytes, randomUUID, SHA-2 createHash, SHA-256 createHmac, and timingSafeEqual backed by sloppy/crypto. Hash/HMAC digest helpers are Promise-shaped because the Sloppy crypto API is async.
node:assert, assertpartialsloppy/node/assertok, loose equal, strictEqual, notStrictEqual, JSON-shaped deepEqual/deepStrictEqual, throws, doesNotThrow, rejects, doesNotReject, fail, ifError, and AssertionError.
node:assert/strict, assert/strictpartialsloppy/node/assert/strictSame small assert subset, with equal mapped to strictEqual.
node:stream, streampartialsloppy/node/streamSmall EventEmitter-based subset: Readable.from, minimal Writable, PassThrough, and pipeline. No full Node stream backpressure or transform contract.
node:stream/promises, stream/promisespartialsloppy/node/stream/promisesPromise-shaped pipeline from the small node:stream compatibility subset.
node:module, modulepartialsloppy/node/modulebuiltinModules and createRequire() for bundled Sloppy program modules.
node:string_decoder, string_decoderpartialsloppy/node/string_decoderUTF-8 StringDecoder backed by Sloppy text decoding.
node:zlib, zlibpartialsloppy/node/zlibAsync callback gzip/gunzip backed by Sloppy compression. deflate/inflate and sync zlib APIs throw explicit unsupported errors.
node:perf_hooks, perf_hookspartialsloppy/node/perf_hooksMinimal performance.now() and timeOrigin.
node:diagnostics_channel, diagnostics_channelpartialsloppy/node/diagnostics_channelIn-process channel publish/subscribe for package instrumentation hooks.
node:tty, ttystubbedsloppy/node/ttyisatty() and stream classes report non-TTY.
node:http, httpstubbedsloppy/node/httpImportable client/server entry points throw SLOPPY_E_NODE_HTTP_UNSUPPORTED.
node:https, httpsstubbedsloppy/node/httpsImportable client/server entry points throw SLOPPY_E_NODE_HTTPS_UNSUPPORTED.

Unsupported families include node:http2, node:net, node:tls, node:dns, node:worker_threads, node:child_process, node:vm, node:inspector, node:test, node:repl, and Node internal modules.

Runtime Globals

Compatibility shims are modules first. Sloppy does not claim process-wide Node identity. For bundled installed packages, the generated program wrapper installs only global, process, and Buffer while the program entry runs, because many pure-JS packages probe those globals. Source code should still import the compatibility module explicitly:

ts
import { Buffer } from "node:buffer";
import process from "node:process";

Packages that require other Node globals still fail unless the generated graph has a documented shim for them.

Diagnostics

Unsupported builtins fail at build time:

text
SLOPPYC_E_UNSUPPORTED_NODE_BUILTIN
node:child_process is not supported by Sloppy's Node compatibility registry yet.

Unsupported members inside a partial shim fail at runtime with a module-specific message, for example:

text
node:fs.watch is not implemented by Sloppy's node:fs compatibility shim.

Native addons fail at build time:

text
SLOPPYC_E_NATIVE_ADDON_UNSUPPORTED
Package "sharp" requires a native Node addon. Sloppy does not support Node native addons yet.

Use sloppy deps, sloppy audit, and sloppy doctor to inspect registry use and compatibility findings.

Package Resolution Matrix

The package shapes Sloppy currently tests are committed at tests/fixtures/npm-compat/ with a matrix.json index. The compiler resolver test walks the matrix on every test run. The matrix is the regression baseline for currently tested package shapes; shapes outside the matrix are not implicit non-regressions for users. Add a fixture plus matrix entry alongside any change that broadens resolver behavior.

The resolver matrix proves package shapes resolve.

Package Runtime Behavior Matrix

The runtime behaviors Sloppy currently tests are committed at tests/fixtures/npm-runtime/ with its own matrix.json index. Each runtime fixture is built, packaged, copied outside the source checkout, and re-run under V8. The matrix asserts the documented stdout for supported fixtures and the documented stderr substring for stubbed and negative-runtime fixtures.

The runtime matrix proves selected package behaviors execute after packaging.

GroupFixturesNotes
cjs3module.exports = fn, exports.foo/module.exports.bar mutation, exports = ... rebind no-op.
interop2CJS require("./data.json"), ESM app default-imports a CJS package.
exports2import and require branches of the same exports object, observed through ESM import and createRequire.
self-reference1Package imports itself by declared name; identity preserved through createRequire.
imports1Package imports #alias resolves at runtime.
module2node:module createRequire for sealed JSON and subpath, require.resolve against the sealed graph, and __dirname/__filename based on sealed module IDs.
buffer1Buffer.from for utf8/base64/hex, Buffer.concat, Buffer.byteLength.
crypto1createHash("sha256"), randomBytes, timingSafeEqual.
stream1Readable.from and PassThrough only; backpressure and Transform are out of scope.
zlib1Async callback gzip and gunzip round-trip.
fs1Sync fs.readFileSync/existsSync/statSync against the sealed bundled asset map (currently stubbed pending compile-time asset baking).
negative7Native addon rejection, unsupported node: builtin, computed require without moduleInclude, missing package asset, createRequire/require.resolve on unknown package, sync fs outside sealed policy.

The runtime matrix and the resolver matrix are complementary; neither implies the other.

Public alpha. APIs and artifact formats may still change between alpha revisions.