Skip to content

Commit f2f95ea

Browse files
committed
chore: remove the need for tail
improve build compat for non unix
1 parent 2938bff commit f2f95ea

File tree

6 files changed

+85
-92
lines changed

6 files changed

+85
-92
lines changed

CLAUDE.md

-49 Bytes
Binary file not shown.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"release": "node scripts/release.mjs",
1414
"size": "node scripts/check-size.mjs",
1515
"build": "pnpm run -r build",
16-
"build:dts": "pnpm run -r build:dts",
1716
"docs": "pnpm run --filter ./packages/docs -r docs",
1817
"docs:api": "pnpm run --filter ./packages/docs -r docs:api",
1918
"docs:translation:compare": "pnpm run --filter ./packages/docs -r docs:translation:compare",

packages/router/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@
9494
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
9595
"build": "tsdown",
9696
"build:old": "rimraf dist && rollup -c rollup.config.mjs",
97-
"build:dts": "tail -n +10 src/globalExtensions.ts >> dist/vue-router.d.mts",
9897
"build:playground": "vue-tsc --noEmit && vite build --config playground/vite.config.ts",
9998
"build:e2e": "vue-tsc --noEmit && vite build --config e2e/vite.config.mjs",
10099
"build:size": "pnpm run build && rollup -c size-checks/rollup.config.mjs",
101100
"dev:e2e": "vite --config e2e/vite.config.mjs",
102101
"test:types": "tsc --build tsconfig.json",
103102
"test:unit": "vitest --coverage run",
104-
"test": "pnpm run build && pnpm run build:dts && pnpm run test:types && pnpm run test:unit && pnpm run test:e2e",
103+
"test": "pnpm run build && pnpm run test:types && pnpm run test:unit && pnpm run test:e2e",
105104
"test:e2e": "pnpm run test:e2e:headless",
106105
"test:e2e:headless": "node e2e/runner.mjs --env chrome-headless",
107106
"test:e2e:native": "node e2e/runner.mjs --env chrome",

packages/router/src/globalExtensions.ts

Lines changed: 0 additions & 82 deletions
This file was deleted.

packages/router/src/index.ts

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* The official Router for Vue 3.
3+
*
4+
* @packageDocumentation
5+
*/
6+
17
export { createWebHistory } from './history/html5'
28
export { createMemoryHistory } from './history/memory'
39
export { createWebHashHistory } from './history/hash'
@@ -167,10 +173,82 @@ export type { TypesConfig } from './config'
167173

168174
export * from './useApi'
169175

170-
export * from './globalExtensions'
176+
// Global extensions for Vue
177+
import type { TypesConfig } from './config'
178+
import type { Router } from './router'
179+
import type { RouterLink } from './RouterLink'
180+
import type { RouterView } from './RouterView'
181+
import type {
182+
NavigationGuard,
183+
NavigationGuardWithThis,
184+
RouteLocationNormalizedLoaded,
185+
} from './typed-routes'
171186

172-
/**
173-
* The official Router for Vue 3.
174-
*
175-
* @packageDocumentation
176-
*/
187+
declare module 'vue' {
188+
export interface ComponentCustomOptions {
189+
/**
190+
* Guard called when the router is navigating to the route that is rendering
191+
* this component from a different route. Differently from `beforeRouteUpdate`
192+
* and `beforeRouteLeave`, `beforeRouteEnter` does not have access to the
193+
* component instance through `this` because it triggers before the component
194+
* is even mounted.
195+
*
196+
* @param to - RouteLocationRaw we are navigating to
197+
* @param from - RouteLocationRaw we are navigating from
198+
* @param next - function to validate, cancel or modify (by redirecting) the
199+
* navigation
200+
*/
201+
beforeRouteEnter?: TypesConfig extends Record<'beforeRouteEnter', infer T>
202+
? T
203+
: NavigationGuardWithThis<undefined>
204+
205+
/**
206+
* Guard called whenever the route that renders this component has changed, but
207+
* it is reused for the new route. This allows you to guard for changes in
208+
* params, the query or the hash.
209+
*
210+
* @param to - RouteLocationRaw we are navigating to
211+
* @param from - RouteLocationRaw we are navigating from
212+
* @param next - function to validate, cancel or modify (by redirecting) the
213+
* navigation
214+
*/
215+
beforeRouteUpdate?: TypesConfig extends Record<'beforeRouteUpdate', infer T>
216+
? T
217+
: NavigationGuard
218+
219+
/**
220+
* Guard called when the router is navigating away from the current route that
221+
* is rendering this component.
222+
*
223+
* @param to - RouteLocationRaw we are navigating to
224+
* @param from - RouteLocationRaw we are navigating from
225+
* @param next - function to validate, cancel or modify (by redirecting) the
226+
* navigation
227+
*/
228+
beforeRouteLeave?: TypesConfig extends Record<'beforeRouteLeave', infer T>
229+
? T
230+
: NavigationGuard
231+
}
232+
233+
export interface ComponentCustomProperties {
234+
/**
235+
* Normalized current location. See {@link RouteLocationNormalizedLoaded}.
236+
*/
237+
$route: TypesConfig extends Record<'$route', infer T>
238+
? T
239+
: RouteLocationNormalizedLoaded
240+
/**
241+
* {@link Router} instance used by the application.
242+
*/
243+
$router: TypesConfig extends Record<'$router', infer T> ? T : Router
244+
}
245+
246+
export interface GlobalComponents {
247+
RouterView: TypesConfig extends Record<'RouterView', infer T>
248+
? T
249+
: typeof RouterView
250+
RouterLink: TypesConfig extends Record<'RouterLink', infer T>
251+
? T
252+
: typeof RouterLink
253+
}
254+
}

scripts/release.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ async function main() {
246246
step('\nBuilding all packages...')
247247
if (!skipBuild && !isDryRun) {
248248
await run('pnpm', ['run', 'build'])
249-
await run('pnpm', ['run', 'build:dts'])
250249
} else {
251250
console.log(`(skipped)`)
252251
}

0 commit comments

Comments
 (0)