You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/non-trapping-shim/README.md
+13
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,24 @@ This package is currently organized internally as a ponyfill, and a shim based o
11
11
12
12
See https://github.com/endojs/endo/blob/master/packages/ses/docs/preparing-for-stabilize.md for guidance on how to prepare for the changes that will be introduced by this proposal.
13
13
14
+
The shim needs to be imported ***early***, in particular before other code might sample of freeze the primordials that this shim would modify or replace. Even though the `@endo/non-trapping-shim` package does not export a ponyfill, to uphold the convention on side-effecting exports, it does not export the shim as the package's default export. Rather, you need to import it as:
15
+
16
+
```js
17
+
import'@endo/non-trapping-shim/shim.js';
18
+
```
19
+
14
20
## Opt-in env-option `SES_NON_TRAPPING_SHIM`
15
21
16
22
To cope with various compat problems in linking code that uses or assumes this shim to code that does not, we have made this shim opt-in via the env-option `SES_NON_TRAPPING_SHIM`. This has two settings, `'enabled'` and the default `'disabled'`. As with all env options, this is represented at the property `process.env.SES_NON_TRAPPING_SHIM`, which typically represents the environment variable `SES_NON_TRAPPING_SHIM`. Thus, if nothing else sets `process.env.SES_NON_TRAPPING_SHIM`, you can opt-in at the shell level by
17
23
```sh
18
24
$ export SES_NON_TRAPPING_SHIM=enabled
19
25
```
20
26
27
+
The shim senses the setting of this env-option at the time it is imported, so any desired setting will need to happen earlier. Using a genuine environment variable does this. Otherwise, as a convenience, this package also exports a module to opt-in by setting `process.env.SES_NON_TRAPPING_SHIM`. To use this convenience, import the exported `prepare-enable-shim.js` before importing the exported shim itself:
0 commit comments