@nuxt/kit 3.4.2 → 3.5.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/dist/index.d.ts +15 -4
- package/dist/index.mjs +24 -23
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
|
|
|
38
38
|
declare function buildNuxt(nuxt: Nuxt): Promise<any>;
|
|
39
39
|
|
|
40
40
|
declare function addImports(imports: Import | Import[]): void;
|
|
41
|
-
declare function addImportsDir(dirs: string | string[]
|
|
41
|
+
declare function addImportsDir(dirs: string | string[], opts?: {
|
|
42
|
+
prepend?: boolean;
|
|
43
|
+
}): void;
|
|
42
44
|
declare function addImportsSources(presets: ImportPresetWithDeprecation | ImportPresetWithDeprecation[]): void;
|
|
43
45
|
|
|
44
46
|
interface ExtendConfigOptions {
|
|
@@ -66,6 +68,10 @@ interface ExtendConfigOptions {
|
|
|
66
68
|
* @default true
|
|
67
69
|
*/
|
|
68
70
|
client?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Prepends the plugin to the array with `unshit()` instead of `push()`.
|
|
73
|
+
*/
|
|
74
|
+
prepend?: boolean;
|
|
69
75
|
}
|
|
70
76
|
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
|
|
71
77
|
}
|
|
@@ -85,11 +91,16 @@ declare function extendViteConfig(fn: ((config: UserConfig) => void), options?:
|
|
|
85
91
|
/**
|
|
86
92
|
* Append webpack plugin to the config.
|
|
87
93
|
*/
|
|
88
|
-
declare function addWebpackPlugin(
|
|
94
|
+
declare function addWebpackPlugin(pluginOrGetter: WebpackPluginInstance | WebpackPluginInstance[] | (() => WebpackPluginInstance | WebpackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
|
|
89
95
|
/**
|
|
90
96
|
* Append Vite plugin to the config.
|
|
91
97
|
*/
|
|
92
|
-
declare function addVitePlugin(
|
|
98
|
+
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendViteConfigOptions): void;
|
|
99
|
+
interface AddBuildPluginFactory {
|
|
100
|
+
vite?: () => Plugin | Plugin[];
|
|
101
|
+
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
|
|
102
|
+
}
|
|
103
|
+
declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
|
|
93
104
|
|
|
94
105
|
/**
|
|
95
106
|
* Check version constraints and return incompatibility issues as an array
|
|
@@ -347,4 +358,4 @@ declare const templateUtils: {
|
|
|
347
358
|
}) => string;
|
|
348
359
|
};
|
|
349
360
|
|
|
350
|
-
export { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, hasNuxtCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
|
361
|
+
export { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, hasNuxtCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveModule, resolvePath, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
package/dist/index.mjs
CHANGED
|
@@ -266,16 +266,6 @@ function resolveModule(id, opts = {}) {
|
|
|
266
266
|
).filter(Boolean)
|
|
267
267
|
}));
|
|
268
268
|
}
|
|
269
|
-
function tryResolveModule$1(path, opts = {}) {
|
|
270
|
-
try {
|
|
271
|
-
return resolveModule(path, opts);
|
|
272
|
-
} catch (error) {
|
|
273
|
-
if (error?.code !== "MODULE_NOT_FOUND") {
|
|
274
|
-
throw error;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
269
|
function requireModule(id, opts = {}) {
|
|
280
270
|
const resolvedPath = resolveModule(id, opts);
|
|
281
271
|
if (opts.clearCache && !isNodeModules(id)) {
|
|
@@ -389,7 +379,7 @@ async function resolvePath(path, opts = {}) {
|
|
|
389
379
|
return pathWithIndex;
|
|
390
380
|
}
|
|
391
381
|
}
|
|
392
|
-
const resolveModulePath =
|
|
382
|
+
const resolveModulePath = await resolvePath$1(_path, { url: [cwd, ...modulesDir] }).catch(() => null);
|
|
393
383
|
if (resolveModulePath) {
|
|
394
384
|
return resolveModulePath;
|
|
395
385
|
}
|
|
@@ -471,10 +461,9 @@ const normalizeModuleTranspilePath = (p) => {
|
|
|
471
461
|
async function normalizeModule(nuxtModule, inlineOptions) {
|
|
472
462
|
const nuxt = useNuxt();
|
|
473
463
|
if (typeof nuxtModule === "string") {
|
|
474
|
-
const
|
|
475
|
-
const isESM = _src.endsWith(".mjs");
|
|
464
|
+
const src = normalize(resolveAlias(nuxtModule));
|
|
476
465
|
try {
|
|
477
|
-
nuxtModule =
|
|
466
|
+
nuxtModule = await importModule(src, nuxt.options.modulesDir).catch(() => null) ?? requireModule(src, { paths: nuxt.options.modulesDir });
|
|
478
467
|
} catch (error) {
|
|
479
468
|
console.error(`Error while requiring module \`${nuxtModule}\`: ${error}`);
|
|
480
469
|
throw error;
|
|
@@ -572,11 +561,11 @@ function addImports(imports) {
|
|
|
572
561
|
_imports.push(...Array.isArray(imports) ? imports : [imports]);
|
|
573
562
|
});
|
|
574
563
|
}
|
|
575
|
-
function addImportsDir(dirs) {
|
|
564
|
+
function addImportsDir(dirs, opts = {}) {
|
|
576
565
|
assertNuxtCompatibility({ bridge: true });
|
|
577
566
|
useNuxt().hook("imports:dirs", (_dirs) => {
|
|
578
567
|
for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
|
|
579
|
-
_dirs.push(dir);
|
|
568
|
+
_dirs[opts.prepend ? "unshift" : "push"](dir);
|
|
580
569
|
}
|
|
581
570
|
});
|
|
582
571
|
}
|
|
@@ -632,26 +621,38 @@ function extendViteConfig(fn, options = {}) {
|
|
|
632
621
|
}
|
|
633
622
|
});
|
|
634
623
|
}
|
|
635
|
-
function addWebpackPlugin(
|
|
624
|
+
function addWebpackPlugin(pluginOrGetter, options) {
|
|
636
625
|
extendWebpackConfig((config) => {
|
|
626
|
+
const method = options?.prepend ? "unshift" : "push";
|
|
627
|
+
const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
|
|
637
628
|
config.plugins = config.plugins || [];
|
|
638
629
|
if (Array.isArray(plugin)) {
|
|
639
|
-
config.plugins
|
|
630
|
+
config.plugins[method](...plugin);
|
|
640
631
|
} else {
|
|
641
|
-
config.plugins
|
|
632
|
+
config.plugins[method](plugin);
|
|
642
633
|
}
|
|
643
634
|
}, options);
|
|
644
635
|
}
|
|
645
|
-
function addVitePlugin(
|
|
636
|
+
function addVitePlugin(pluginOrGetter, options) {
|
|
646
637
|
extendViteConfig((config) => {
|
|
638
|
+
const method = options?.prepend ? "unshift" : "push";
|
|
639
|
+
const plugin = typeof pluginOrGetter === "function" ? pluginOrGetter() : pluginOrGetter;
|
|
647
640
|
config.plugins = config.plugins || [];
|
|
648
641
|
if (Array.isArray(plugin)) {
|
|
649
|
-
config.plugins
|
|
642
|
+
config.plugins[method](...plugin);
|
|
650
643
|
} else {
|
|
651
|
-
config.plugins
|
|
644
|
+
config.plugins[method](plugin);
|
|
652
645
|
}
|
|
653
646
|
}, options);
|
|
654
647
|
}
|
|
648
|
+
function addBuildPlugin(pluginFactory, options) {
|
|
649
|
+
if (pluginFactory.vite) {
|
|
650
|
+
addVitePlugin(pluginFactory.vite, options);
|
|
651
|
+
}
|
|
652
|
+
if (pluginFactory.webpack) {
|
|
653
|
+
addWebpackPlugin(pluginFactory.webpack, options);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
655
656
|
|
|
656
657
|
async function addComponentsDir(dir) {
|
|
657
658
|
const nuxt = useNuxt();
|
|
@@ -885,4 +886,4 @@ function useNitro() {
|
|
|
885
886
|
return nuxt._nitro;
|
|
886
887
|
}
|
|
887
888
|
|
|
888
|
-
export { addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, hasNuxtCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveModule, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
|
889
|
+
export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, hasNuxtCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveModule, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"repository": "nuxt/nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,28 +26,28 @@
|
|
|
26
26
|
"jiti": "^1.18.2",
|
|
27
27
|
"knitwork": "^1.0.0",
|
|
28
28
|
"lodash.template": "^4.5.0",
|
|
29
|
-
"mlly": "^1.2.
|
|
29
|
+
"mlly": "^1.2.1",
|
|
30
30
|
"pathe": "^1.1.0",
|
|
31
|
-
"pkg-types": "^1.0.
|
|
31
|
+
"pkg-types": "^1.0.3",
|
|
32
32
|
"scule": "^1.0.0",
|
|
33
|
-
"semver": "^7.5.
|
|
33
|
+
"semver": "^7.5.1",
|
|
34
34
|
"unctx": "^2.3.0",
|
|
35
35
|
"unimport": "^3.0.6",
|
|
36
36
|
"untyped": "^1.3.2",
|
|
37
|
-
"@nuxt/schema": "3.
|
|
37
|
+
"@nuxt/schema": "3.5.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/hash-sum": "^1.0.0",
|
|
41
41
|
"@types/lodash.template": "^4.5.1",
|
|
42
|
-
"@types/semver": "^7.
|
|
43
|
-
"nitropack": "^2.
|
|
42
|
+
"@types/semver": "^7.5.0",
|
|
43
|
+
"nitropack": "^2.4.0",
|
|
44
44
|
"unbuild": "latest",
|
|
45
|
-
"vite": "^4.3.
|
|
46
|
-
"vitest": "^0.
|
|
47
|
-
"webpack": "^5.
|
|
45
|
+
"vite": "^4.3.6",
|
|
46
|
+
"vitest": "^0.31.0",
|
|
47
|
+
"webpack": "^5.82.1"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
|
-
"node": "^14.18.0 ||
|
|
50
|
+
"node": "^14.18.0 || >=16.10.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {}
|
|
53
53
|
}
|