@@ -4,6 +4,11 @@ var config = require('./config'),
44 makeHash = utils . hash ,
55 assetTypes = [ 'directive' , 'filter' , 'partial' , 'transition' , 'component' ]
66
7+ // require these so Browserify can catch them
8+ // so they can be used in Vue.require
9+ require ( './observer' )
10+ require ( './transition' )
11+
712ViewModel . options = config . globalAssets = {
813 directives : require ( './directives' ) ,
914 filters : require ( './filters' ) ,
@@ -48,13 +53,6 @@ ViewModel.config = function (opts, val) {
4853 return this
4954}
5055
51- /**
52- * Expose internal modules for plugins
53- */
54- ViewModel . require = function ( path ) {
55- return require ( './' + path )
56- }
57-
5856/**
5957 * Expose an interface for plugins
6058 */
@@ -69,13 +67,21 @@ ViewModel.use = function (plugin) {
6967
7068 // additional parameters
7169 var args = [ ] . slice . call ( arguments , 1 )
72- args . unshift ( ViewModel )
70+ args . unshift ( this )
7371
7472 if ( typeof plugin . install === 'function' ) {
7573 plugin . install . apply ( plugin , args )
7674 } else {
7775 plugin . apply ( null , args )
7876 }
77+ return this
78+ }
79+
80+ /**
81+ * Expose internal modules for plugins
82+ */
83+ ViewModel . require = function ( path ) {
84+ return require ( './' + path )
7985}
8086
8187ViewModel . extend = extend
@@ -118,15 +124,19 @@ function extend (options) {
118124 }
119125
120126 // allow extended VM to be further extended
121- ExtendedVM . extend = extend
122- ExtendedVM . super = ParentVM
127+ ExtendedVM . extend = extend
128+ ExtendedVM . super = ParentVM
123129 ExtendedVM . options = options
124130
125131 // allow extended VM to add its own assets
126132 assetTypes . forEach ( function ( type ) {
127133 ExtendedVM [ type ] = ViewModel [ type ]
128134 } )
129135
136+ // allow extended VM to use plugins
137+ ExtendedVM . use = ViewModel . use
138+ ExtendedVM . require = ViewModel . require
139+
130140 return ExtendedVM
131141}
132142
0 commit comments