@nuxt/kit 4.1.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.d.mts +27 -4
- package/dist/index.d.ts +27 -4
- package/dist/index.mjs +160 -81
- package/package.json +11 -12
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ Example of an `app.vue`:
|
|
|
60
60
|
<script setup lang="ts">
|
|
61
61
|
useSeoMeta({
|
|
62
62
|
title: 'Meet Nuxt',
|
|
63
|
-
description: 'The Intuitive Vue Framework.'
|
|
63
|
+
description: 'The Intuitive Vue Framework.',
|
|
64
64
|
})
|
|
65
65
|
</script>
|
|
66
66
|
|
|
@@ -93,13 +93,13 @@ Discover our [list of modules](https://nuxt.com/modules) to supercharge your Nux
|
|
|
93
93
|
We invite you to contribute and help improve Nuxt 💚
|
|
94
94
|
|
|
95
95
|
Here are a few ways you can get involved:
|
|
96
|
-
- **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/community/reporting-bugs) to learn how to submit a bug report.
|
|
97
|
-
- **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/community/contribution) to share your suggestions.
|
|
98
|
-
- **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/community/getting-help) provides resources to help you out.
|
|
96
|
+
- **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/4.x/community/reporting-bugs) to learn how to submit a bug report.
|
|
97
|
+
- **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/4.x/community/contribution) to share your suggestions.
|
|
98
|
+
- **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/4.x/community/getting-help) provides resources to help you out.
|
|
99
99
|
|
|
100
100
|
## <a name="local-development">🏠 Local Development</a>
|
|
101
101
|
|
|
102
|
-
Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#setup) to contribute to the framework and documentation.
|
|
102
|
+
Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/4.x/community/framework-contribution#setup) to contribute to the framework and documentation.
|
|
103
103
|
|
|
104
104
|
## <a name="professional-support">🛟 Professional Support</a>
|
|
105
105
|
|
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';
|
|
@@ -113,6 +113,8 @@ 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;
|
|
@@ -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[];
|
|
@@ -398,6 +416,9 @@ type PathType = 'file' | 'dir';
|
|
|
398
416
|
* @param path path to the directory to resolve files in
|
|
399
417
|
* @param pattern glob pattern or an array of glob patterns to match files
|
|
400
418
|
* @param opts options for globbing
|
|
419
|
+
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
|
|
420
|
+
* @param opts.ignore additional glob patterns to ignore
|
|
421
|
+
* @returns sorted array of absolute file paths
|
|
401
422
|
*/
|
|
402
423
|
declare function resolveFiles(path: string, pattern: string | string[], opts?: {
|
|
403
424
|
followSymbolicLinks?: boolean;
|
|
@@ -498,6 +519,8 @@ interface ResolveModuleOptions {
|
|
|
498
519
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
499
520
|
paths?: string | string[];
|
|
500
521
|
url?: URL | URL[];
|
|
522
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
523
|
+
extensions?: string[];
|
|
501
524
|
}
|
|
502
525
|
declare function directoryToURL(dir: string): URL;
|
|
503
526
|
/**
|
|
@@ -525,5 +548,5 @@ declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptio
|
|
|
525
548
|
*/
|
|
526
549
|
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
|
|
527
550
|
|
|
528
|
-
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 };
|
|
529
552
|
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';
|
|
@@ -113,6 +113,8 @@ 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;
|
|
@@ -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[];
|
|
@@ -398,6 +416,9 @@ type PathType = 'file' | 'dir';
|
|
|
398
416
|
* @param path path to the directory to resolve files in
|
|
399
417
|
* @param pattern glob pattern or an array of glob patterns to match files
|
|
400
418
|
* @param opts options for globbing
|
|
419
|
+
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
|
|
420
|
+
* @param opts.ignore additional glob patterns to ignore
|
|
421
|
+
* @returns sorted array of absolute file paths
|
|
401
422
|
*/
|
|
402
423
|
declare function resolveFiles(path: string, pattern: string | string[], opts?: {
|
|
403
424
|
followSymbolicLinks?: boolean;
|
|
@@ -498,6 +519,8 @@ interface ResolveModuleOptions {
|
|
|
498
519
|
/** @deprecated use `url` with URLs pointing at a file - never a directory */
|
|
499
520
|
paths?: string | string[];
|
|
500
521
|
url?: URL | URL[];
|
|
522
|
+
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
|
|
523
|
+
extensions?: string[];
|
|
501
524
|
}
|
|
502
525
|
declare function directoryToURL(dir: string): URL;
|
|
503
526
|
/**
|
|
@@ -525,5 +548,5 @@ declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptio
|
|
|
525
548
|
*/
|
|
526
549
|
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
|
|
527
550
|
|
|
528
|
-
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 };
|
|
529
552
|
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };
|
package/dist/index.mjs
CHANGED
|
@@ -7,10 +7,10 @@ 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';
|
|
@@ -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));
|
|
@@ -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) {
|
|
@@ -1277,18 +1352,21 @@ function addTypeTemplate(_template, context) {
|
|
|
1277
1352
|
throw new Error(`Invalid type template. Filename must end with .d.ts : "${template.filename}"`);
|
|
1278
1353
|
}
|
|
1279
1354
|
if (!context || context.nuxt) {
|
|
1280
|
-
nuxt.hook("prepare:types", (
|
|
1281
|
-
references
|
|
1355
|
+
nuxt.hook("prepare:types", (payload) => {
|
|
1356
|
+
payload.references ||= [];
|
|
1357
|
+
payload.references.push({ path: template.dst });
|
|
1282
1358
|
});
|
|
1283
1359
|
}
|
|
1284
1360
|
if (context?.node) {
|
|
1285
|
-
nuxt.hook("prepare:types", (
|
|
1286
|
-
nodeReferences
|
|
1361
|
+
nuxt.hook("prepare:types", (payload) => {
|
|
1362
|
+
payload.nodeReferences ||= [];
|
|
1363
|
+
payload.nodeReferences.push({ path: template.dst });
|
|
1287
1364
|
});
|
|
1288
1365
|
}
|
|
1289
1366
|
if (context?.shared) {
|
|
1290
|
-
nuxt.hook("prepare:types", (
|
|
1291
|
-
sharedReferences
|
|
1367
|
+
nuxt.hook("prepare:types", (payload) => {
|
|
1368
|
+
payload.sharedReferences ||= [];
|
|
1369
|
+
payload.sharedReferences.push({ path: template.dst });
|
|
1292
1370
|
});
|
|
1293
1371
|
}
|
|
1294
1372
|
if (!context || context.nuxt || context.shared) {
|
|
@@ -1299,8 +1377,9 @@ function addTypeTemplate(_template, context) {
|
|
|
1299
1377
|
});
|
|
1300
1378
|
}
|
|
1301
1379
|
if (context?.nitro) {
|
|
1302
|
-
nuxt.hook("nitro:prepare:types", (
|
|
1303
|
-
references
|
|
1380
|
+
nuxt.hook("nitro:prepare:types", (payload) => {
|
|
1381
|
+
payload.references ||= [];
|
|
1382
|
+
payload.references.push({ path: template.dst });
|
|
1304
1383
|
});
|
|
1305
1384
|
}
|
|
1306
1385
|
return template;
|
|
@@ -1874,4 +1953,4 @@ function addPluginTemplate(plugin, opts = {}) {
|
|
|
1874
1953
|
return addPlugin(normalizedPlugin, opts);
|
|
1875
1954
|
}
|
|
1876
1955
|
|
|
1877
|
-
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,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
7
7
|
"directory": "packages/kit"
|
|
8
8
|
},
|
|
9
|
-
"homepage": "https://nuxt.com/docs/api/kit",
|
|
9
|
+
"homepage": "https://nuxt.com/docs/4.x/api/kit",
|
|
10
10
|
"description": "Toolkit for authoring modules and interacting with Nuxt",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"type": "module",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"c12": "^3.
|
|
26
|
+
"c12": "^3.3.1",
|
|
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
|
"mlly": "^1.8.0",
|
|
36
36
|
"ohash": "^2.0.11",
|
|
@@ -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.2.0",
|
|
47
45
|
"untyped": "^2.0.0"
|
|
48
46
|
},
|
|
49
47
|
"devDependencies": {
|
|
50
|
-
"@rspack/core": "1.5.
|
|
48
|
+
"@rspack/core": "1.5.8",
|
|
51
49
|
"@types/semver": "7.7.1",
|
|
52
50
|
"hookable": "5.5.3",
|
|
53
|
-
"nitropack": "2.12.
|
|
51
|
+
"nitropack": "2.12.8",
|
|
54
52
|
"unbuild": "3.6.1",
|
|
55
|
-
"
|
|
53
|
+
"unimport": "5.5.0",
|
|
54
|
+
"vite": "7.1.12",
|
|
56
55
|
"vitest": "3.2.4",
|
|
57
|
-
"webpack": "5.
|
|
58
|
-
"@nuxt/schema": "4.
|
|
56
|
+
"webpack": "5.102.1",
|
|
57
|
+
"@nuxt/schema": "4.2.0"
|
|
59
58
|
},
|
|
60
59
|
"engines": {
|
|
61
60
|
"node": ">=18.12.0"
|