mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
refactor: remove caniuse-lite dependency (#4419)
This commit is contained in:
parent
33edef2d40
commit
29c5bb6513
@ -1,9 +1,10 @@
|
||||
{
|
||||
"edge": "16",
|
||||
"firefox": "60",
|
||||
"chrome": "61",
|
||||
"safari": "10.1",
|
||||
"opera": "48",
|
||||
"ios_saf": "10.3",
|
||||
"and_ff": "60"
|
||||
"Edge": "16",
|
||||
"Firefox": "60",
|
||||
"Chrome": "61",
|
||||
"Chrome Headless": "61",
|
||||
"Chromium": "61",
|
||||
"Safari": "10.1",
|
||||
"Opera": "48",
|
||||
"Mobile Safari": "10.3"
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
"@nuxt/common": "2.3.4",
|
||||
"@nuxt/config": "2.3.4",
|
||||
"@nuxtjs/youch": "^4.2.3",
|
||||
"browserslist-useragent": "^2.0.1",
|
||||
"chalk": "^2.4.1",
|
||||
"compression": "^1.7.3",
|
||||
"connect": "^3.6.6",
|
||||
@ -22,9 +21,11 @@
|
||||
"ip": "^1.1.5",
|
||||
"launch-editor-middleware": "^2.2.1",
|
||||
"pify": "^4.0.1",
|
||||
"semver": "^5.6.0",
|
||||
"serve-placeholder": "^1.1.0",
|
||||
"serve-static": "^1.13.2",
|
||||
"server-destroy": "^1.0.1"
|
||||
"server-destroy": "^1.0.1",
|
||||
"ua-parser-js": "^0.7.19"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -1,16 +1,22 @@
|
||||
import chalk from 'chalk'
|
||||
import consola from 'consola'
|
||||
import { ModernBrowsers } from '@nuxt/common'
|
||||
import { matchesUA } from 'browserslist-useragent'
|
||||
import UAParser from 'ua-parser-js'
|
||||
import semver from 'semver'
|
||||
|
||||
const modernBrowsers = Object.keys(ModernBrowsers)
|
||||
.map(browser => `${browser} >= ${ModernBrowsers[browser]}`)
|
||||
.reduce((allBrowsers, browser) => {
|
||||
allBrowsers[browser] = semver.coerce(ModernBrowsers[browser])
|
||||
return allBrowsers
|
||||
}, {})
|
||||
|
||||
const isModernBrowser = (ua) => {
|
||||
return Boolean(ua) && matchesUA(ua, {
|
||||
allowHigherVersions: true,
|
||||
browsers: modernBrowsers
|
||||
})
|
||||
if (!ua) {
|
||||
return false
|
||||
}
|
||||
const { browser } = UAParser(ua)
|
||||
const browserVersion = semver.coerce(browser.version)
|
||||
return modernBrowsers[browser.name] && semver.gte(browserVersion, modernBrowsers[browser.name])
|
||||
}
|
||||
|
||||
let detected = false
|
||||
|
Loading…
Reference in New Issue
Block a user