@nuxt/kit 3.11.2 → 3.12.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 +9 -1
- package/dist/index.d.mts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.mjs +264 -130
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
|
|
|
33
33
|
- ❤️ [Contribute](#contribute)
|
|
34
34
|
- 🏠 [Local Development](#local-development)
|
|
35
35
|
- ⛰️ [Nuxt 2](#nuxt-2)
|
|
36
|
+
- 🛟 [Professional Support](#professional-support)
|
|
36
37
|
- 🔗 [Follow us](#follow-us)
|
|
37
38
|
- ⚖️ [License](#license)
|
|
38
39
|
|
|
@@ -93,7 +94,7 @@ We invite you to contribute and help improve Nuxt 💚
|
|
|
93
94
|
|
|
94
95
|
Here are a few ways you can get involved:
|
|
95
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.
|
|
96
|
-
- **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/community/contribution
|
|
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.
|
|
97
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.
|
|
98
99
|
|
|
99
100
|
## <a name="local-development">🏠 Local Development</a>
|
|
@@ -104,6 +105,13 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
|
|
|
104
105
|
|
|
105
106
|
You can find the code for Nuxt 2 on the [`2.x` branch](https://github.com/nuxt/nuxt/tree/2.x) and the documentation at [v2.nuxt.com](https://v2.nuxt.com).
|
|
106
107
|
|
|
108
|
+
If you expect to be using Nuxt 2 beyond the EOL (End of Life) date (June 30, 2024), and still need a maintained version that can satisfy security and browser compatibility requirements, make sure to check out [HeroDevs’ NES (Never-Ending Support) Nuxt 2](https://www.herodevs.com/support/nuxt-nes?utm_source=nuxt-github&utm_medium=nuxt-readme).
|
|
109
|
+
|
|
110
|
+
## <a name="professional-support">🛟 Professional Support</a>
|
|
111
|
+
|
|
112
|
+
- Technical audit & consulting: [Nuxt Experts](https://nuxt.com/enterprise/support)
|
|
113
|
+
- Custom development & more: [Nuxt Agencies Partners](https://nuxt.com/enterprise/agencies)
|
|
114
|
+
|
|
107
115
|
## <a name="follow-us">🔗 Follow us</a>
|
|
108
116
|
|
|
109
117
|
<p valign="center">
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ModuleOptions, ModuleDefinition, NuxtModule, Nuxt, ModuleMeta,
|
|
1
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtMiddleware, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
2
2
|
import { LoadConfigOptions } from 'c12';
|
|
3
3
|
import { Import } from 'unimport';
|
|
4
4
|
import { Configuration, WebpackPluginInstance } from 'webpack';
|
|
5
5
|
import { UserConfig, Plugin } from 'vite';
|
|
6
|
-
import * as
|
|
6
|
+
import * as unctx from 'unctx';
|
|
7
7
|
import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
|
|
8
8
|
import * as consola from 'consola';
|
|
9
9
|
import { ConsolaOptions } from 'consola';
|
|
@@ -16,7 +16,7 @@ import { genSafeVariableName } from 'knitwork';
|
|
|
16
16
|
declare function defineNuxtModule<OptionsT extends ModuleOptions>(definition: ModuleDefinition<OptionsT> | NuxtModule<OptionsT>): NuxtModule<OptionsT>;
|
|
17
17
|
|
|
18
18
|
/** Installs a module on a Nuxt instance. */
|
|
19
|
-
declare function installModule
|
|
19
|
+
declare function installModule<T extends string | NuxtModule, Config extends Extract<NonNullable<NuxtConfig['modules']>[number], [T, any]>>(moduleToInstall: T, inlineOptions?: [Config] extends [never] ? any : Config[1], nuxt?: Nuxt): Promise<void>;
|
|
20
20
|
declare function getDirectory(p: string): string;
|
|
21
21
|
declare const normalizeModuleTranspilePath: (p: string) => string;
|
|
22
22
|
declare function loadNuxtModuleInstance(nuxtModule: string | NuxtModule, nuxt?: Nuxt): Promise<{
|
|
@@ -67,6 +67,17 @@ declare function addImportsDir(dirs: string | string[], opts?: {
|
|
|
67
67
|
}): void;
|
|
68
68
|
declare function addImportsSources(presets: ImportPresetWithDeprecation | ImportPresetWithDeprecation[]): void;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
72
|
+
*
|
|
73
|
+
* This mirrors the runtime behavior of Nitro.
|
|
74
|
+
*/
|
|
75
|
+
declare function useRuntimeConfig(): Record<string, any>;
|
|
76
|
+
/**
|
|
77
|
+
* Update Nuxt runtime configuration.
|
|
78
|
+
*/
|
|
79
|
+
declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
|
|
80
|
+
|
|
70
81
|
interface ExtendConfigOptions {
|
|
71
82
|
/**
|
|
72
83
|
* Install plugin on dev
|
|
@@ -168,7 +179,7 @@ type AddComponentOptions = {
|
|
|
168
179
|
declare function addComponent(opts: AddComponentOptions): Promise<void>;
|
|
169
180
|
|
|
170
181
|
/** Direct access to the Nuxt context - see https://github.com/unjs/unctx. */
|
|
171
|
-
declare const nuxtCtx:
|
|
182
|
+
declare const nuxtCtx: unctx.UseContext<Nuxt>;
|
|
172
183
|
/**
|
|
173
184
|
* Get access to Nuxt instance.
|
|
174
185
|
*
|
|
@@ -254,6 +265,17 @@ interface ResolvePathOptions {
|
|
|
254
265
|
alias?: Record<string, string>;
|
|
255
266
|
/** The file extensions to try. Default is Nuxt configured extensions. */
|
|
256
267
|
extensions?: string[];
|
|
268
|
+
/**
|
|
269
|
+
* Whether to resolve files that exist in the Nuxt VFS (for example, as a Nuxt template).
|
|
270
|
+
* @default false
|
|
271
|
+
*/
|
|
272
|
+
virtual?: boolean;
|
|
273
|
+
/**
|
|
274
|
+
* Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
|
|
275
|
+
*
|
|
276
|
+
* @default false
|
|
277
|
+
*/
|
|
278
|
+
fallbackToOriginal?: boolean;
|
|
257
279
|
}
|
|
258
280
|
/**
|
|
259
281
|
* Resolve full path to a file or directory respecting Nuxt alias and extensions options
|
|
@@ -400,4 +422,4 @@ declare const templateUtils: {
|
|
|
400
422
|
}) => string;
|
|
401
423
|
};
|
|
402
424
|
|
|
403
|
-
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
|
|
425
|
+
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ModuleOptions, ModuleDefinition, NuxtModule, Nuxt, ModuleMeta,
|
|
1
|
+
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtMiddleware, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtTypeTemplate } from '@nuxt/schema';
|
|
2
2
|
import { LoadConfigOptions } from 'c12';
|
|
3
3
|
import { Import } from 'unimport';
|
|
4
4
|
import { Configuration, WebpackPluginInstance } from 'webpack';
|
|
5
5
|
import { UserConfig, Plugin } from 'vite';
|
|
6
|
-
import * as
|
|
6
|
+
import * as unctx from 'unctx';
|
|
7
7
|
import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
|
|
8
8
|
import * as consola from 'consola';
|
|
9
9
|
import { ConsolaOptions } from 'consola';
|
|
@@ -16,7 +16,7 @@ import { genSafeVariableName } from 'knitwork';
|
|
|
16
16
|
declare function defineNuxtModule<OptionsT extends ModuleOptions>(definition: ModuleDefinition<OptionsT> | NuxtModule<OptionsT>): NuxtModule<OptionsT>;
|
|
17
17
|
|
|
18
18
|
/** Installs a module on a Nuxt instance. */
|
|
19
|
-
declare function installModule
|
|
19
|
+
declare function installModule<T extends string | NuxtModule, Config extends Extract<NonNullable<NuxtConfig['modules']>[number], [T, any]>>(moduleToInstall: T, inlineOptions?: [Config] extends [never] ? any : Config[1], nuxt?: Nuxt): Promise<void>;
|
|
20
20
|
declare function getDirectory(p: string): string;
|
|
21
21
|
declare const normalizeModuleTranspilePath: (p: string) => string;
|
|
22
22
|
declare function loadNuxtModuleInstance(nuxtModule: string | NuxtModule, nuxt?: Nuxt): Promise<{
|
|
@@ -67,6 +67,17 @@ declare function addImportsDir(dirs: string | string[], opts?: {
|
|
|
67
67
|
}): void;
|
|
68
68
|
declare function addImportsSources(presets: ImportPresetWithDeprecation | ImportPresetWithDeprecation[]): void;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
|
|
72
|
+
*
|
|
73
|
+
* This mirrors the runtime behavior of Nitro.
|
|
74
|
+
*/
|
|
75
|
+
declare function useRuntimeConfig(): Record<string, any>;
|
|
76
|
+
/**
|
|
77
|
+
* Update Nuxt runtime configuration.
|
|
78
|
+
*/
|
|
79
|
+
declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
|
|
80
|
+
|
|
70
81
|
interface ExtendConfigOptions {
|
|
71
82
|
/**
|
|
72
83
|
* Install plugin on dev
|
|
@@ -168,7 +179,7 @@ type AddComponentOptions = {
|
|
|
168
179
|
declare function addComponent(opts: AddComponentOptions): Promise<void>;
|
|
169
180
|
|
|
170
181
|
/** Direct access to the Nuxt context - see https://github.com/unjs/unctx. */
|
|
171
|
-
declare const nuxtCtx:
|
|
182
|
+
declare const nuxtCtx: unctx.UseContext<Nuxt>;
|
|
172
183
|
/**
|
|
173
184
|
* Get access to Nuxt instance.
|
|
174
185
|
*
|
|
@@ -254,6 +265,17 @@ interface ResolvePathOptions {
|
|
|
254
265
|
alias?: Record<string, string>;
|
|
255
266
|
/** The file extensions to try. Default is Nuxt configured extensions. */
|
|
256
267
|
extensions?: string[];
|
|
268
|
+
/**
|
|
269
|
+
* Whether to resolve files that exist in the Nuxt VFS (for example, as a Nuxt template).
|
|
270
|
+
* @default false
|
|
271
|
+
*/
|
|
272
|
+
virtual?: boolean;
|
|
273
|
+
/**
|
|
274
|
+
* Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
|
|
275
|
+
*
|
|
276
|
+
* @default false
|
|
277
|
+
*/
|
|
278
|
+
fallbackToOriginal?: boolean;
|
|
257
279
|
}
|
|
258
280
|
/**
|
|
259
281
|
* Resolve full path to a file or directory respecting Nuxt alias and extensions options
|
|
@@ -400,4 +422,4 @@ declare const templateUtils: {
|
|
|
400
422
|
}) => string;
|
|
401
423
|
};
|
|
402
424
|
|
|
403
|
-
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
|
|
425
|
+
export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type LoadNuxtConfigOptions, type LoadNuxtOptions, type RequireModuleOptions, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { promises, existsSync, readFileSync, lstatSync } from 'node:fs';
|
|
2
2
|
import { performance } from 'node:perf_hooks';
|
|
3
|
-
import { defu } from 'defu';
|
|
3
|
+
import defu$1, { defu } from 'defu';
|
|
4
4
|
import { applyDefaults } from 'untyped';
|
|
5
5
|
import { dirname, normalize, relative, join, resolve, isAbsolute, basename, parse } from 'pathe';
|
|
6
6
|
import { consola } from 'consola';
|
|
7
7
|
import { getContext } from 'unctx';
|
|
8
8
|
import satisfies from 'semver/functions/satisfies.js';
|
|
9
|
+
import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
|
|
9
10
|
import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork';
|
|
10
11
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
11
12
|
import { interopDefault, resolvePath as resolvePath$1 } from 'mlly';
|
|
@@ -15,10 +16,13 @@ import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
|
15
16
|
import ignore from 'ignore';
|
|
16
17
|
import { loadConfig } from 'c12';
|
|
17
18
|
import { NuxtConfigSchema } from '@nuxt/schema';
|
|
18
|
-
import
|
|
19
|
-
import
|
|
19
|
+
import process$1 from 'node:process';
|
|
20
|
+
import destr from 'destr';
|
|
21
|
+
import { snakeCase, kebabCase, pascalCase } from 'scule';
|
|
22
|
+
import { klona } from 'klona';
|
|
20
23
|
import hash from 'hash-sum';
|
|
21
24
|
import { withTrailingSlash } from 'ufo';
|
|
25
|
+
import { gte } from 'semver';
|
|
22
26
|
|
|
23
27
|
const logger = consola;
|
|
24
28
|
function useLogger(tag, options = {}) {
|
|
@@ -38,8 +42,12 @@ function tryUseNuxt() {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
function normalizeSemanticVersion(version) {
|
|
41
|
-
return version.replace(
|
|
45
|
+
return version.replace(/-\d+\.[0-9a-f]+/, "");
|
|
42
46
|
}
|
|
47
|
+
const builderMap = {
|
|
48
|
+
"@nuxt/vite-builder": "vite",
|
|
49
|
+
"@nuxt/webpack-builder": "webpack"
|
|
50
|
+
};
|
|
43
51
|
async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
44
52
|
const issues = [];
|
|
45
53
|
if (constraints.nuxt) {
|
|
@@ -66,6 +74,26 @@ async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
|
66
74
|
});
|
|
67
75
|
}
|
|
68
76
|
}
|
|
77
|
+
if (constraints.builder && typeof nuxt.options.builder === "string") {
|
|
78
|
+
const currentBuilder = builderMap[nuxt.options.builder] || nuxt.options.builder;
|
|
79
|
+
if (currentBuilder in constraints.builder) {
|
|
80
|
+
const constraint = constraints.builder[currentBuilder];
|
|
81
|
+
if (constraint === false) {
|
|
82
|
+
issues.push({
|
|
83
|
+
name: "builder",
|
|
84
|
+
message: `Not compatible with \`${nuxt.options.builder}\`.`
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
const builderVersion = await readPackageJSON(nuxt.options.builder, { url: nuxt.options.modulesDir }).then((r) => r.version).catch(() => void 0);
|
|
88
|
+
if (builderVersion && !satisfies(normalizeSemanticVersion(builderVersion), constraint, { includePrerelease: true })) {
|
|
89
|
+
issues.push({
|
|
90
|
+
name: "builder",
|
|
91
|
+
message: `Not compatible with \`${builderVersion}\` of \`${currentBuilder}\`. This module requires \`${constraint}\`.`
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
69
97
|
await nuxt.callHook("kit:compatibility", constraints, issues);
|
|
70
98
|
issues.toString = () => issues.map((issue) => ` - [${issue.name}] ${issue.message}`).join("\n");
|
|
71
99
|
return issues;
|
|
@@ -625,8 +653,6 @@ var baseSetToString = !defineProperty ? identity : function(func, string) {
|
|
|
625
653
|
});
|
|
626
654
|
};
|
|
627
655
|
|
|
628
|
-
const baseSetToString$1 = baseSetToString;
|
|
629
|
-
|
|
630
656
|
/**
|
|
631
657
|
* Sets the `toString` method of `func` to return `string`.
|
|
632
658
|
*
|
|
@@ -635,7 +661,7 @@ const baseSetToString$1 = baseSetToString;
|
|
|
635
661
|
* @param {Function} string The `toString` result.
|
|
636
662
|
* @returns {Function} Returns `func`.
|
|
637
663
|
*/
|
|
638
|
-
var setToString = shortOut(baseSetToString
|
|
664
|
+
var setToString = shortOut(baseSetToString);
|
|
639
665
|
|
|
640
666
|
/** Used as references for various `Number` constants. */
|
|
641
667
|
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
@@ -1594,8 +1620,6 @@ var htmlEscapes = {
|
|
|
1594
1620
|
*/
|
|
1595
1621
|
var escapeHtmlChar = basePropertyOf(htmlEscapes);
|
|
1596
1622
|
|
|
1597
|
-
const escapeHtmlChar$1 = escapeHtmlChar;
|
|
1598
|
-
|
|
1599
1623
|
/** Used to match HTML entities and HTML characters. */
|
|
1600
1624
|
var reUnescapedHtml = /[&<>"']/g,
|
|
1601
1625
|
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
@@ -1631,7 +1655,7 @@ var reUnescapedHtml = /[&<>"']/g,
|
|
|
1631
1655
|
function escape(string) {
|
|
1632
1656
|
string = toString(string);
|
|
1633
1657
|
return (string && reHasUnescapedHtml.test(string))
|
|
1634
|
-
? string.replace(reUnescapedHtml, escapeHtmlChar
|
|
1658
|
+
? string.replace(reUnescapedHtml, escapeHtmlChar)
|
|
1635
1659
|
: string;
|
|
1636
1660
|
}
|
|
1637
1661
|
|
|
@@ -1701,18 +1725,12 @@ function escapeStringChar(chr) {
|
|
|
1701
1725
|
/** Used to match template delimiters. */
|
|
1702
1726
|
var reInterpolate = /<%=([\s\S]+?)%>/g;
|
|
1703
1727
|
|
|
1704
|
-
const reInterpolate$1 = reInterpolate;
|
|
1705
|
-
|
|
1706
1728
|
/** Used to match template delimiters. */
|
|
1707
1729
|
var reEscape = /<%-([\s\S]+?)%>/g;
|
|
1708
1730
|
|
|
1709
|
-
const reEscape$1 = reEscape;
|
|
1710
|
-
|
|
1711
1731
|
/** Used to match template delimiters. */
|
|
1712
1732
|
var reEvaluate = /<%([\s\S]+?)%>/g;
|
|
1713
1733
|
|
|
1714
|
-
const reEvaluate$1 = reEvaluate;
|
|
1715
|
-
|
|
1716
1734
|
/**
|
|
1717
1735
|
* By default, the template delimiters used by lodash are like those in
|
|
1718
1736
|
* embedded Ruby (ERB) as well as ES2015 template strings. Change the
|
|
@@ -1730,7 +1748,7 @@ var templateSettings = {
|
|
|
1730
1748
|
* @memberOf _.templateSettings
|
|
1731
1749
|
* @type {RegExp}
|
|
1732
1750
|
*/
|
|
1733
|
-
'escape': reEscape
|
|
1751
|
+
'escape': reEscape,
|
|
1734
1752
|
|
|
1735
1753
|
/**
|
|
1736
1754
|
* Used to detect code to be evaluated.
|
|
@@ -1738,7 +1756,7 @@ var templateSettings = {
|
|
|
1738
1756
|
* @memberOf _.templateSettings
|
|
1739
1757
|
* @type {RegExp}
|
|
1740
1758
|
*/
|
|
1741
|
-
'evaluate': reEvaluate
|
|
1759
|
+
'evaluate': reEvaluate,
|
|
1742
1760
|
|
|
1743
1761
|
/**
|
|
1744
1762
|
* Used to detect `data` property values to inject.
|
|
@@ -1746,7 +1764,7 @@ var templateSettings = {
|
|
|
1746
1764
|
* @memberOf _.templateSettings
|
|
1747
1765
|
* @type {RegExp}
|
|
1748
1766
|
*/
|
|
1749
|
-
'interpolate': reInterpolate
|
|
1767
|
+
'interpolate': reInterpolate,
|
|
1750
1768
|
|
|
1751
1769
|
/**
|
|
1752
1770
|
* Used to reference the data object in the template text.
|
|
@@ -1921,10 +1939,6 @@ function template(string, options, guard) {
|
|
|
1921
1939
|
// (http://ejohn.org/blog/javascript-micro-templating/)
|
|
1922
1940
|
// and Laura Doktorova's doT.js (https://github.com/olado/doT).
|
|
1923
1941
|
var settings = templateSettings.imports._.templateSettings || templateSettings;
|
|
1924
|
-
|
|
1925
|
-
if (guard && isIterateeCall(string, options, guard)) {
|
|
1926
|
-
options = undefined;
|
|
1927
|
-
}
|
|
1928
1942
|
string = toString(string);
|
|
1929
1943
|
options = assignInWith({}, options, settings, customDefaultsAssignIn);
|
|
1930
1944
|
|
|
@@ -1942,7 +1956,7 @@ function template(string, options, guard) {
|
|
|
1942
1956
|
var reDelimiters = RegExp(
|
|
1943
1957
|
(options.escape || reNoMatch).source + '|' +
|
|
1944
1958
|
interpolate.source + '|' +
|
|
1945
|
-
(interpolate === reInterpolate
|
|
1959
|
+
(interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
|
|
1946
1960
|
(options.evaluate || reNoMatch).source + '|$'
|
|
1947
1961
|
, 'g');
|
|
1948
1962
|
|
|
@@ -2053,7 +2067,7 @@ async function compileTemplate(template$1, ctx) {
|
|
|
2053
2067
|
}
|
|
2054
2068
|
throw new Error("Invalid template: " + JSON.stringify(template$1));
|
|
2055
2069
|
}
|
|
2056
|
-
const serialize = (data) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, (r) => JSON.parse(r).replace(
|
|
2070
|
+
const serialize = (data) => JSON.stringify(data, null, 2).replace(/"\{(.+)\}"(?=,?$)/gm, (r) => JSON.parse(r).replace(/^\{(.*)\}$/, "$1"));
|
|
2057
2071
|
const importSources = (sources, { lazy = false } = {}) => {
|
|
2058
2072
|
return toArray(sources).map((src) => {
|
|
2059
2073
|
if (lazy) {
|
|
@@ -2110,8 +2124,8 @@ ${issues.toString()}`);
|
|
|
2110
2124
|
const key = `nuxt:module:${uniqueKey || Math.round(Math.random() * 1e4)}`;
|
|
2111
2125
|
const mark = performance.mark(key);
|
|
2112
2126
|
const res = await module.setup?.call(null, _options, nuxt) ?? {};
|
|
2113
|
-
const perf = performance.measure(key, mark
|
|
2114
|
-
const setupTime =
|
|
2127
|
+
const perf = performance.measure(key, mark.name);
|
|
2128
|
+
const setupTime = Math.round(perf.duration * 100) / 100;
|
|
2115
2129
|
if (setupTime > 5e3 && uniqueKey !== "@nuxt/telemetry") {
|
|
2116
2130
|
logger.warn(`Slow module \`${uniqueKey || "<no name>"}\` took \`${setupTime}ms\` to setup.`);
|
|
2117
2131
|
} else if (nuxt.options.debug) {
|
|
@@ -2273,23 +2287,28 @@ function isIgnored(pathname) {
|
|
|
2273
2287
|
}
|
|
2274
2288
|
return !!(relativePath && nuxt._ignore.ignores(relativePath));
|
|
2275
2289
|
}
|
|
2290
|
+
const NEGATION_RE = /^(!?)(.*)$/;
|
|
2276
2291
|
function resolveIgnorePatterns(relativePath) {
|
|
2277
2292
|
const nuxt = tryUseNuxt();
|
|
2278
2293
|
if (!nuxt) {
|
|
2279
2294
|
return [];
|
|
2280
2295
|
}
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
nuxt._ignorePatterns.push(...contents.trim().split(/\r?\n/));
|
|
2287
|
-
}
|
|
2296
|
+
const ignorePatterns = nuxt.options.ignore.flatMap((s) => resolveGroupSyntax(s));
|
|
2297
|
+
const nuxtignoreFile = join(nuxt.options.rootDir, ".nuxtignore");
|
|
2298
|
+
if (existsSync(nuxtignoreFile)) {
|
|
2299
|
+
const contents = readFileSync(nuxtignoreFile, "utf-8");
|
|
2300
|
+
ignorePatterns.push(...contents.trim().split(/\r?\n/));
|
|
2288
2301
|
}
|
|
2289
2302
|
if (relativePath) {
|
|
2290
|
-
return
|
|
2303
|
+
return ignorePatterns.map((p) => {
|
|
2304
|
+
const [_, negation = "", pattern] = p.match(NEGATION_RE) || [];
|
|
2305
|
+
if (pattern[0] === "*") {
|
|
2306
|
+
return p;
|
|
2307
|
+
}
|
|
2308
|
+
return negation + relative(relativePath, resolve(nuxt.options.rootDir, pattern || p));
|
|
2309
|
+
});
|
|
2291
2310
|
}
|
|
2292
|
-
return
|
|
2311
|
+
return ignorePatterns;
|
|
2293
2312
|
}
|
|
2294
2313
|
function resolveGroupSyntax(group) {
|
|
2295
2314
|
let groups = [group];
|
|
@@ -2309,8 +2328,13 @@ function resolveGroupSyntax(group) {
|
|
|
2309
2328
|
async function resolvePath(path, opts = {}) {
|
|
2310
2329
|
const _path = path;
|
|
2311
2330
|
path = normalize(path);
|
|
2312
|
-
if (isAbsolute(path)
|
|
2313
|
-
|
|
2331
|
+
if (isAbsolute(path)) {
|
|
2332
|
+
if (opts?.virtual && existsInVFS(path)) {
|
|
2333
|
+
return path;
|
|
2334
|
+
}
|
|
2335
|
+
if (existsSync(path) && !await isDirectory(path)) {
|
|
2336
|
+
return path;
|
|
2337
|
+
}
|
|
2314
2338
|
}
|
|
2315
2339
|
const nuxt = tryUseNuxt();
|
|
2316
2340
|
const cwd = opts.cwd || (nuxt ? nuxt.options.rootDir : process.cwd());
|
|
@@ -2320,6 +2344,9 @@ async function resolvePath(path, opts = {}) {
|
|
|
2320
2344
|
if (!isAbsolute(path)) {
|
|
2321
2345
|
path = resolve(cwd, path);
|
|
2322
2346
|
}
|
|
2347
|
+
if (opts?.virtual && existsInVFS(path, nuxt)) {
|
|
2348
|
+
return path;
|
|
2349
|
+
}
|
|
2323
2350
|
let _isDir = false;
|
|
2324
2351
|
if (existsSync(path)) {
|
|
2325
2352
|
_isDir = await isDirectory(path);
|
|
@@ -2329,10 +2356,16 @@ async function resolvePath(path, opts = {}) {
|
|
|
2329
2356
|
}
|
|
2330
2357
|
for (const ext of extensions) {
|
|
2331
2358
|
const pathWithExt = path + ext;
|
|
2359
|
+
if (opts?.virtual && existsInVFS(pathWithExt, nuxt)) {
|
|
2360
|
+
return pathWithExt;
|
|
2361
|
+
}
|
|
2332
2362
|
if (existsSync(pathWithExt)) {
|
|
2333
2363
|
return pathWithExt;
|
|
2334
2364
|
}
|
|
2335
2365
|
const pathWithIndex = join(path, "index" + ext);
|
|
2366
|
+
if (opts?.virtual && existsInVFS(pathWithIndex, nuxt)) {
|
|
2367
|
+
return pathWithIndex;
|
|
2368
|
+
}
|
|
2336
2369
|
if (_isDir && existsSync(pathWithIndex)) {
|
|
2337
2370
|
return pathWithIndex;
|
|
2338
2371
|
}
|
|
@@ -2341,11 +2374,15 @@ async function resolvePath(path, opts = {}) {
|
|
|
2341
2374
|
if (resolveModulePath) {
|
|
2342
2375
|
return resolveModulePath;
|
|
2343
2376
|
}
|
|
2344
|
-
return path;
|
|
2377
|
+
return opts.fallbackToOriginal ? _path : path;
|
|
2345
2378
|
}
|
|
2346
2379
|
async function findPath(paths, opts, pathType = "file") {
|
|
2380
|
+
const nuxt = opts?.virtual ? tryUseNuxt() : void 0;
|
|
2347
2381
|
for (const path of toArray(paths)) {
|
|
2348
2382
|
const rPath = await resolvePath(path, opts);
|
|
2383
|
+
if (opts?.virtual && existsInVFS(rPath, nuxt)) {
|
|
2384
|
+
return rPath;
|
|
2385
|
+
}
|
|
2349
2386
|
if (await existsSensitive(rPath)) {
|
|
2350
2387
|
const _isDir = await isDirectory(rPath);
|
|
2351
2388
|
if (!pathType || pathType === "file" && !_isDir || pathType === "dir" && _isDir) {
|
|
@@ -2397,6 +2434,16 @@ async function existsSensitive(path) {
|
|
|
2397
2434
|
async function isDirectory(path) {
|
|
2398
2435
|
return (await promises.lstat(path)).isDirectory();
|
|
2399
2436
|
}
|
|
2437
|
+
function existsInVFS(path, nuxt = tryUseNuxt()) {
|
|
2438
|
+
if (!nuxt) {
|
|
2439
|
+
return false;
|
|
2440
|
+
}
|
|
2441
|
+
if (path in nuxt.vfs) {
|
|
2442
|
+
return true;
|
|
2443
|
+
}
|
|
2444
|
+
const templates = nuxt.apps.default?.templates ?? nuxt.options.build.templates;
|
|
2445
|
+
return templates.some((template) => template.dst === path);
|
|
2446
|
+
}
|
|
2400
2447
|
async function resolveFiles(path, pattern, opts = {}) {
|
|
2401
2448
|
const files = await globby(pattern, { cwd: path, followSymbolicLinks: opts.followSymbolicLinks ?? true });
|
|
2402
2449
|
return files.map((p) => resolve(path, p)).filter((p) => !isIgnored(p)).sort();
|
|
@@ -2424,10 +2471,14 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
|
2424
2471
|
}
|
|
2425
2472
|
}
|
|
2426
2473
|
nuxt.options._installedModules = nuxt.options._installedModules || [];
|
|
2474
|
+
const entryPath = typeof moduleToInstall === "string" ? resolveAlias(moduleToInstall) : void 0;
|
|
2475
|
+
if (typeof moduleToInstall === "string" && entryPath !== moduleToInstall) {
|
|
2476
|
+
buildTimeModuleMeta.rawPath = moduleToInstall;
|
|
2477
|
+
}
|
|
2427
2478
|
nuxt.options._installedModules.push({
|
|
2428
2479
|
meta: defu(await nuxtModule.getMeta?.(), buildTimeModuleMeta),
|
|
2429
2480
|
timings: res.timings,
|
|
2430
|
-
entryPath
|
|
2481
|
+
entryPath
|
|
2431
2482
|
});
|
|
2432
2483
|
}
|
|
2433
2484
|
function getDirectory(p) {
|
|
@@ -2447,7 +2498,7 @@ async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
|
|
|
2447
2498
|
let error;
|
|
2448
2499
|
for (const path of paths) {
|
|
2449
2500
|
try {
|
|
2450
|
-
const src = await resolvePath(path);
|
|
2501
|
+
const src = await resolvePath(path, { fallbackToOriginal: true });
|
|
2451
2502
|
nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir });
|
|
2452
2503
|
const moduleMetadataPath = join(dirname(src), "module.json");
|
|
2453
2504
|
if (existsSync(moduleMetadataPath)) {
|
|
@@ -2511,13 +2562,21 @@ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
|
|
|
2511
2562
|
return false;
|
|
2512
2563
|
}
|
|
2513
2564
|
|
|
2565
|
+
const layerSchemaKeys = ["future", "srcDir", "rootDir", "dir"];
|
|
2566
|
+
const layerSchema = Object.fromEntries(Object.entries(NuxtConfigSchema).filter(([key]) => layerSchemaKeys.includes(key)));
|
|
2514
2567
|
async function loadNuxtConfig(opts) {
|
|
2568
|
+
opts.overrides = defu$1(opts.overrides, {
|
|
2569
|
+
_extends: await globby("layers/*", {
|
|
2570
|
+
onlyDirectories: true,
|
|
2571
|
+
cwd: opts.cwd || process.cwd()
|
|
2572
|
+
})
|
|
2573
|
+
});
|
|
2515
2574
|
globalThis.defineNuxtConfig = (c) => c;
|
|
2516
2575
|
const result = await loadConfig({
|
|
2517
2576
|
name: "nuxt",
|
|
2518
2577
|
configFile: "nuxt.config",
|
|
2519
2578
|
rcFile: ".nuxtrc",
|
|
2520
|
-
extend: { extendKey: ["theme", "extends"] },
|
|
2579
|
+
extend: { extendKey: ["theme", "extends", "_extends"] },
|
|
2521
2580
|
dotenv: true,
|
|
2522
2581
|
globalRc: true,
|
|
2523
2582
|
...opts
|
|
@@ -2528,12 +2587,16 @@ async function loadNuxtConfig(opts) {
|
|
|
2528
2587
|
nuxtConfig.rootDir = nuxtConfig.rootDir || cwd;
|
|
2529
2588
|
nuxtConfig._nuxtConfigFile = configFile;
|
|
2530
2589
|
nuxtConfig._nuxtConfigFiles = [configFile];
|
|
2590
|
+
const _layers = [];
|
|
2531
2591
|
for (const layer of layers) {
|
|
2532
2592
|
layer.config = layer.config || {};
|
|
2533
2593
|
layer.config.rootDir = layer.config.rootDir ?? layer.cwd;
|
|
2534
|
-
layer.config
|
|
2594
|
+
layer.config = await applyDefaults(layerSchema, layer.config);
|
|
2595
|
+
if (!layer.configFile || layer.configFile.endsWith(".nuxtrc")) {
|
|
2596
|
+
continue;
|
|
2597
|
+
}
|
|
2598
|
+
_layers.push(layer);
|
|
2535
2599
|
}
|
|
2536
|
-
const _layers = layers.filter((layer) => layer.configFile && !layer.configFile.endsWith(".nuxtrc"));
|
|
2537
2600
|
nuxtConfig._layers = _layers;
|
|
2538
2601
|
if (!_layers.length) {
|
|
2539
2602
|
_layers.push({
|
|
@@ -2563,7 +2626,7 @@ async function loadNuxt(opts) {
|
|
|
2563
2626
|
throw new Error(`Cannot find any nuxt version from ${opts.cwd}`);
|
|
2564
2627
|
}
|
|
2565
2628
|
const pkg = await readPackageJSON(nearestNuxtPkg);
|
|
2566
|
-
const majorVersion = pkg.version ? parseInt(pkg.version.split(".")[0]) : "";
|
|
2629
|
+
const majorVersion = pkg.version ? Number.parseInt(pkg.version.split(".")[0]) : "";
|
|
2567
2630
|
const rootDir = pathToFileURL(opts.cwd || process.cwd()).href;
|
|
2568
2631
|
if (majorVersion === 3) {
|
|
2569
2632
|
const { loadNuxt: loadNuxt3 } = await importModule(pkg._name || pkg.name, rootDir);
|
|
@@ -2624,6 +2687,125 @@ function addImportsSources(presets) {
|
|
|
2624
2687
|
});
|
|
2625
2688
|
}
|
|
2626
2689
|
|
|
2690
|
+
function normalizeHandlerMethod(handler) {
|
|
2691
|
+
const [, method = void 0] = handler.handler.match(/\.(get|head|patch|post|put|delete|connect|options|trace)(\.\w+)*$/) || [];
|
|
2692
|
+
return {
|
|
2693
|
+
method,
|
|
2694
|
+
...handler,
|
|
2695
|
+
handler: normalize(handler.handler)
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
function addServerHandler(handler) {
|
|
2699
|
+
useNuxt().options.serverHandlers.push(normalizeHandlerMethod(handler));
|
|
2700
|
+
}
|
|
2701
|
+
function addDevServerHandler(handler) {
|
|
2702
|
+
useNuxt().options.devServerHandlers.push(handler);
|
|
2703
|
+
}
|
|
2704
|
+
function addServerPlugin(plugin) {
|
|
2705
|
+
const nuxt = useNuxt();
|
|
2706
|
+
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || [];
|
|
2707
|
+
nuxt.options.nitro.plugins.push(normalize(plugin));
|
|
2708
|
+
}
|
|
2709
|
+
function addPrerenderRoutes(routes) {
|
|
2710
|
+
const nuxt = useNuxt();
|
|
2711
|
+
routes = toArray(routes).filter(Boolean);
|
|
2712
|
+
if (!routes.length) {
|
|
2713
|
+
return;
|
|
2714
|
+
}
|
|
2715
|
+
nuxt.hook("prerender:routes", (ctx) => {
|
|
2716
|
+
for (const route of routes) {
|
|
2717
|
+
ctx.routes.add(route);
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
function useNitro() {
|
|
2722
|
+
const nuxt = useNuxt();
|
|
2723
|
+
if (!nuxt._nitro) {
|
|
2724
|
+
throw new Error("Nitro is not initialized yet. You can call `useNitro()` only after `ready` hook.");
|
|
2725
|
+
}
|
|
2726
|
+
return nuxt._nitro;
|
|
2727
|
+
}
|
|
2728
|
+
function addServerImports(imports) {
|
|
2729
|
+
const nuxt = useNuxt();
|
|
2730
|
+
nuxt.hook("nitro:config", (config) => {
|
|
2731
|
+
config.imports = config.imports || {};
|
|
2732
|
+
config.imports.imports = config.imports.imports || [];
|
|
2733
|
+
config.imports.imports.push(...imports);
|
|
2734
|
+
});
|
|
2735
|
+
}
|
|
2736
|
+
function addServerImportsDir(dirs, opts = {}) {
|
|
2737
|
+
const nuxt = useNuxt();
|
|
2738
|
+
const _dirs = toArray(dirs);
|
|
2739
|
+
nuxt.hook("nitro:config", (config) => {
|
|
2740
|
+
config.imports = config.imports || {};
|
|
2741
|
+
config.imports.dirs = config.imports.dirs || [];
|
|
2742
|
+
config.imports.dirs[opts.prepend ? "unshift" : "push"](..._dirs);
|
|
2743
|
+
});
|
|
2744
|
+
}
|
|
2745
|
+
function addServerScanDir(dirs, opts = {}) {
|
|
2746
|
+
const nuxt = useNuxt();
|
|
2747
|
+
nuxt.hook("nitro:config", (config) => {
|
|
2748
|
+
config.scanDirs = config.scanDirs || [];
|
|
2749
|
+
for (const dir of toArray(dirs)) {
|
|
2750
|
+
config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
|
|
2751
|
+
}
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
function useRuntimeConfig() {
|
|
2756
|
+
const nuxt = useNuxt();
|
|
2757
|
+
return applyEnv(klona(nuxt.options.nitro.runtimeConfig), {
|
|
2758
|
+
prefix: "NITRO_",
|
|
2759
|
+
altPrefix: "NUXT_",
|
|
2760
|
+
envExpansion: nuxt.options.nitro.experimental?.envExpansion ?? !!process$1.env.NITRO_ENV_EXPANSION
|
|
2761
|
+
});
|
|
2762
|
+
}
|
|
2763
|
+
function updateRuntimeConfig(runtimeConfig) {
|
|
2764
|
+
const nuxt = useNuxt();
|
|
2765
|
+
Object.assign(nuxt.options.nitro.runtimeConfig, defu$1(runtimeConfig, nuxt.options.nitro.runtimeConfig));
|
|
2766
|
+
try {
|
|
2767
|
+
return useNitro().updateConfig({ runtimeConfig });
|
|
2768
|
+
} catch {
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
function getEnv(key, opts, env = process$1.env) {
|
|
2772
|
+
const envKey = snakeCase(key).toUpperCase();
|
|
2773
|
+
return destr(
|
|
2774
|
+
env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey]
|
|
2775
|
+
);
|
|
2776
|
+
}
|
|
2777
|
+
function _isObject(input) {
|
|
2778
|
+
return typeof input === "object" && !Array.isArray(input);
|
|
2779
|
+
}
|
|
2780
|
+
function applyEnv(obj, opts, parentKey = "") {
|
|
2781
|
+
for (const key in obj) {
|
|
2782
|
+
const subKey = parentKey ? `${parentKey}_${key}` : key;
|
|
2783
|
+
const envValue = getEnv(subKey, opts);
|
|
2784
|
+
if (_isObject(obj[key])) {
|
|
2785
|
+
if (_isObject(envValue)) {
|
|
2786
|
+
obj[key] = { ...obj[key], ...envValue };
|
|
2787
|
+
applyEnv(obj[key], opts, subKey);
|
|
2788
|
+
} else if (envValue === void 0) {
|
|
2789
|
+
applyEnv(obj[key], opts, subKey);
|
|
2790
|
+
} else {
|
|
2791
|
+
obj[key] = envValue ?? obj[key];
|
|
2792
|
+
}
|
|
2793
|
+
} else {
|
|
2794
|
+
obj[key] = envValue ?? obj[key];
|
|
2795
|
+
}
|
|
2796
|
+
if (opts.envExpansion && typeof obj[key] === "string") {
|
|
2797
|
+
obj[key] = _expandFromEnv(obj[key]);
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
return obj;
|
|
2801
|
+
}
|
|
2802
|
+
const envExpandRx = /\{\{(.*?)\}\}/g;
|
|
2803
|
+
function _expandFromEnv(value, env = process$1.env) {
|
|
2804
|
+
return value.replace(envExpandRx, (match, key) => {
|
|
2805
|
+
return env[key] || match;
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2627
2809
|
function extendWebpackConfig(fn, options = {}) {
|
|
2628
2810
|
const nuxt = useNuxt();
|
|
2629
2811
|
if (options.dev === false && nuxt.options.dev) {
|
|
@@ -2804,27 +2986,48 @@ async function _generateTypes(nuxt) {
|
|
|
2804
2986
|
rootDirWithSlash,
|
|
2805
2987
|
nuxt.options._installedModules.filter((m) => m.entryPath).map((m) => getDirectory(m.entryPath))
|
|
2806
2988
|
);
|
|
2989
|
+
const isV4 = nuxt.options.future?.compatibilityVersion === 4;
|
|
2990
|
+
const hasTypescriptVersionWithModulePreserve = await readPackageJSON("typescript", { url: nuxt.options.modulesDir }).then((r) => r?.version && gte(r.version, "5.4.0")).catch(() => isV4);
|
|
2807
2991
|
const tsConfig = defu(nuxt.options.typescript?.tsConfig, {
|
|
2808
2992
|
compilerOptions: {
|
|
2993
|
+
/* Base options: */
|
|
2994
|
+
esModuleInterop: true,
|
|
2995
|
+
skipLibCheck: true,
|
|
2996
|
+
target: "ESNext",
|
|
2997
|
+
allowJs: true,
|
|
2998
|
+
resolveJsonModule: true,
|
|
2999
|
+
moduleDetection: "force",
|
|
3000
|
+
isolatedModules: true,
|
|
3001
|
+
verbatimModuleSyntax: true,
|
|
3002
|
+
/* Strictness */
|
|
3003
|
+
strict: nuxt.options.typescript?.strict ?? true,
|
|
3004
|
+
noUncheckedIndexedAccess: isV4,
|
|
2809
3005
|
forceConsistentCasingInFileNames: true,
|
|
3006
|
+
noImplicitOverride: true,
|
|
3007
|
+
/* If NOT transpiling with TypeScript: */
|
|
3008
|
+
module: hasTypescriptVersionWithModulePreserve ? "preserve" : "ESNext",
|
|
3009
|
+
noEmit: true,
|
|
3010
|
+
/* If your code runs in the DOM: */
|
|
3011
|
+
lib: [
|
|
3012
|
+
"ESNext",
|
|
3013
|
+
"dom",
|
|
3014
|
+
"dom.iterable"
|
|
3015
|
+
],
|
|
3016
|
+
/* JSX support for Vue */
|
|
2810
3017
|
jsx: "preserve",
|
|
2811
3018
|
jsxImportSource: "vue",
|
|
2812
|
-
|
|
2813
|
-
|
|
3019
|
+
/* remove auto-scanning for types */
|
|
3020
|
+
types: [],
|
|
3021
|
+
/* add paths object for filling-in later */
|
|
3022
|
+
paths: {},
|
|
3023
|
+
/* Possibly consider removing the following in future */
|
|
2814
3024
|
moduleResolution: nuxt.options.future?.typescriptBundlerResolution || nuxt.options.experimental?.typescriptBundlerResolution ? "Bundler" : "Node",
|
|
2815
|
-
|
|
2816
|
-
isolatedModules: true,
|
|
3025
|
+
/* implied by module: preserve */
|
|
2817
3026
|
useDefineForClassFields: true,
|
|
2818
|
-
|
|
3027
|
+
/* implied by target: es2022+ */
|
|
2819
3028
|
noImplicitThis: true,
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
verbatimModuleSyntax: true,
|
|
2823
|
-
allowJs: true,
|
|
2824
|
-
noEmit: true,
|
|
2825
|
-
resolveJsonModule: true,
|
|
2826
|
-
allowSyntheticDefaultImports: true,
|
|
2827
|
-
paths: {}
|
|
3029
|
+
/* enabled with `strict` */
|
|
3030
|
+
allowSyntheticDefaultImports: true
|
|
2828
3031
|
},
|
|
2829
3032
|
include: [
|
|
2830
3033
|
"./nuxt.d.ts",
|
|
@@ -2874,7 +3077,7 @@ async function _generateTypes(nuxt) {
|
|
|
2874
3077
|
tsConfig.include.push(relativePath);
|
|
2875
3078
|
}
|
|
2876
3079
|
} else {
|
|
2877
|
-
const path = stats?.isFile() ? relativePath.replace(
|
|
3080
|
+
const path = stats?.isFile() ? relativePath.replace(/\b\.\w+$/g, "") : aliases[alias];
|
|
2878
3081
|
tsConfig.compilerOptions.paths[alias] = [path];
|
|
2879
3082
|
if (!absolutePath.startsWith(rootDirWithSlash)) {
|
|
2880
3083
|
tsConfig.include.push(path);
|
|
@@ -2897,7 +3100,7 @@ async function _generateTypes(nuxt) {
|
|
|
2897
3100
|
() => null
|
|
2898
3101
|
/* file does not exist */
|
|
2899
3102
|
);
|
|
2900
|
-
return relativeWithDot(nuxt.options.buildDir, stats?.isFile() ? path.replace(
|
|
3103
|
+
return relativeWithDot(nuxt.options.buildDir, stats?.isFile() ? path.replace(/\b\.\w+$/g, "") : path);
|
|
2901
3104
|
}));
|
|
2902
3105
|
}
|
|
2903
3106
|
tsConfig.include = [...new Set(tsConfig.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
|
|
@@ -3021,10 +3224,6 @@ function normalizePlugin(plugin) {
|
|
|
3021
3224
|
if (!plugin.src) {
|
|
3022
3225
|
throw new Error("Invalid plugin. src option is required: " + JSON.stringify(plugin));
|
|
3023
3226
|
}
|
|
3024
|
-
const nonTopLevelPlugin = plugin.src.match(/\/plugins\/[^/]+\/index\.[^/]+$/i);
|
|
3025
|
-
if (nonTopLevelPlugin && nonTopLevelPlugin.length > 0 && !useNuxt().options.plugins.find((i) => (typeof i === "string" ? i : i.src).endsWith(nonTopLevelPlugin[0]))) {
|
|
3026
|
-
logger.warn(`[deprecation] You are using a plugin that is within a subfolder of your plugins directory without adding it to your config explicitly. You can move it to the top-level plugins directory, or include the file '~${nonTopLevelPlugin[0]}' in your plugins config (https://nuxt.com/docs/api/nuxt-config#plugins-1) to remove this warning.`);
|
|
3027
|
-
}
|
|
3028
3227
|
plugin.src = normalize(resolveAlias(plugin.src));
|
|
3029
3228
|
if (plugin.ssr) {
|
|
3030
3229
|
plugin.mode = "server";
|
|
@@ -3047,69 +3246,4 @@ function addPluginTemplate(plugin, opts = {}) {
|
|
|
3047
3246
|
return addPlugin(normalizedPlugin, opts);
|
|
3048
3247
|
}
|
|
3049
3248
|
|
|
3050
|
-
|
|
3051
|
-
const [, method = void 0] = handler.handler.match(/\.(get|head|patch|post|put|delete|connect|options|trace)(\.\w+)*$/) || [];
|
|
3052
|
-
return {
|
|
3053
|
-
method,
|
|
3054
|
-
...handler,
|
|
3055
|
-
handler: normalize(handler.handler)
|
|
3056
|
-
};
|
|
3057
|
-
}
|
|
3058
|
-
function addServerHandler(handler) {
|
|
3059
|
-
useNuxt().options.serverHandlers.push(normalizeHandlerMethod(handler));
|
|
3060
|
-
}
|
|
3061
|
-
function addDevServerHandler(handler) {
|
|
3062
|
-
useNuxt().options.devServerHandlers.push(handler);
|
|
3063
|
-
}
|
|
3064
|
-
function addServerPlugin(plugin) {
|
|
3065
|
-
const nuxt = useNuxt();
|
|
3066
|
-
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || [];
|
|
3067
|
-
nuxt.options.nitro.plugins.push(normalize(plugin));
|
|
3068
|
-
}
|
|
3069
|
-
function addPrerenderRoutes(routes) {
|
|
3070
|
-
const nuxt = useNuxt();
|
|
3071
|
-
routes = toArray(routes).filter(Boolean);
|
|
3072
|
-
if (!routes.length) {
|
|
3073
|
-
return;
|
|
3074
|
-
}
|
|
3075
|
-
nuxt.hook("prerender:routes", (ctx) => {
|
|
3076
|
-
for (const route of routes) {
|
|
3077
|
-
ctx.routes.add(route);
|
|
3078
|
-
}
|
|
3079
|
-
});
|
|
3080
|
-
}
|
|
3081
|
-
function useNitro() {
|
|
3082
|
-
const nuxt = useNuxt();
|
|
3083
|
-
if (!nuxt._nitro) {
|
|
3084
|
-
throw new Error("Nitro is not initialized yet. You can call `useNitro()` only after `ready` hook.");
|
|
3085
|
-
}
|
|
3086
|
-
return nuxt._nitro;
|
|
3087
|
-
}
|
|
3088
|
-
function addServerImports(imports) {
|
|
3089
|
-
const nuxt = useNuxt();
|
|
3090
|
-
nuxt.hook("nitro:config", (config) => {
|
|
3091
|
-
config.imports = config.imports || {};
|
|
3092
|
-
config.imports.imports = config.imports.imports || [];
|
|
3093
|
-
config.imports.imports.push(...imports);
|
|
3094
|
-
});
|
|
3095
|
-
}
|
|
3096
|
-
function addServerImportsDir(dirs, opts = {}) {
|
|
3097
|
-
const nuxt = useNuxt();
|
|
3098
|
-
const _dirs = toArray(dirs);
|
|
3099
|
-
nuxt.hook("nitro:config", (config) => {
|
|
3100
|
-
config.imports = config.imports || {};
|
|
3101
|
-
config.imports.dirs = config.imports.dirs || [];
|
|
3102
|
-
config.imports.dirs[opts.prepend ? "unshift" : "push"](..._dirs);
|
|
3103
|
-
});
|
|
3104
|
-
}
|
|
3105
|
-
function addServerScanDir(dirs, opts = {}) {
|
|
3106
|
-
const nuxt = useNuxt();
|
|
3107
|
-
nuxt.hook("nitro:config", (config) => {
|
|
3108
|
-
config.scanDirs = config.scanDirs || [];
|
|
3109
|
-
for (const dir of toArray(dirs)) {
|
|
3110
|
-
config.scanDirs[opts.prepend ? "unshift" : "push"](dir);
|
|
3111
|
-
}
|
|
3112
|
-
});
|
|
3113
|
-
}
|
|
3114
|
-
|
|
3115
|
-
export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt, writeTypes };
|
|
3249
|
+
export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, templateUtils, tryImportModule$1 as 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.12.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -26,21 +26,23 @@
|
|
|
26
26
|
"c12": "^1.10.0",
|
|
27
27
|
"consola": "^3.2.3",
|
|
28
28
|
"defu": "^6.1.4",
|
|
29
|
+
"destr": "^2.0.3",
|
|
29
30
|
"globby": "^14.0.1",
|
|
30
31
|
"hash-sum": "^2.0.0",
|
|
31
32
|
"ignore": "^5.3.1",
|
|
32
|
-
"jiti": "^1.21.
|
|
33
|
+
"jiti": "^1.21.6",
|
|
34
|
+
"klona": "^2.0.6",
|
|
33
35
|
"knitwork": "^1.1.0",
|
|
34
|
-
"mlly": "^1.
|
|
36
|
+
"mlly": "^1.7.1",
|
|
35
37
|
"pathe": "^1.1.2",
|
|
36
|
-
"pkg-types": "^1.
|
|
38
|
+
"pkg-types": "^1.1.1",
|
|
37
39
|
"scule": "^1.3.0",
|
|
38
|
-
"semver": "^7.6.
|
|
40
|
+
"semver": "^7.6.2",
|
|
39
41
|
"ufo": "^1.5.3",
|
|
40
42
|
"unctx": "^2.3.1",
|
|
41
|
-
"unimport": "^3.7.
|
|
43
|
+
"unimport": "^3.7.2",
|
|
42
44
|
"untyped": "^1.4.2",
|
|
43
|
-
"@nuxt/schema": "3.
|
|
45
|
+
"@nuxt/schema": "3.12.0"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
48
|
"@types/hash-sum": "1.0.2",
|
|
@@ -49,8 +51,8 @@
|
|
|
49
51
|
"lodash-es": "4.17.21",
|
|
50
52
|
"nitropack": "2.9.6",
|
|
51
53
|
"unbuild": "latest",
|
|
52
|
-
"vite": "5.2.
|
|
53
|
-
"vitest": "1.
|
|
54
|
+
"vite": "5.2.13",
|
|
55
|
+
"vitest": "1.6.0",
|
|
54
56
|
"webpack": "5.91.0"
|
|
55
57
|
},
|
|
56
58
|
"engines": {
|