@nuxt/kit 3.0.0-rc.8 → 3.0.0-rc.9
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/dist/index.d.ts +20 -12
- package/dist/index.mjs +35 -23
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nuxt, ModuleContainer, ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, NuxtOptions, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtPlugin, NuxtPluginTemplate } from '@nuxt/schema';
|
|
1
|
+
import { Nuxt, ModuleContainer, ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, NuxtOptions, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate } from '@nuxt/schema';
|
|
2
2
|
import { LoadConfigOptions } from 'c12';
|
|
3
3
|
import { Import } from 'unimport';
|
|
4
4
|
import { Configuration, WebpackPluginInstance } from 'webpack';
|
|
@@ -37,8 +37,16 @@ interface LoadNuxtOptions extends LoadNuxtConfigOptions {
|
|
|
37
37
|
declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
|
|
38
38
|
declare function buildNuxt(nuxt: Nuxt): Promise<any>;
|
|
39
39
|
|
|
40
|
-
declare function
|
|
41
|
-
|
|
40
|
+
declare function addImports(imports: Import | Import[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Please use `addImports` instead with nuxt>=3.0.0-rc.9
|
|
43
|
+
*/
|
|
44
|
+
declare const addAutoImport: typeof addImports;
|
|
45
|
+
declare function addImportsDir(dirs: string | string[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Please use `addImportsDir` instead with nuxt>=3.0.0-rc.9
|
|
48
|
+
*/
|
|
49
|
+
declare const addAutoImportDir: typeof addImportsDir;
|
|
42
50
|
|
|
43
51
|
interface ExtendConfigOptions {
|
|
44
52
|
/**
|
|
@@ -87,7 +95,7 @@ declare function extendWebpackConfig(fn: ((config: Configuration) => void), opti
|
|
|
87
95
|
/**
|
|
88
96
|
* Extend Vite config
|
|
89
97
|
*/
|
|
90
|
-
declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): () => void;
|
|
98
|
+
declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): (() => void) | undefined;
|
|
91
99
|
/**
|
|
92
100
|
* Append Webpack plugin to the config.
|
|
93
101
|
*/
|
|
@@ -172,7 +180,7 @@ declare function tryUseNuxt(): Nuxt | null;
|
|
|
172
180
|
*/
|
|
173
181
|
declare function isIgnored(pathname: string): boolean;
|
|
174
182
|
|
|
175
|
-
declare function addLayout(
|
|
183
|
+
declare function addLayout(this: any, template: NuxtTemplate, name?: string): void;
|
|
176
184
|
|
|
177
185
|
declare function extendPages(cb: NuxtHooks['pages:extend']): void;
|
|
178
186
|
|
|
@@ -228,7 +236,7 @@ declare function findPath(paths: string | string[], opts?: ResolvePathOptions, p
|
|
|
228
236
|
*/
|
|
229
237
|
declare function resolveAlias(path: string, alias?: Record<string, string>): string;
|
|
230
238
|
interface Resolver {
|
|
231
|
-
resolve(...path:
|
|
239
|
+
resolve(...path: string[]): string;
|
|
232
240
|
resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
|
|
233
241
|
}
|
|
234
242
|
/**
|
|
@@ -265,11 +273,11 @@ declare function addDevServerHandler(handler: NitroDevEventHandler): void;
|
|
|
265
273
|
/**
|
|
266
274
|
* Renders given template using lodash template during build into the project buildDir
|
|
267
275
|
*/
|
|
268
|
-
declare function addTemplate(_template: NuxtTemplate | string):
|
|
276
|
+
declare function addTemplate(_template: NuxtTemplate<any> | string): ResolvedNuxtTemplate<any>;
|
|
269
277
|
/**
|
|
270
278
|
* Normalize a nuxt template object
|
|
271
279
|
*/
|
|
272
|
-
declare function normalizeTemplate(template: NuxtTemplate | string):
|
|
280
|
+
declare function normalizeTemplate(template: NuxtTemplate<any> | string): ResolvedNuxtTemplate<any>;
|
|
273
281
|
|
|
274
282
|
declare const logger: consola.Consola;
|
|
275
283
|
declare function useLogger(scope?: string): consola.Consola;
|
|
@@ -287,7 +295,7 @@ declare function isNodeModules(id: string): boolean;
|
|
|
287
295
|
declare function clearRequireCache(id: string): void;
|
|
288
296
|
declare function scanRequireTree(id: string, files?: Set<string>): Set<string>;
|
|
289
297
|
/** Access the require cache by module id. */
|
|
290
|
-
declare function getRequireCacheItem(id: string): NodeModule;
|
|
298
|
+
declare function getRequireCacheItem(id: string): NodeModule | undefined;
|
|
291
299
|
/** Resolve the `package.json` file for a given module. */
|
|
292
300
|
declare function requireModulePkg(id: string, opts?: RequireModuleOptions): any;
|
|
293
301
|
/** Resolve the path of a module. */
|
|
@@ -297,7 +305,7 @@ declare function tryResolveModule(path: string, opts?: ResolveModuleOptions): st
|
|
|
297
305
|
/** Require a module and return it. */
|
|
298
306
|
declare function requireModule(id: string, opts?: RequireModuleOptions): any;
|
|
299
307
|
declare function importModule(id: string, opts?: RequireModuleOptions): Promise<any>;
|
|
300
|
-
declare function tryImportModule(id: string, opts?: RequireModuleOptions): Promise<any
|
|
308
|
+
declare function tryImportModule(id: string, opts?: RequireModuleOptions): Promise<any> | undefined;
|
|
301
309
|
/** Try to require a module, but don't emit an error if the module can't be required. */
|
|
302
310
|
declare function tryRequireModule(id: string, opts?: RequireModuleOptions): any;
|
|
303
311
|
|
|
@@ -307,8 +315,8 @@ declare const templateUtils: {
|
|
|
307
315
|
serialize: (data: any) => string;
|
|
308
316
|
importName: typeof genSafeVariableName;
|
|
309
317
|
importSources: (sources: string | string[], { lazy }?: {
|
|
310
|
-
lazy?: boolean;
|
|
318
|
+
lazy?: boolean | undefined;
|
|
311
319
|
}) => string;
|
|
312
320
|
};
|
|
313
321
|
|
|
314
|
-
export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LegacyServerMiddleware, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addLayout, addPlugin, addPluginTemplate, addServerHandler, addServerMiddleware, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendPages, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, useLogger, useModuleContainer, useNuxt };
|
|
322
|
+
export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LegacyServerMiddleware, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addLayout, addPlugin, addPluginTemplate, addServerHandler, addServerMiddleware, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendPages, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, useLogger, useModuleContainer, useNuxt };
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import satisfies from 'semver/functions/satisfies.js';
|
|
|
7
7
|
import consola from 'consola';
|
|
8
8
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
9
9
|
import { globby } from 'globby';
|
|
10
|
+
import { normalizeAliases } from 'pathe/utils';
|
|
10
11
|
import { interopDefault } from 'mlly';
|
|
11
12
|
import jiti from 'jiti';
|
|
12
13
|
import ignore from 'ignore';
|
|
@@ -99,8 +100,8 @@ async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
|
99
100
|
const issues = [];
|
|
100
101
|
if (constraints.nuxt) {
|
|
101
102
|
const nuxtVersion = getNuxtVersion(nuxt);
|
|
102
|
-
const nuxtSemanticVersion = nuxtVersion.
|
|
103
|
-
if (!satisfies(nuxtSemanticVersion, constraints.nuxt)) {
|
|
103
|
+
const nuxtSemanticVersion = nuxtVersion.replace(/-[0-9]+\.[0-9a-f]{7}/, "");
|
|
104
|
+
if (!satisfies(nuxtSemanticVersion, constraints.nuxt, { includePrerelease: true })) {
|
|
104
105
|
issues.push({
|
|
105
106
|
name: "nuxt",
|
|
106
107
|
message: `Nuxt version \`${constraints.nuxt}\` is required but currently using \`${nuxtVersion}\``
|
|
@@ -156,10 +157,10 @@ function useLogger(scope) {
|
|
|
156
157
|
return scope ? logger.withScope(scope) : logger;
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
function addLayout(
|
|
160
|
+
function addLayout(template, name) {
|
|
160
161
|
const nuxt = useNuxt();
|
|
161
|
-
const { filename, src } = addTemplate(
|
|
162
|
-
const layoutName = kebabCase(name || parse(
|
|
162
|
+
const { filename, src } = addTemplate(template);
|
|
163
|
+
const layoutName = kebabCase(name || parse(filename).name).replace(/["']/g, "");
|
|
163
164
|
if (isNuxt2(nuxt)) {
|
|
164
165
|
const layout = nuxt.options.layouts[layoutName];
|
|
165
166
|
if (layout) {
|
|
@@ -253,7 +254,7 @@ function resolveModule(id, opts = {}) {
|
|
|
253
254
|
return normalize(_require.resolve(id, {
|
|
254
255
|
paths: [].concat(
|
|
255
256
|
global.__NUXT_PREPATHS__,
|
|
256
|
-
opts.paths,
|
|
257
|
+
opts.paths || [],
|
|
257
258
|
process.cwd(),
|
|
258
259
|
global.__NUXT_PATHS__
|
|
259
260
|
).filter(Boolean)
|
|
@@ -263,7 +264,7 @@ function tryResolveModule(path, opts = {}) {
|
|
|
263
264
|
try {
|
|
264
265
|
return resolveModule(path, opts);
|
|
265
266
|
} catch (error) {
|
|
266
|
-
if (error
|
|
267
|
+
if (error?.code !== "MODULE_NOT_FOUND") {
|
|
267
268
|
throw error;
|
|
268
269
|
}
|
|
269
270
|
}
|
|
@@ -300,7 +301,7 @@ function tryRequireModule(id, opts = {}) {
|
|
|
300
301
|
function isIgnored(pathname) {
|
|
301
302
|
const nuxt = tryUseNuxt();
|
|
302
303
|
if (!nuxt) {
|
|
303
|
-
return
|
|
304
|
+
return false;
|
|
304
305
|
}
|
|
305
306
|
if (!nuxt._ignore) {
|
|
306
307
|
nuxt._ignore = ignore(nuxt.options.ignoreOptions);
|
|
@@ -314,7 +315,7 @@ function isIgnored(pathname) {
|
|
|
314
315
|
if (relativePath.startsWith("..")) {
|
|
315
316
|
return false;
|
|
316
317
|
}
|
|
317
|
-
return relativePath && nuxt._ignore.ignores(relativePath);
|
|
318
|
+
return !!(relativePath && nuxt._ignore.ignores(relativePath));
|
|
318
319
|
}
|
|
319
320
|
|
|
320
321
|
async function resolvePath(path, opts = {}) {
|
|
@@ -373,7 +374,7 @@ function resolveAlias(path, alias) {
|
|
|
373
374
|
if (!alias) {
|
|
374
375
|
alias = tryUseNuxt()?.options.alias || {};
|
|
375
376
|
}
|
|
376
|
-
for (const key in alias) {
|
|
377
|
+
for (const key in normalizeAliases(alias)) {
|
|
377
378
|
if (key === "@" && !path.startsWith("@/")) {
|
|
378
379
|
continue;
|
|
379
380
|
}
|
|
@@ -445,7 +446,11 @@ function addPluginTemplate(plugin, opts = {}) {
|
|
|
445
446
|
async function installModule(moduleToInstall, _inlineOptions, _nuxt) {
|
|
446
447
|
const nuxt = useNuxt();
|
|
447
448
|
const { nuxtModule, inlineOptions } = await normalizeModule(moduleToInstall, _inlineOptions);
|
|
448
|
-
await nuxtModule.call(
|
|
449
|
+
await nuxtModule.call(
|
|
450
|
+
useModuleContainer(),
|
|
451
|
+
inlineOptions,
|
|
452
|
+
nuxt
|
|
453
|
+
);
|
|
449
454
|
nuxt.options._installedModules = nuxt.options._installedModules || [];
|
|
450
455
|
nuxt.options._installedModules.push({
|
|
451
456
|
meta: await nuxtModule.getMeta?.(),
|
|
@@ -492,7 +497,7 @@ function useModuleContainer(nuxt = useNuxt()) {
|
|
|
492
497
|
}
|
|
493
498
|
await installModule(src, inlineOptions);
|
|
494
499
|
}
|
|
495
|
-
|
|
500
|
+
const container = {
|
|
496
501
|
nuxt,
|
|
497
502
|
options: nuxt.options,
|
|
498
503
|
ready() {
|
|
@@ -541,6 +546,7 @@ function useModuleContainer(nuxt = useNuxt()) {
|
|
|
541
546
|
}
|
|
542
547
|
}
|
|
543
548
|
};
|
|
549
|
+
nuxt[MODULE_CONTAINER_KEY] = container;
|
|
544
550
|
return nuxt[MODULE_CONTAINER_KEY];
|
|
545
551
|
}
|
|
546
552
|
|
|
@@ -669,18 +675,22 @@ function nuxt2Shims(nuxt) {
|
|
|
669
675
|
}
|
|
670
676
|
|
|
671
677
|
async function loadNuxtConfig(opts) {
|
|
672
|
-
const
|
|
678
|
+
const result = await loadConfig({
|
|
673
679
|
name: "nuxt",
|
|
674
680
|
configFile: "nuxt.config",
|
|
675
681
|
rcFile: ".nuxtrc",
|
|
682
|
+
extend: { extendKey: ["theme", "extends"] },
|
|
676
683
|
dotenv: true,
|
|
677
684
|
globalRc: true,
|
|
678
685
|
...opts
|
|
679
686
|
});
|
|
687
|
+
const { configFile, layers = [], cwd } = result;
|
|
688
|
+
const nuxtConfig = result.config;
|
|
680
689
|
nuxtConfig.rootDir = nuxtConfig.rootDir || cwd;
|
|
681
690
|
nuxtConfig._nuxtConfigFile = configFile;
|
|
682
691
|
nuxtConfig._nuxtConfigFiles = [configFile];
|
|
683
692
|
for (const layer of layers) {
|
|
693
|
+
layer.config = layer.config || {};
|
|
684
694
|
layer.config.rootDir = layer.config.rootDir ?? layer.cwd;
|
|
685
695
|
layer.config.srcDir = resolve(layer.config.rootDir, layer.config.srcDir);
|
|
686
696
|
}
|
|
@@ -724,20 +734,22 @@ async function buildNuxt(nuxt) {
|
|
|
724
734
|
return build(nuxt);
|
|
725
735
|
}
|
|
726
736
|
|
|
727
|
-
function
|
|
737
|
+
function addImports(imports) {
|
|
728
738
|
assertNuxtCompatibility({ bridge: true });
|
|
729
|
-
useNuxt().hook("autoImports:extend", (
|
|
730
|
-
|
|
731
|
-
});
|
|
739
|
+
useNuxt().hook("autoImports:extend", (_imports) => {
|
|
740
|
+
_imports.push(...Array.isArray(imports) ? imports : [imports]);
|
|
741
|
+
}, { allowDeprecated: true });
|
|
732
742
|
}
|
|
733
|
-
|
|
743
|
+
const addAutoImport = addImports;
|
|
744
|
+
function addImportsDir(dirs) {
|
|
734
745
|
assertNuxtCompatibility({ bridge: true });
|
|
735
|
-
useNuxt().hook("autoImports:dirs", (
|
|
736
|
-
for (const dir of Array.isArray(
|
|
737
|
-
|
|
746
|
+
useNuxt().hook("autoImports:dirs", (_dirs) => {
|
|
747
|
+
for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
|
|
748
|
+
_dirs.push(dir);
|
|
738
749
|
}
|
|
739
|
-
});
|
|
750
|
+
}, { allowDeprecated: true });
|
|
740
751
|
}
|
|
752
|
+
const addAutoImportDir = addImportsDir;
|
|
741
753
|
|
|
742
754
|
function extendWebpackConfig(fn, options = {}) {
|
|
743
755
|
const nuxt = useNuxt();
|
|
@@ -850,4 +862,4 @@ function extendPages(cb) {
|
|
|
850
862
|
}
|
|
851
863
|
}
|
|
852
864
|
|
|
853
|
-
export { addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addLayout, addPlugin, addPluginTemplate, addServerHandler, addServerMiddleware, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendPages, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, useLogger, useModuleContainer, useNuxt };
|
|
865
|
+
export { addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addLayout, addPlugin, addPluginTemplate, addServerHandler, addServerMiddleware, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendPages, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, useLogger, useModuleContainer, useNuxt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.9",
|
|
4
4
|
"repository": "nuxt/framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,24 +13,24 @@
|
|
|
13
13
|
"prepack": "unbuild"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuxt/schema": "3.0.0-rc.
|
|
17
|
-
"c12": "^0.2.
|
|
16
|
+
"@nuxt/schema": "3.0.0-rc.9",
|
|
17
|
+
"c12": "^0.2.10",
|
|
18
18
|
"consola": "^2.15.3",
|
|
19
|
-
"defu": "^6.
|
|
19
|
+
"defu": "^6.1.0",
|
|
20
20
|
"globby": "^13.1.2",
|
|
21
21
|
"hash-sum": "^2.0.0",
|
|
22
22
|
"ignore": "^5.2.0",
|
|
23
23
|
"jiti": "^1.14.0",
|
|
24
24
|
"knitwork": "^0.1.2",
|
|
25
25
|
"lodash.template": "^4.5.0",
|
|
26
|
-
"mlly": "^0.5.
|
|
27
|
-
"pathe": "^0.3.
|
|
28
|
-
"pkg-types": "^0.3.
|
|
26
|
+
"mlly": "^0.5.14",
|
|
27
|
+
"pathe": "^0.3.5",
|
|
28
|
+
"pkg-types": "^0.3.4",
|
|
29
29
|
"scule": "^0.3.2",
|
|
30
30
|
"semver": "^7.3.7",
|
|
31
|
-
"unctx": "^2.0.
|
|
31
|
+
"unctx": "^2.0.2",
|
|
32
32
|
"unimport": "^0.6.7",
|
|
33
|
-
"untyped": "^0.4.
|
|
33
|
+
"untyped": "^0.4.7"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/lodash.template": "^4",
|