nuxt-typed-router 4.0.5 → 4.0.7

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0 || >= 4.0.0"
6
6
  },
7
- "version": "4.0.5",
7
+ "version": "4.0.7",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -7,8 +7,7 @@ import { startCase, camelCase } from 'lodash-es';
7
7
  import { nanoid } from 'nanoid/non-secure';
8
8
  import prettier from 'prettier';
9
9
  import fs, { existsSync } from 'fs';
10
- import { fileURLToPath } from 'url';
11
- import { dirname, resolve } from 'pathe';
10
+ import { resolve } from 'pathe';
12
11
  import { mkdirp } from 'mkdirp';
13
12
  import { readFile } from 'fs/promises';
14
13
 
@@ -1121,7 +1120,7 @@ function createPathsFiles({ routesPaths, routesList }) {
1121
1120
  const hasPrefixStrategy = i18n && i18nOptions?.strategy !== "no_prefix";
1122
1121
  const filteredRoutesPaths = routesPaths.filter((route) => !routesPaths.find((r) => `${route.path}/` === r.path)).map((route) => ({
1123
1122
  ...route,
1124
- path: route.path.replace(/\(\)/g, "")
1123
+ path: route.path.replace(/\(\)/g, "").replace(/\/\//g, "/")
1125
1124
  })).sort((a, b) => {
1126
1125
  const pathCountA = a.path.split("/");
1127
1126
  const pathCountB = b.path.split("/");
@@ -1427,17 +1426,15 @@ async function formatOutputWithPrettier(template) {
1427
1426
  }
1428
1427
  }
1429
1428
 
1430
- dirname(fileURLToPath(import.meta.url));
1431
1429
  async function processPathAndWriteFile({
1432
1430
  content,
1433
1431
  fileName,
1434
1432
  outDir
1435
1433
  }) {
1436
1434
  try {
1437
- const { rootDir, disablePrettier } = moduleOptionStore;
1438
- const finalOutDir = outDir ?? `.nuxt/typed-router`;
1439
- const processedOutDir = resolve(rootDir, finalOutDir);
1440
- const outputFile = resolve(process.cwd(), `${processedOutDir}/${fileName}`);
1435
+ const { buildDir, disablePrettier } = moduleOptionStore;
1436
+ const processedOutDir = outDir ?? resolve(buildDir, "typed-router");
1437
+ const outputFile = resolve(processedOutDir, fileName);
1441
1438
  const formatedContent = disablePrettier ? content : await formatOutputWithPrettier(content);
1442
1439
  if (fs.existsSync(outputFile)) {
1443
1440
  await writeFile(outputFile, formatedContent);
@@ -1734,9 +1731,10 @@ async function createTypedRouter({
1734
1731
  }) {
1735
1732
  try {
1736
1733
  const rootDir = nuxt.options.rootDir;
1734
+ const buildDir = nuxt.options.buildDir;
1737
1735
  const srcDir = nuxt.options.srcDir;
1738
1736
  const autoImport = nuxt.options.imports.autoImport ?? true;
1739
- moduleOptionStore.updateOptions({ rootDir, autoImport, srcDir });
1737
+ moduleOptionStore.updateOptions({ rootDir, buildDir, autoImport, srcDir });
1740
1738
  if (!isHookCall) {
1741
1739
  if (routesConfig) {
1742
1740
  await nuxt.callHook("pages:extend", routesConfig);
@@ -1795,7 +1793,7 @@ async function removeNuxtDefinitions({
1795
1793
  processPathAndWriteFile({
1796
1794
  content: replacedNuxtLink,
1797
1795
  fileName: "components.d.ts",
1798
- outDir: ".nuxt"
1796
+ outDir: buildDir
1799
1797
  });
1800
1798
  }
1801
1799
  if (autoImport) {
@@ -1818,7 +1816,7 @@ async function removeNuxtDefinitions({
1818
1816
  processPathAndWriteFile({
1819
1817
  content: globalDefinitions,
1820
1818
  fileName: "types/imports.d.ts",
1821
- outDir: ".nuxt"
1819
+ outDir: buildDir
1822
1820
  });
1823
1821
  }
1824
1822
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-typed-router",
3
- "version": "4.0.5",
3
+ "version": "4.0.7",
4
4
  "description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
5
5
  "type": "module",
6
6
  "main": "./dist/module.mjs",
@@ -103,7 +103,8 @@
103
103
  "test:fixtures": "vitest run --dir test",
104
104
  "test:types": "pnpm run typecheck && pnpm run test:vue",
105
105
  "test:vue": "vue-tsc -p test/fixtures/simple/tsconfig.json --noEmit && vue-tsc -p test/fixtures/complex/tsconfig.json --noEmit",
106
- "test": "pnpm run dev:prepare && pnpm run test:types && pnpm run test:fixtures",
106
+ "test": "pnpm run dev:prepare && pnpm run test:types && pnpm run test:fixtures && pnpm run test:build",
107
+ "test:build": "nuxi build tests/fixtures/simple",
107
108
  "lint": "oxlint",
108
109
  "lint:fix": "oxlint --fix",
109
110
  "format:check": "oxfmt --check",