File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,22 @@ var shimmed = false
9
9
exports . install = function ( Vue ) {
10
10
if ( shimmed ) return
11
11
shimmed = true
12
- console . log ( '[HMR] Vue component hot reload shim applied.' )
12
+
13
+ exports . compatible = ! ! Vue . internalDirectives
14
+ if ( ! exports . compatible ) {
15
+ console . warn (
16
+ '[HMR] vue-loader hot reload is only compatible with ' +
17
+ 'Vue.js 1.0.0+.'
18
+ )
19
+ return
20
+ }
21
+
22
+ // create global hot reload map
13
23
var map = Vue . config . _hotComponents = Object . create ( null )
24
+ // check compatibility
14
25
var componentDir = Vue . internalDirectives . component
15
-
26
+
27
+ // shim the component directive
16
28
var set = componentDir . setComponent
17
29
componentDir . setComponent = function ( id , cb ) {
18
30
var prevComponent = this . Component
@@ -50,6 +62,8 @@ exports.install = function (Vue) {
50
62
}
51
63
unbind . call ( this )
52
64
}
65
+
66
+ console . log ( '[HMR] Vue component hot reload shim applied.' )
53
67
}
54
68
55
69
/**
Original file line number Diff line number Diff line change @@ -137,8 +137,9 @@ module.exports = function (content) {
137
137
// shim the component directive so that it
138
138
// registers the instances
139
139
'var Vue = require("vue")\n' +
140
- 'var shim = require("' + require . resolve ( './hot-shim' ) + '")\n' +
141
- 'shim.install(Vue)\n' +
140
+ 'var hotAPI = require("' + require . resolve ( './hot-reload-api' ) + '")\n' +
141
+ 'hotAPI.install(Vue)\n' +
142
+ 'if (!hotAPI.compatible) return\n' +
142
143
'var map = Vue.config._hotComponents\n' +
143
144
'var id = module.exports.hotID = ' + ( scriptString || templateString ) + '\n' +
144
145
'module.hot.accept(' + JSON . stringify ( accepted ) + ', function () {\n' +
@@ -149,7 +150,7 @@ module.exports = function (content) {
149
150
// reset linker
150
151
'Ctor.linker = null\n' +
151
152
// reload directive instances
152
- 'map[id].instances.forEach(shim .update)\n' +
153
+ 'map[id].instances.forEach(hotAPI .update)\n' +
153
154
// re-enable transitions
154
155
'})\n' +
155
156
'})()\n' +
You can’t perform that action at this time.
0 commit comments