-
Notifications
You must be signed in to change notification settings - Fork 68
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
refactor(compartment-mapper)!: Cleanly separate StaticModuleRecord dependency #698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing calls app.agar-make
. Shouldn't it be called during yarn build
? If so, can we avoid checking in unreviewable binary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Still reviewing, but accidentally hit return while writing text for the eventual review message. Interesting github hazard.
Checking in |
This all makes sense. Is it stated anywhere? |
I’ve appended two commits to address feedback. The second change documents the process for updating the checked-in archive test fixture, including a test log with instructions for when that test fails. |
From #698 (comment)
Doh! That's what I was missing. No change suggested. Resolving. For some reason I cannot comment on this conversation in within that conversation. |
From #698 (comment)
Object.prototype.hasOwnProperty = myEvilFunction; Obviously impossible in SES, but still a concern outside of SES. Our spec would use the internal |
Also Function.prototype.call = myEvilFunction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
parsers: languageForExtension = {}, | ||
types: languageForModuleSpecifier = {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to rename the property names to match these much clearer variable names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might. They’re very verbose for a JSON file, but it might be a good idea.
Currently, the compartment mapper gets a lot of leverage from a shared assembler and import hook maker. Unfortunately, that means that import, archive, and importArchive all entrain a dependency on the fat StaticModuleRecord constructor and Babel. It should be possible for tools like
@agoric/import-bundle
to avoid that dependency by importing@endo/compartment-mapper/import-archive
and so only support execution of precompiled archives.This change begins the process of teasing apart these entry points. First, we consolidate some of the machinery in
parse.js
that is only used inassemble.js
into the assembler directly. Instead of capturing theparserForLanguage
mapping from lexical scope, we now thread it intoassemble
as a required field on the so-called options bag.Then,
import
,archive
, andimport-archive
each create their ownparserForLanguage
table with parsers that may be customized for their specific purpose. For example,archive
usesparse-archive-mjs
andparse-archive-cjs
which pre-compile and pre-analyze modules respectively and enter a Syrup record into the archive instead of the source bytes.importArchive
then expects to see onlypremjs
andprecjs
files in archives, and has aparseForLanguage
table that can produce static module records from the Syrup-encoded record.Notably,
import
gains an efficiency from this factoring, since itsparserForLanguage
table consists of parsers that don't do any extra work for archiving.A future change will need to create the API surface so these layers of
compartment-mapper
can be imported directly.Refs #655