Skip to content

Commit

Permalink
add a workaround of a BrowserFS NodeJS process polyfill bug that in…
Browse files Browse the repository at this point in the history
…correctly reports V8 version that's used in some cases of `core-js` feature detection

jvilk/bfs-process#5

codesandbox/codesandbox-client#5943
  • Loading branch information
zloirock committed Oct 17, 2021
1 parent feacaa9 commit b2144bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
## Changelog
##### Unreleased
- Added a workaround of [a BrowserFS NodeJS `process` polyfill bug](https://github.com/jvilk/bfs-process/issues/5) that incorrectly reports V8 version that's used in some cases of `core-js` feature detection
- Fixed normalization of `message` `AggregateError` argument
- Fixed order of arguments conversion in `Math.scale`, [a spec draft bug](https://github.com/rwaldron/proposal-math-extensions/issues/24)
- Updated Electron 16.0 compat data mapping
Expand Down
14 changes: 10 additions & 4 deletions packages/core-js/internals/engine-v8-version.js
Expand Up @@ -9,13 +9,19 @@ var match, version;

if (v8) {
match = v8.split('.');
version = match[0] < 4 ? 1 : match[0] + match[1];
} else if (userAgent) {
// in old Chrome, versions of V8 isn't V8 = Chrome / 10
// but their correct versions are not interesting for us
version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
}

// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
// so check `userAgent` even if `.v8` exists, but 0
if (!version && userAgent) {
match = userAgent.match(/Edge\/(\d+)/);
if (!match || match[1] >= 74) {
match = userAgent.match(/Chrome\/(\d+)/);
if (match) version = match[1];
if (match) version = +match[1];
}
}

module.exports = version && +version;
module.exports = version;

0 comments on commit b2144bb

Please sign in to comment.