Commit f418bd95 authored by Evan You's avatar Evan You

feat: basic hot reload

parent 878f1b8c
const hotReloadAPIPath = require.resolve('vue-hot-reload-api')
module.exports = function genHotReloadCode (id, functional) {
// TODO handle CSSModules and style injection disposal
return `
/* hot reload */
if (module.hot) {
var api = require('${hotReloadAPIPath}')
api.install(require('vue'))
if (api.compatible) {
module.hot.accept()
if (!module.hot.data) {
api.createRecord('${id}', component.options)
} else {
api.${functional ? `rerender` : `reload`}('${id}', component.options)
}
}
}
`.trim()
}
......@@ -5,6 +5,7 @@ const qs = require('querystring')
const loaderUtils = require('loader-utils')
const selectBlock = require('./selector')
const plugin = require('./plugin')
const genHotReloadCode = require('./hotReload')
const componentNormalizerPath = require.resolve('./runtime/componentNormalizer')
module.exports = function (source) {
......@@ -119,7 +120,7 @@ var component = normalizer(
${isServer ? JSON.stringify(hash(request)) : `null`}
${incomingQuery.shadow ? `,true` : ``}
)
`.trim()
`.trim()
if (descriptor.customBlocks && descriptor.customBlocks.length) {
// TODO custom blocks
......@@ -130,7 +131,7 @@ var component = normalizer(
}
if (needsHotReload) {
// TODO hot reload
code += genHotReloadCode(id, hasFunctional)
}
code += `\nexport default component.exports`
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment