-
Notifications
You must be signed in to change notification settings - Fork 19
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
Resolve issue #60 with mangled variable. #65
Resolve issue #60 with mangled variable. #65
Conversation
a185aa7
to
84e4c57
Compare
globalEval was needed to prevent ESM from mangling the We may need to find a different solution for rollup only. |
Can use const globalEval = Math.random()>-1?eval: undefined
Instead of (1, eval)
Michael FIG <[email protected]> 于 2019年10月1日周二 上午11:45写道:
… globalEval was needed to prevent ESM from mangling the (1,eval) form.
Please see #54 <#54> (which
incorrectly cites rollup as the cause) and test that importing realms-shim
under ESM using your PR with SES can create a root realm.
We may need to find a different solution for rollup only.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#65?email_source=notifications&email_token=ABJEC74H253E2HE2R2MLMRTQMLBVXA5CNFSM4I4DROS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD772RII#issuecomment-536848545>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABJEC7ZURTF4E6YIWUHWEXDQMLBVXANCNFSM4I4DROSQ>
.
|
@michaelfig Thanks for the info! Would you know of a test that fails? |
@Jack-Works, good trick, and it works. Normally,
But instead I'm passing the unsafe global as an argument. It's a little more obvious. I've check that this approach also defeats ESM detection by removing the call to |
Here is a test that fails:
Expected result: Actual result:
This error happened before #54 was merged, in commit hash |
Agoric#60 Changes: - Keep cleanupSource for builds. - Use minimized UMD in demo.
be25d06
to
6c899e0
Compare
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.
Need less magic in cleanupSources.
src/utilities.js
Outdated
@@ -29,14 +29,11 @@ export function assert(condition, message) { | |||
|
|||
// Remove code modifications. | |||
export function cleanupSource(src) { | |||
/* START_TESTS_ONLY */ | |||
|
|||
// Restore eval which is modified by esm module. | |||
src = src.replace(/\(0,[^)]+\)/g, '(0, eval)'); |
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.
This is getting really close!
Can you please focus the regexp a little more rather than just relying on (0,any(thing), after a zero comma)
to mean (0, eval)
? I'd suggest changing the calls to ('indirectEval', eval)
and then matching on that pattern.
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.
How about we implement the fix from the "other" branch?
export function cleanupSource(src) {
// Restore eval which is modified by esm module.
// (0, eval) => (0, _<something>.e)
src = src.replace(/\(0, _[^.]+\.e\)/g, '(0, eval)');
// Restore Reflect which is modified by esm module.
// Reflect => _<something>.e.Reflect
src = src.replace(/_[^.]+\.g\.Reflect/g, 'Reflect');
// Remove code coverage which is injected by nyc module.
src = src.replace(/cov_[^+]+\+\+[;,]/g, '');
return src;
}
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!
@michaelfig Many thanks. |
Prevent mangling of variables.
#60
Changes: