Merge branch 'main' into chore/deps-replace-micromatch-with-picomatch

pull/4505/head
Divyansh Singh 8 months ago committed by GitHub
commit 362ab67204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,3 +1,9 @@
## [1.6.2](https://github.com/vuejs/vitepress/compare/v1.6.1...v1.6.2) (2025-01-22)
### Bug Fixes
- fix static content removal for lean chunks due to Vue 3.5 changes ([#4508](https://github.com/vuejs/vitepress/issues/4508)) ([8214cae](https://github.com/vuejs/vitepress/commit/8214cae21bb16842d8870d5867e974146c51fd61))
## [1.6.1](https://github.com/vuejs/vitepress/compare/v1.6.0...v1.6.1) (2025-01-20)
### Bug Fixes

@ -43,8 +43,7 @@ describe('static data file support in vite 3', () => {
`)
})
// TODO: make it `.runIf(!process.env.VITE_TEST_BUILD)` -- it currently works, but is skipped to avoid vite's ecosystem-ci from failing (https://github.com/vitejs/vite/pull/16471#issuecomment-2308437187)
test.skip('hmr works', async () => {
test.runIf(!process.env.VITE_TEST_BUILD)('hmr works', async () => {
const a = fileURLToPath(new URL('./data/a.json', import.meta.url))
const b = fileURLToPath(new URL('./data/b.json', import.meta.url))

@ -1,6 +1,6 @@
{
"name": "vitepress",
"version": "1.6.1",
"version": "1.6.2",
"description": "Vite & Vue powered static site generator",
"keywords": [
"vite",
@ -95,12 +95,12 @@
"*": "prettier --write --ignore-unknown"
},
"dependencies": {
"@docsearch/css": "^3.8.2",
"@docsearch/js": "^3.8.2",
"@iconify-json/simple-icons": "^1.2.20",
"@shikijs/core": "^2.0.0",
"@shikijs/transformers": "^2.0.0",
"@shikijs/types": "^2.0.0",
"@docsearch/css": "^3.8.3",
"@docsearch/js": "^3.8.3",
"@iconify-json/simple-icons": "^1.2.21",
"@shikijs/core": "^2.1.0",
"@shikijs/transformers": "^2.1.0",
"@shikijs/types": "^2.1.0",
"@types/markdown-it": "^14.1.2",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/devtools-api": "^7.7.0",
@ -110,8 +110,8 @@
"focus-trap": "^7.6.4",
"mark.js": "8.11.1",
"minisearch": "^7.1.1",
"shiki": "^2.0.0",
"vite": "^5.4.12",
"shiki": "^2.1.0",
"vite": "^6.0.11",
"vue": "^3.5.13"
},
"devDependencies": {
@ -186,7 +186,7 @@
"synckit": "^0.9.2",
"tinyglobby": "^0.2.10",
"typescript": "^5.7.3",
"vitest": "^3.0.2",
"vitest": "^3.0.3",
"vue-tsc": "^2.2.0",
"wait-on": "^8.0.2"
},

File diff suppressed because it is too large Load Diff

@ -119,21 +119,14 @@ function newApp(): App {
function newRouter(): Router {
let isInitialPageLoad = inBrowser
let initialPath: string
return createRouter((path) => {
let pageFilePath = pathToFile(path)
let pageModule = null
if (pageFilePath) {
// use lean build if this is the initial page load
if (isInitialPageLoad) {
initialPath = pageFilePath
}
// use lean build if this is the initial page load or navigating back
// to the initial loaded path (the static vnodes already adopted the
// static content on that load so no need to re-fetch the page)
if (isInitialPageLoad || initialPath === pageFilePath) {
pageFilePath = pageFilePath.replace(/\.js$/, '.lean.js')
}

@ -38,8 +38,7 @@ declare module 'vite' {
const themeRE = /\/\.vitepress\/theme\/index\.(m|c)?(j|t)s$/
const hashRE = /\.([-\w]+)\.js$/
const staticInjectMarkerRE =
/\b(const _hoisted_\d+ = \/\*(?:#|@)__PURE__\*\/\s*createStaticVNode)\("(.*)", (\d+)\)/g
const staticInjectMarkerRE = /\bcreateStaticVNode\((?:(".*")|('.*')), (\d+)\)/g
const staticStripRE = /['"`]__VP_STATIC_START__[^]*?__VP_STATIC_END__['"`]/g
const staticRestoreRE = /__VP_STATIC_(START|END)__/g
@ -325,10 +324,11 @@ export async function createVitePressPlugin(
// Using a regexp relies on specific output from Vue compiler core,
// which is a reasonable trade-off considering the massive perf win over
// a full AST parse.
code = code.replace(
staticInjectMarkerRE,
'$1("__VP_STATIC_START__$2__VP_STATIC_END__", $3)'
)
code = code.replace(staticInjectMarkerRE, (_, str1, str2, flag) => {
const str = str1 || str2
const quote = str[0]
return `createStaticVNode(${quote}__VP_STATIC_START__${str.slice(1, -1)}__VP_STATIC_END__${quote}, ${flag})`
})
return code
}
return null

@ -2,6 +2,7 @@ import { isMatch } from 'picomatch'
import path, { dirname, resolve } from 'node:path'
import { glob } from 'tinyglobby'
import {
type EnvironmentModuleNode,
type Plugin,
type ViteDevServer,
loadConfigFromFile,
@ -122,44 +123,25 @@ export const staticDataPlugin: Plugin = {
}
},
transform(_code, id) {
if (server && loaderMatch.test(id) && '_importGlobMap' in server) {
// register this module as a glob importer
const { watch } = idToLoaderModulesMap[id]!
if (watch) {
;(server as any)._importGlobMap.set(
id,
[Array.isArray(watch) ? watch : [watch]].map((globs) => {
const affirmed: string[] = []
const negated: string[] = []
for (const glob of globs) {
;(glob[0] === '!' ? negated : affirmed).push(glob)
}
return { affirmed, negated }
})
)
}
}
return null
},
handleHotUpdate(ctx) {
hotUpdate(ctx) {
const file = ctx.file
const modules: EnvironmentModuleNode[] = []
// dependency of data loader changed
// (note the dep array includes the loader file itself)
if (file in depToLoaderModuleIdMap) {
const id = depToLoaderModuleIdMap[file]!
delete idToLoaderModulesMap[id]
ctx.modules.push(server.moduleGraph.getModuleById(id)!)
modules.push(this.environment.moduleGraph.getModuleById(id)!)
}
for (const id in idToLoaderModulesMap) {
const { watch } = idToLoaderModulesMap[id]!
if (watch && isMatch(file, watch)) {
ctx.modules.push(server.moduleGraph.getModuleById(id)!)
modules.push(this.environment.moduleGraph.getModuleById(id)!)
}
}
return modules.length > 0 ? [...ctx.modules, ...modules] : undefined
}
}

Loading…
Cancel
Save