@@ -4,6 +4,11 @@ var config = require('./config'),
4
4
makeHash = utils . hash ,
5
5
assetTypes = [ 'directive' , 'filter' , 'partial' , 'transition' , 'component' ]
6
6
7
+ // require these so Browserify can catch them
8
+ // so they can be used in Vue.require
9
+ require ( './observer' )
10
+ require ( './transition' )
11
+
7
12
ViewModel . options = config . globalAssets = {
8
13
directives : require ( './directives' ) ,
9
14
filters : require ( './filters' ) ,
@@ -48,13 +53,6 @@ ViewModel.config = function (opts, val) {
48
53
return this
49
54
}
50
55
51
- /**
52
- * Expose internal modules for plugins
53
- */
54
- ViewModel . require = function ( path ) {
55
- return require ( './' + path )
56
- }
57
-
58
56
/**
59
57
* Expose an interface for plugins
60
58
*/
@@ -69,13 +67,21 @@ ViewModel.use = function (plugin) {
69
67
70
68
// additional parameters
71
69
var args = [ ] . slice . call ( arguments , 1 )
72
- args . unshift ( ViewModel )
70
+ args . unshift ( this )
73
71
74
72
if ( typeof plugin . install === 'function' ) {
75
73
plugin . install . apply ( plugin , args )
76
74
} else {
77
75
plugin . apply ( null , args )
78
76
}
77
+ return this
78
+ }
79
+
80
+ /**
81
+ * Expose internal modules for plugins
82
+ */
83
+ ViewModel . require = function ( path ) {
84
+ return require ( './' + path )
79
85
}
80
86
81
87
ViewModel . extend = extend
@@ -118,15 +124,19 @@ function extend (options) {
118
124
}
119
125
120
126
// allow extended VM to be further extended
121
- ExtendedVM . extend = extend
122
- ExtendedVM . super = ParentVM
127
+ ExtendedVM . extend = extend
128
+ ExtendedVM . super = ParentVM
123
129
ExtendedVM . options = options
124
130
125
131
// allow extended VM to add its own assets
126
132
assetTypes . forEach ( function ( type ) {
127
133
ExtendedVM [ type ] = ViewModel [ type ]
128
134
} )
129
135
136
+ // allow extended VM to use plugins
137
+ ExtendedVM . use = ViewModel . use
138
+ ExtendedVM . require = ViewModel . require
139
+
130
140
return ExtendedVM
131
141
}
132
142
0 commit comments