Limitations

edit

The engine implements the ECMAScript language and its standard library. What a browser or Node.js adds on top of it is not part of the engine.

No host APIs

A realm has the built-ins of ECMAScript only. These are not provided:

  • console, setTimeout, setInterval, queueMicrotask, structuredClone;
  • fetch, URL, TextEncoder, TextDecoder, atob, btoa, and the other APIs of the web platform: the DOM, window, document, workers...;
  • Node.js: require, process, Buffer, and the built-in modules (fs, path...);
  • WebAssembly.

Add what your scripts need with .NET functions and objects: see Console, timers and other host APIs, Functions and Exposing .NET objects. To run scripts in HTML documents with the DOM API, use Meziantou.Framework.WebPlatform with Meziantou.Framework.WebPlatform.JavaScript, which runs them with this engine.

Modules

  • Only ES modules are supported. A CommonJS package (require, module.exports) must be bundled or converted to an ES module first, or run by a require that your application provides: see CommonJS modules.
  • The engine resolves and reads no file: your module loader resolves each specifier and gives its source. There is no node_modules resolution and no import map. See Modules.
  • The export defer proposal is not implemented (import defer is).

.NET interop

  • No automatic binding: .NET objects, methods, properties, events and enumerables are not exposed by reflection. You create the JavaScript objects and functions that represent them. See Exposing .NET objects.
  • The conversions of Converting .NET values cover the primitives, the dates, the collections, the dictionaries and JSON, not the other classes.
  • The promises of tasks settle while the host runs the jobs of the engine. See Async code and promises.

Execution

  • An interpreter. The code is compiled to bytecode and interpreted; there is no JIT compilation to machine code. Compile the scripts that run many times once, with JsPreparedScript.
  • One thread at a time per engine. Use one engine per thread to run scripts in parallel. Engines share memory only through SharedArrayBuffer.
  • No debugger. There is no debugging protocol and no breakpoints; the errors give their location and their stack.
  • The memory limit counts allocations, not the memory that the script keeps. See Limits and sandboxing.
  • The nesting of the code is limited. A source nested deeper than 1,500 levels (parentheses, brackets, blocks, unary operators, nested functions...) is a SyntaxError ("the code is nested too deeply"), and so is a shallower one when the stack of the thread is too small to compile it: the engine never overflows the stack. The long chains of generated code are not nested: else if chains and chains of operators, member accesses and calls are handled in loops.

Results

  • Some results are left to the implementation by the specification (the time zone names of Date.prototype.toString, the error messages, the precision of Math.sin...), and the Unicode, locale and time zone data have their own versions: they can differ from Node.js and the browsers. See Data versions and output differences.