feat: bundle type definitions of dev-deps (#1257)

pull/1263/head
Divyansh Singh 2 years ago committed by GitHub
parent 887f5fc831
commit 12591a9487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,7 +58,7 @@
"build": "run-s build-prepare build-client build-node",
"build-prepare": "rimraf dist && node scripts/copyShared",
"build-client": "vue-tsc --noEmit -p src/client && tsc -p src/client && node scripts/copyClient",
"build-node": "rollup --config rollup.config.ts --configPlugin esbuild",
"build-node": "tsc -p src/node --noEmit && rollup --config rollup.config.ts --configPlugin esbuild",
"format": "prettier --check --write .",
"format-fail": "prettier --check .",
"lint": "pnpm run format",
@ -85,21 +85,20 @@
"@docsearch/js": "^3.2.1",
"@vitejs/plugin-vue": "^3.0.3",
"@vue/devtools-api": "^6.2.1",
"@vueuse/core": "^9.1.0",
"@vueuse/core": "^9.1.1",
"body-scroll-lock": "^4.0.0-beta.0",
"shiki": "^0.11.1",
"vite": "^3.0.8",
"vue": "^3.2.37"
"vite": "^3.0.9",
"vue": "^3.2.38"
},
"devDependencies": {
"@mdit-vue/plugin-component": "^0.11.0",
"@mdit-vue/plugin-frontmatter": "^0.11.0",
"@mdit-vue/plugin-headers": "^0.11.0",
"@mdit-vue/plugin-sfc": "^0.11.0",
"@mdit-vue/plugin-title": "^0.11.0",
"@mdit-vue/plugin-toc": "^0.11.0",
"@mdit-vue/plugin-component": "^0.11.1",
"@mdit-vue/plugin-frontmatter": "^0.11.1",
"@mdit-vue/plugin-headers": "^0.11.1",
"@mdit-vue/plugin-sfc": "^0.11.1",
"@mdit-vue/plugin-title": "^0.11.1",
"@mdit-vue/plugin-toc": "^0.11.1",
"@mdit-vue/shared": "^0.11.0",
"@mdit-vue/types": "^0.11.0",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-json": "^4.1.0",
@ -120,7 +119,7 @@
"@types/markdown-it-emoji": "^2.0.2",
"@types/micromatch": "^4.0.2",
"@types/minimist": "^1.2.2",
"@types/node": "^18.7.5",
"@types/node": "^18.7.14",
"@types/polka": "^0.5.4",
"@types/prompts": "^2.0.14",
"chokidar": "^3.5.3",
@ -130,13 +129,13 @@
"debug": "^4.3.4",
"diacritics": "^1.3.0",
"enquirer": "^2.3.6",
"esbuild": "^0.15.3",
"esbuild": "^0.15.6",
"escape-html": "^1.0.3",
"execa": "^6.1.0",
"fast-glob": "^3.2.11",
"fs-extra": "^10.1.0",
"lint-staged": "^13.0.3",
"lru-cache": "^7.13.2",
"lru-cache": "^7.14.0",
"markdown-it": "^13.0.1",
"markdown-it-anchor": "^8.6.4",
"markdown-it-attrs": "^4.1.4",
@ -147,22 +146,22 @@
"npm-run-all": "^4.1.5",
"ora": "^5.4.1",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.25.0",
"playwright-chromium": "^1.25.1",
"polka": "^0.5.2",
"prettier": "^2.7.1",
"prompts": "^2.4.2",
"punycode": "^2.1.1",
"rimraf": "^3.0.2",
"rollup": "^2.78.0",
"rollup": "^2.78.1",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-esbuild": "^4.9.3",
"rollup-plugin-esbuild": "^4.10.1",
"semver": "^7.3.7",
"simple-git-hooks": "^2.8.0",
"sirv": "^2.0.2",
"supports-color": "^9.2.2",
"typescript": "^4.7.4",
"vitest": "^0.22.0",
"vue-tsc": "^0.40.1"
"typescript": "^4.8.2",
"vitest": "^0.22.1",
"vue-tsc": "^0.40.4"
},
"pnpm": {
"peerDependencyRules": {

File diff suppressed because it is too large Load Diff

@ -22,7 +22,8 @@ const external = [
...Object.keys(pkg.dependencies),
...builtinModules.flatMap((m) =>
m.includes('punycode') ? [] : [m, `node:${m}`]
)
),
r('types/shared.d.ts')
]
const plugins = [
@ -79,7 +80,8 @@ const nodeTypes: RollupOptions = {
format: 'esm',
file: 'dist/node/index.d.ts'
},
plugins: [dts()]
external,
plugins: [dts({ respectExternal: true })]
}
const clientTypes: RollupOptions = {
@ -88,8 +90,9 @@ const clientTypes: RollupOptions = {
format: 'esm',
file: 'dist/client/index.d.ts'
},
external,
plugins: [
dts(),
dts({ respectExternal: true }),
{
name: 'cleanup',
async closeBundle() {

@ -1,6 +1,6 @@
export * from './config'
export * from './server'
export * from './markdown/markdown'
export * from './markdown'
export * from './build/build'
export * from './serve/serve'

@ -1,7 +1,37 @@
import type { MarkdownItEnv } from '@mdit-vue/types'
import { CleanUrlsMode } from '../shared'
import type { MarkdownSfcBlocks } from '@mdit-vue/plugin-sfc'
import type { CleanUrlsMode, Header } from '../shared'
export interface MarkdownEnv extends MarkdownItEnv {
// Manually declaring all properties as rollup-plugin-dts
// is unable to merge augmented module declarations
export interface MarkdownEnv {
/**
* The raw Markdown content without frontmatter
*/
content?: string
/**
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
*
* - Would be the rendered HTML when `renderExcerpt` is enabled
* - Would be the raw Markdown when `renderExcerpt` is disabled
*/
excerpt?: string
/**
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
*/
frontmatter?: Record<string, unknown>
/**
* The headers that extracted by `@mdit-vue/plugin-headers`
*/
headers?: Header[]
/**
* SFC blocks that extracted by `@mdit-vue/plugin-sfc`
*/
sfcBlocks?: MarkdownSfcBlocks
/**
* The title that extracted by `@mdit-vue/plugin-title`
*/
title?: string
path: string
relativePath: string
cleanUrls: CleanUrlsMode

36
types/index.d.ts vendored

@ -1,35 +1,3 @@
export * from './shared.js'
export {
Content,
EnhanceAppContext,
Route,
Router,
Theme,
VitePressData,
inBrowser,
useData,
useRoute,
useRouter,
withBase
} from '../dist/client/index.js'
export {
MarkdownOptions,
MarkdownParsedData,
MarkdownRenderer,
RawConfigExports,
ServeOptions,
SiteConfig,
ThemeOptions,
UserConfig,
build,
createMarkdownRenderer,
createServer,
defineConfig,
defineConfigWithTheme,
resolveConfig,
resolveSiteData,
resolveSiteDataByRoute,
serve
} from '../dist/node/index.js'
export * from '../dist/client/index.js'
export * from '../dist/node/index.js'

31
types/shared.d.ts vendored

@ -1,5 +1,4 @@
// types shared between server and client
import type { MarkdownItHeader } from '@mdit-vue/types'
export type { DefaultTheme } from './default-theme.js'
export interface PageData {
@ -12,7 +11,35 @@ export interface PageData {
lastUpdated?: number
}
export type Header = MarkdownItHeader
export interface Header {
/**
* The level of the header
*
* `1` to `6` for `<h1>` to `<h6>`
*/
level: number
/**
* The title of the header
*/
title: string
/**
* The slug of the header
*
* Typically the `id` attr of the header anchor
*/
slug: string
/**
* Link of the header
*
* Typically using `#${slug}` as the anchor hash
*/
link: string
/**
* The children of the header
*/
children: Header[]
}
export type CleanUrlsMode =
| 'disabled'
| 'without-subfolders'

Loading…
Cancel
Save