From 846e287b68b41b2014b7b24060f3873fe2539658 Mon Sep 17 00:00:00 2001 From: skirtle <65301168+skirtles-code@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:10:52 +0000 Subject: [PATCH 1/3] build: add vue-router.esm-browser.prod.js (#2242) Co-authored-by: kianfang Co-authored-by: Kian <16569491+kianfang@users.noreply.github.com> --- packages/router/rollup.config.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/router/rollup.config.mjs b/packages/router/rollup.config.mjs index d82c47954..fc8aaa3b0 100644 --- a/packages/router/rollup.config.mjs +++ b/packages/router/rollup.config.mjs @@ -59,7 +59,7 @@ const packageConfigs = packageBuilds.map(buildName => packageBuilds.forEach(buildName => { if (buildName === 'cjs') { packageConfigs.push(createProductionConfig(buildName)) - } else if (buildName === 'global') { + } else if (buildName === 'global' || buildName === 'browser') { packageConfigs.push(createMinifiedConfig(buildName)) } }) @@ -125,6 +125,10 @@ function createConfig(buildName, output, plugins = []) { // Global and Browser ESM builds inlines everything so that they can be // used alone. external, + treeshake: { + // Ensure @vue/devtools-api can be treeshaken in production builds + moduleSideEffects: false, + }, plugins: [ tsPlugin, createReplacePlugin( @@ -224,7 +228,7 @@ function createMinifiedConfig(format) { return createConfig( format, { - file: `dist/${name}.${format}.prod.js`, + file: outputConfigs[format].file.replace(/.js$/, '.prod.js'), format: outputConfigs[format].format, }, [ From d992bb2085cadf01b270e4f04b3d91c4fd5a70e3 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 13 Nov 2024 12:11:16 +0100 Subject: [PATCH 2/3] fix(router): allow duplicated navigation on back + redirect (#2133) --- packages/router/src/router.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index 1906ba452..748a06a32 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -1022,7 +1022,7 @@ export function createRouter(options: RouterOptions): Router { const shouldRedirect = handleRedirectRecord(toLocation) if (shouldRedirect) { pushWithRedirect( - assign(shouldRedirect, { replace: true }), + assign(shouldRedirect, { replace: true, force: true }), toLocation ).catch(noop) return @@ -1063,7 +1063,9 @@ export function createRouter(options: RouterOptions): Router { // the error is already handled by router.push we just want to avoid // logging the error pushWithRedirect( - (error as NavigationRedirectError).to, + assign(locationAsObject((error as NavigationRedirectError).to), { + force: true, + }), toLocation // avoid an uncaught rejection, let push call triggerError ) From e978eb8efeef193dfaf5f358a56109633d17fc56 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 13 Nov 2024 12:11:59 +0100 Subject: [PATCH 3/3] feat(link): add view-transition prop (#2356) --- packages/router/src/RouterLink.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/router/src/RouterLink.ts b/packages/router/src/RouterLink.ts index e9c014196..11a830473 100644 --- a/packages/router/src/RouterLink.ts +++ b/packages/router/src/RouterLink.ts @@ -83,6 +83,11 @@ export interface RouterLinkProps extends RouterLinkOptions { | 'time' | 'true' | 'false' + + /** + * Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported. + */ + viewTransition?: boolean } /** @@ -106,7 +111,13 @@ export interface UseLinkOptions { | RouteLocationAsPath | RouteLocationRaw > + replace?: MaybeRef + + /** + * Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported. + */ + viewTransition?: boolean } /** @@ -214,10 +225,19 @@ export function useLink( e: MouseEvent = {} as MouseEvent ): Promise { if (guardEvent(e)) { - return router[unref(props.replace) ? 'replace' : 'push']( + const p = router[unref(props.replace) ? 'replace' : 'push']( unref(props.to) // avoid uncaught errors are they are logged anyway ).catch(noop) + if ( + props.viewTransition && + typeof document !== 'undefined' && + 'startViewTransition' in document + ) { + // @ts-expect-error: not added to types yet + document.startViewTransition(() => p) + } + return p } return Promise.resolve() }