mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(nuxi, kit): import individual semver function (#1598)
This commit is contained in:
parent
b49c62b335
commit
47e0721413
@ -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}\``
|
||||||
|
@ -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}).`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user