Skip to content

how to load modules into a Compartment? #1624

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

You must be logged in to vote

@tgrecojs and @ClemensLey Please pardon the long wait for my answer!

The Compartment has an import(specifier) method, but for that to be useful, you need to create a Compartment with an appropriate importHook and resolveHook. But, those are very, very low-level and have no opinions about Node.js versus Web style import semantics. Regardless, that looks like:

For import behavior that resembles Node.js, you would use @endo/compartment-mapper, which configures a Compartment for every package in an application, looking in all the places Node.j…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

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

dckc
Jun 8, 2023
Maintainer Author

You must be logged in to vote
0 replies
Comment options

dckc
Jun 8, 2023
Maintainer Author

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
documentation Improvements or additions to documentation question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #963 on June 08, 2023 20:56.