Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
...to avoid SyntaxError in legacy browsers
googleanalytics/autotrack#137
Description
Reports of
Uncaught SyntaxError: Use of const in strict mode
when viewing Beenest on legacy browsers (Safari 9/10 were the reports, Chromium 40 was any reproduction environment). Generally, these occur when trying to run ES6 code in a browser without ES6 support, such as when an ES6 dependency gets included by webpack without transpilation. In our case, this was theautotrack
dependency. Ran into miscellaneous errors trying to enable transpilation fornode_modules/autotrack
; instead, changed therequire
call which imports this to point toautotrack/autotrack.js
, which is a minified ES5 version of the dependency.How to Test
npm run prod
)cd dist; http-server
)Which devices did you test on?
REVIEWERS:
Check against these principles:
High level
Does this code need to be written?
What are the alternatives?
Will this implementation become a support issue?
How much error margin does this solution have?
Code
Does the code follow industry standards?
JS: https://github.com/airbnb/javascript
React: https://github.com/airbnb/javascript/tree/master/react
https://github.com/vasanthk/react-bits
Documentation headers: http://usejsdoc.org/index.html
Is there duplicated code? Can it be refactored into a shared method?
Is the code consistent with our project?
Are there unit tests? Do they test the states?
Is the person refactoring another developer's code? If possible, did the original developer approve?
Variables/Naming:
Security
Further Work
This solution is not ideal, insofar as it increases the scope of the dependency we include; fine-grained inclusion of plugins would be preferable. Our
index.js
goes from 1575840 bytes to 1582801 bytes with this change. That extra ~7k looks "negligible" at that scale; we should probably look into pruning our other dependencies.Learnings
webpack
can introduce some obscure errors...