]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
chore: remove the need for tail
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 18 Sep 2025 15:24:18 +0000 (17:24 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 18 Sep 2025 15:24:18 +0000 (17:24 +0200)
improve build compat for non unix

CLAUDE.md
package.json
packages/router/package.json
packages/router/src/globalExtensions.ts [deleted file]
packages/router/src/index.ts
scripts/release.mjs

index 4fcb8a9cd6f717a22e702dfd3b1c72cc68caa8b3..4dc520db9334a6f3d3fe575001cf7f2d3696ef8b 100644 (file)
Binary files a/CLAUDE.md and b/CLAUDE.md differ
index 91214ca1d87acf7381ca8add1a0fd7ea9c5dd690..6b56252617527463f33fd2f386dffe9b6085aaa7 100644 (file)
@@ -13,7 +13,6 @@
     "release": "node scripts/release.mjs",
     "size": "node scripts/check-size.mjs",
     "build": "pnpm run -r build",
-    "build:dts": "pnpm run -r build:dts",
     "docs": "pnpm run --filter ./packages/docs -r docs",
     "docs:api": "pnpm run --filter ./packages/docs -r docs:api",
     "docs:translation:compare": "pnpm run --filter ./packages/docs -r docs:translation:compare",
index 13a5e1c907749a294c4aeea82bc7be17a5d3cc63..6479627572fea0d04a444f8f757f5af089dbf842 100644 (file)
     "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
     "build": "tsdown",
     "build:old": "rimraf dist && rollup -c rollup.config.mjs",
-    "build:dts": "tail -n +10 src/globalExtensions.ts >> dist/vue-router.d.mts",
     "build:playground": "vue-tsc --noEmit && vite build --config playground/vite.config.ts",
     "build:e2e": "vue-tsc --noEmit && vite build --config e2e/vite.config.mjs",
     "build:size": "pnpm run build && rollup -c size-checks/rollup.config.mjs",
     "dev:e2e": "vite --config e2e/vite.config.mjs",
     "test:types": "tsc --build tsconfig.json",
     "test:unit": "vitest --coverage run",
-    "test": "pnpm run build && pnpm run build:dts && pnpm run test:types && pnpm run test:unit && pnpm run test:e2e",
+    "test": "pnpm run build && pnpm run test:types && pnpm run test:unit && pnpm run test:e2e",
     "test:e2e": "pnpm run test:e2e:headless",
     "test:e2e:headless": "node e2e/runner.mjs --env chrome-headless",
     "test:e2e:native": "node e2e/runner.mjs --env chrome",
diff --git a/packages/router/src/globalExtensions.ts b/packages/router/src/globalExtensions.ts
deleted file mode 100644 (file)
index 22c49c3..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-import type {
-  NavigationGuardWithThis,
-  NavigationGuard,
-  RouteLocationNormalizedLoaded,
-} from './typed-routes'
-import type { RouterView } from './RouterView'
-import type { RouterLink } from './RouterLink'
-import type { Router } from './router'
-import type { TypesConfig } from './config'
-
-/**
- * NOTE: this used to be `@vue/runtime-core` but it should have been `vue` for a long time. Using both declaration at
- * the same time breaks so using only one everywhere is the preferred way.
- */
-declare module 'vue' {
-  export interface ComponentCustomOptions {
-    /**
-     * Guard called when the router is navigating to the route that is rendering
-     * this component from a different route. Differently from `beforeRouteUpdate`
-     * and `beforeRouteLeave`, `beforeRouteEnter` does not have access to the
-     * component instance through `this` because it triggers before the component
-     * is even mounted.
-     *
-     * @param to - RouteLocationRaw we are navigating to
-     * @param from - RouteLocationRaw we are navigating from
-     * @param next - function to validate, cancel or modify (by redirecting) the
-     * navigation
-     */
-    beforeRouteEnter?: TypesConfig extends Record<'beforeRouteEnter', infer T>
-      ? T
-      : NavigationGuardWithThis<undefined>
-
-    /**
-     * Guard called whenever the route that renders this component has changed, but
-     * it is reused for the new route. This allows you to guard for changes in
-     * params, the query or the hash.
-     *
-     * @param to - RouteLocationRaw we are navigating to
-     * @param from - RouteLocationRaw we are navigating from
-     * @param next - function to validate, cancel or modify (by redirecting) the
-     * navigation
-     */
-    beforeRouteUpdate?: TypesConfig extends Record<'beforeRouteUpdate', infer T>
-      ? T
-      : NavigationGuard
-
-    /**
-     * Guard called when the router is navigating away from the current route that
-     * is rendering this component.
-     *
-     * @param to - RouteLocationRaw we are navigating to
-     * @param from - RouteLocationRaw we are navigating from
-     * @param next - function to validate, cancel or modify (by redirecting) the
-     * navigation
-     */
-    beforeRouteLeave?: TypesConfig extends Record<'beforeRouteLeave', infer T>
-      ? T
-      : NavigationGuard
-  }
-
-  export interface ComponentCustomProperties {
-    /**
-     * Normalized current location. See {@link RouteLocationNormalizedLoaded}.
-     */
-    $route: TypesConfig extends Record<'$route', infer T>
-      ? T
-      : RouteLocationNormalizedLoaded
-    /**
-     * {@link Router} instance used by the application.
-     */
-    $router: TypesConfig extends Record<'$router', infer T> ? T : Router
-  }
-
-  export interface GlobalComponents {
-    RouterView: TypesConfig extends Record<'RouterView', infer T>
-      ? T
-      : typeof RouterView
-    RouterLink: TypesConfig extends Record<'RouterLink', infer T>
-      ? T
-      : typeof RouterLink
-  }
-}
index 71899d34a87060e7c84497c98af2750a92927888..ca57f53099e0dde1ebc57826576e2cf18fe62143 100644 (file)
@@ -1,3 +1,9 @@
+/**
+ * The official Router for Vue 3.
+ *
+ * @packageDocumentation
+ */
+
 export { createWebHistory } from './history/html5'
 export { createMemoryHistory } from './history/memory'
 export { createWebHashHistory } from './history/hash'
@@ -167,10 +173,82 @@ export type { TypesConfig } from './config'
 
 export * from './useApi'
 
-export * from './globalExtensions'
+// Global extensions for Vue
+import type { TypesConfig } from './config'
+import type { Router } from './router'
+import type { RouterLink } from './RouterLink'
+import type { RouterView } from './RouterView'
+import type {
+  NavigationGuard,
+  NavigationGuardWithThis,
+  RouteLocationNormalizedLoaded,
+} from './typed-routes'
 
-/**
- * The official Router for Vue 3.
- *
- * @packageDocumentation
- */
+declare module 'vue' {
+  export interface ComponentCustomOptions {
+    /**
+     * Guard called when the router is navigating to the route that is rendering
+     * this component from a different route. Differently from `beforeRouteUpdate`
+     * and `beforeRouteLeave`, `beforeRouteEnter` does not have access to the
+     * component instance through `this` because it triggers before the component
+     * is even mounted.
+     *
+     * @param to - RouteLocationRaw we are navigating to
+     * @param from - RouteLocationRaw we are navigating from
+     * @param next - function to validate, cancel or modify (by redirecting) the
+     * navigation
+     */
+    beforeRouteEnter?: TypesConfig extends Record<'beforeRouteEnter', infer T>
+      ? T
+      : NavigationGuardWithThis<undefined>
+
+    /**
+     * Guard called whenever the route that renders this component has changed, but
+     * it is reused for the new route. This allows you to guard for changes in
+     * params, the query or the hash.
+     *
+     * @param to - RouteLocationRaw we are navigating to
+     * @param from - RouteLocationRaw we are navigating from
+     * @param next - function to validate, cancel or modify (by redirecting) the
+     * navigation
+     */
+    beforeRouteUpdate?: TypesConfig extends Record<'beforeRouteUpdate', infer T>
+      ? T
+      : NavigationGuard
+
+    /**
+     * Guard called when the router is navigating away from the current route that
+     * is rendering this component.
+     *
+     * @param to - RouteLocationRaw we are navigating to
+     * @param from - RouteLocationRaw we are navigating from
+     * @param next - function to validate, cancel or modify (by redirecting) the
+     * navigation
+     */
+    beforeRouteLeave?: TypesConfig extends Record<'beforeRouteLeave', infer T>
+      ? T
+      : NavigationGuard
+  }
+
+  export interface ComponentCustomProperties {
+    /**
+     * Normalized current location. See {@link RouteLocationNormalizedLoaded}.
+     */
+    $route: TypesConfig extends Record<'$route', infer T>
+      ? T
+      : RouteLocationNormalizedLoaded
+    /**
+     * {@link Router} instance used by the application.
+     */
+    $router: TypesConfig extends Record<'$router', infer T> ? T : Router
+  }
+
+  export interface GlobalComponents {
+    RouterView: TypesConfig extends Record<'RouterView', infer T>
+      ? T
+      : typeof RouterView
+    RouterLink: TypesConfig extends Record<'RouterLink', infer T>
+      ? T
+      : typeof RouterLink
+  }
+}
index 4346f105e23da777a16cb4e2f22e684bef5ca654..ef0d93ec719ed376f313a498953a4fb58fa8960f 100644 (file)
@@ -246,7 +246,6 @@ async function main() {
   step('\nBuilding all packages...')
   if (!skipBuild && !isDryRun) {
     await run('pnpm', ['run', 'build'])
-    await run('pnpm', ['run', 'build:dts'])
   } else {
     console.log(`(skipped)`)
   }