fix(nuxi, kit): import individual semver function (#1598)

This commit is contained in:
Daniel Roe 2021-11-02 09:43:08 +00:00 committed by GitHub
parent b49c62b335
commit 47e0721413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ import hash from 'hash-sum'
import type { WebpackPluginInstance, Configuration as WebpackConfig } from 'webpack' import type { WebpackPluginInstance, Configuration as WebpackConfig } from 'webpack'
import type { Plugin as VitePlugin, UserConfig as ViteConfig } from 'vite' import type { Plugin as VitePlugin, UserConfig as ViteConfig } from 'vite'
import { camelCase } from 'scule' import { camelCase } from 'scule'
import semver from 'semver' import satisfies from 'semver/functions/satisfies.js' // npm/node-semver#381
import { NuxtCompatibilityConstraints, NuxtCompatibilityIssues } from '../types/module' import { NuxtCompatibilityConstraints, NuxtCompatibilityIssues } from '../types/module'
import { Nuxt } from '../types/nuxt' import { Nuxt } from '../types/nuxt'
import { useNuxt } from '../nuxt' import { useNuxt } from '../nuxt'
@ -357,7 +357,7 @@ export function checkNuxtCompatibilityIssues (constraints: NuxtCompatibilityCons
if (constraints.nuxt) { if (constraints.nuxt) {
const nuxtVersion = getNuxtVersion(nuxt) const nuxtVersion = getNuxtVersion(nuxt)
const nuxtSemanticVersion = nuxtVersion.split('-').shift() const nuxtSemanticVersion = nuxtVersion.split('-').shift()
if (!semver.satisfies(nuxtSemanticVersion, constraints.nuxt)) { if (!satisfies(nuxtSemanticVersion, constraints.nuxt)) {
issues.push({ issues.push({
name: 'nuxt', name: 'nuxt',
message: `Nuxt version \`${constraints.nuxt}\` is required but currently using \`${nuxtVersion}\`` message: `Nuxt version \`${constraints.nuxt}\` is required but currently using \`${nuxtVersion}\``

View File

@ -1,11 +1,11 @@
import { engines } from '../../package.json' import { engines } from '../../package.json'
export async function checkEngines () { export async function checkEngines () {
const semver = await import('semver').then(r => r.default || r) const satisfies = await import('semver/functions/satisfies.js').then(r => r.default) // npm/node-semver#381
const currentNode = process.versions.node const currentNode = process.versions.node
const nodeRange = engines.node const nodeRange = engines.node
if (!semver.satisfies(process.versions.node, engines.node)) { if (!satisfies(currentNode, nodeRange)) {
console.warn(`Current version of Node.js (\`${currentNode}\`) is unsupported and might cause issues.\n Please upgrade to a compatible version (${nodeRange}).`) console.warn(`Current version of Node.js (\`${currentNode}\`) is unsupported and might cause issues.\n Please upgrade to a compatible version (${nodeRange}).`)
} }
} }