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",
|
"Edge": "16",
|
||||||
"firefox": "60",
|
"Firefox": "60",
|
||||||
"chrome": "61",
|
"Chrome": "61",
|
||||||
"safari": "10.1",
|
"Chrome Headless": "61",
|
||||||
"opera": "48",
|
"Chromium": "61",
|
||||||
"ios_saf": "10.3",
|
"Safari": "10.1",
|
||||||
"and_ff": "60"
|
"Opera": "48",
|
||||||
|
"Mobile Safari": "10.3"
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
"@nuxt/common": "2.3.4",
|
"@nuxt/common": "2.3.4",
|
||||||
"@nuxt/config": "2.3.4",
|
"@nuxt/config": "2.3.4",
|
||||||
"@nuxtjs/youch": "^4.2.3",
|
"@nuxtjs/youch": "^4.2.3",
|
||||||
"browserslist-useragent": "^2.0.1",
|
|
||||||
"chalk": "^2.4.1",
|
"chalk": "^2.4.1",
|
||||||
"compression": "^1.7.3",
|
"compression": "^1.7.3",
|
||||||
"connect": "^3.6.6",
|
"connect": "^3.6.6",
|
||||||
@ -22,9 +21,11 @@
|
|||||||
"ip": "^1.1.5",
|
"ip": "^1.1.5",
|
||||||
"launch-editor-middleware": "^2.2.1",
|
"launch-editor-middleware": "^2.2.1",
|
||||||
"pify": "^4.0.1",
|
"pify": "^4.0.1",
|
||||||
|
"semver": "^5.6.0",
|
||||||
"serve-placeholder": "^1.1.0",
|
"serve-placeholder": "^1.1.0",
|
||||||
"serve-static": "^1.13.2",
|
"serve-static": "^1.13.2",
|
||||||
"server-destroy": "^1.0.1"
|
"server-destroy": "^1.0.1",
|
||||||
|
"ua-parser-js": "^0.7.19"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { ModernBrowsers } from '@nuxt/common'
|
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)
|
const modernBrowsers = Object.keys(ModernBrowsers)
|
||||||
.map(browser => `${browser} >= ${ModernBrowsers[browser]}`)
|
.reduce((allBrowsers, browser) => {
|
||||||
|
allBrowsers[browser] = semver.coerce(ModernBrowsers[browser])
|
||||||
|
return allBrowsers
|
||||||
|
}, {})
|
||||||
|
|
||||||
const isModernBrowser = (ua) => {
|
const isModernBrowser = (ua) => {
|
||||||
return Boolean(ua) && matchesUA(ua, {
|
if (!ua) {
|
||||||
allowHigherVersions: true,
|
return false
|
||||||
browsers: modernBrowsers
|
}
|
||||||
})
|
const { browser } = UAParser(ua)
|
||||||
|
const browserVersion = semver.coerce(browser.version)
|
||||||
|
return modernBrowsers[browser.name] && semver.gte(browserVersion, modernBrowsers[browser.name])
|
||||||
}
|
}
|
||||||
|
|
||||||
let detected = false
|
let detected = false
|
||||||
|
Loading…
Reference in New Issue
Block a user