Skip to content

Commit 1d83c15

Browse files
mikehearnwoess
authored andcommitted
Make the esm-eval-returns-exports option be stable and usable in sandbox mode.
(cherry picked from commit e70567f)
1 parent 7d4bf7c commit 1d83c15

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

Diff for: docs/user/Modules.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ Note that the ES module file has `.mjs` extension.
6969
Also note that the `allowIO()` option is provided to enable IO access.
7070
More examples of ES modules usage are available [here](https://github.com/oracle/graaljs/blob/master/graal-js/src/com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/interop/ESModuleTest.java).
7171

72-
#### Experimental module namespace exports
72+
#### Module namespace exports
7373

74-
The `--js.esm-eval-returns-exports` experimental option can be used to expose the ES module namespace exported object to a Polyglot `Context`.
74+
The `--js.esm-eval-returns-exports` option (off by default) can be used to expose the ES module namespace exported object to a Polyglot `Context`.
7575
This can be handy when an ES module is used directly from Java:
76+
7677
```java
7778
public static void main(String[] args) throws IOException {
7879

@@ -92,8 +93,6 @@ public static void main(String[] args) throws IOException {
9293
System.out.println(exports.getMember("foo").toString()); // prints `42`
9394
}
9495
```
95-
The option is disabled by default.
96-
9796

9897
### Truffle FileSystem
9998

Diff for: docs/user/Options.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ The following stable options are frequently relevant:
7373
* `--js.allow-eval`: allow the code generation from strings, e.g. using `eval()` or the `Function` constructor. Boolean value, default is `true`.
7474
* `--js.timer-resolution`: sets the resolution of timing functions, like `Date.now()` and `performance.now()`, in nanoseconds. Default: `1000000` (i.e. 1 ms).
7575
* `--js.unhandled-rejections`: configure unhandled promise rejection tracking. Accepted values are `none` (default, no tracking), `warn` (print a warning to stderr), `throw` (throw an exception), and `handler` (invoke a custom handler).
76+
* `--js.esm-eval-returns-exports`: `context.eval` of an ES module `Source` returns its exported symbols.
7677

7778
For a complete list, use `js --help:js:internal`
7879

@@ -116,6 +117,5 @@ To use them, the `--experimental-options` flag is required or the experimental o
116117
* `--js.nashorn-compat`: provide compatibility mode with the Nashorn engine. Sets ECMAScript version to 5 by default. Might conflict with newer ECMAScript versions. Boolean value, default is `false`.
117118
* `--js.timezone`: set the local time zone. String value, default is the system default.
118119
* `--js.v8-compat`: provide better compatibility with Google's V8 engine. Boolean value, default is `false`.
119-
* `--js.esm-eval-returns-exports`: `context.eval` of an ES module `Source` returns its exported symbols.
120-
* `--js.temporal`: enable  [`Temporal` API](https://github.com/tc39/proposal-temporal).
120+
* `--js.temporal`: enable [`Temporal` API](https://github.com/tc39/proposal-temporal).
121121
* `--js.webassembly`: enable `WebAssembly` API.

Diff for: graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/runtime/JSContextOptions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public String toString() {
639639
@CompilationFinal private boolean wasmBigInt;
640640

641641
public static final String ESM_EVAL_RETURNS_EXPORTS_NAME = JS_OPTION_PREFIX + "esm-eval-returns-exports";
642-
@Option(name = ESM_EVAL_RETURNS_EXPORTS_NAME, category = OptionCategory.EXPERT, help = "Eval of an ES module through the polyglot API returns its exported symbols.") //
642+
@Option(name = ESM_EVAL_RETURNS_EXPORTS_NAME, category = OptionCategory.EXPERT, stability = OptionStability.STABLE, sandbox = SandboxPolicy.UNTRUSTED, help = "Eval of an ES module through the polyglot API returns its exported symbols.") //
643643
public static final OptionKey<Boolean> ESM_EVAL_RETURNS_EXPORTS = new OptionKey<>(false);
644644
@CompilationFinal private boolean esmEvalReturnsExports;
645645

0 commit comments

Comments
 (0)