@nuxt/kit 3.19.3 → 3.20.1
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 +4 -4
- package/dist/index.d.mts +26 -6
- package/dist/index.d.ts +26 -6
- package/dist/index.mjs +154 -75
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
[](https://nuxt.com)
|
|
2
2
|
|
|
3
3
|
# Nuxt
|
|
4
4
|
|
|
5
5
|
<p>
|
|
6
6
|
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
|
|
8
|
-
<a href="https://github.com/nuxt/nuxt/
|
|
8
|
+
<a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
|
|
9
9
|
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
|
|
10
10
|
<a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
|
|
11
11
|
<a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
|
|
@@ -109,9 +109,9 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
|
|
|
109
109
|
## <a name="follow-us">🔗 Follow Us</a>
|
|
110
110
|
|
|
111
111
|
<p valign="center">
|
|
112
|
-
<a href="https://go.nuxt.com/discord"><img width="20px" src="https://github.com/nuxt/nuxt/
|
|
112
|
+
<a href="https://go.nuxt.com/discord"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/discord.svg" alt="Discord"></a> <a href="https://go.nuxt.com/x"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/twitter.svg" alt="Twitter"></a> <a href="https://go.nuxt.com/github"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/github.svg" alt="GitHub"></a> <a href="https://go.nuxt.com/bluesky"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/bluesky.svg" alt="Bluesky"></a>
|
|
113
113
|
</p>
|
|
114
114
|
|
|
115
115
|
## <a name="license">⚖️ License</a>
|
|
116
116
|
|
|
117
|
-
[MIT](https://github.com/nuxt/nuxt/
|
|
117
|
+
[MIT](https://github.com/nuxt/nuxt/blob/main/LICENSE)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition,
|
|
2
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
3
3
|
import { LoadConfigOptions } from 'c12';
|
|
4
|
-
import { Import } from 'unimport';
|
|
4
|
+
import { Import, InlinePreset } from 'unimport';
|
|
5
5
|
import { WebpackPluginInstance, Configuration } from 'webpack';
|
|
6
6
|
import { RspackPluginInstance } from '@rspack/core';
|
|
7
7
|
import { Plugin, UserConfig } from 'vite';
|
|
@@ -118,11 +118,13 @@ 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;
|
|
124
126
|
}): void;
|
|
125
|
-
declare function addImportsSources(presets:
|
|
127
|
+
declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
|
|
126
128
|
|
|
127
129
|
/**
|
|
128
130
|
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
@@ -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[];
|
|
@@ -508,6 +526,8 @@ interface ResolveModuleOptions {
|
|
|
508
526
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
509
527
|
paths?: string | string[];
|
|
510
528
|
url?: URL | URL[];
|
|
529
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
530
|
+
extensions?: string[];
|
|
511
531
|
}
|
|
512
532
|
declare function directoryToURL(dir: string): URL;
|
|
513
533
|
/**
|
|
@@ -546,5 +566,5 @@ declare const templateUtils: {
|
|
|
546
566
|
}) => string;
|
|
547
567
|
};
|
|
548
568
|
|
|
549
|
-
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 };
|
|
550
570
|
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition,
|
|
2
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
3
3
|
import { LoadConfigOptions } from 'c12';
|
|
4
|
-
import { Import } from 'unimport';
|
|
4
|
+
import { Import, InlinePreset } from 'unimport';
|
|
5
5
|
import { WebpackPluginInstance, Configuration } from 'webpack';
|
|
6
6
|
import { RspackPluginInstance } from '@rspack/core';
|
|
7
7
|
import { Plugin, UserConfig } from 'vite';
|
|
@@ -118,11 +118,13 @@ 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;
|
|
124
126
|
}): void;
|
|
125
|
-
declare function addImportsSources(presets:
|
|
127
|
+
declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
|
|
126
128
|
|
|
127
129
|
/**
|
|
128
130
|
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
@@ -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[];
|
|
@@ -508,6 +526,8 @@ interface ResolveModuleOptions {
|
|
|
508
526
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
509
527
|
paths?: string | string[];
|
|
510
528
|
url?: URL | URL[];
|
|
529
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
530
|
+
extensions?: string[];
|
|
511
531
|
}
|
|
512
532
|
declare function directoryToURL(dir: string): URL;
|
|
513
533
|
/**
|
|
@@ -546,5 +566,5 @@ declare const templateUtils: {
|
|
|
546
566
|
}) => string;
|
|
547
567
|
};
|
|
548
568
|
|
|
549
|
-
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 };
|
|
550
570
|
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
|
package/dist/index.mjs
CHANGED
|
@@ -9,23 +9,23 @@ 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';
|
|
20
|
+
import process from 'node:process';
|
|
19
21
|
import { glob } from 'tinyglobby';
|
|
20
22
|
import { resolveAlias as resolveAlias$1, reverseResolveAlias } from 'pathe/utils';
|
|
21
23
|
import ignore from 'ignore';
|
|
22
24
|
import { loadConfig } from 'c12';
|
|
23
|
-
import process$1 from 'node:process';
|
|
24
25
|
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) => {
|
|
@@ -3069,7 +3113,7 @@ function useRuntimeConfig() {
|
|
|
3069
3113
|
return applyEnv(klona(nuxt.options.nitro.runtimeConfig), {
|
|
3070
3114
|
prefix: "NITRO_",
|
|
3071
3115
|
altPrefix: "NUXT_",
|
|
3072
|
-
envExpansion: nuxt.options.nitro.experimental?.envExpansion ?? !!process
|
|
3116
|
+
envExpansion: nuxt.options.nitro.experimental?.envExpansion ?? !!process.env.NITRO_ENV_EXPANSION
|
|
3073
3117
|
});
|
|
3074
3118
|
}
|
|
3075
3119
|
function updateRuntimeConfig(runtimeConfig) {
|
|
@@ -3080,7 +3124,7 @@ function updateRuntimeConfig(runtimeConfig) {
|
|
|
3080
3124
|
} catch {
|
|
3081
3125
|
}
|
|
3082
3126
|
}
|
|
3083
|
-
function getEnv(key, opts, env = process
|
|
3127
|
+
function getEnv(key, opts, env = process.env) {
|
|
3084
3128
|
const envKey = snakeCase(key).toUpperCase();
|
|
3085
3129
|
return destr(
|
|
3086
3130
|
env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey]
|
|
@@ -3112,7 +3156,7 @@ function applyEnv(obj, opts, parentKey = "") {
|
|
|
3112
3156
|
return obj;
|
|
3113
3157
|
}
|
|
3114
3158
|
const envExpandRx = /\{\{([^{}]*)\}\}/g;
|
|
3115
|
-
function _expandFromEnv(value, env = process
|
|
3159
|
+
function _expandFromEnv(value, env = process.env) {
|
|
3116
3160
|
return value.replace(envExpandRx, (match, key) => {
|
|
3117
3161
|
return env[key] || match;
|
|
3118
3162
|
});
|
|
@@ -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.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"c12": "^3.3.
|
|
26
|
+
"c12": "^3.3.1",
|
|
27
27
|
"consola": "^3.4.2",
|
|
28
28
|
"defu": "^6.1.4",
|
|
29
29
|
"destr": "^2.0.5",
|
|
@@ -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.4.1",
|
|
48
46
|
"untyped": "^2.0.0"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
|
-
"@rspack/core": "1.
|
|
49
|
+
"@rspack/core": "1.6.1",
|
|
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.9",
|
|
57
55
|
"unbuild": "3.6.1",
|
|
58
|
-
"
|
|
56
|
+
"unimport": "5.5.0",
|
|
57
|
+
"vite": "7.2.1",
|
|
59
58
|
"vitest": "3.2.4",
|
|
60
|
-
"webpack": "5.102.
|
|
61
|
-
"@nuxt/schema": "3.
|
|
59
|
+
"webpack": "5.102.1",
|
|
60
|
+
"@nuxt/schema": "3.20.1"
|
|
62
61
|
},
|
|
63
62
|
"engines": {
|
|
64
63
|
"node": ">=18.12.0"
|