@nuxt/kit 3.0.0-rc.10 → 3.0.0-rc.12
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/LICENSE +21 -0
- package/dist/index.d.ts +25 -9
- package/dist/index.mjs +24 -4
- package/package.json +12 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 - Nuxt Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ 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
|
|
7
|
-
import {
|
|
8
|
-
import { NitroEventHandler, NitroDevEventHandler } from 'nitropack';
|
|
6
|
+
import * as unctx_index from 'unctx/index';
|
|
7
|
+
import { NodeMiddleware } from 'h3';
|
|
8
|
+
import { NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
|
|
9
9
|
import * as consola from 'consola';
|
|
10
10
|
import { genSafeVariableName } from 'knitwork';
|
|
11
11
|
|
|
@@ -100,11 +100,11 @@ declare function extendViteConfig(fn: ((config: UserConfig) => void), options?:
|
|
|
100
100
|
/**
|
|
101
101
|
* Append Webpack plugin to the config.
|
|
102
102
|
*/
|
|
103
|
-
declare function addWebpackPlugin(plugin: WebpackPluginInstance, options?: ExtendWebpackConfigOptions): void;
|
|
103
|
+
declare function addWebpackPlugin(plugin: WebpackPluginInstance | WebpackPluginInstance[], options?: ExtendWebpackConfigOptions): void;
|
|
104
104
|
/**
|
|
105
105
|
* Append Vite plugin to the config.
|
|
106
106
|
*/
|
|
107
|
-
declare function addVitePlugin(plugin: Plugin, options?: ExtendViteConfigOptions): void;
|
|
107
|
+
declare function addVitePlugin(plugin: Plugin | Plugin[], options?: ExtendViteConfigOptions): void;
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Check version constraints and return incompatibility issues as an array
|
|
@@ -149,7 +149,7 @@ declare type AddComponentOptions = {
|
|
|
149
149
|
declare function addComponent(opts: AddComponentOptions): Promise<void>;
|
|
150
150
|
|
|
151
151
|
/** Direct access to the Nuxt context - see https://github.com/unjs/unctx. */
|
|
152
|
-
declare const nuxtCtx:
|
|
152
|
+
declare const nuxtCtx: unctx_index.UseContext<Nuxt>;
|
|
153
153
|
/**
|
|
154
154
|
* Get access to Nuxt instance.
|
|
155
155
|
*
|
|
@@ -251,8 +251,8 @@ declare function resolveFiles(path: string, pattern: string | string[], opts?: {
|
|
|
251
251
|
interface LegacyServerMiddleware {
|
|
252
252
|
route?: string;
|
|
253
253
|
path?: string;
|
|
254
|
-
handle?:
|
|
255
|
-
handler:
|
|
254
|
+
handle?: NodeMiddleware | string;
|
|
255
|
+
handler: NodeMiddleware | string;
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* Adds a new server middleware to the end of the server middleware array.
|
|
@@ -270,6 +270,22 @@ declare function addServerHandler(handler: NitroEventHandler): void;
|
|
|
270
270
|
*
|
|
271
271
|
*/
|
|
272
272
|
declare function addDevServerHandler(handler: NitroDevEventHandler): void;
|
|
273
|
+
/**
|
|
274
|
+
* Access to the Nitro instance
|
|
275
|
+
*
|
|
276
|
+
* **Note:** You can call `useNitro()` only after `ready` hook.
|
|
277
|
+
*
|
|
278
|
+
* **Note:** Changes to the Nitro instance configuration are not applied.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* nuxt.hook('ready', () => {
|
|
284
|
+
* console.log(useNitro())
|
|
285
|
+
* })
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
declare function useNitro(): Nitro;
|
|
273
289
|
|
|
274
290
|
/**
|
|
275
291
|
* Renders given template using lodash template during build into the project buildDir
|
|
@@ -320,4 +336,4 @@ declare const templateUtils: {
|
|
|
320
336
|
}) => string;
|
|
321
337
|
};
|
|
322
338
|
|
|
323
|
-
export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LegacyServerMiddleware, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, 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 };
|
|
339
|
+
export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LegacyServerMiddleware, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, 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, useNitro, useNuxt };
|
package/dist/index.mjs
CHANGED
|
@@ -204,6 +204,13 @@ function addServerHandler(handler) {
|
|
|
204
204
|
function addDevServerHandler(handler) {
|
|
205
205
|
useNuxt().options.devServerHandlers.push(handler);
|
|
206
206
|
}
|
|
207
|
+
function useNitro() {
|
|
208
|
+
const nuxt = useNuxt();
|
|
209
|
+
if (!nuxt._nitro) {
|
|
210
|
+
throw new Error("Nitro is not initialized yet. You can call `useNitro()` only after `ready` hook.");
|
|
211
|
+
}
|
|
212
|
+
return nuxt._nitro;
|
|
213
|
+
}
|
|
207
214
|
|
|
208
215
|
const _require = jiti(process.cwd(), { interopDefault: true, esmResolve: true });
|
|
209
216
|
function isNodeModules(id) {
|
|
@@ -466,7 +473,12 @@ async function normalizeModule(nuxtModule, inlineOptions) {
|
|
|
466
473
|
if (typeof nuxtModule === "string") {
|
|
467
474
|
const _src = resolveModule(resolveAlias(nuxtModule), { paths: nuxt.options.modulesDir });
|
|
468
475
|
const isESM = _src.endsWith(".mjs");
|
|
469
|
-
|
|
476
|
+
try {
|
|
477
|
+
nuxtModule = isESM ? await importModule(_src) : requireModule(_src);
|
|
478
|
+
} catch (error) {
|
|
479
|
+
console.error(`Error while requiring module \`${nuxtModule}\`: ${error}`);
|
|
480
|
+
throw error;
|
|
481
|
+
}
|
|
470
482
|
}
|
|
471
483
|
if (typeof nuxtModule !== "function") {
|
|
472
484
|
throw new TypeError("Nuxt module should be a function: " + nuxtModule);
|
|
@@ -822,13 +834,21 @@ function extendViteConfig(fn, options = {}) {
|
|
|
822
834
|
function addWebpackPlugin(plugin, options) {
|
|
823
835
|
extendWebpackConfig((config) => {
|
|
824
836
|
config.plugins = config.plugins || [];
|
|
825
|
-
|
|
837
|
+
if (Array.isArray(plugin)) {
|
|
838
|
+
config.plugins.push(...plugin);
|
|
839
|
+
} else {
|
|
840
|
+
config.plugins.push(plugin);
|
|
841
|
+
}
|
|
826
842
|
}, options);
|
|
827
843
|
}
|
|
828
844
|
function addVitePlugin(plugin, options) {
|
|
829
845
|
extendViteConfig((config) => {
|
|
830
846
|
config.plugins = config.plugins || [];
|
|
831
|
-
|
|
847
|
+
if (Array.isArray(plugin)) {
|
|
848
|
+
config.plugins.push(...plugin);
|
|
849
|
+
} else {
|
|
850
|
+
config.plugins.push(plugin);
|
|
851
|
+
}
|
|
832
852
|
}, options);
|
|
833
853
|
}
|
|
834
854
|
|
|
@@ -881,4 +901,4 @@ function extendPages(cb) {
|
|
|
881
901
|
}
|
|
882
902
|
}
|
|
883
903
|
|
|
884
|
-
export { addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, 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 };
|
|
904
|
+
export { addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, 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, useNitro, 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.12",
|
|
4
4
|
"repository": "nuxt/framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,27 +9,24 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"prepack": "unbuild"
|
|
14
|
-
},
|
|
15
12
|
"dependencies": {
|
|
16
|
-
"@nuxt/schema": "3.0.0-rc.
|
|
17
|
-
"c12": "^0.2.
|
|
13
|
+
"@nuxt/schema": "3.0.0-rc.12",
|
|
14
|
+
"c12": "^0.2.13",
|
|
18
15
|
"consola": "^2.15.3",
|
|
19
16
|
"defu": "^6.1.0",
|
|
20
17
|
"globby": "^13.1.2",
|
|
21
18
|
"hash-sum": "^2.0.0",
|
|
22
19
|
"ignore": "^5.2.0",
|
|
23
|
-
"jiti": "^1.
|
|
20
|
+
"jiti": "^1.16.0",
|
|
24
21
|
"knitwork": "^0.1.2",
|
|
25
22
|
"lodash.template": "^4.5.0",
|
|
26
|
-
"mlly": "^0.5.
|
|
27
|
-
"pathe": "^0.3.
|
|
23
|
+
"mlly": "^0.5.16",
|
|
24
|
+
"pathe": "^0.3.9",
|
|
28
25
|
"pkg-types": "^0.3.5",
|
|
29
26
|
"scule": "^0.3.2",
|
|
30
|
-
"semver": "^7.3.
|
|
27
|
+
"semver": "^7.3.8",
|
|
31
28
|
"unctx": "^2.0.2",
|
|
32
|
-
"unimport": "^0.6.
|
|
29
|
+
"unimport": "^0.6.8",
|
|
33
30
|
"untyped": "^0.5.0"
|
|
34
31
|
},
|
|
35
32
|
"devDependencies": {
|
|
@@ -38,6 +35,7 @@
|
|
|
38
35
|
"unbuild": "latest"
|
|
39
36
|
},
|
|
40
37
|
"engines": {
|
|
41
|
-
"node": "^14.16.0 || ^16.
|
|
42
|
-
}
|
|
43
|
-
}
|
|
38
|
+
"node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {}
|
|
41
|
+
}
|