@nuxt/kit 3.19.2 → 3.20.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.mts +27 -4
- package/dist/index.d.ts +27 -4
- package/dist/index.mjs +150 -71
- package/package.json +10 -11
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
2
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
3
3
|
import { LoadConfigOptions } from 'c12';
|
|
4
4
|
import { Import } from 'unimport';
|
|
5
5
|
import { WebpackPluginInstance, Configuration } from 'webpack';
|
|
@@ -118,6 +118,8 @@ interface LayerDirectories {
|
|
|
118
118
|
*/
|
|
119
119
|
declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
|
|
120
120
|
|
|
121
|
+
declare function setGlobalHead(head: NuxtAppConfig['head']): void;
|
|
122
|
+
|
|
121
123
|
declare function addImports(imports: Import | Import[]): void;
|
|
122
124
|
declare function addImportsDir(dirs: string | string[], opts?: {
|
|
123
125
|
prepend?: boolean;
|
|
@@ -163,7 +165,23 @@ interface ExtendConfigOptions {
|
|
|
163
165
|
}
|
|
164
166
|
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
|
165
167
|
}
|
|
166
|
-
interface ExtendViteConfigOptions extends ExtendConfigOptions {
|
|
168
|
+
interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | 'client'> {
|
|
169
|
+
/**
|
|
170
|
+
* Extend server Vite configuration
|
|
171
|
+
* @default true
|
|
172
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
173
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
174
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
175
|
+
*/
|
|
176
|
+
server?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Extend client Vite configuration
|
|
179
|
+
* @default true
|
|
180
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
181
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
182
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
183
|
+
*/
|
|
184
|
+
client?: boolean;
|
|
167
185
|
}
|
|
168
186
|
/**
|
|
169
187
|
* Extend webpack config
|
|
@@ -194,7 +212,7 @@ declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPl
|
|
|
194
212
|
/**
|
|
195
213
|
* Append Vite plugin to the config.
|
|
196
214
|
*/
|
|
197
|
-
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?:
|
|
215
|
+
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
|
|
198
216
|
interface AddBuildPluginFactory {
|
|
199
217
|
vite?: () => Plugin | Plugin[];
|
|
200
218
|
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
|
|
@@ -407,6 +425,9 @@ type PathType = 'file' | 'dir';
|
|
|
407
425
|
* @param path path to the directory to resolve files in
|
|
408
426
|
* @param pattern glob pattern or an array of glob patterns to match files
|
|
409
427
|
* @param opts options for globbing
|
|
428
|
+
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
|
|
429
|
+
* @param opts.ignore additional glob patterns to ignore
|
|
430
|
+
* @returns sorted array of absolute file paths
|
|
410
431
|
*/
|
|
411
432
|
declare function resolveFiles(path: string, pattern: string | string[], opts?: {
|
|
412
433
|
followSymbolicLinks?: boolean;
|
|
@@ -505,6 +526,8 @@ interface ResolveModuleOptions {
|
|
|
505
526
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
506
527
|
paths?: string | string[];
|
|
507
528
|
url?: URL | URL[];
|
|
529
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
530
|
+
extensions?: string[];
|
|
508
531
|
}
|
|
509
532
|
declare function directoryToURL(dir: string): URL;
|
|
510
533
|
/**
|
|
@@ -543,5 +566,5 @@ declare const templateUtils: {
|
|
|
543
566
|
}) => string;
|
|
544
567
|
};
|
|
545
568
|
|
|
546
|
-
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
569
|
+
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
547
570
|
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
2
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
3
3
|
import { LoadConfigOptions } from 'c12';
|
|
4
4
|
import { Import } from 'unimport';
|
|
5
5
|
import { WebpackPluginInstance, Configuration } from 'webpack';
|
|
@@ -118,6 +118,8 @@ interface LayerDirectories {
|
|
|
118
118
|
*/
|
|
119
119
|
declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
|
|
120
120
|
|
|
121
|
+
declare function setGlobalHead(head: NuxtAppConfig['head']): void;
|
|
122
|
+
|
|
121
123
|
declare function addImports(imports: Import | Import[]): void;
|
|
122
124
|
declare function addImportsDir(dirs: string | string[], opts?: {
|
|
123
125
|
prepend?: boolean;
|
|
@@ -163,7 +165,23 @@ interface ExtendConfigOptions {
|
|
|
163
165
|
}
|
|
164
166
|
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
|
165
167
|
}
|
|
166
|
-
interface ExtendViteConfigOptions extends ExtendConfigOptions {
|
|
168
|
+
interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | 'client'> {
|
|
169
|
+
/**
|
|
170
|
+
* Extend server Vite configuration
|
|
171
|
+
* @default true
|
|
172
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
173
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
174
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
175
|
+
*/
|
|
176
|
+
server?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Extend client Vite configuration
|
|
179
|
+
* @default true
|
|
180
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
181
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
182
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
183
|
+
*/
|
|
184
|
+
client?: boolean;
|
|
167
185
|
}
|
|
168
186
|
/**
|
|
169
187
|
* Extend webpack config
|
|
@@ -194,7 +212,7 @@ declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPl
|
|
|
194
212
|
/**
|
|
195
213
|
* Append Vite plugin to the config.
|
|
196
214
|
*/
|
|
197
|
-
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?:
|
|
215
|
+
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
|
|
198
216
|
interface AddBuildPluginFactory {
|
|
199
217
|
vite?: () => Plugin | Plugin[];
|
|
200
218
|
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
|
|
@@ -407,6 +425,9 @@ type PathType = 'file' | 'dir';
|
|
|
407
425
|
* @param path path to the directory to resolve files in
|
|
408
426
|
* @param pattern glob pattern or an array of glob patterns to match files
|
|
409
427
|
* @param opts options for globbing
|
|
428
|
+
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
|
|
429
|
+
* @param opts.ignore additional glob patterns to ignore
|
|
430
|
+
* @returns sorted array of absolute file paths
|
|
410
431
|
*/
|
|
411
432
|
declare function resolveFiles(path: string, pattern: string | string[], opts?: {
|
|
412
433
|
followSymbolicLinks?: boolean;
|
|
@@ -505,6 +526,8 @@ interface ResolveModuleOptions {
|
|
|
505
526
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
506
527
|
paths?: string | string[];
|
|
507
528
|
url?: URL | URL[];
|
|
529
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
530
|
+
extensions?: string[];
|
|
508
531
|
}
|
|
509
532
|
declare function directoryToURL(dir: string): URL;
|
|
510
533
|
/**
|
|
@@ -543,5 +566,5 @@ declare const templateUtils: {
|
|
|
543
566
|
}) => string;
|
|
544
567
|
};
|
|
545
568
|
|
|
546
|
-
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
569
|
+
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
547
570
|
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
|
package/dist/index.mjs
CHANGED
|
@@ -9,13 +9,14 @@ import { getContext, createContext } from 'unctx';
|
|
|
9
9
|
import satisfies from 'semver/functions/satisfies.js';
|
|
10
10
|
import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
|
|
11
11
|
import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork';
|
|
12
|
-
import {
|
|
12
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
13
13
|
import { createJiti } from 'jiti';
|
|
14
|
-
import {
|
|
14
|
+
import { parseNodeModulePath, interopDefault, resolveModuleExportNames } from 'mlly';
|
|
15
15
|
import { resolveModulePath, resolveModuleURL } from 'exsolve';
|
|
16
16
|
import { isRelative, withTrailingSlash as withTrailingSlash$2 } from 'ufo';
|
|
17
17
|
import { read, update } from 'rc9';
|
|
18
18
|
import semver, { gte } from 'semver';
|
|
19
|
+
import { captureStackTrace } from 'errx';
|
|
19
20
|
import { glob } from 'tinyglobby';
|
|
20
21
|
import { resolveAlias as resolveAlias$1, reverseResolveAlias } from 'pathe/utils';
|
|
21
22
|
import ignore from 'ignore';
|
|
@@ -25,7 +26,6 @@ import destr from 'destr';
|
|
|
25
26
|
import { snakeCase, pascalCase, kebabCase } from 'scule';
|
|
26
27
|
import { klona } from 'klona';
|
|
27
28
|
import { hash } from 'ohash';
|
|
28
|
-
import { captureStackTrace } from 'errx';
|
|
29
29
|
import { isAbsolute as isAbsolute$1 } from 'node:path';
|
|
30
30
|
|
|
31
31
|
const logger = consola;
|
|
@@ -2239,49 +2239,26 @@ function nuxt2Shims(nuxt) {
|
|
|
2239
2239
|
});
|
|
2240
2240
|
}
|
|
2241
2241
|
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
return Promise.resolve(resolveModulePath(id, {
|
|
2247
|
-
from: url,
|
|
2248
|
-
suffixes: ["", "index"],
|
|
2249
|
-
try: true
|
|
2250
|
-
}));
|
|
2251
|
-
}
|
|
2252
|
-
function resolveModule(id, options) {
|
|
2253
|
-
return resolveModulePath(id, {
|
|
2254
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
2255
|
-
from: options?.url ?? options?.paths ?? [import.meta.url],
|
|
2256
|
-
extensions: [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
async function importModule(id, opts) {
|
|
2260
|
-
const resolvedPath = resolveModule(id, opts);
|
|
2261
|
-
return await import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
|
|
2262
|
-
}
|
|
2263
|
-
function tryImportModule(id, opts) {
|
|
2264
|
-
try {
|
|
2265
|
-
return importModule(id, opts).catch(() => void 0);
|
|
2266
|
-
} catch {
|
|
2242
|
+
const distURL = import.meta.url.replace(/\/dist\/.*$/, "/");
|
|
2243
|
+
function getUserCaller() {
|
|
2244
|
+
if (!import.meta.dev) {
|
|
2245
|
+
return null;
|
|
2267
2246
|
}
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
if (!warnings.has(id)) {
|
|
2272
|
-
console.warn("[@nuxt/kit] `requireModule` is deprecated. Please use `importModule` instead.");
|
|
2273
|
-
warnings.add(id);
|
|
2247
|
+
const { source, line, column } = captureStackTrace().find((entry) => !entry.source.startsWith(distURL)) ?? {};
|
|
2248
|
+
if (!source) {
|
|
2249
|
+
return null;
|
|
2274
2250
|
}
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2251
|
+
return {
|
|
2252
|
+
source: source.replace(/^file:\/\//, ""),
|
|
2253
|
+
line,
|
|
2254
|
+
column
|
|
2255
|
+
};
|
|
2280
2256
|
}
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2257
|
+
const warnings = /* @__PURE__ */ new Set();
|
|
2258
|
+
function warn(warning) {
|
|
2259
|
+
if (!warnings.has(warning)) {
|
|
2260
|
+
console.warn(warning);
|
|
2261
|
+
warnings.add(warning);
|
|
2285
2262
|
}
|
|
2286
2263
|
}
|
|
2287
2264
|
|
|
@@ -2542,6 +2519,51 @@ async function resolveFiles(path, pattern, opts = {}) {
|
|
|
2542
2519
|
return files.sort();
|
|
2543
2520
|
}
|
|
2544
2521
|
|
|
2522
|
+
function directoryToURL(dir) {
|
|
2523
|
+
return pathToFileURL(dir + "/");
|
|
2524
|
+
}
|
|
2525
|
+
function tryResolveModule(id, url = import.meta.url) {
|
|
2526
|
+
return Promise.resolve(resolveModulePath(id, {
|
|
2527
|
+
from: url,
|
|
2528
|
+
suffixes: ["", "index"],
|
|
2529
|
+
try: true
|
|
2530
|
+
}));
|
|
2531
|
+
}
|
|
2532
|
+
function resolveModule(id, options) {
|
|
2533
|
+
return resolveModulePath(id, {
|
|
2534
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
2535
|
+
from: options?.url ?? options?.paths ?? [import.meta.url],
|
|
2536
|
+
extensions: options?.extensions ?? [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
async function importModule(id, opts) {
|
|
2540
|
+
const resolvedPath = resolveModule(id, opts);
|
|
2541
|
+
return await import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
|
|
2542
|
+
}
|
|
2543
|
+
function tryImportModule(id, opts) {
|
|
2544
|
+
try {
|
|
2545
|
+
return importModule(id, opts).catch(() => void 0);
|
|
2546
|
+
} catch {
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
function requireModule(id, opts) {
|
|
2550
|
+
const caller = getUserCaller();
|
|
2551
|
+
const explanation = caller ? ` (used at \`${resolveAlias(caller.source)}:${caller.line}:${caller.column}\`)` : "";
|
|
2552
|
+
const warning = `[@nuxt/kit] \`requireModule\` is deprecated${explanation}. Please use \`importModule\` instead.`;
|
|
2553
|
+
warn(warning);
|
|
2554
|
+
const resolvedPath = resolveModule(id, opts);
|
|
2555
|
+
const jiti = createJiti(import.meta.url, {
|
|
2556
|
+
interopDefault: opts?.interopDefault !== false
|
|
2557
|
+
});
|
|
2558
|
+
return jiti(pathToFileURL(resolvedPath).href);
|
|
2559
|
+
}
|
|
2560
|
+
function tryRequireModule(id, opts) {
|
|
2561
|
+
try {
|
|
2562
|
+
return requireModule(id, opts);
|
|
2563
|
+
} catch {
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2545
2567
|
const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
|
|
2546
2568
|
async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useNuxt()) {
|
|
2547
2569
|
const localLayerModuleDirs = [];
|
|
@@ -2838,17 +2860,17 @@ async function loadNuxtConfig(opts) {
|
|
|
2838
2860
|
cwd: opts.cwd || process.cwd()
|
|
2839
2861
|
})).map((d) => d.endsWith("/") ? d.substring(0, d.length - 1) : d).sort((a, b) => b.localeCompare(a));
|
|
2840
2862
|
opts.overrides = defu$1(opts.overrides, { _extends: localLayers });
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2863
|
+
const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await withDefineNuxtConfig(
|
|
2864
|
+
() => loadConfig({
|
|
2865
|
+
name: "nuxt",
|
|
2866
|
+
configFile: "nuxt.config",
|
|
2867
|
+
rcFile: ".nuxtrc",
|
|
2868
|
+
extend: { extendKey: ["theme", "_extends", "extends"] },
|
|
2869
|
+
dotenv: true,
|
|
2870
|
+
globalRc: true,
|
|
2871
|
+
...opts
|
|
2872
|
+
})
|
|
2873
|
+
);
|
|
2852
2874
|
nuxtConfig.rootDir ||= cwd;
|
|
2853
2875
|
nuxtConfig._nuxtConfigFile = configFile;
|
|
2854
2876
|
nuxtConfig._nuxtConfigFiles = [configFile];
|
|
@@ -2916,6 +2938,23 @@ async function loadNuxtSchema(cwd) {
|
|
|
2916
2938
|
const schemaPath = resolveModuleURL("@nuxt/schema", { try: true, from: urls }) ?? "@nuxt/schema";
|
|
2917
2939
|
return await import(schemaPath).then((r) => r.NuxtConfigSchema);
|
|
2918
2940
|
}
|
|
2941
|
+
async function withDefineNuxtConfig(fn) {
|
|
2942
|
+
const key = "defineNuxtConfig";
|
|
2943
|
+
const globalSelf = globalThis;
|
|
2944
|
+
if (!globalSelf[key]) {
|
|
2945
|
+
globalSelf[key] = (c) => c;
|
|
2946
|
+
globalSelf[key].count = 0;
|
|
2947
|
+
}
|
|
2948
|
+
globalSelf[key].count++;
|
|
2949
|
+
try {
|
|
2950
|
+
return await fn();
|
|
2951
|
+
} finally {
|
|
2952
|
+
globalSelf[key].count--;
|
|
2953
|
+
if (!globalSelf[key].count) {
|
|
2954
|
+
delete globalSelf[key];
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2919
2958
|
|
|
2920
2959
|
function extendNuxtSchema(def) {
|
|
2921
2960
|
const nuxt = useNuxt();
|
|
@@ -2974,6 +3013,11 @@ async function buildNuxt(nuxt) {
|
|
|
2974
3013
|
return runWithNuxtContext(nuxt, () => build(nuxt));
|
|
2975
3014
|
}
|
|
2976
3015
|
|
|
3016
|
+
function setGlobalHead(head) {
|
|
3017
|
+
const nuxt = useNuxt();
|
|
3018
|
+
nuxt.options.app.head = defu(head, nuxt.options.app.head);
|
|
3019
|
+
}
|
|
3020
|
+
|
|
2977
3021
|
function addImports(imports) {
|
|
2978
3022
|
assertNuxtCompatibility({ bridge: true });
|
|
2979
3023
|
useNuxt().hook("imports:extend", (_imports) => {
|
|
@@ -3151,17 +3195,13 @@ function extendViteConfig(fn, options = {}) {
|
|
|
3151
3195
|
if (options.build === false && nuxt.options.build) {
|
|
3152
3196
|
return;
|
|
3153
3197
|
}
|
|
3154
|
-
if (options.server
|
|
3155
|
-
|
|
3198
|
+
if (options.server === false || options.client === false) {
|
|
3199
|
+
const caller = getUserCaller();
|
|
3200
|
+
const explanation = caller ? ` (used at \`${resolveAlias(caller.source)}:${caller.line}:${caller.column}\`)` : "";
|
|
3201
|
+
const warning = `[@nuxt/kit] calling \`extendViteConfig\` with only server/client environment is deprecated${explanation}. Nuxt 5+ will use the Vite Environment API which shares a configuration between environments. You can likely use a Vite plugin to achieve the same result.`;
|
|
3202
|
+
warn(warning);
|
|
3156
3203
|
}
|
|
3157
|
-
nuxt.hook("vite:
|
|
3158
|
-
if (options.server !== false && isServer) {
|
|
3159
|
-
return fn(config);
|
|
3160
|
-
}
|
|
3161
|
-
if (options.client !== false && isClient) {
|
|
3162
|
-
return fn(config);
|
|
3163
|
-
}
|
|
3164
|
-
});
|
|
3204
|
+
return nuxt.hook("vite:extend", ({ config }) => fn(config));
|
|
3165
3205
|
}
|
|
3166
3206
|
function addWebpackPlugin(pluginOrGetter, options) {
|
|
3167
3207
|
extendWebpackConfig((config) => {
|
|
@@ -3179,13 +3219,52 @@ function addRspackPlugin(pluginOrGetter, options) {
|
|
|
3179
3219
|
config.plugins[method](...toArray(plugin));
|
|
3180
3220
|
}, options);
|
|
3181
3221
|
}
|
|
3182
|
-
function addVitePlugin(pluginOrGetter, options) {
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3222
|
+
function addVitePlugin(pluginOrGetter, options = {}) {
|
|
3223
|
+
const nuxt = useNuxt();
|
|
3224
|
+
if (options.dev === false && nuxt.options.dev) {
|
|
3225
|
+
return;
|
|
3226
|
+
}
|
|
3227
|
+
if (options.build === false && nuxt.options.build) {
|
|
3228
|
+
return;
|
|
3229
|
+
}
|
|
3230
|
+
let needsEnvInjection = false;
|
|
3231
|
+
nuxt.hook("vite:extend", ({ config }) => {
|
|
3186
3232
|
config.plugins ||= [];
|
|
3187
|
-
|
|
3188
|
-
|
|
3233
|
+
const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
|
|
3234
|
+
if (options.server !== false && options.client !== false) {
|
|
3235
|
+
const method = options?.prepend ? "unshift" : "push";
|
|
3236
|
+
config.plugins[method](...plugin);
|
|
3237
|
+
return;
|
|
3238
|
+
}
|
|
3239
|
+
if (!config.environments?.ssr || !config.environments.client) {
|
|
3240
|
+
needsEnvInjection = true;
|
|
3241
|
+
return;
|
|
3242
|
+
}
|
|
3243
|
+
const environmentName = options.server === false ? "client" : "ssr";
|
|
3244
|
+
const pluginName = plugin.map((p) => p.name).join("|");
|
|
3245
|
+
config.plugins.push({
|
|
3246
|
+
name: `${pluginName}:wrapper`,
|
|
3247
|
+
enforce: options?.prepend ? "pre" : "post",
|
|
3248
|
+
applyToEnvironment(environment) {
|
|
3249
|
+
if (environment.name === environmentName) {
|
|
3250
|
+
return plugin;
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
});
|
|
3254
|
+
});
|
|
3255
|
+
nuxt.hook("vite:extendConfig", (config, env) => {
|
|
3256
|
+
if (!needsEnvInjection) {
|
|
3257
|
+
return;
|
|
3258
|
+
}
|
|
3259
|
+
const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
|
|
3260
|
+
const method = options?.prepend ? "unshift" : "push";
|
|
3261
|
+
if (env.isClient && options.server === false) {
|
|
3262
|
+
config.plugins[method](...plugin);
|
|
3263
|
+
}
|
|
3264
|
+
if (env.isServer && options.client === false) {
|
|
3265
|
+
config.plugins[method](...plugin);
|
|
3266
|
+
}
|
|
3267
|
+
});
|
|
3189
3268
|
}
|
|
3190
3269
|
function addBuildPlugin(pluginFactory, options) {
|
|
3191
3270
|
if (pluginFactory.vite) {
|
|
@@ -3718,4 +3797,4 @@ function addPluginTemplate(plugin, opts = {}) {
|
|
|
3718
3797
|
return addPlugin(normalizedPlugin, opts);
|
|
3719
3798
|
}
|
|
3720
3799
|
|
|
3721
|
-
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
3800
|
+
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"c12": "^3.
|
|
26
|
+
"c12": "^3.3.0",
|
|
27
27
|
"consola": "^3.4.2",
|
|
28
28
|
"defu": "^6.1.4",
|
|
29
29
|
"destr": "^2.0.5",
|
|
30
30
|
"errx": "^0.1.0",
|
|
31
31
|
"exsolve": "^1.0.7",
|
|
32
32
|
"ignore": "^7.0.5",
|
|
33
|
-
"jiti": "^2.
|
|
33
|
+
"jiti": "^2.6.1",
|
|
34
34
|
"klona": "^2.0.6",
|
|
35
35
|
"knitwork": "^1.2.0",
|
|
36
36
|
"mlly": "^1.8.0",
|
|
@@ -39,26 +39,25 @@
|
|
|
39
39
|
"pkg-types": "^2.3.0",
|
|
40
40
|
"rc9": "^2.1.2",
|
|
41
41
|
"scule": "^1.3.0",
|
|
42
|
-
"semver": "^7.7.
|
|
43
|
-
"std-env": "^3.9.0",
|
|
42
|
+
"semver": "^7.7.3",
|
|
44
43
|
"tinyglobby": "^0.2.15",
|
|
45
44
|
"ufo": "^1.6.1",
|
|
46
45
|
"unctx": "^2.4.1",
|
|
47
|
-
"unimport": "^5.2.0",
|
|
48
46
|
"untyped": "^2.0.0"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
|
-
"@rspack/core": "1.5.
|
|
49
|
+
"@rspack/core": "1.5.8",
|
|
52
50
|
"@types/lodash-es": "4.17.12",
|
|
53
51
|
"@types/semver": "7.7.1",
|
|
54
52
|
"hookable": "5.5.3",
|
|
55
53
|
"lodash-es": "4.17.21",
|
|
56
|
-
"nitropack": "2.12.
|
|
54
|
+
"nitropack": "2.12.8",
|
|
57
55
|
"unbuild": "3.6.1",
|
|
58
|
-
"
|
|
56
|
+
"unimport": "5.4.1",
|
|
57
|
+
"vite": "7.1.9",
|
|
59
58
|
"vitest": "3.2.4",
|
|
60
|
-
"webpack": "5.
|
|
61
|
-
"@nuxt/schema": "3.
|
|
59
|
+
"webpack": "5.102.1",
|
|
60
|
+
"@nuxt/schema": "3.20.0"
|
|
62
61
|
},
|
|
63
62
|
"engines": {
|
|
64
63
|
"node": ">=18.12.0"
|