For AI agents: the complete documentation index is available at /tc39-atlas/en/llms.txt, the full documentation bundle is available at /tc39-atlas/en/llms-full.txt, and this page is available as Markdown at /tc39-atlas/en/proposals/stage/2.7/proposal-shadowrealm.md.
  • English
  • ShadowRealm S2.7

    Proposal details
    Proposal overview

    The ShadowRealm proposal addresses the need for creating isolated JavaScript environments by providing a standard API to create a distinct global environment with its own intrinsics and built-ins. It provides a class with methods to evaluate source text synchronously and dynamically import modules asynchronously, returning only primitive values or callable functions.7, the proposal has evolved from an earlier globalThis-based model to a leaner, isolated realm API.

    Note

    The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.

    ECMAScript spec proposal for ShadowRealm API

    Status

    Champions

    • @dherman
    • @caridy
    • @erights
    • @leobalter
    • @rwaldron
    • @legendecas

    Index

    What are ShadowRealms?

    ShadowRealms are a distinct global environment, with its own global object containing its own intrinsics and built-ins (standard objects that are not bound to global variables, like the initial value of Object.prototype).

    See more at the explainer document.

    API (TypeScript Format)

    declare class ShadowRealm {
        constructor();
        importValue(specifier: string, bindingName: string): Promise<PrimitiveValueOrCallable>;
        evaluate(sourceText: string): PrimitiveValueOrCallable;
    }

    See some examples in the Explainer file.

    Presentations

    History

    Contributing

    Updating the spec text for this proposal

    The source for the spec text is located in spec.html and it is written in ecmarkup language.

    When modifying the spec text, you should be able to build the HTML version by using the following command:

    npm install
    npm run build
    open dist/index.html

    Alternatively, you can use npm run watch.