@nuxt/kit 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.mjs +26 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
|
|
|
114
114
|
|
|
115
115
|
## Nuxt 2
|
|
116
116
|
|
|
117
|
-
You can find the code for Nuxt 2 on the [`2.x
|
|
117
|
+
You can find the code for Nuxt 2 on the [`2.x` branch](https://github.com/nuxt/nuxt/tree/2.x) and the documentation at [nuxtjs.org](https://nuxtjs.org).
|
|
118
118
|
|
|
119
119
|
## Follow us
|
|
120
120
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleOptions, ModuleDefinition, NuxtModule, Nuxt, NuxtConfig, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate } from '@nuxt/schema';
|
|
1
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, Nuxt, NuxtConfig, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtMiddleware, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate } from '@nuxt/schema';
|
|
2
2
|
import { LoadConfigOptions } from 'c12';
|
|
3
3
|
import { Import } from 'unimport';
|
|
4
4
|
import { Configuration, WebpackPluginInstance } from 'webpack';
|
|
@@ -177,6 +177,15 @@ interface ExtendRouteRulesOptions {
|
|
|
177
177
|
override?: boolean;
|
|
178
178
|
}
|
|
179
179
|
declare function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void;
|
|
180
|
+
interface AddRouteMiddlewareOptions {
|
|
181
|
+
/**
|
|
182
|
+
* Override existing middleware with the same name, if it exists
|
|
183
|
+
*
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
override?: boolean;
|
|
187
|
+
}
|
|
188
|
+
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
|
|
180
189
|
|
|
181
190
|
/**
|
|
182
191
|
* Normalize a nuxt plugin object
|
|
@@ -341,4 +350,4 @@ declare const templateUtils: {
|
|
|
341
350
|
}) => string;
|
|
342
351
|
};
|
|
343
352
|
|
|
344
|
-
export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
|
353
|
+
export { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises, existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import
|
|
2
|
+
import { defu } from 'defu';
|
|
3
3
|
import { applyDefaults } from 'untyped';
|
|
4
4
|
import { dirname, join, normalize, relative, isAbsolute, resolve, basename, parse } from 'pathe';
|
|
5
5
|
import consola from 'consola';
|
|
@@ -147,7 +147,7 @@ function defineNuxtModule(definition) {
|
|
|
147
147
|
if (uniqueKey) {
|
|
148
148
|
nuxt.options._requiredModules = nuxt.options._requiredModules || {};
|
|
149
149
|
if (nuxt.options._requiredModules[uniqueKey]) {
|
|
150
|
-
return;
|
|
150
|
+
return false;
|
|
151
151
|
}
|
|
152
152
|
nuxt.options._requiredModules[uniqueKey] = true;
|
|
153
153
|
}
|
|
@@ -432,7 +432,10 @@ async function resolveFiles(path, pattern, opts = {}) {
|
|
|
432
432
|
async function installModule(moduleToInstall, _inlineOptions, _nuxt) {
|
|
433
433
|
const nuxt = useNuxt();
|
|
434
434
|
const { nuxtModule, inlineOptions } = await normalizeModule(moduleToInstall, _inlineOptions);
|
|
435
|
-
await nuxtModule(inlineOptions, nuxt);
|
|
435
|
+
const res = await nuxtModule(inlineOptions, nuxt);
|
|
436
|
+
if (res === false) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
436
439
|
if (typeof moduleToInstall === "string") {
|
|
437
440
|
nuxt.options.build.transpile.push(moduleToInstall);
|
|
438
441
|
}
|
|
@@ -752,9 +755,27 @@ function extendRouteRules(route, rule, options = {}) {
|
|
|
752
755
|
if (!opts.routeRules) {
|
|
753
756
|
opts.routeRules = {};
|
|
754
757
|
}
|
|
755
|
-
opts.routeRules[route] = options.override ? defu
|
|
758
|
+
opts.routeRules[route] = options.override ? defu(rule, opts.routeRules[route]) : defu(opts.routeRules[route], rule);
|
|
756
759
|
}
|
|
757
760
|
}
|
|
761
|
+
function addRouteMiddleware(input, options = {}) {
|
|
762
|
+
const nuxt = useNuxt();
|
|
763
|
+
const middlewares = Array.isArray(input) ? input : [input];
|
|
764
|
+
nuxt.hook("app:resolve", (app) => {
|
|
765
|
+
for (const middleware of middlewares) {
|
|
766
|
+
const find = app.middleware.findIndex((item) => item.name === middleware.name);
|
|
767
|
+
if (find >= 0) {
|
|
768
|
+
if (options.override === true) {
|
|
769
|
+
app.middleware[find] = middleware;
|
|
770
|
+
} else {
|
|
771
|
+
console.warn(`'${middleware.name}' middleware already exists at '${app.middleware[find].path}'. You can set \`override: true\` to replace it.`);
|
|
772
|
+
}
|
|
773
|
+
} else {
|
|
774
|
+
app.middleware.push(middleware);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
}
|
|
758
779
|
|
|
759
780
|
function normalizePlugin(plugin) {
|
|
760
781
|
if (typeof plugin === "string") {
|
|
@@ -829,4 +850,4 @@ function useNitro() {
|
|
|
829
850
|
return nuxt._nitro;
|
|
830
851
|
}
|
|
831
852
|
|
|
832
|
-
export { addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
|
853
|
+
export { addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"repository": "nuxt/nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nuxt/schema": "3.
|
|
13
|
+
"@nuxt/schema": "3.2.0",
|
|
14
14
|
"c12": "^1.1.0",
|
|
15
15
|
"consola": "^2.15.3",
|
|
16
16
|
"defu": "^6.1.2",
|
|
17
17
|
"globby": "^13.1.3",
|
|
18
18
|
"hash-sum": "^2.0.0",
|
|
19
19
|
"ignore": "^5.2.4",
|
|
20
|
-
"jiti": "^1.
|
|
20
|
+
"jiti": "^1.17.0",
|
|
21
21
|
"knitwork": "^1.0.0",
|
|
22
22
|
"lodash.template": "^4.5.0",
|
|
23
23
|
"mlly": "^1.1.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"scule": "^1.0.0",
|
|
27
27
|
"semver": "^7.3.8",
|
|
28
28
|
"unctx": "^2.1.1",
|
|
29
|
-
"unimport": "^2.
|
|
29
|
+
"unimport": "^2.2.4",
|
|
30
30
|
"untyped": "^1.2.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|