mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(docs): describe compatibility
This commit is contained in:
parent
066390972c
commit
4e9d82f52d
@ -183,12 +183,218 @@ Options to pass in [`c12`](https://github.com/unjs/c12#options) `loadConfig` cal
|
||||
|
||||
[source code](https://github.com/nuxt/nuxt/blob/main/packages/kit/src/compatibility.ts)
|
||||
|
||||
- `checkNuxtCompatibility(constraints)`
|
||||
- `assertNuxtCompatibility(constraints)`
|
||||
- `hasNuxtCompatibility(constraints)`
|
||||
- `isNuxt2()`
|
||||
- `isNuxt3()`
|
||||
- `getNuxtVersion()`
|
||||
### `checkNuxtCompatibility`
|
||||
|
||||
Checks if constraints are met for the current Nuxt version. If not, returns an array of messages. Nuxt 2 version also checks for `bridge` support.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
async function checkNuxtCompatibility(
|
||||
constraints: NuxtCompatibility,
|
||||
nuxt?: Nuxt
|
||||
): Promise<NuxtCompatibilityIssues>;
|
||||
|
||||
interface NuxtCompatibility {
|
||||
nuxt?: string;
|
||||
bridge?: boolean;
|
||||
}
|
||||
|
||||
interface NuxtCompatibilityIssue {
|
||||
name: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface NuxtCompatibilityIssues extends Array<NuxtCompatibilityIssue> {
|
||||
toString(): string;
|
||||
}
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `constraints`
|
||||
|
||||
**Type**: `NuxtCompatibility`
|
||||
|
||||
**Default**: `{}`
|
||||
|
||||
Constraints to check for. It accepts the following properties:
|
||||
|
||||
- `nuxt` (optional)
|
||||
|
||||
**Type**: `string`ч
|
||||
|
||||
Nuxt version in semver format. Versions may be defined in Node.js way, for exmaple: `>=2.15.0 <3.0.0`.
|
||||
|
||||
- `bridge` (optional)
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
If set to `true`, it will check if the current Nuxt version supports `bridge`.
|
||||
|
||||
##### `nuxt`
|
||||
|
||||
**Type**: `Nuxt`
|
||||
|
||||
**Default**: `useNuxt()`
|
||||
|
||||
Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
||||
|
||||
### `assertNuxtCompatibility`
|
||||
|
||||
Asserts that constraints are met for the current Nuxt version. If not, throws an error with the list of issues as string.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
async function assertNuxtCompatibility(
|
||||
constraints: NuxtCompatibility,
|
||||
nuxt?: Nuxt
|
||||
): Promise<true>;
|
||||
|
||||
interface NuxtCompatibility {
|
||||
nuxt?: string;
|
||||
bridge?: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `constraints`
|
||||
|
||||
**Type**: `NuxtCompatibility`
|
||||
|
||||
**Default**: `{}`
|
||||
|
||||
Constraints to check for. It accepts the following properties:
|
||||
|
||||
- `nuxt` (optional)
|
||||
|
||||
**Type**: `string`ч
|
||||
|
||||
Nuxt version in semver format. Versions may be defined in Node.js way, for exmaple: `>=2.15.0 <3.0.0`.
|
||||
|
||||
- `bridge` (optional)
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
If set to `true`, it will check if the current Nuxt version supports `bridge`.
|
||||
|
||||
##### `nuxt`
|
||||
|
||||
**Type**: `Nuxt`
|
||||
|
||||
**Default**: `useNuxt()`
|
||||
|
||||
Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
||||
|
||||
### `hasNuxtCompatibility`
|
||||
|
||||
Checks if constraints are met for the current Nuxt version. Return `true` if all constraints are met, otherwise returns `false`. Nuxt 2 version also checks for `bridge` support.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
async function hasNuxtCompatibility(
|
||||
constraints: NuxtCompatibility,
|
||||
nuxt?: Nuxt
|
||||
): Promise<boolean>;
|
||||
|
||||
interface NuxtCompatibility {
|
||||
nuxt?: string;
|
||||
bridge?: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `constraints`
|
||||
|
||||
**Type**: `NuxtCompatibility`
|
||||
|
||||
**Default**: `{}`
|
||||
|
||||
Constraints to check for. It accepts the following properties:
|
||||
|
||||
- `nuxt` (optional)
|
||||
|
||||
**Type**: `string`ч
|
||||
|
||||
Nuxt version in semver format. Versions may be defined in Node.js way, for exmaple: `>=2.15.0 <3.0.0`.
|
||||
|
||||
- `bridge` (optional)
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
If set to `true`, it will check if the current Nuxt version supports `bridge`.
|
||||
|
||||
##### `nuxt`
|
||||
|
||||
**Type**: `Nuxt`
|
||||
|
||||
**Default**: `useNuxt()`
|
||||
|
||||
Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
||||
|
||||
### `isNuxt2`
|
||||
|
||||
Checks if the current Nuxt version is 2.x.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
function isNuxt2(nuxt?: Nuxt): boolean;
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `nuxt`
|
||||
|
||||
**Type**: `Nuxt`
|
||||
|
||||
**Default**: `useNuxt()`
|
||||
|
||||
Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
||||
|
||||
### `isNuxt3`
|
||||
|
||||
Checks if the current Nuxt version is 3.x.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
function isNuxt3(nuxt?: Nuxt): boolean;
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `nuxt`
|
||||
|
||||
**Type**: `Nuxt`
|
||||
|
||||
**Default**: `useNuxt()`
|
||||
|
||||
Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
||||
|
||||
### `getNuxtVersion`
|
||||
|
||||
Returns the current Nuxt version.
|
||||
|
||||
#### Type
|
||||
|
||||
```ts
|
||||
function getNuxtVersion(nuxt?: Nuxt): string;
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
##### `nuxt`
|
||||
|
||||
**Type**: `Nuxt`
|
||||
|
||||
**Default**: `useNuxt()`
|
||||
|
||||
Nuxt instance. If not provided, it will be retrieved from the context via `useNuxt()` call.
|
||||
|
||||
## Auto-imports
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user