@nuxt/kit 3.0.0 → 3.1.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 - Nuxt Project
3
+ Copyright (c) 2016-present - Nuxt Team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,128 @@
1
- # Nuxt Kit
2
1
 
3
- > Toolkit for authoring Nuxt Modules
2
+ [![Nuxt banner](./.github/assets/banner.png)](https://nuxt.com)
3
+
4
+ # 👋 Welcome to Nuxt
5
+
6
+
7
+ Nuxt's goal is to make web development intuitive and performant, with a great developer experience.<br>Learn more in the ['What is Nuxt?'](https://nuxt.com/docs/getting-started/introduction) section of our documentation.
8
+
9
+
10
+ <p>
11
+ <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
12
+ <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
13
+ <a href="./LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
14
+ <a href="https://volta.net/nuxt/nuxt?utm_source=nuxt_readme"><img src="https://user-images.githubusercontent.com/904724/209143798-32345f6c-3cf8-4e06-9659-f4ace4a6acde.svg" alt="Volta board"></a>
15
+ </p>
16
+
17
+ <table>
18
+ <thead>
19
+ <tr>
20
+ <th width="2000" colspan="2">
21
+ </th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <tr>
26
+ <td width="80" align="center" valign="top">
27
+ <br>
28
+ <a href="https://nuxt.com/docs"><img src="./.github/assets/documentation.png"></a>
29
+ </td>
30
+ <td valign="top">
31
+ <h3>Documentation</h3>
32
+ <p>
33
+ We highly recommend you take a look at <a href="https://nuxt.com">the Nuxt documentation</a> to level up.
34
+ </p>
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td width="80" align="center" valign="top">
39
+ <br>
40
+ <a href="https://nuxt.com/modules"><img src="./.github/assets/modules.png"></a>
41
+ </td>
42
+ <td valign="top">
43
+ <h3>Modules</h3>
44
+ <p>
45
+ Discover our <a href="https://nuxt.com/modules">list of modules</a> to supercharge your Nuxt project. Created by the Nuxt team and community.
46
+ </p>
47
+ </td>
48
+ </tr>
49
+ <tr>
50
+ <td width="80" align="center" valign="top">
51
+ <br>
52
+ <a href="https://nuxt.com/docs/examples/hello-world"><img src="./.github/assets/examples.png"></a>
53
+ </td>
54
+ <td>
55
+ <h3>Examples</h3>
56
+ <p>
57
+ Explore different ways of using Nuxt features and get inspired with <a href="https://nuxt.com/docs/examples/essentials/hello-world">our list of examples</a>.
58
+ </p>
59
+ </td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+
64
+ <table>
65
+ <thead>
66
+ <tr>
67
+ <th width="2000" colspan="2">
68
+ </th>
69
+ </tr>
70
+ </thead>
71
+ <tbody>
72
+ <tr>
73
+ <td width="80" align="center" valign="top">
74
+ <br>
75
+ <a href="https://nuxt.com/docs/community/reporting-bugs"><img src="./.github/assets/reporting-bugs.png"></a>
76
+ </td>
77
+ <td valign="top">
78
+ <h3>Reporting bugs</h3>
79
+ <p>
80
+ Check out the <a href="https://nuxt.com/docs/community/reporting-bugs">Reporting Bugs</a> page.</p>
81
+ </p>
82
+ </td>
83
+ </tr>
84
+ <tr>
85
+ <td width="80" align="center" valign="top">
86
+ <br>
87
+ <a href="https://nuxt.com/docs/community/contribution"><img src="./.github/assets/suggestions.png"></a>
88
+ </td>
89
+ <td valign="top">
90
+ <h3>Suggestions</h3>
91
+ <p>
92
+ Check out the <a href="https://nuxt.com/docs/community/contribution">Contribution</a> page.
93
+ </p>
94
+ </td>
95
+ </tr>
96
+ <tr>
97
+ <td width="80" align="center" valign="top">
98
+ <br>
99
+ <a href="https://nuxt.com/docs/community/getting-help"><img src="./.github/assets/questions.png"></a>
100
+ </td>
101
+ <td valign="top">
102
+ <h3>Questions</h3>
103
+ <p>
104
+ Check out the <a href="https://nuxt.com/docs/community/getting-help">Getting Help</a> page.
105
+ </p>
106
+ </td>
107
+ </tr>
108
+ </tbody>
109
+ </table>
110
+
111
+ ## Local Development
112
+
113
+ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#set-up-your-local-development-environment) to contribute to the framework and documentation.
114
+
115
+ ## Nuxt 2
116
+
117
+ You can find the code for Nuxt 2 on the [`2.x-dev` branch](https://github.com/nuxt/nuxt/tree/2.x-dev) and the documentation at [nuxtjs.org](https://nuxtjs.org).
118
+
119
+ ## Follow us
120
+
121
+ <p valign="center">
122
+ <a href="https://chat.nuxt.dev"><img width="20px" src="./.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://twitter.nuxt.dev"><img width="20px" src="./.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://github.nuxt.dev"><img width="20px" src="./.github/assets/github.svg" alt="GitHub"></a>
123
+ </p>
124
+
125
+ ## License
126
+
127
+ [MIT](./LICENSE)
4
128
 
5
- Learn more about this package: <https://v3.nuxtjs.org>
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { ModuleOptions, ModuleDefinition, NuxtModule, Nuxt, NuxtConfig, NuxtOptions, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate } from '@nuxt/schema';
1
+ import { ModuleOptions, ModuleDefinition, NuxtModule, Nuxt, NuxtConfig, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, 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';
5
5
  import { UserConfig, Plugin } from 'vite';
6
6
  import * as unctx_index from 'unctx/index';
7
- import { NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
7
+ import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
8
8
  import * as consola from 'consola';
9
9
  import { genSafeVariableName } from 'knitwork';
10
10
 
@@ -21,6 +21,8 @@ interface LoadNuxtConfigOptions extends LoadConfigOptions<NuxtConfig> {
21
21
  }
22
22
  declare function loadNuxtConfig(opts: LoadNuxtConfigOptions): Promise<NuxtOptions>;
23
23
 
24
+ declare function extendNuxtSchema(def: SchemaDefinition | (() => SchemaDefinition)): void;
25
+
24
26
  interface LoadNuxtOptions extends LoadNuxtConfigOptions {
25
27
  /** Load nuxt with development mode */
26
28
  dev?: boolean;
@@ -69,7 +71,7 @@ interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
69
71
  interface ExtendViteConfigOptions extends ExtendConfigOptions {
70
72
  }
71
73
  /**
72
- * Extend Webpack config
74
+ * Extend webpack config
73
75
  *
74
76
  * The fallback function might be called multiple times
75
77
  * when applying to both client and server builds.
@@ -80,7 +82,7 @@ declare function extendWebpackConfig(fn: ((config: Configuration) => void), opti
80
82
  */
81
83
  declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): (() => void) | undefined;
82
84
  /**
83
- * Append Webpack plugin to the config.
85
+ * Append webpack plugin to the config.
84
86
  */
85
87
  declare function addWebpackPlugin(plugin: WebpackPluginInstance | WebpackPluginInstance[], options?: ExtendWebpackConfigOptions): void;
86
88
  /**
@@ -166,6 +168,15 @@ declare function isIgnored(pathname: string): boolean;
166
168
  declare function addLayout(this: any, template: NuxtTemplate, name?: string): void;
167
169
 
168
170
  declare function extendPages(cb: NuxtHooks['pages:extend']): void;
171
+ interface ExtendRouteRulesOptions {
172
+ /**
173
+ * Override route rule config
174
+ *
175
+ * @default false
176
+ */
177
+ override?: boolean;
178
+ }
179
+ declare function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void;
169
180
 
170
181
  /**
171
182
  * Normalize a nuxt plugin object
@@ -330,4 +341,4 @@ declare const templateUtils: {
330
341
  }) => string;
331
342
  };
332
343
 
333
- export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, 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, updateTemplates, useLogger, useNitro, useNuxt };
344
+ export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, 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, updateTemplates, useLogger, useNitro, useNuxt };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { promises, existsSync, readFileSync } from 'node:fs';
2
- import defu from 'defu';
2
+ import defu, { defu as defu$1 } from 'defu';
3
3
  import { applyDefaults } from 'untyped';
4
4
  import { dirname, join, normalize, relative, isAbsolute, resolve, basename, parse } from 'pathe';
5
5
  import consola from 'consola';
@@ -259,9 +259,11 @@ function requireModulePkg(id, opts = {}) {
259
259
  function resolveModule(id, opts = {}) {
260
260
  return normalize(_require.resolve(id, {
261
261
  paths: [].concat(
262
+ // @ts-ignore
262
263
  global.__NUXT_PREPATHS__,
263
264
  opts.paths || [],
264
265
  process.cwd(),
266
+ // @ts-ignore
265
267
  global.__NUXT_PATHS__
266
268
  ).filter(Boolean)
267
269
  }));
@@ -311,18 +313,35 @@ function isIgnored(pathname) {
311
313
  }
312
314
  if (!nuxt._ignore) {
313
315
  nuxt._ignore = ignore(nuxt.options.ignoreOptions);
314
- nuxt._ignore.add(nuxt.options.ignore);
316
+ const resolvedIgnore = nuxt.options.ignore.flatMap((s) => resolveGroupSyntax(s));
317
+ nuxt._ignore.add(resolvedIgnore);
315
318
  const nuxtignoreFile = join(nuxt.options.rootDir, ".nuxtignore");
316
319
  if (existsSync(nuxtignoreFile)) {
317
320
  nuxt._ignore.add(readFileSync(nuxtignoreFile, "utf-8"));
318
321
  }
319
322
  }
320
- const relativePath = relative(nuxt.options.rootDir, pathname);
323
+ const cwds = nuxt.options._layers?.map((layer2) => layer2.cwd).sort((a, b) => b.length - a.length);
324
+ const layer = cwds?.find((cwd) => pathname.startsWith(cwd));
325
+ const relativePath = relative(layer ?? nuxt.options.rootDir, pathname);
321
326
  if (relativePath.startsWith("..")) {
322
327
  return false;
323
328
  }
324
329
  return !!(relativePath && nuxt._ignore.ignores(relativePath));
325
330
  }
331
+ function resolveGroupSyntax(group) {
332
+ let groups = [group];
333
+ while (groups.some((group2) => group2.includes("{"))) {
334
+ groups = groups.flatMap((group2) => {
335
+ const [head, ...tail] = group2.split("{");
336
+ if (tail.length) {
337
+ const [body, ...rest] = tail.join("{").split("}");
338
+ return body.split(",").map((part) => `${head}${part}${rest.join("")}`);
339
+ }
340
+ return group2;
341
+ });
342
+ }
343
+ return groups;
344
+ }
326
345
 
327
346
  async function resolvePath(path, opts = {}) {
328
347
  const _path = path;
@@ -477,6 +496,13 @@ async function loadNuxtConfig(opts) {
477
496
  return await applyDefaults(NuxtConfigSchema, nuxtConfig);
478
497
  }
479
498
 
499
+ function extendNuxtSchema(def) {
500
+ const nuxt = useNuxt();
501
+ nuxt.hook("schema:extend", (schemas) => {
502
+ schemas.push(typeof def === "function" ? def() : def);
503
+ });
504
+ }
505
+
480
506
  async function loadNuxt(opts) {
481
507
  opts.cwd = opts.cwd || opts.rootDir;
482
508
  opts.overrides = opts.overrides || opts.config || {};
@@ -500,6 +526,7 @@ async function loadNuxt(opts) {
500
526
  configOverrides: opts.overrides,
501
527
  ready: opts.ready,
502
528
  envConfig: opts.dotenv
529
+ // TODO: Backward format convertion
503
530
  });
504
531
  return nuxt;
505
532
  }
@@ -719,6 +746,15 @@ function extendPages(cb) {
719
746
  nuxt.hook("pages:extend", cb);
720
747
  }
721
748
  }
749
+ function extendRouteRules(route, rule, options = {}) {
750
+ const nuxt = useNuxt();
751
+ for (const opts of [nuxt.options, nuxt.options.nitro]) {
752
+ if (!opts.routeRules) {
753
+ opts.routeRules = {};
754
+ }
755
+ opts.routeRules[route] = options.override ? defu$1(rule, opts.routeRules[route]) : defu$1(opts.routeRules[route], rule);
756
+ }
757
+ }
722
758
 
723
759
  function normalizePlugin(plugin) {
724
760
  if (typeof plugin === "string") {
@@ -793,4 +829,4 @@ function useNitro() {
793
829
  return nuxt._nitro;
794
830
  }
795
831
 
796
- export { addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, 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, updateTemplates, useLogger, useNitro, useNuxt };
832
+ export { addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, 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, updateTemplates, useLogger, useNitro, useNuxt };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "3.0.0",
4
- "repository": "nuxt/framework",
3
+ "version": "3.1.0",
4
+ "repository": "nuxt/nuxt",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.mjs",
@@ -10,28 +10,28 @@
10
10
  "dist"
11
11
  ],
12
12
  "dependencies": {
13
- "@nuxt/schema": "3.0.0",
14
- "c12": "^1.0.1",
13
+ "@nuxt/schema": "3.1.0",
14
+ "c12": "^1.1.0",
15
15
  "consola": "^2.15.3",
16
16
  "defu": "^6.1.1",
17
- "globby": "^13.1.2",
17
+ "globby": "^13.1.3",
18
18
  "hash-sum": "^2.0.0",
19
- "ignore": "^5.2.0",
20
- "jiti": "^1.16.0",
19
+ "ignore": "^5.2.4",
20
+ "jiti": "^1.16.2",
21
21
  "knitwork": "^1.0.0",
22
22
  "lodash.template": "^4.5.0",
23
- "mlly": "^1.0.0",
23
+ "mlly": "^1.1.0",
24
24
  "pathe": "^1.0.0",
25
25
  "pkg-types": "^1.0.1",
26
26
  "scule": "^1.0.0",
27
27
  "semver": "^7.3.8",
28
- "unctx": "^2.1.0",
29
- "unimport": "^1.0.1",
30
- "untyped": "^1.0.0"
28
+ "unctx": "^2.1.1",
29
+ "unimport": "^2.0.1",
30
+ "untyped": "^1.2.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/lodash.template": "^4",
34
- "@types/semver": "^7",
34
+ "@types/semver": "^7.3.13",
35
35
  "unbuild": "latest"
36
36
  },
37
37
  "engines": {