File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -166,15 +166,33 @@ module.exports = function (browserify, options) {
166
166
167
167
loader . fetch ( relFilename , '/' ) . then ( function ( tokens ) {
168
168
var deps = loader . deps . dependenciesOf ( filename ) ;
169
- var output = deps . map ( function ( f ) {
170
- return "require('" + f + "')\n"
171
- } ) + '\n\n' + 'module.exports = ' + JSON . stringify ( tokens ) ;
169
+ var output = [
170
+ deps . map ( function ( f ) {
171
+ return "require('" + f + "')"
172
+ } ) . join ( '\n' ) ,
173
+ 'module.exports = ' + JSON . stringify ( tokens )
174
+ ] . join ( '\n' ) ;
175
+
176
+ var isValid = true ;
177
+ var isUndefined = / \b u n d e f i n e d \b / ;
178
+ Object . keys ( tokens ) . forEach ( function ( k ) {
179
+ if ( isUndefined . test ( tokens [ k ] ) ) {
180
+ isValid = false ;
181
+ }
182
+ } ) ;
183
+
184
+ if ( ! isValid ) {
185
+ var err = 'Composition in ' + filename + ' contains an undefined reference' ;
186
+ console . error ( err )
187
+ output += '\nconsole.error("' + err + '");' ;
188
+ }
172
189
173
190
assign ( tokensByFile , loader . tokensByFile ) ;
174
191
175
192
self . push ( output ) ;
176
193
return callback ( )
177
- } , function ( err ) {
194
+ } ) . catch ( function ( err ) {
195
+ self . push ( 'console.error("' + err + '");' ) ;
178
196
browserify . emit ( 'error' , err ) ;
179
197
return callback ( )
180
198
} ) ;
You can’t perform that action at this time.
0 commit comments