@nuxt/kit 4.1.3 → 4.2.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 +152 -77
- 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';
|
|
@@ -113,11 +113,13 @@ interface LayerDirectories {
|
|
|
113
113
|
*/
|
|
114
114
|
declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
|
|
115
115
|
|
|
116
|
+
declare function setGlobalHead(head: NuxtAppConfig['head']): void;
|
|
117
|
+
|
|
116
118
|
declare function addImports(imports: Import | Import[]): void;
|
|
117
119
|
declare function addImportsDir(dirs: string | string[], opts?: {
|
|
118
120
|
prepend?: boolean;
|
|
119
121
|
}): void;
|
|
120
|
-
declare function addImportsSources(presets:
|
|
122
|
+
declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
125
|
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
@@ -158,7 +160,23 @@ interface ExtendConfigOptions {
|
|
|
158
160
|
}
|
|
159
161
|
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
|
160
162
|
}
|
|
161
|
-
interface ExtendViteConfigOptions extends ExtendConfigOptions {
|
|
163
|
+
interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | 'client'> {
|
|
164
|
+
/**
|
|
165
|
+
* Extend server Vite configuration
|
|
166
|
+
* @default true
|
|
167
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
168
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
169
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
170
|
+
*/
|
|
171
|
+
server?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Extend client Vite configuration
|
|
174
|
+
* @default true
|
|
175
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
176
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
177
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
178
|
+
*/
|
|
179
|
+
client?: boolean;
|
|
162
180
|
}
|
|
163
181
|
/**
|
|
164
182
|
* Extend webpack config
|
|
@@ -189,7 +207,7 @@ declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPl
|
|
|
189
207
|
/**
|
|
190
208
|
* Append Vite plugin to the config.
|
|
191
209
|
*/
|
|
192
|
-
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?:
|
|
210
|
+
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
|
|
193
211
|
interface AddBuildPluginFactory {
|
|
194
212
|
vite?: () => Plugin | Plugin[];
|
|
195
213
|
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
|
|
@@ -501,6 +519,8 @@ interface ResolveModuleOptions {
|
|
|
501
519
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
502
520
|
paths?: string | string[];
|
|
503
521
|
url?: URL | URL[];
|
|
522
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
523
|
+
extensions?: string[];
|
|
504
524
|
}
|
|
505
525
|
declare function directoryToURL(dir: string): URL;
|
|
506
526
|
/**
|
|
@@ -528,5 +548,5 @@ declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptio
|
|
|
528
548
|
*/
|
|
529
549
|
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
|
|
530
550
|
|
|
531
|
-
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, 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, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
551
|
+
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, 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, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
532
552
|
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';
|
|
@@ -113,11 +113,13 @@ interface LayerDirectories {
|
|
|
113
113
|
*/
|
|
114
114
|
declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
|
|
115
115
|
|
|
116
|
+
declare function setGlobalHead(head: NuxtAppConfig['head']): void;
|
|
117
|
+
|
|
116
118
|
declare function addImports(imports: Import | Import[]): void;
|
|
117
119
|
declare function addImportsDir(dirs: string | string[], opts?: {
|
|
118
120
|
prepend?: boolean;
|
|
119
121
|
}): void;
|
|
120
|
-
declare function addImportsSources(presets:
|
|
122
|
+
declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
125
|
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
@@ -158,7 +160,23 @@ interface ExtendConfigOptions {
|
|
|
158
160
|
}
|
|
159
161
|
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
|
160
162
|
}
|
|
161
|
-
interface ExtendViteConfigOptions extends ExtendConfigOptions {
|
|
163
|
+
interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | 'client'> {
|
|
164
|
+
/**
|
|
165
|
+
* Extend server Vite configuration
|
|
166
|
+
* @default true
|
|
167
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
168
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
169
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
170
|
+
*/
|
|
171
|
+
server?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Extend client Vite configuration
|
|
174
|
+
* @default true
|
|
175
|
+
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
|
|
176
|
+
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
|
|
177
|
+
* You can likely use a Vite plugin to achieve the same result.
|
|
178
|
+
*/
|
|
179
|
+
client?: boolean;
|
|
162
180
|
}
|
|
163
181
|
/**
|
|
164
182
|
* Extend webpack config
|
|
@@ -189,7 +207,7 @@ declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPl
|
|
|
189
207
|
/**
|
|
190
208
|
* Append Vite plugin to the config.
|
|
191
209
|
*/
|
|
192
|
-
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?:
|
|
210
|
+
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
|
|
193
211
|
interface AddBuildPluginFactory {
|
|
194
212
|
vite?: () => Plugin | Plugin[];
|
|
195
213
|
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
|
|
@@ -501,6 +519,8 @@ interface ResolveModuleOptions {
|
|
|
501
519
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
502
520
|
paths?: string | string[];
|
|
503
521
|
url?: URL | URL[];
|
|
522
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
523
|
+
extensions?: string[];
|
|
504
524
|
}
|
|
505
525
|
declare function directoryToURL(dir: string): URL;
|
|
506
526
|
/**
|
|
@@ -528,5 +548,5 @@ declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptio
|
|
|
528
548
|
*/
|
|
529
549
|
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
|
|
530
550
|
|
|
531
|
-
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, 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, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
551
|
+
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, 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, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
532
552
|
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
|
package/dist/index.mjs
CHANGED
|
@@ -7,20 +7,20 @@ import { getContext, createContext } from 'unctx';
|
|
|
7
7
|
import satisfies from 'semver/functions/satisfies.js';
|
|
8
8
|
import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
|
|
9
9
|
import { existsSync, readFileSync, promises, lstatSync } from 'node:fs';
|
|
10
|
-
import {
|
|
10
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
11
11
|
import { resolve, relative, join, dirname, normalize, isAbsolute, basename, parse } from 'pathe';
|
|
12
12
|
import { createJiti } from 'jiti';
|
|
13
|
-
import {
|
|
13
|
+
import { parseNodeModulePath, interopDefault, resolveModuleExportNames } from 'mlly';
|
|
14
14
|
import { resolveModulePath, resolveModuleURL } from 'exsolve';
|
|
15
15
|
import { isRelative, withTrailingSlash as withTrailingSlash$2 } from 'ufo';
|
|
16
16
|
import { read, update } from 'rc9';
|
|
17
17
|
import semver, { gte } from 'semver';
|
|
18
18
|
import { captureStackTrace } from 'errx';
|
|
19
|
+
import process from 'node:process';
|
|
19
20
|
import { glob } from 'tinyglobby';
|
|
20
21
|
import { resolveAlias as resolveAlias$1, reverseResolveAlias } from 'pathe/utils';
|
|
21
22
|
import ignore from 'ignore';
|
|
22
23
|
import { loadConfig } from 'c12';
|
|
23
|
-
import process$1 from 'node:process';
|
|
24
24
|
import destr from 'destr';
|
|
25
25
|
import { snakeCase, pascalCase, kebabCase } from 'scule';
|
|
26
26
|
import { klona } from 'klona';
|
|
@@ -221,53 +221,27 @@ ${issues.toString()}`;
|
|
|
221
221
|
return normalizedModule;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}));
|
|
233
|
-
}
|
|
234
|
-
function resolveModule(id, options) {
|
|
235
|
-
return resolveModulePath(id, {
|
|
236
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
237
|
-
from: options?.url ?? options?.paths ?? [import.meta.url],
|
|
238
|
-
extensions: [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
async function importModule(id, opts) {
|
|
242
|
-
const resolvedPath = resolveModule(id, opts);
|
|
243
|
-
return await import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
|
|
244
|
-
}
|
|
245
|
-
function tryImportModule(id, opts) {
|
|
246
|
-
try {
|
|
247
|
-
return importModule(id, opts).catch(() => void 0);
|
|
248
|
-
} catch {
|
|
224
|
+
const distURL = import.meta.url.replace(/\/dist\/.*$/, "/");
|
|
225
|
+
function getUserCaller() {
|
|
226
|
+
if (!import.meta.dev) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
const { source, line, column } = captureStackTrace().find((entry) => !entry.source.startsWith(distURL)) ?? {};
|
|
230
|
+
if (!source) {
|
|
231
|
+
return null;
|
|
249
232
|
}
|
|
233
|
+
return {
|
|
234
|
+
source: source.replace(/^file:\/\//, ""),
|
|
235
|
+
line,
|
|
236
|
+
column
|
|
237
|
+
};
|
|
250
238
|
}
|
|
251
239
|
const warnings = /* @__PURE__ */ new Set();
|
|
252
|
-
function
|
|
253
|
-
const { source, line, column } = captureStackTrace().find((entry) => entry.source !== import.meta.url) ?? {};
|
|
254
|
-
const explanation = source ? ` (used at \`${fileURLToPath(source)}:${line}:${column}\`)` : "";
|
|
255
|
-
const warning = `[@nuxt/kit] \`requireModule\` is deprecated${explanation}. Please use \`importModule\` instead.`;
|
|
240
|
+
function warn(warning) {
|
|
256
241
|
if (!warnings.has(warning)) {
|
|
257
242
|
console.warn(warning);
|
|
258
243
|
warnings.add(warning);
|
|
259
244
|
}
|
|
260
|
-
const resolvedPath = resolveModule(id, opts);
|
|
261
|
-
const jiti = createJiti(import.meta.url, {
|
|
262
|
-
interopDefault: opts?.interopDefault !== false
|
|
263
|
-
});
|
|
264
|
-
return jiti(pathToFileURL(resolvedPath).href);
|
|
265
|
-
}
|
|
266
|
-
function tryRequireModule(id, opts) {
|
|
267
|
-
try {
|
|
268
|
-
return requireModule(id, opts);
|
|
269
|
-
} catch {
|
|
270
|
-
}
|
|
271
245
|
}
|
|
272
246
|
|
|
273
247
|
const layerMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -541,6 +515,51 @@ async function resolveFiles(path, pattern, opts = {}) {
|
|
|
541
515
|
return files.sort();
|
|
542
516
|
}
|
|
543
517
|
|
|
518
|
+
function directoryToURL(dir) {
|
|
519
|
+
return pathToFileURL(dir + "/");
|
|
520
|
+
}
|
|
521
|
+
function tryResolveModule(id, url = import.meta.url) {
|
|
522
|
+
return Promise.resolve(resolveModulePath(id, {
|
|
523
|
+
from: url,
|
|
524
|
+
suffixes: ["", "index"],
|
|
525
|
+
try: true
|
|
526
|
+
}));
|
|
527
|
+
}
|
|
528
|
+
function resolveModule(id, options) {
|
|
529
|
+
return resolveModulePath(id, {
|
|
530
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
531
|
+
from: options?.url ?? options?.paths ?? [import.meta.url],
|
|
532
|
+
extensions: options?.extensions ?? [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
async function importModule(id, opts) {
|
|
536
|
+
const resolvedPath = resolveModule(id, opts);
|
|
537
|
+
return await import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
|
|
538
|
+
}
|
|
539
|
+
function tryImportModule(id, opts) {
|
|
540
|
+
try {
|
|
541
|
+
return importModule(id, opts).catch(() => void 0);
|
|
542
|
+
} catch {
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function requireModule(id, opts) {
|
|
546
|
+
const caller = getUserCaller();
|
|
547
|
+
const explanation = caller ? ` (used at \`${resolveAlias(caller.source)}:${caller.line}:${caller.column}\`)` : "";
|
|
548
|
+
const warning = `[@nuxt/kit] \`requireModule\` is deprecated${explanation}. Please use \`importModule\` instead.`;
|
|
549
|
+
warn(warning);
|
|
550
|
+
const resolvedPath = resolveModule(id, opts);
|
|
551
|
+
const jiti = createJiti(import.meta.url, {
|
|
552
|
+
interopDefault: opts?.interopDefault !== false
|
|
553
|
+
});
|
|
554
|
+
return jiti(pathToFileURL(resolvedPath).href);
|
|
555
|
+
}
|
|
556
|
+
function tryRequireModule(id, opts) {
|
|
557
|
+
try {
|
|
558
|
+
return requireModule(id, opts);
|
|
559
|
+
} catch {
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
544
563
|
const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
|
|
545
564
|
async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useNuxt()) {
|
|
546
565
|
const localLayerModuleDirs = [];
|
|
@@ -843,20 +862,19 @@ async function loadNuxtConfig(opts) {
|
|
|
843
862
|
cwd: opts.cwd || process.cwd()
|
|
844
863
|
})).map((d) => d.endsWith("/") ? d.substring(0, d.length - 1) : d).sort((a, b) => b.localeCompare(a));
|
|
845
864
|
opts.overrides = defu$1(opts.overrides, { _extends: localLayers });
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
delete globalSelf.defineNuxtConfig;
|
|
865
|
+
const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await withDefineNuxtConfig(
|
|
866
|
+
() => loadConfig({
|
|
867
|
+
name: "nuxt",
|
|
868
|
+
configFile: "nuxt.config",
|
|
869
|
+
rcFile: ".nuxtrc",
|
|
870
|
+
extend: { extendKey: ["theme", "_extends", "extends"] },
|
|
871
|
+
dotenv: true,
|
|
872
|
+
globalRc: true,
|
|
873
|
+
// @ts-expect-error TODO: fix type in c12, it should accept createDefu directly
|
|
874
|
+
merger,
|
|
875
|
+
...opts
|
|
876
|
+
})
|
|
877
|
+
);
|
|
860
878
|
nuxtConfig.rootDir ||= cwd;
|
|
861
879
|
nuxtConfig._nuxtConfigFile = configFile;
|
|
862
880
|
nuxtConfig._nuxtConfigFiles = [configFile];
|
|
@@ -924,6 +942,23 @@ async function loadNuxtSchema(cwd) {
|
|
|
924
942
|
const schemaPath = resolveModuleURL("@nuxt/schema", { try: true, from: urls }) ?? "@nuxt/schema";
|
|
925
943
|
return await import(schemaPath).then((r) => r.NuxtConfigSchema);
|
|
926
944
|
}
|
|
945
|
+
async function withDefineNuxtConfig(fn) {
|
|
946
|
+
const key = "defineNuxtConfig";
|
|
947
|
+
const globalSelf = globalThis;
|
|
948
|
+
if (!globalSelf[key]) {
|
|
949
|
+
globalSelf[key] = (c) => c;
|
|
950
|
+
globalSelf[key].count = 0;
|
|
951
|
+
}
|
|
952
|
+
globalSelf[key].count++;
|
|
953
|
+
try {
|
|
954
|
+
return await fn();
|
|
955
|
+
} finally {
|
|
956
|
+
globalSelf[key].count--;
|
|
957
|
+
if (!globalSelf[key].count) {
|
|
958
|
+
delete globalSelf[key];
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
927
962
|
|
|
928
963
|
function extendNuxtSchema(def) {
|
|
929
964
|
const nuxt = useNuxt();
|
|
@@ -953,6 +988,11 @@ async function buildNuxt(nuxt) {
|
|
|
953
988
|
return runWithNuxtContext(nuxt, () => build(nuxt));
|
|
954
989
|
}
|
|
955
990
|
|
|
991
|
+
function setGlobalHead(head) {
|
|
992
|
+
const nuxt = useNuxt();
|
|
993
|
+
nuxt.options.app.head = defu(head, nuxt.options.app.head);
|
|
994
|
+
}
|
|
995
|
+
|
|
956
996
|
function addImports(imports) {
|
|
957
997
|
useNuxt().hook("imports:extend", (_imports) => {
|
|
958
998
|
_imports.push(...toArray(imports));
|
|
@@ -1045,7 +1085,7 @@ function useRuntimeConfig() {
|
|
|
1045
1085
|
return applyEnv(klona(nuxt.options.nitro.runtimeConfig), {
|
|
1046
1086
|
prefix: "NITRO_",
|
|
1047
1087
|
altPrefix: "NUXT_",
|
|
1048
|
-
envExpansion: nuxt.options.nitro.experimental?.envExpansion ?? !!process
|
|
1088
|
+
envExpansion: nuxt.options.nitro.experimental?.envExpansion ?? !!process.env.NITRO_ENV_EXPANSION
|
|
1049
1089
|
});
|
|
1050
1090
|
}
|
|
1051
1091
|
function updateRuntimeConfig(runtimeConfig) {
|
|
@@ -1056,7 +1096,7 @@ function updateRuntimeConfig(runtimeConfig) {
|
|
|
1056
1096
|
} catch {
|
|
1057
1097
|
}
|
|
1058
1098
|
}
|
|
1059
|
-
function getEnv(key, opts, env = process
|
|
1099
|
+
function getEnv(key, opts, env = process.env) {
|
|
1060
1100
|
const envKey = snakeCase(key).toUpperCase();
|
|
1061
1101
|
return destr(
|
|
1062
1102
|
env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey]
|
|
@@ -1088,7 +1128,7 @@ function applyEnv(obj, opts, parentKey = "") {
|
|
|
1088
1128
|
return obj;
|
|
1089
1129
|
}
|
|
1090
1130
|
const envExpandRx = /\{\{([^{}]*)\}\}/g;
|
|
1091
|
-
function _expandFromEnv(value, env = process
|
|
1131
|
+
function _expandFromEnv(value, env = process.env) {
|
|
1092
1132
|
return value.replace(envExpandRx, (match, key) => {
|
|
1093
1133
|
return env[key] || match;
|
|
1094
1134
|
});
|
|
@@ -1127,17 +1167,13 @@ function extendViteConfig(fn, options = {}) {
|
|
|
1127
1167
|
if (options.build === false && nuxt.options.build) {
|
|
1128
1168
|
return;
|
|
1129
1169
|
}
|
|
1130
|
-
if (options.server
|
|
1131
|
-
|
|
1170
|
+
if (options.server === false || options.client === false) {
|
|
1171
|
+
const caller = getUserCaller();
|
|
1172
|
+
const explanation = caller ? ` (used at \`${resolveAlias(caller.source)}:${caller.line}:${caller.column}\`)` : "";
|
|
1173
|
+
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.`;
|
|
1174
|
+
warn(warning);
|
|
1132
1175
|
}
|
|
1133
|
-
nuxt.hook("vite:
|
|
1134
|
-
if (options.server !== false && isServer) {
|
|
1135
|
-
return fn(config);
|
|
1136
|
-
}
|
|
1137
|
-
if (options.client !== false && isClient) {
|
|
1138
|
-
return fn(config);
|
|
1139
|
-
}
|
|
1140
|
-
});
|
|
1176
|
+
return nuxt.hook("vite:extend", ({ config }) => fn(config));
|
|
1141
1177
|
}
|
|
1142
1178
|
function addWebpackPlugin(pluginOrGetter, options) {
|
|
1143
1179
|
extendWebpackConfig((config) => {
|
|
@@ -1155,13 +1191,52 @@ function addRspackPlugin(pluginOrGetter, options) {
|
|
|
1155
1191
|
config.plugins[method](...toArray(plugin));
|
|
1156
1192
|
}, options);
|
|
1157
1193
|
}
|
|
1158
|
-
function addVitePlugin(pluginOrGetter, options) {
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1194
|
+
function addVitePlugin(pluginOrGetter, options = {}) {
|
|
1195
|
+
const nuxt = useNuxt();
|
|
1196
|
+
if (options.dev === false && nuxt.options.dev) {
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
if (options.build === false && nuxt.options.build) {
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
let needsEnvInjection = false;
|
|
1203
|
+
nuxt.hook("vite:extend", ({ config }) => {
|
|
1162
1204
|
config.plugins ||= [];
|
|
1163
|
-
|
|
1164
|
-
|
|
1205
|
+
const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
|
|
1206
|
+
if (options.server !== false && options.client !== false) {
|
|
1207
|
+
const method = options?.prepend ? "unshift" : "push";
|
|
1208
|
+
config.plugins[method](...plugin);
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
if (!config.environments?.ssr || !config.environments.client) {
|
|
1212
|
+
needsEnvInjection = true;
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const environmentName = options.server === false ? "client" : "ssr";
|
|
1216
|
+
const pluginName = plugin.map((p) => p.name).join("|");
|
|
1217
|
+
config.plugins.push({
|
|
1218
|
+
name: `${pluginName}:wrapper`,
|
|
1219
|
+
enforce: options?.prepend ? "pre" : "post",
|
|
1220
|
+
applyToEnvironment(environment) {
|
|
1221
|
+
if (environment.name === environmentName) {
|
|
1222
|
+
return plugin;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1227
|
+
nuxt.hook("vite:extendConfig", (config, env) => {
|
|
1228
|
+
if (!needsEnvInjection) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
const plugin = toArray(typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter);
|
|
1232
|
+
const method = options?.prepend ? "unshift" : "push";
|
|
1233
|
+
if (env.isClient && options.server === false) {
|
|
1234
|
+
config.plugins[method](...plugin);
|
|
1235
|
+
}
|
|
1236
|
+
if (env.isServer && options.client === false) {
|
|
1237
|
+
config.plugins[method](...plugin);
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1165
1240
|
}
|
|
1166
1241
|
function addBuildPlugin(pluginFactory, options) {
|
|
1167
1242
|
if (pluginFactory.vite) {
|
|
@@ -1878,4 +1953,4 @@ function addPluginTemplate(plugin, opts = {}) {
|
|
|
1878
1953
|
return addPlugin(normalizedPlugin, opts);
|
|
1879
1954
|
}
|
|
1880
1955
|
|
|
1881
|
-
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, 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, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
|
1956
|
+
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, 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, 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": "4.1
|
|
3
|
+
"version": "4.2.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",
|
|
@@ -38,24 +38,23 @@
|
|
|
38
38
|
"pkg-types": "^2.3.0",
|
|
39
39
|
"rc9": "^2.1.2",
|
|
40
40
|
"scule": "^1.3.0",
|
|
41
|
-
"semver": "^7.7.
|
|
42
|
-
"std-env": "^3.9.0",
|
|
41
|
+
"semver": "^7.7.3",
|
|
43
42
|
"tinyglobby": "^0.2.15",
|
|
44
43
|
"ufo": "^1.6.1",
|
|
45
44
|
"unctx": "^2.4.1",
|
|
46
|
-
"unimport": "^5.4.1",
|
|
47
45
|
"untyped": "^2.0.0"
|
|
48
46
|
},
|
|
49
47
|
"devDependencies": {
|
|
50
|
-
"@rspack/core": "1.
|
|
48
|
+
"@rspack/core": "1.6.1",
|
|
51
49
|
"@types/semver": "7.7.1",
|
|
52
50
|
"hookable": "5.5.3",
|
|
53
|
-
"nitropack": "2.12.
|
|
51
|
+
"nitropack": "2.12.9",
|
|
54
52
|
"unbuild": "3.6.1",
|
|
55
|
-
"
|
|
53
|
+
"unimport": "5.5.0",
|
|
54
|
+
"vite": "7.2.1",
|
|
56
55
|
"vitest": "3.2.4",
|
|
57
|
-
"webpack": "5.102.
|
|
58
|
-
"@nuxt/schema": "4.1
|
|
56
|
+
"webpack": "5.102.1",
|
|
57
|
+
"@nuxt/schema": "4.2.1"
|
|
59
58
|
},
|
|
60
59
|
"engines": {
|
|
61
60
|
"node": ">=18.12.0"
|