@nuxt/kit 4.0.1 → 4.0.3

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.mjs +27 -14
  3. package/package.json +10 -10
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.mjs CHANGED
@@ -15,7 +15,7 @@ import { resolveModulePath, resolveModuleURL } from 'exsolve';
15
15
  import { isRelative, withTrailingSlash } from 'ufo';
16
16
  import { captureStackTrace } from 'errx';
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';
@@ -372,10 +372,16 @@ async function resolveNuxtModule(base, paths) {
372
372
  for (const path of paths) {
373
373
  if (path.startsWith(base)) {
374
374
  resolved.push(path.split("/index.ts")[0]);
375
- } else {
376
- const resolvedPath = await resolver.resolvePath(path);
377
- resolved.push(resolvedPath.slice(0, resolvedPath.lastIndexOf(path) + path.length));
375
+ continue;
378
376
  }
377
+ const resolvedPath = await resolver.resolvePath(path);
378
+ const dir = parseNodeModulePath(resolvedPath).dir;
379
+ if (dir) {
380
+ resolved.push(dir);
381
+ continue;
382
+ }
383
+ const index = resolvedPath.lastIndexOf(path);
384
+ resolved.push(index === -1 ? dirname(resolvedPath) : resolvedPath.slice(0, index + path.length));
379
385
  }
380
386
  return resolved;
381
387
  }
@@ -472,8 +478,7 @@ function existsInVFS(path, nuxt = tryUseNuxt()) {
472
478
  }
