-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not rerender when code snippet file changes #1309
Comments
The problem is we use cache in markdown-loader: https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/markdown-loader/index.js#L36 In that case, changes in code snippets will not be able to be detected even if we add them as dependencies. |
@ulivz What do you mean by: https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/markdown-loader/index.js#L30-L32 Can we only cache the markdown tokens and do the rendering repetitively? |
I hava a plan.
// const cached = cache.get(key)
// if (cached && (isProd || /\?vue/.test(this.resourceQuery))) {
// return cached
// }
...
// the render method has been augmented to allow plugins to
// register data during render
const {
html,
data: { hoistedTags, links, deps },
dataBlockString
} = markdown.render(content, {
frontmatter: frontmatter.data,
relPath: path.relative(sourceDir, file)
})
deps.forEach(this.addDependency) // <-- add deps for webpack
md.$data = md.$data || {}
md.$data.deps = md.$data.deps || []
md.$data.deps.push(filename) // <-- add dep
module.exports.dataReturnable = function dataReturnable (md) {
// override render to allow custom plugins return data
const render = md.render
md.render = (...args) => {
md.$data = md.$data || {} // <-- markdown-it plugins can pass deps via md.$data
...
}
} @ulivz what do you think? |
@BuptStEve |
Yeah, it's just a simple and naive solution. Any better ideas? |
My idea is to separate Every part will has cache with it, which will not only solve the problem but improve performance for general situations as well. I will open a pr later to clarify some technical details. |
Bug report
Version
1.0.0-alpha.39
Steps to reproduce
The issue is found by @jiaming743 in #1297. Thanks!
Suppose we have two files, foo.js and foo.md.
foo.js
foo.md
What is expected?
When updating foo.js, foo.html will automatically rerender.
What is actually happening?
After updating foo.js, foo.html does not changes.
Other relevant information
The text was updated successfully, but these errors were encountered: