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

Avoid the assumption of Buffer in browser envs #3452

Merged
merged 8 commits into from Mar 24, 2020

Conversation

JoviDeCroock
Copy link
Contributor

@JoviDeCroock JoviDeCroock commented Mar 21, 2020

This was meant as a draft sorry!

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Will try to include these asap (no clue yet how to mock this)

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

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.

@codecov
Copy link

codecov bot commented Mar 21, 2020

Codecov Report

Merging #3452 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/utils/FileEmitter.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 399bbf4...6614496. Read the comment docs.

src/utils/FileEmitter.ts Outdated Show resolved Hide resolved
@@ -24,6 +24,8 @@ interface OutputSpecificFileData {
bundle: OutputBundleWithPlaceholders;
}

const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
Copy link
Member

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.

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.

None yet

3 participants