From c13a4bcf3bddfcfadc55823910259e01c159357d Mon Sep 17 00:00:00 2001 From: legendecas Date: Tue, 3 May 2022 00:46:31 +0800 Subject: [PATCH] src: add initial shadow realm support Add initial shadow realm support behind an off-by-default flag `--experimental-shadow-realm`. PR-URL: https://github.com/nodejs/node/pull/42869 Refs: https://github.com/nodejs/node/issues/42528 Reviewed-By: Antoine du Hamel Reviewed-By: Darshan Sen --- .eslintrc.js | 1 + doc/api/cli.md | 12 +++++++++++- doc/node.1 | 3 +++ lib/.eslintrc.yaml | 4 ++++ node.gyp | 2 ++ src/api/environment.cc | 7 +++++++ src/node_options.cc | 9 +++++++++ src/node_options.h | 1 + src/node_shadow_realm.cc | 16 ++++++++++++++++ src/node_shadow_realm.h | 19 +++++++++++++++++++ test/parallel/test-shadow-realm.js | 12 ++++++++++++ 11 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/node_shadow_realm.cc create mode 100644 src/node_shadow_realm.h create mode 100644 test/parallel/test-shadow-realm.js diff --git a/.eslintrc.js b/.eslintrc.js index 6d75f4534fa0b2..1dedcd1bd76e15 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -338,6 +338,7 @@ module.exports = { TextEncoderStream: 'readable', TransformStream: 'readable', TransformStreamDefaultController: 'readable', + ShadowRealm: 'readable', SubtleCrypto: 'readable', WritableStream: 'readable', WritableStreamDefaultWriter: 'readable', diff --git a/doc/api/cli.md b/doc/api/cli.md index 4b4a766854a338..7fd2e6a919ab64 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -411,10 +411,18 @@ Disable experimental support for the [Fetch API][]. +--> Use this flag to disable top-level await in REPL. +### `--experimental-shadow-realm` + + + +Use this flag to enable [ShadowRealm][] support. + ### `--experimental-specifier-resolution=mode`