From e86a6383054623e5168384a83d8cd6ebfe1fb584 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 ea69a2893ff188..167107a0018e08 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -337,6 +337,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 44ba09624b0884..5bb0c3cf33df7c 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -346,10 +346,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`