Skip to content

How to run third party javascript code in compartment in a browser #1931

Answered by kriskowal
bozhidarc asked this question in Q&A
Discussion options

You must be logged in to vote

To load ESM, you’ll need @endo/compartment-mapper. In its current form, it provides importLocation, which is suitable for loading packages laid out in a node_modules tree. It can also build an archive in zip format and read it out later, with makeArchive and importArchive. This may be enough to get you going in the right direction, but to securely load ESM on the web, you will probably need something analogous but not the same.

One option is to use a tool like Browserify, Rollup, or esbuild to compile ESM down to a single script that can run in Compartment().evaluate(script). That works pretty well today.

The compartment mapper is designed to permit the eventual addition of something anal…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kriskowal
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1411 on January 08, 2024 21:59.