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

Export Math to global object #129

Merged
merged 1 commit into from
Dec 18, 2021
Merged

Conversation

worenga
Copy link
Contributor

@worenga worenga commented Dec 17, 2021

No description provided.

@worenga
Copy link
Contributor Author

worenga commented Dec 17, 2021

Fixes #128

@mrbbot
Copy link
Contributor

mrbbot commented Dec 17, 2021

Hey! 👋 Have you verified this fixes the issue? Math is a JavaScript built-in, like Object, Uint8Array, etc so should be available without explictly passing it as a global:

import vm from "vm";

const ctx = vm.createContext({}); // Empty sandbox

console.log(vm.runInContext("Math.min(1, 2)", ctx)); // 1

@worenga
Copy link
Contributor Author

worenga commented Dec 17, 2021

@mrbbot yes, it fixed it.

@mrbbot
Copy link
Contributor

mrbbot commented Dec 18, 2021

Ok, just had a look at this. Thanks for setting up a reproduction over at miniflare-typescript-esbuild-jest. 🙂 This is such as weird issue, but probably just Jest being weird 🙃, since it only happens in tests. 🤹‍♂️ Will get this merged!

@mrbbot mrbbot merged commit b30006f into cloudflare:v2 Dec 18, 2021
@worenga
Copy link
Contributor Author

worenga commented Dec 20, 2021

Thanks!

mrbbot pushed a commit that referenced this pull request Jan 7, 2022
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.

2 participants