From: Anthony Fu Date: Fri, 16 Oct 2020 08:04:15 +0000 (+0800) Subject: refactor: add __PURE__ to improve tree-shaking (#535) X-Git-Tag: v4.0.0-rc.1~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45db3b66b8c3dbab39c0abe923eef684684c7702;p=thirdparty%2Fvuejs%2Frouter.git refactor: add __PURE__ to improve tree-shaking (#535) --- diff --git a/src/RouterLink.ts b/src/RouterLink.ts index 9fb714f5..da874c78 100644 --- a/src/RouterLink.ts +++ b/src/RouterLink.ts @@ -125,7 +125,7 @@ export function useLink(props: UseLinkOptions) { } } -export const RouterLinkImpl = defineComponent({ +export const RouterLinkImpl = /*#__PURE__*/ defineComponent({ name: 'RouterLink', props: { to: { @@ -259,7 +259,7 @@ function getOriginalPath(record: RouteRecord | undefined): string { * @param globalClass * @param defaultClass */ -let getLinkClass = ( +const getLinkClass = ( propClass: string | undefined, globalClass: string | undefined, defaultClass: string diff --git a/src/RouterView.ts b/src/RouterView.ts index 8691f9f4..ddb0def3 100644 --- a/src/RouterView.ts +++ b/src/RouterView.ts @@ -33,7 +33,7 @@ export interface RouterViewProps { route?: RouteLocationNormalized } -export const RouterViewImpl = defineComponent({ +export const RouterViewImpl = /*#__PURE__*/ defineComponent({ name: 'RouterView', props: { name: { diff --git a/src/errors.ts b/src/errors.ts index cb6cb31f..705d4353 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -20,7 +20,7 @@ export const enum ErrorTypes { NAVIGATION_DUPLICATED = 16, } -const NavigationFailureSymbol = PolySymbol( +const NavigationFailureSymbol = /*#__PURE__*/ PolySymbol( __DEV__ ? 'navigation failure' : 'nf' ) diff --git a/src/injectionSymbols.ts b/src/injectionSymbols.ts index 73ecdc97..0f6aa039 100644 --- a/src/injectionSymbols.ts +++ b/src/injectionSymbols.ts @@ -13,19 +13,19 @@ export const PolySymbol = (name: string) => : (__DEV__ ? '[vue-router]: ' : '_vr_') + name // rvlm = Router View Location Matched -export const matchedRouteKey = PolySymbol( +export const matchedRouteKey = /*#__PURE__*/ PolySymbol( __DEV__ ? 'router view location matched' : 'rvlm' ) as InjectionKey> // rvd = Router View Depth -export const viewDepthKey = PolySymbol( +export const viewDepthKey = /*#__PURE__*/ PolySymbol( __DEV__ ? 'router view depth' : 'rvd' ) as InjectionKey // r = router -export const routerKey = PolySymbol(__DEV__ ? 'router' : 'r') as InjectionKey< - Router -> +export const routerKey = /*#__PURE__*/ PolySymbol( + __DEV__ ? 'router' : 'r' +) as InjectionKey // rt = route location -export const routeLocationKey = PolySymbol( +export const routeLocationKey = /*#__PURE__*/ PolySymbol( __DEV__ ? 'route location' : 'rl' ) as InjectionKey