nuxt-typed-router 3.1.0 → 3.1.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/dist/module.json +1 -1
- package/dist/module.mjs +34 -28
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { defu } from 'defu';
|
|
|
5
5
|
import { customAlphabet } from 'nanoid/non-secure';
|
|
6
6
|
import { nanoid as nanoid$1 } from 'nanoid';
|
|
7
7
|
import prettier from 'prettier';
|
|
8
|
-
import fs from 'fs';
|
|
8
|
+
import fs, { existsSync } from 'fs';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
10
|
import { dirname, resolve } from 'pathe';
|
|
11
11
|
import mkdirp from 'mkdirp';
|
|
@@ -1664,39 +1664,45 @@ async function removeNuxtDefinitions({
|
|
|
1664
1664
|
autoImport
|
|
1665
1665
|
}) {
|
|
1666
1666
|
const { resolve } = createResolver(import.meta.url);
|
|
1667
|
-
const
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
const replacedNuxtLink = componentDefinitions.replace(
|
|
1671
|
-
/'NuxtLink': typeof import\(".*"\)\['default'\]/gm,
|
|
1672
|
-
""
|
|
1673
|
-
);
|
|
1674
|
-
processPathAndWriteFile({
|
|
1675
|
-
content: replacedNuxtLink,
|
|
1676
|
-
fileName: "components.d.ts",
|
|
1677
|
-
outDir: ".nuxt"
|
|
1678
|
-
});
|
|
1679
|
-
if (autoImport) {
|
|
1680
|
-
let globalDefinitions = await readFile(resolve(buildDir, "types/imports.d.ts"), {
|
|
1667
|
+
const componentFilePath = resolve(buildDir, "components.d.ts");
|
|
1668
|
+
if (existsSync(componentFilePath)) {
|
|
1669
|
+
const componentDefinitions = await readFile(componentFilePath, {
|
|
1681
1670
|
encoding: "utf8"
|
|
1682
1671
|
});
|
|
1683
|
-
const
|
|
1684
|
-
"
|
|
1685
|
-
"
|
|
1686
|
-
|
|
1687
|
-
"useLocaleRoute",
|
|
1688
|
-
"definePageMeta",
|
|
1689
|
-
"navigateTo"
|
|
1690
|
-
].map((m) => new RegExp(`const ${m}: typeof import\\('.*'\\)\\['${m}'\\]`, "gm"));
|
|
1691
|
-
importsToRemove.forEach((imp) => {
|
|
1692
|
-
globalDefinitions = globalDefinitions.replace(imp, "");
|
|
1693
|
-
});
|
|
1672
|
+
const replacedNuxtLink = componentDefinitions.replace(
|
|
1673
|
+
/'NuxtLink': typeof import\(".*"\)\['default'\]/gm,
|
|
1674
|
+
""
|
|
1675
|
+
);
|
|
1694
1676
|
processPathAndWriteFile({
|
|
1695
|
-
content:
|
|
1696
|
-
fileName: "
|
|
1677
|
+
content: replacedNuxtLink,
|
|
1678
|
+
fileName: "components.d.ts",
|
|
1697
1679
|
outDir: ".nuxt"
|
|
1698
1680
|
});
|
|
1699
1681
|
}
|
|
1682
|
+
if (autoImport) {
|
|
1683
|
+
const importsFilePath = resolve(buildDir, "types/imports.d.ts");
|
|
1684
|
+
if (importsFilePath) {
|
|
1685
|
+
let globalDefinitions = await readFile(importsFilePath, {
|
|
1686
|
+
encoding: "utf8"
|
|
1687
|
+
});
|
|
1688
|
+
const importsToRemove = [
|
|
1689
|
+
"useRouter",
|
|
1690
|
+
"useRoute",
|
|
1691
|
+
"useLocalePath",
|
|
1692
|
+
"useLocaleRoute",
|
|
1693
|
+
"definePageMeta",
|
|
1694
|
+
"navigateTo"
|
|
1695
|
+
].map((m) => new RegExp(`const ${m}: typeof import\\('.*'\\)\\['${m}'\\]`, "gm"));
|
|
1696
|
+
importsToRemove.forEach((imp) => {
|
|
1697
|
+
globalDefinitions = globalDefinitions.replace(imp, "");
|
|
1698
|
+
});
|
|
1699
|
+
processPathAndWriteFile({
|
|
1700
|
+
content: globalDefinitions,
|
|
1701
|
+
fileName: "types/imports.d.ts",
|
|
1702
|
+
outDir: ".nuxt"
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1700
1706
|
}
|
|
1701
1707
|
|
|
1702
1708
|
const module = defineNuxtModule({
|