@nuxt/kit 3.17.7 → 3.18.1

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 CHANGED
@@ -44,7 +44,7 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
44
44
  Use the following command to create a new starter project. This will create a starter project with all the necessary files and dependencies:
45
45
 
46
46
  ```bash
47
- npm create nuxt <my-project>
47
+ npm create nuxt@latest <my-project>
48
48
  ```
49
49
 
50
50
  > [!TIP]
package/dist/index.d.mts CHANGED
@@ -381,7 +381,7 @@ declare function useNitro(): Nitro;
381
381
  /**
382
382
  * Add server imports to be auto-imported by Nitro
383
383
  */
384
- declare function addServerImports(imports: Import[]): void;
384
+ declare function addServerImports(imports: Import | Import[]): void;
385
385
  /**
386
386
  * Add directories to be scanned for auto-imports by Nitro
387
387
  */
package/dist/index.d.ts CHANGED
@@ -381,7 +381,7 @@ declare function useNitro(): Nitro;
381
381
  /**
382
382
  * Add server imports to be auto-imported by Nitro
383
383
  */
384
- declare function addServerImports(imports: Import[]): void;
384
+ declare function addServerImports(imports: Import | Import[]): void;
385
385
  /**
386
386
  * Add directories to be scanned for auto-imports by Nitro
387
387
  */
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ import { interopDefault, parseNodeModulePath, resolveModuleExportNames } from 'm
15
15
  import { resolveModulePath, resolveModuleURL } from 'exsolve';
16
16
  import { isRelative, withTrailingSlash } from 'ufo';
17
17
  import { glob } from 'tinyglobby';
18
- import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
18
+ import { resolveAlias as resolveAlias$1, reverseResolveAlias } from 'pathe/utils';
19
19
  import ignore from 'ignore';
20
20
  import { loadConfig } from 'c12';
21
21
  import process$1 from 'node:process';
@@ -2372,10 +2372,16 @@ async function resolveNuxtModule(base, paths) {
2372
2372
  for (const path of paths) {
2373
2373
  if (path.startsWith(base)) {
2374
2374
  resolved.push(path.split("/index.ts")[0]);
2375
- } else {
2376
- const resolvedPath = await resolver.resolvePath(path);
2377
- resolved.push(resolvedPath.slice(0, resolvedPath.lastIndexOf(path) + path.length));
2375
+ continue;
2378
2376
  }
2377
+ const resolvedPath = await resolver.resolvePath(path);
2378
+ const dir = parseNodeModulePath(resolvedPath).dir;
2379
+ if (dir) {
2380
+ resolved.push(dir);
2381
+ continue;
2382
+ }
2383
+ const index = resolvedPath.lastIndexOf(path);
2384
+ resolved.push(index === -1 ? dirname(resolvedPath) : resolvedPath.slice(0, index + path.length));
2379
2385
  }
2380
2386
  return resolved;
2381
2387
  }
@@ -2472,8 +2478,7 @@ function existsInVFS(path, nuxt = tryUseNuxt()) {
2472
2478
  }
