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
Avoid the assumption of Buffer in browser envs #3452
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3452 +/- ##
==========================================
+ Coverage 95.01% 95.02% +<.01%
==========================================
Files 171 171
Lines 5843 5851 +8
Branches 1724 1726 +2
==========================================
+ Hits 5552 5560 +8
Misses 157 157
Partials 134 134
Continue to review full report at Codecov.
|
src/utils/FileEmitter.ts
Outdated
@@ -24,6 +24,8 @@ interface OutputSpecificFileData { | |||
bundle: OutputBundleWithPlaceholders; | |||
} | |||
|
|||
const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined'; |
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.
I see the motivation but I am not really happy about connecting the presence of Buffer
with the presence of some completely unrelated browser globals. A simple fix would be to just check for the presence of Buffer
, but there is no reason this cannot work in the browser. Except for equality and type checking, we are not using any more Buffer specific features. I will add some changes and a test.
This was meant as a draft sorry!
This PR contains:
Are tests included?
Will try to include these asap (no clue yet how to mock this)
Breaking Changes?
List any relevant issue numbers:
#3450
Description
Since Buffers can't exist in the browser (node.js thing) we can safely make the condition of not checking for it in the browser.