-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add simple require()
to the SES environment, replace global Nat/def with requires
#169
Comments
There's an esm-related name-mangling problem still pending, so this patch can't use a simple lazy eval() yet. Instead, we use r.evaluate() from outside, then pass the new Nat() function into makeRequire(). This forces us to evaluate the function when creating the SES realm, even if nobody ever calls require() with 'nat'. Once we figure out that problem, we can revert to the simpler/lazier version. refs #51
Adds an option named `requireMode: 'allow'`. When enabled, the confined code has access to a `require()` function that behaves somewhat like the `require()` in Node.js, except that it is limited to a single name for now, `nat`. `require('nat')` should yield the same module as it would in Node.js when you have `@agoric/nat` in your `package.json`. We'll add more modules to this over time, as well as changing the syntax of the `requireMode` option, so the use of a binary `allow` is temporary. refs #51 , but doesn't close it because we have more modules to add
Note to self: per the discussion in agoric-labs/PlaygroundVat#13 (comment) , @jdalton is planning on making a new |
This yields the same as the previous 'def' global (which has been removed), which is the one built-in to SES. We are not using the external harden/makeHardener code yet. refs #51
As mentioned in https://github.com/Agoric/SES/issues/9#issuecomment-465003139 , instead of adding a |
This is done, to my satisfaction. I struggled a bit for lack of docs, but #159 was enough clues for me to write https://github.com/dckc/do-your-worst/blob/master/loader.js |
To help with Agoric/SES#13, we're going to add a rudimentary
require()
to the SES environment. It will initially only accept one of three names:nat
,def
(which will be renamedharden
), andses
. Rather than havingNat
/def
/SES
be injected onto the global namespace, we'll instead injectrequire
into that namespace, and you'll get the other symbols by usingrequire()
exactly as you would outside of SES:The object you get back when using
require('ses')
inside a SES realm will be different than what you'd get from outside of one. ForNat
they'll be the same butSES
needs to build a separate version for each nested realm, anddef
/harden
will return a hardener that already knows about all the primordials that are already frozen.This
require()
will throw an exception if you give it any other module name: it is not yet a general-purpose module loader (although of course this is a natural place to build one in the future). We'll have to decide later aboutrequire
/CJS vsimport
/es6 style.. for now, a basicrequire()
should be enough to let us share code between SES and non-SES environments.The text was updated successfully, but these errors were encountered: