From a79e1e1916a71271728e6fe7c2b734fc2f209518 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 11 Jan 2021 21:56:08 -0500 Subject: [PATCH] refactor: move default theme to 'vitepress/theme' Fixes the case when using a completely custom theme, importing anything from vitepress causes the entire default theme to be imported too. BREAKING CHANGE: the default theme is now exposed via 'vitepress/theme', instead of a named export from 'vitepress'. --- src/client/index.ts | 5 +---- src/node/alias.ts | 4 ++++ theme.d.ts | 3 +++ types/index.d.ts | 3 +-- 4 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 theme.d.ts diff --git a/src/client/index.ts b/src/client/index.ts index 8dc04483..4bbc0251 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -5,7 +5,7 @@ export type { Router, Route } from './app/router' // theme types -export * from './app/theme' +export type { Theme, EnhanceAppContext } from './app/theme' // composables export { useRouter, useRoute } from './app/router' @@ -24,6 +24,3 @@ import { ComponentOptions } from 'vue' import _Debug from './app/components/Debug.vue' const Debug = _Debug as ComponentOptions export { Debug } - -// default theme -export { default as DefaultTheme } from './theme-default' diff --git a/src/node/alias.ts b/src/node/alias.ts index fbe2cea5..15bc8290 100644 --- a/src/node/alias.ts +++ b/src/node/alias.ts @@ -38,6 +38,10 @@ export function resolveAliases( find: /^vitepress$/, replacement: path.join(__dirname, '../client/index') }, + { + find: /^vitepress\/theme$/, + replacement: path.join(__dirname, '../client/theme-default/index') + }, // alias for local linked development { find: /^vitepress\//, replacement: PKG_ROOT + '/' }, // make sure it always use the same vue dependency that comes with diff --git a/theme.d.ts b/theme.d.ts new file mode 100644 index 00000000..dd034b53 --- /dev/null +++ b/theme.d.ts @@ -0,0 +1,3 @@ +// so that users can do `import DefaultTheme from 'vitepress/theme'` +import DefaultTheme from './dist/client/theme-default/index' +export default DefaultTheme diff --git a/types/index.d.ts b/types/index.d.ts index fb753f96..10a5d0c2 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,4 @@ export * from './shared' export * from '../dist/node/index' -export * from '../dist/client/app/exports' +export * from '../dist/client/index' export * from '../dist/client/theme-default/config' -export { default as defaultTheme } from '../dist/client/theme-default/index'