Skip to content
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

fix(ses)!: Simplify transforms #325

Merged
merged 3 commits into from
May 21, 2020
Merged

fix(ses)!: Simplify transforms #325

merged 3 commits into from
May 21, 2020

Conversation

kriskowal
Copy link
Member

@kriskowal kriskowal commented May 20, 2020

This change simplifies the compartment transforms for evaluated programs to just an array of functions that accept and return program strings. The previous version of this API enabled transforms to add endowments and left room for future transformable properties. We have elected to use the compartment evaluate function to introduce lexical endowments and globalThis to introduce enumerable and computable endowments.

Fixes #321

This change simplifies the compartment transforms for evaluated programs to just an array of functions that accept and return program strings.  The previous version of this API enabled transforms to add endowments and left room for future transformable properties.  We have elected to use the compartment `evaluate` function to introduce lexical endowments and `globalThis` to introduce enumerable and computable endowments.
Copy link
Contributor

@erights erights left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love negative line number code reviews!

LGTM

@@ -95,6 +95,7 @@ export function rejectImportExpressions(src) {

const someDirectEvalPattern = new RegExp('\\beval\\s*(?:\\(|/[/*])');

// Exported for unit tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noting that.

For all these, what is needed so that the error here could carry more context that just the line number? (not suggesting any such change for this PR though.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could change the non-capture group for the body of the eval expression in the regular expression to a capture-group and report that. I imagine that could get quite unwieldy depending on the length of the expression.

@kriskowal kriskowal merged commit 86a373e into master May 21, 2020
@kriskowal kriskowal deleted the kris/simplify-transforms branch May 21, 2020 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove endowments from the compartment transforms API
2 participants