From 16064023cfe390eccc1552792b906156e4936382 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 17 Mar 2023 10:10:45 +0800 Subject: [PATCH] chore: upgrade to TS 5.0 + use moduleResolution: "bundler" --- package.json | 4 +- pnpm-lock.yaml | 62 +++++++++---------- src/client/app/components/Content.ts | 4 +- src/client/app/composables/head.ts | 4 +- src/client/app/composables/preFetch.ts | 4 +- src/client/app/data.ts | 4 +- src/client/app/devtools.ts | 4 +- src/client/app/index.ts | 20 +++--- src/client/app/router.ts | 8 +-- src/client/app/ssr.ts | 4 +- src/client/app/theme.ts | 4 +- src/client/app/utils.ts | 6 +- src/client/index.ts | 21 +++---- src/client/theme-default/Layout.vue | 4 +- src/client/theme-default/NotFound.vue | 4 +- .../components/VPAlgoliaSearchBox.vue | 7 +-- .../theme-default/components/VPButton.vue | 4 +- .../theme-default/components/VPCarbonAds.vue | 4 +- .../theme-default/components/VPContent.vue | 4 +- src/client/theme-default/components/VPDoc.vue | 2 +- .../theme-default/components/VPDocAside.vue | 2 +- .../components/VPDocAsideOutline.vue | 4 +- .../theme-default/components/VPDocFooter.vue | 8 +-- .../components/VPDocFooterLastUpdated.vue | 2 +- .../components/VPDocOutlineDropdown.vue | 4 +- .../components/VPDocOutlineItem.vue | 2 +- .../theme-default/components/VPFlyout.vue | 2 +- .../theme-default/components/VPFooter.vue | 4 +- .../components/VPHomeFeatures.vue | 2 +- .../theme-default/components/VPHomeHero.vue | 2 +- .../theme-default/components/VPLink.vue | 4 +- .../theme-default/components/VPLocalNav.vue | 4 +- .../components/VPLocalNavOutlineDropdown.vue | 4 +- .../theme-default/components/VPMenuLink.vue | 6 +- src/client/theme-default/components/VPNav.vue | 2 +- .../theme-default/components/VPNavBar.vue | 2 +- .../components/VPNavBarAppearance.vue | 2 +- .../components/VPNavBarExtra.vue | 4 +- .../theme-default/components/VPNavBarMenu.vue | 2 +- .../components/VPNavBarMenuGroup.vue | 4 +- .../components/VPNavBarMenuLink.vue | 4 +- .../components/VPNavBarSearch.vue | 2 +- .../components/VPNavBarSocialLinks.vue | 2 +- .../components/VPNavBarTitle.vue | 8 +-- .../components/VPNavBarTranslations.vue | 4 +- .../components/VPNavScreenAppearance.vue | 2 +- .../components/VPNavScreenMenu.vue | 2 +- .../components/VPNavScreenSocialLinks.vue | 2 +- .../components/VPNavScreenTranslations.vue | 2 +- .../theme-default/components/VPSidebar.vue | 2 +- .../components/VPSidebarItem.vue | 2 +- .../theme-default/components/VPSocialLink.vue | 2 +- .../theme-default/components/VPSponsors.vue | 2 +- .../components/VPSponsorsGrid.vue | 4 +- .../components/VPSwitchAppearance.vue | 4 +- src/client/theme-default/composables/aside.ts | 2 +- .../theme-default/composables/edit-link.ts | 2 +- .../theme-default/composables/flyout.ts | 2 +- src/client/theme-default/composables/langs.ts | 4 +- .../theme-default/composables/outline.ts | 6 +- .../theme-default/composables/prev-next.ts | 6 +- .../theme-default/composables/sidebar.ts | 6 +- .../theme-default/composables/sponsor-grid.ts | 2 +- src/client/theme-default/index.ts | 4 +- src/client/theme-default/support/sidebar.ts | 2 +- src/client/theme-default/support/utils.ts | 6 +- src/client/tsconfig.json | 4 +- src/shared/shared.ts | 2 +- tsconfig.json | 4 +- 69 files changed, 165 insertions(+), 175 deletions(-) diff --git a/package.json b/package.json index b030223a..485bc10f 100644 --- a/package.json +++ b/package.json @@ -170,9 +170,9 @@ "simple-git-hooks": "^2.8.1", "sirv": "^2.0.2", "supports-color": "^9.3.1", - "typescript": "^4.9.5", + "typescript": "^5.0.0", "vitest": "^0.29.2", - "vue-tsc": "^1.2.0", + "vue-tsc": "^1.3.2", "wait-on": "^7.0.1" }, "pnpm": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b383ce75..29306c23 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -83,11 +83,11 @@ importers: simple-git-hooks: ^2.8.1 sirv: ^2.0.2 supports-color: ^9.3.1 - typescript: ^4.9.5 + typescript: ^5.0.0 vite: ^4.1.4 vitest: ^0.29.2 vue: ^3.2.47 - vue-tsc: ^1.2.0 + vue-tsc: ^1.3.2 wait-on: ^7.0.1 dependencies: '@docsearch/css': 3.3.3 @@ -165,16 +165,16 @@ importers: punycode: 2.3.0 rimraf: 4.4.0 rollup: 3.19.1 - rollup-plugin-dts: 5.2.0_h4kaxwm6ctjivrsm4cpxaz7nqu + rollup-plugin-dts: 5.2.0_7iejawhbqmte5pthjozf4tfuqy rollup-plugin-esbuild: 5.0.0_pguajubqukbnwk3mu7gtzimteq semver: 7.3.8 shiki-processor: 0.1.3_shiki@0.14.1 simple-git-hooks: 2.8.1 sirv: 2.0.2 supports-color: 9.3.1 - typescript: 4.9.5 + typescript: 5.0.2 vitest: 0.29.2_supports-color@9.3.1 - vue-tsc: 1.2.0_typescript@4.9.5 + vue-tsc: 1.3.2_typescript@5.0.2 wait-on: 7.0.1_debug@4.3.4 __tests__/e2e: @@ -1271,29 +1271,29 @@ packages: pretty-format: 27.5.1 dev: true - /@volar/language-core/1.3.0-alpha.0: - resolution: {integrity: sha512-W3uMzecHPcbwddPu4SJpUcPakRBK/y/BP+U0U6NiPpUX1tONLC4yCawt+QBJqtgJ+sfD6ztf5PyvPL3hQRqfOA==} + /@volar/language-core/1.4.0-alpha.3: + resolution: {integrity: sha512-TDDqgvVgNWE952EQ6+iyasksYeLHdSKKhWMVmsMIywmE2gPdcqKIUBI+M8JNz2uKEraiOEtU+kJZpk5GJaTDTg==} dependencies: - '@volar/source-map': 1.3.0-alpha.0 + '@volar/source-map': 1.4.0-alpha.3 dev: true - /@volar/source-map/1.3.0-alpha.0: - resolution: {integrity: sha512-jSdizxWFvDTvkPYZnO6ew3sBZUnS0abKCbuopkc0JrIlFbznWC/fPH3iPFIMS8/IIkRxq1Jh9VVG60SmtsdaMQ==} + /@volar/source-map/1.4.0-alpha.3: + resolution: {integrity: sha512-3qwtBAp6TkkrNW9dLNjaZYzWttUWEI9XKSi/V7odt3rC9yPoWgqizC0J95essDtrEu9PoxbxTkTeZvRx5c//Ow==} dependencies: muggle-string: 0.2.2 dev: true - /@volar/typescript/1.3.0-alpha.0: - resolution: {integrity: sha512-5UItyW2cdH2mBLu4RrECRNJRgtvvzKrSCn2y3v/D61QwIDkGx4aeil6x8RFuUL5TFtV6QvVHXnsOHxNgd+sCow==} + /@volar/typescript/1.4.0-alpha.3: + resolution: {integrity: sha512-O8LTFLp9rw2nhJfHqcikx/im69r9Pfih+qHc2lCgaNlvwFmk7VGdWGghWlPmdGd1XE48gu9MmdCZP3NZ5hqCKg==} dependencies: - '@volar/language-core': 1.3.0-alpha.0 + '@volar/language-core': 1.4.0-alpha.3 dev: true - /@volar/vue-language-core/1.2.0: - resolution: {integrity: sha512-w7yEiaITh2WzKe6u8ZdeLKCUz43wdmY/OqAmsB/PGDvvhTcVhCJ6f0W/RprZL1IhqH8wALoWiwEh/Wer7ZviMQ==} + /@volar/vue-language-core/1.3.2: + resolution: {integrity: sha512-5HCMVoFFDIuf5bHnHux1jaRscZW5hsK/2T0p7qp+XuGWZ2fDN1nr9Ujn49jSvM7LqQB93Y1fFLKp3vZswV2YUw==} dependencies: - '@volar/language-core': 1.3.0-alpha.0 - '@volar/source-map': 1.3.0-alpha.0 + '@volar/language-core': 1.4.0-alpha.3 + '@volar/source-map': 1.4.0-alpha.3 '@vue/compiler-dom': 3.2.47 '@vue/compiler-sfc': 3.2.47 '@vue/reactivity': 3.2.47 @@ -1303,11 +1303,11 @@ packages: vue-template-compiler: 2.7.14 dev: true - /@volar/vue-typescript/1.2.0: - resolution: {integrity: sha512-zjmRi9y3J1EkG+pfuHp8IbHmibihrKK485cfzsHjiuvJMGrpkWvlO5WVEk8oslMxxeGC5XwBFE9AOlvh378EPA==} + /@volar/vue-typescript/1.3.2: + resolution: {integrity: sha512-/yOWlfgHOfk2u0bBDvSaV2VtS9rTPPgCSkiLsa9rYYgc9fldYNou5GFHdg/2vP6K0Pw3+zKTPjLc5ot7NfuImw==} dependencies: - '@volar/typescript': 1.3.0-alpha.0 - '@volar/vue-language-core': 1.2.0 + '@volar/typescript': 1.4.0-alpha.3 + '@volar/vue-language-core': 1.3.2 dev: true /@vue/compiler-core/3.2.47: @@ -3828,7 +3828,7 @@ packages: glob: 9.2.1 dev: true - /rollup-plugin-dts/5.2.0_h4kaxwm6ctjivrsm4cpxaz7nqu: + /rollup-plugin-dts/5.2.0_7iejawhbqmte5pthjozf4tfuqy: resolution: {integrity: sha512-B68T/haEu2MKcz4kNUhXB8/h5sq4gpplHAJIYNHbh8cp4ZkvzDvNca/11KQdFrB9ZeKucegQIotzo5T0JUtM8w==} engines: {node: '>=v14'} peerDependencies: @@ -3837,7 +3837,7 @@ packages: dependencies: magic-string: 0.29.0 rollup: 3.19.1 - typescript: 4.9.5 + typescript: 5.0.2 optionalDependencies: '@babel/code-frame': 7.18.6 dev: true @@ -4321,9 +4321,9 @@ packages: is-typed-array: 1.1.10 dev: true - /typescript/4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} + /typescript/5.0.2: + resolution: {integrity: sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==} + engines: {node: '>=12.20'} hasBin: true dev: true @@ -4516,15 +4516,15 @@ packages: he: 1.2.0 dev: true - /vue-tsc/1.2.0_typescript@4.9.5: - resolution: {integrity: sha512-rIlzqdrhyPYyLG9zxsVRa+JEseeS9s8F2BbVVVWRRsTZvJO2BbhLEb2HW3MY+DFma0378tnIqs+vfTzbcQtRFw==} + /vue-tsc/1.3.2_typescript@5.0.2: + resolution: {integrity: sha512-RfPXpQID6TTlJrMzuYuvU3lE21zN+2sTUs1l2Xo++2oqst+Aur0Ctdmi6sZ37QkluGBuWoXy8UUiyVp6nKMTfQ==} hasBin: true peerDependencies: typescript: '*' dependencies: - '@volar/vue-language-core': 1.2.0 - '@volar/vue-typescript': 1.2.0 - typescript: 4.9.5 + '@volar/vue-language-core': 1.3.2 + '@volar/vue-typescript': 1.3.2 + typescript: 5.0.2 dev: true /vue/3.2.47: diff --git a/src/client/app/components/Content.ts b/src/client/app/components/Content.ts index a8df57d9..4752554e 100644 --- a/src/client/app/components/Content.ts +++ b/src/client/app/components/Content.ts @@ -1,6 +1,6 @@ import { defineComponent, h } from 'vue' -import { useRoute } from '../router.js' -import { contentUpdatedCallbacks } from '../utils.js' +import { useRoute } from '../router' +import { contentUpdatedCallbacks } from '../utils' const runCbs = () => contentUpdatedCallbacks.forEach((fn) => fn()) diff --git a/src/client/app/composables/head.ts b/src/client/app/composables/head.ts index fdc4f7b9..5dc1a4fb 100644 --- a/src/client/app/composables/head.ts +++ b/src/client/app/composables/head.ts @@ -4,8 +4,8 @@ import { type SiteData, createTitle, mergeHead -} from '../../shared.js' -import type { Route } from '../router.js' +} from '../../shared' +import type { Route } from '../router' export function useUpdateHead(route: Route, siteDataByRouteRef: Ref) { let managedHeadTags: HTMLElement[] = [] diff --git a/src/client/app/composables/preFetch.ts b/src/client/app/composables/preFetch.ts index a37e24e5..04492144 100644 --- a/src/client/app/composables/preFetch.ts +++ b/src/client/app/composables/preFetch.ts @@ -1,9 +1,9 @@ // Customized pre-fetch for page chunks based on // https://github.com/GoogleChromeLabs/quicklink -import { useRoute } from '../router.js' +import { useRoute } from '../router' import { onMounted, onUnmounted, watch } from 'vue' -import { inBrowser, pathToFile } from '../utils.js' +import { inBrowser, pathToFile } from '../utils' const hasFetched = new Set() const createLink = () => document.createElement('link') diff --git a/src/client/app/data.ts b/src/client/app/data.ts index 143c3529..d6d3efa3 100644 --- a/src/client/app/data.ts +++ b/src/client/app/data.ts @@ -7,14 +7,14 @@ import { ref, shallowRef } from 'vue' -import type { Route } from './router.js' +import type { Route } from './router' import siteData from '@siteData' import { type PageData, type SiteData, resolveSiteDataByRoute, createTitle -} from '../shared.js' +} from '../shared' export const dataSymbol: InjectionKey = Symbol() diff --git a/src/client/app/devtools.ts b/src/client/app/devtools.ts index 2a71e259..81b91b66 100644 --- a/src/client/app/devtools.ts +++ b/src/client/app/devtools.ts @@ -1,7 +1,7 @@ import { setupDevtoolsPlugin } from '@vue/devtools-api' import type { App } from 'vue' -import type { Router } from './router.js' -import type { VitePressData } from './data.js' +import type { Router } from './router' +import type { VitePressData } from './data' const COMPONENT_STATE_TYPE = 'VitePress' diff --git a/src/client/app/index.ts b/src/client/app/index.ts index 795674a2..e594ab9d 100644 --- a/src/client/app/index.ts +++ b/src/client/app/index.ts @@ -8,16 +8,16 @@ import { watchEffect } from 'vue' import RawTheme from '@theme/index' -import { inBrowser, pathToFile } from './utils.js' -import { type Router, RouterSymbol, createRouter, scrollTo } from './router.js' -import { siteDataRef, useData } from './data.js' -import { useUpdateHead } from './composables/head.js' -import { usePrefetch } from './composables/preFetch.js' -import { dataSymbol, initData } from './data.js' -import { Content } from './components/Content.js' -import { ClientOnly } from './components/ClientOnly.js' -import { useCopyCode } from './composables/copyCode.js' -import { useCodeGroups } from './composables/codeGroups.js' +import { inBrowser, pathToFile } from './utils' +import { type Router, RouterSymbol, createRouter, scrollTo } from './router' +import { siteDataRef, useData } from './data' +import { useUpdateHead } from './composables/head' +import { usePrefetch } from './composables/preFetch' +import { dataSymbol, initData } from './data' +import { Content } from './components/Content' +import { ClientOnly } from './components/ClientOnly' +import { useCopyCode } from './composables/copyCode' +import { useCodeGroups } from './composables/codeGroups' function resolveThemeExtends(theme: typeof RawTheme): typeof RawTheme { if (theme.extends) { diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 7c91404d..023a1803 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -1,9 +1,9 @@ import { reactive, inject, markRaw, nextTick, readonly } from 'vue' import type { Component, InjectionKey } from 'vue' -import { notFoundPageData } from '../shared.js' -import type { PageData, PageDataPayload, Awaitable } from '../shared.js' -import { inBrowser, withBase } from './utils.js' -import { siteDataRef } from './data.js' +import { notFoundPageData } from '../shared' +import type { PageData, PageDataPayload, Awaitable } from '../shared' +import { inBrowser, withBase } from './utils' +import { siteDataRef } from './data' export interface Route { path: string diff --git a/src/client/app/ssr.ts b/src/client/app/ssr.ts index a66e6e47..eb408cc7 100644 --- a/src/client/app/ssr.ts +++ b/src/client/app/ssr.ts @@ -1,7 +1,7 @@ // entry for SSR -import { createApp } from './index.js' +import { createApp } from './index' import { renderToString } from 'vue/server-renderer' -import type { SSGContext } from '../shared.js' +import type { SSGContext } from '../shared' export async function render(path: string) { const { app, router } = await createApp() diff --git a/src/client/app/theme.ts b/src/client/app/theme.ts index 4284bf15..155ba1a7 100644 --- a/src/client/app/theme.ts +++ b/src/client/app/theme.ts @@ -1,6 +1,6 @@ import type { App, Ref, Component } from 'vue' -import type { Router } from './router.js' -import type { Awaitable, SiteData } from '../shared.js' +import type { Router } from './router' +import type { Awaitable, SiteData } from '../shared' export interface EnhanceAppContext { app: App diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index 2e8bba9d..673d1fbb 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -1,5 +1,5 @@ -import { siteDataRef } from './data.js' -import { inBrowser, EXTERNAL_URL_RE, sanitizeFileName } from '../shared.js' +import { siteDataRef } from './data' +import { inBrowser, EXTERNAL_URL_RE, sanitizeFileName } from '../shared' import { h, onMounted, @@ -8,7 +8,7 @@ import { type AsyncComponentLoader } from 'vue' -export { inBrowser } from '../shared.js' +export { inBrowser } from '../shared' /** * Join two paths by resolving the slash collision. diff --git a/src/client/index.ts b/src/client/index.ts index 6fb7a399..c8673544 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -2,23 +2,18 @@ // so the user can do `import { useRoute, useSiteData } from 'vitepress'` // generic types -export type { VitePressData } from './app/data.js' -export type { Route, Router } from './app/router.js' +export type { VitePressData } from './app/data' +export type { Route, Router } from './app/router' // theme types -export type { EnhanceAppContext, Theme } from './app/theme.js' +export type { EnhanceAppContext, Theme } from './app/theme' // shared types -export type { - HeadConfig, - Header, - PageData, - SiteData -} from '../../types/shared.js' +export type { HeadConfig, Header, PageData, SiteData } from '../../types/shared' // composables -export { useData } from './app/data.js' -export { useRoute, useRouter } from './app/router.js' +export { useData } from './app/data' +export { useRoute, useRouter } from './app/router' // utilities export { @@ -26,7 +21,7 @@ export { onContentUpdated, defineClientComponent, withBase -} from './app/utils.js' +} from './app/utils' // components -export { Content } from './app/components/Content.js' +export { Content } from './app/components/Content' diff --git a/src/client/theme-default/Layout.vue b/src/client/theme-default/Layout.vue index ac7cf693..ba3572c9 100644 --- a/src/client/theme-default/Layout.vue +++ b/src/client/theme-default/Layout.vue @@ -1,8 +1,8 @@