-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
disable built-ins in Browserify #2133
Conversation
I guess the verification step would be something like concatenating this script with a simple check for window.process and run that in puppeteer. |
I've looked into this and already did some work in sinonjs/fake-timers#270 and sinonjs/nise#108. I think the flag we want is The next step is to integrate the above changes in Sinon and make sure tests pass in all supported environments with these settings. |
What are we verifying? Do we need to test that browserify options work? |
It's an integration test. We test that the individual bits have been assembled correctly and works as expected in unison. So yes. It's just a simple smoke test, not anything involved. |
Like this one in Mochify I guess? https://github.com/mantoni/mochify.js/blob/master/test/chromium-test.js#L475 |
--no-builtins removes browserify's node native modules mapping. Shall I add |
I'm not sure what that actually means/does ... |
OK, so I looked into this and why this fails. Basically, disabling built-ins means we have to do the work of finding or injecting these globals ourselves, like in the good old days. So the above build triggered by @mshaaban0 failed due to neither After that, it failed in Lolex, which also has some Not totally sure what the best solution ™️ is here, but a relatively simple one could be to add function getGlobalObject(){
var root;
if (typeof window !== "undefined") {
root = window;
} else if (typeof global !== "undefined") {
root = global;
} else if (typeof self !== "undefined") {
root = self;
}
return root;
} Once the dependencies have been patched to handle not injecting But all of this seems a bit unnecessary ... I was hoping that all these globals were just defined by an outer closure per module and not for the entire bundle. That would have made these issues local. |
This has been fixed with #2175. Closing. |
Purpose (TL;DR) - mandatory
In favor of @mantoni's comment in sinonjs/commons#37 (comment)
How to verify - mandatory
npm install
npm run build
Checklist for author
npm run lint
passes