From: Eduardo San Martin Morote Date: Thu, 18 Sep 2025 15:24:18 +0000 (+0200) Subject: chore: remove the need for tail X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f2f95eaf34723970578b3c4ced7004a13e06ed1b;p=thirdparty%2Fvuejs%2Frouter.git chore: remove the need for tail improve build compat for non unix --- diff --git a/CLAUDE.md b/CLAUDE.md index 4fcb8a9c..4dc520db 100644 Binary files a/CLAUDE.md and b/CLAUDE.md differ diff --git a/package.json b/package.json index 91214ca1..6b562526 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/router/package.json b/packages/router/package.json index 13a5e1c9..64796275 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -94,14 +94,13 @@ "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 index 22c49c3c..00000000 --- a/packages/router/src/globalExtensions.ts +++ /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 - - /** - * 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 - } -} diff --git a/packages/router/src/index.ts b/packages/router/src/index.ts index 71899d34..ca57f530 100644 --- a/packages/router/src/index.ts +++ b/packages/router/src/index.ts @@ -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 + + /** + * 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 + } +} diff --git a/scripts/release.mjs b/scripts/release.mjs index 4346f105..ef0d93ec 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -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)`) }