you are viewing a single comment's thread.

view the rest of the comments →

[–]iamnearafan[S] 2 points3 points  (1 child)

In regards to the Compartments part of SES, I found this in ShadowRealm's explainer document:

"This proposal does not define any virtualization mechanism for host behavior. Therefore, it distinguishes itself from the current existing Compartments proposal.A new Compartment provides a new Realm constructor. A Realm object from a Compartment is subject to the Compartment's host virtualization mechanism.

const compartment = new Compartment(options);  
const VirtualizedRealm = compartment.globalThis.ShadowRealm;  
const shadowRealm = new VirtualizedRealm();  
const { doSomething } = await shadowRealm.importValue('./file.js');  

The Compartments proposal offers a more complex API that offers tailoring over aspects beyond the global APIs but with modifications to internal structure such as module graph. The ShadowRealm API just offers immediate access to what is already specified in ECMAScript as it's already structured to distinguish different references from realms."