2473
2479
  async function resolveFiles(path, pattern, opts = {}) {
2474
2480
  const files = [];
2475
- for (const file of await glob(pattern, { cwd: path, followSymbolicLinks: opts.followSymbolicLinks ?? true })) {
2476
- const p = resolve(path, file);
2481
+ for (const p of await glob(pattern, { cwd: path, followSymbolicLinks: opts.followSymbolicLinks ?? true, absolute: true })) {
2477
2482
  if (!isIgnored(p)) {
2478
2483
  files.push(p);
2479
2484
  }
@@ -2638,7 +2643,7 @@ async function loadNuxtConfig(opts) {
2638
2643
  nuxtConfig.alias ||= {};
2639
2644
  if (meta?.name) {
2640
2645
  const alias = `#layers/${meta.name}`;
2641
- nuxtConfig.alias[alias] ||= nuxtConfig.rootDir;
2646
+ nuxtConfig.alias[alias] ||= withTrailingSlash(nuxtConfig.rootDir);
2642
2647
  }
2643
2648
  const defaultBuildDir = join(nuxtConfig.rootDir, ".nuxt");
2644
2649
  if (!opts.overrides?._prepare && !nuxtConfig.dev && !nuxtConfig.buildDir && nuxtConfig.future?.compatibilityVersion === 4 && existsSync(defaultBuildDir)) {
@@ -2672,7 +2677,7 @@ async function loadNuxtConfig(opts) {
2672
2677
  }
2673
2678
  if (layer.meta?.name) {
2674
2679
  const alias = `#layers/${layer.meta.name}`;
2675
- nuxtConfig.alias[alias] ||= layer.config.rootDir || layer.cwd;
2680
+ nuxtConfig.alias[alias] ||= withTrailingSlash(layer.config.rootDir || layer.cwd);
2676
2681
  }
2677
2682
  _layers.push(layer);
2678
2683
  }
@@ -2817,10 +2822,11 @@ function useNitro() {
2817
2822
  }
2818
2823
  function addServerImports(imports) {
2819
2824
  const nuxt = useNuxt();
2825
+ const _imports = toArray(imports);
2820
2826
  nuxt.hook("nitro:config", (config) => {
2821
2827
  config.imports ||= {};
2822
2828
  config.imports.imports ||= [];
2823
- config.imports.imports.push(...imports);
2829
+ config.imports.imports.push(..._imports);
2824
2830
  });
2825
2831
  }
2826
2832
  function addServerImportsDir(dirs, opts = {}) {
@@ -2889,7 +2895,7 @@ function applyEnv(obj, opts, parentKey = "") {
2889
2895
  }
2890
2896
  return obj;
2891
2897
  }
2892
- const envExpandRx = /\{\{(.*?)\}\}/g;
2898
+ const envExpandRx = /\{\{([^{}]*)\}\}/g;
2893
2899
  function _expandFromEnv(value, env = process$1.env) {
2894
2900
  return value.replace(envExpandRx, (match, key) => {
2895
2901
  return env[key] || match;
@@ -3162,8 +3168,9 @@ async function _generateTypes(nuxt) {
3162
3168
  }
3163
3169
  const moduleEntryPaths = [];
3164
3170
  for (const m of nuxt.options._installedModules) {
3165
- if (m.entryPath) {
3166
- moduleEntryPaths.push(getDirectory(m.entryPath));
3171
+ const path = m.meta?.rawPath || m.entryPath;
3172
+ if (path) {
3173
+ moduleEntryPaths.push(getDirectory(path));
3167
3174
  }
3168
3175
  }
3169
3176
  const modulePaths = await resolveNuxtModule(rootDirWithSlash, moduleEntryPaths);
@@ -3265,7 +3272,7 @@ async function _generateTypes(nuxt) {
3265
3272
  }
3266
3273
  }
3267
3274
  const relativePath = relativeWithDot(nuxt.options.buildDir, absolutePath);
3268
- if (stats?.isDirectory()) {
3275
+ if (stats?.isDirectory() || aliases[alias].endsWith("/")) {
3269
3276
  tsConfig.compilerOptions.paths[alias] = [relativePath];
3270
3277
  tsConfig.compilerOptions.paths[`${alias}/*`] = [`${relativePath}/*`];
3271
3278
  if (!absolutePath.startsWith(rootDirWithSlash)) {
@@ -3384,9 +3391,9 @@ function addLayout(template, name) {
3384
3391
  }
3385
3392
  nuxt.hook("app:templates", (app) => {
3386
3393
  if (layoutName in app.layouts) {
3387
- const relativePath = relative(nuxt.options.srcDir, app.layouts[layoutName].file);
3394
+ const relativePath = reverseResolveAlias(app.layouts[layoutName].file, { ...nuxt?.options.alias || {}, ...strippedAtAliases }).pop() || app.layouts[layoutName].file;
3388
3395
  return logger.warn(
3389
- `Not overriding \`${layoutName}\` (provided by \`~/${relativePath}\`) with \`${src || filename}\`.`
3396
+ `Not overriding \`${layoutName}\` (provided by \`${relativePath}\`) with \`${src || filename}\`.`
3390
3397
  );
3391
3398
  }
3392
3399
  app.layouts[layoutName] = {
@@ -3395,6 +3402,10 @@ function addLayout(template, name) {
3395
3402
  };
3396
3403
  });
3397
3404
  }
3405
+ const strippedAtAliases = {
3406
+ "@": "",
3407
+ "@@": ""
3408
+ };
3398
3409
 
3399
3410
  function extendPages(cb) {
3400
3411
  const nuxt = useNuxt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "3.17.7",
3
+ "version": "3.18.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -23,14 +23,14 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "c12": "^3.0.4",
26
+ "c12": "^3.2.0",
27
27
  "consola": "^3.4.2",
28
28
  "defu": "^6.1.4",
29
29
  "destr": "^2.0.5",
30
30
  "errx": "^0.1.0",
31
31
  "exsolve": "^1.0.7",
32
32
  "ignore": "^7.0.5",
33
- "jiti": "^2.4.2",
33
+ "jiti": "^2.5.1",
34
34
  "klona": "^2.0.6",
35
35
  "knitwork": "^1.2.0",
36
36
  "mlly": "^1.7.4",
@@ -43,21 +43,21 @@
43
43
  "tinyglobby": "^0.2.14",
44
44
  "ufo": "^1.6.1",
45
45
  "unctx": "^2.4.1",
46
- "unimport": "^5.1.0",
46
+ "unimport": "^5.2.0",
47
47
  "untyped": "^2.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@rspack/core": "1.4.6",
50
+ "@rspack/core": "1.4.11",
51
51
  "@types/lodash-es": "4.17.12",
52
52
  "@types/semver": "7.7.0",
53
53
  "hookable": "5.5.3",
54
54
  "lodash-es": "4.17.21",
55
- "nitropack": "2.11.13",
56
- "unbuild": "3.5.0",
57
- "vite": "6.3.5",
55
+ "nitropack": "2.12.4",
56
+ "unbuild": "3.6.0",
57
+ "vite": "7.0.6",
58
58
  "vitest": "3.2.4",
59
- "webpack": "5.99.9",
60
- "@nuxt/schema": "3.17.7"
59
+ "webpack": "5.101.0",
60
+ "@nuxt/schema": "3.18.1"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=18.12.0"