473
479
  async function resolveFiles(path, pattern, opts = {}) {
474
480
  const files = [];
475
- for (const file of await glob(pattern, { cwd: path, followSymbolicLinks: opts.followSymbolicLinks ?? true })) {
476
- const p = resolve(path, file);
481
+ for (const p of await glob(pattern, { cwd: path, followSymbolicLinks: opts.followSymbolicLinks ?? true, absolute: true })) {
477
482
  if (!isIgnored(p)) {
478
483
  files.push(p);
479
484
  }
@@ -647,7 +652,7 @@ async function loadNuxtConfig(opts) {
647
652
  nuxtConfig.alias ||= {};
648
653
  if (meta?.name) {
649
654
  const alias = `#layers/${meta.name}`;
650
- nuxtConfig.alias[alias] ||= nuxtConfig.rootDir;
655
+ nuxtConfig.alias[alias] ||= withTrailingSlash(nuxtConfig.rootDir);
651
656
  }
652
657
  const defaultBuildDir = join(nuxtConfig.rootDir, ".nuxt");
653
658
  if (!opts.overrides?._prepare && !nuxtConfig.dev && !nuxtConfig.buildDir && existsSync(defaultBuildDir)) {
@@ -681,7 +686,7 @@ async function loadNuxtConfig(opts) {
681
686
  }
682
687
  if (layer.meta?.name) {
683
688
  const alias = `#layers/${layer.meta.name}`;
684
- nuxtConfig.alias[alias] ||= layer.config.rootDir || layer.cwd;
689
+ nuxtConfig.alias[alias] ||= withTrailingSlash(layer.config.rootDir || layer.cwd);
685
690
  }
686
691
  _layers.push(layer);
687
692
  }
@@ -1216,14 +1221,15 @@ async function _generateTypes(nuxt) {
1216
1221
  }
1217
1222
  const moduleEntryPaths = [];
1218
1223
  for (const m of nuxt.options._installedModules) {
1219
- if (m.entryPath) {
1220
- moduleEntryPaths.push(getDirectory(m.entryPath));
1224
+ const path = m.meta?.rawPath || m.entryPath;
1225
+ if (path) {
1226
+ moduleEntryPaths.push(getDirectory(path));
1221
1227
  }
1222
1228
  }
1223
1229
  const modulePaths = await resolveNuxtModule(rootDirWithSlash, moduleEntryPaths);
1224
1230
  for (const path of modulePaths) {
1225
1231
  const relative2 = relativeWithDot(nuxt.options.buildDir, path);
1226
- if (!path.includes("node_modules")) {
1232
+ if (!path.includes("node_modules") && path.startsWith(rootDirWithSlash)) {
1227
1233
  include.add(join(relative2, "runtime"));
1228
1234
  include.add(join(relative2, "dist/runtime"));
1229
1235
  nodeInclude.add(join(relative2, "*.*"));
@@ -1235,6 +1241,7 @@ async function _generateTypes(nuxt) {
1235
1241
  exclude.add(join(relative2, "runtime/server"));
1236
1242
  exclude.add(join(relative2, "dist/runtime/server"));
1237
1243
  exclude.add(join(relative2, "*.*"));
1244
+ exclude.add(join(relative2, "dist/*.*"));
1238
1245
  legacyExclude.add(join(relative2, "runtime/server"));
1239
1246
  legacyExclude.add(join(relative2, "dist/runtime/server"));
1240
1247
  }
@@ -1392,7 +1399,7 @@ async function _generateTypes(nuxt) {
1392
1399
  }
1393
1400
  }
1394
1401
  const relativePath = relativeWithDot(nuxt.options.buildDir, absolutePath);
1395
- if (stats?.isDirectory()) {
1402
+ if (stats?.isDirectory() || aliases[alias].endsWith("/")) {
1396
1403
  tsConfig.compilerOptions.paths[alias] = [relativePath];
1397
1404
  tsConfig.compilerOptions.paths[`${alias}/*`] = [`${relativePath}/*`];
1398
1405
  } else {
@@ -1411,10 +1418,12 @@ async function _generateTypes(nuxt) {
1411
1418
  const pkg = await readPackageJSON(id, { parent }).catch(() => null);
1412
1419
  if (pkg) {
1413
1420
  nodeReferences.push({ types: pkg.name ?? id });
1421
+ references.push({ types: pkg.name ?? id });
1414
1422
  return;
1415
1423
  }
1416
1424
  }
1417
1425
  nodeReferences.push({ types: id });
1426
+ references.push({ types: id });
1418
1427
  }));
1419
1428
  const declarations = [];
1420
1429
  await nuxt.callHook("prepare:types", { references, declarations, tsConfig, nodeTsConfig, nodeReferences, sharedTsConfig, sharedReferences });
@@ -1542,9 +1551,9 @@ function addLayout(template, name) {
1542
1551
  const layoutName = kebabCase(name || parse(filename).name).replace(LAYOUT_RE, "");
1543
1552
  nuxt.hook("app:templates", (app) => {
1544
1553
  if (layoutName in app.layouts) {
1545
- const relativePath = relative(nuxt.options.srcDir, app.layouts[layoutName].file);
1554
+ const relativePath = reverseResolveAlias(app.layouts[layoutName].file, { ...nuxt?.options.alias || {}, ...strippedAtAliases }).pop() || app.layouts[layoutName].file;
1546
1555
  return logger.warn(
1547
- `Not overriding \`${layoutName}\` (provided by \`~/${relativePath}\`) with \`${src || filename}\`.`
1556
+ `Not overriding \`${layoutName}\` (provided by \`${relativePath}\`) with \`${src || filename}\`.`
1548
1557
  );
1549
1558
  }
1550
1559
  app.layouts[layoutName] = {
@@ -1553,6 +1562,10 @@ function addLayout(template, name) {
1553
1562
  };
1554
1563
  });
1555
1564
  }
1565
+ const strippedAtAliases = {
1566
+ "@": "",
1567
+ "@@": ""
1568
+ };
1556
1569
 
1557
1570
  function extendPages(cb) {
1558
1571
  useNuxt().hook("pages:extend", cb);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
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.1.0",
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
  "mlly": "^1.7.4",
36
36
  "ohash": "^2.0.11",
@@ -42,19 +42,19 @@
42
42
  "tinyglobby": "^0.2.14",
43
43
  "ufo": "^1.6.1",
44
44
  "unctx": "^2.4.1",
45
- "unimport": "^5.1.0",
45
+ "unimport": "^5.2.0",
46
46
  "untyped": "^2.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@rspack/core": "1.4.8",
49
+ "@rspack/core": "1.4.11",
50
50
  "@types/semver": "7.7.0",
51
51
  "hookable": "5.5.3",
52
- "nitropack": "2.12.3",
53
- "unbuild": "3.5.0",
54
- "vite": "7.0.5",
52
+ "nitropack": "2.12.4",
53
+ "unbuild": "3.6.0",
54
+ "vite": "7.0.6",
55
55
  "vitest": "3.2.4",
56
- "webpack": "5.99.9",
57
- "@nuxt/schema": "4.0.1"
56
+ "webpack": "5.101.0",
57
+ "@nuxt/schema": "4.0.3"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">=18.12.0"