@@ -29,6 +29,7 @@ inherits(Browserify, EventEmitter);
2929
3030var fs = require ( 'fs' ) ;
3131var path = require ( 'path' ) ;
32+ var relativePath = require ( 'cached-path-relative' )
3233var paths = {
3334 empty : path . join ( __dirname , 'lib/_empty.js' )
3435} ;
@@ -116,14 +117,14 @@ Browserify.prototype.require = function (file, opts) {
116117 var basedir = defined ( opts . basedir , self . _options . basedir , process . cwd ( ) ) ;
117118 var expose = opts . expose ;
118119 if ( file === expose && / ^ [ \. ] / . test ( expose ) ) {
119- expose = '/' + path . relative ( basedir , expose ) ;
120+ expose = '/' + relativePath ( basedir , expose ) ;
120121 expose = expose . replace ( / \\ / g, '/' ) ;
121122 }
122123 if ( expose === undefined && this . _options . exposeAll ) {
123124 expose = true ;
124125 }
125126 if ( expose === true ) {
126- expose = '/' + path . relative ( basedir , file ) ;
127+ expose = '/' + relativePath ( basedir , file ) ;
127128 expose = expose . replace ( / \\ / g, '/' ) ;
128129 }
129130
@@ -256,15 +257,15 @@ Browserify.prototype.external = function (file, opts) {
256257 if ( ! opts ) opts = { } ;
257258 var basedir = defined ( opts . basedir , process . cwd ( ) ) ;
258259 this . _external . push ( file ) ;
259- this . _external . push ( '/' + path . relative ( basedir , file ) ) ;
260+ this . _external . push ( '/' + relativePath ( basedir , file ) ) ;
260261 return this ;
261262} ;
262263
263264Browserify . prototype . exclude = function ( file , opts ) {
264265 if ( ! opts ) opts = { } ;
265266 var basedir = defined ( opts . basedir , process . cwd ( ) ) ;
266267 this . _exclude . push ( file ) ;
267- this . _exclude . push ( '/' + path . relative ( basedir , file ) ) ;
268+ this . _exclude . push ( '/' + relativePath ( basedir , file ) ) ;
268269 return this ;
269270} ;
270271
@@ -409,10 +410,10 @@ Browserify.prototype._createPipeline = function (opts) {
409410 if ( self . _external . indexOf ( row . file ) >= 0 ) return next ( ) ;
410411
411412 if ( isAbsolutePath ( row . id ) ) {
412- row . id = '/' + path . relative ( basedir , row . file ) ;
413+ row . id = '/' + relativePath ( basedir , row . file ) ;
413414 }
414415 Object . keys ( row . deps || { } ) . forEach ( function ( key ) {
415- row . deps [ key ] = '/' + path . relative ( basedir , row . deps [ key ] ) ;
416+ row . deps [ key ] = '/' + relativePath ( basedir , row . deps [ key ] ) ;
416417 } ) ;
417418 this . push ( row ) ;
418419 next ( ) ;
@@ -475,7 +476,7 @@ Browserify.prototype._createDeps = function (opts) {
475476 }
476477
477478 if ( file ) {
478- var ex = '/' + path . relative ( basedir , file ) ;
479+ var ex = '/' + relativePath ( basedir , file ) ;
479480 if ( self . _external . indexOf ( ex ) >= 0 ) {
480481 return cb ( null , ex ) ;
481482 }
@@ -678,7 +679,7 @@ Browserify.prototype._label = function (opts) {
678679 var prev = row . id ;
679680
680681 if ( self . _external . indexOf ( row . id ) >= 0 ) return next ( ) ;
681- if ( self . _external . indexOf ( '/' + path . relative ( basedir , row . id ) ) >= 0 ) {
682+ if ( self . _external . indexOf ( '/' + relativePath ( basedir , row . id ) ) >= 0 ) {
682683 return next ( ) ;
683684 }
684685 if ( self . _external . indexOf ( row . file ) >= 0 ) return next ( ) ;
@@ -695,7 +696,7 @@ Browserify.prototype._label = function (opts) {
695696 }
696697
697698 var afile = path . resolve ( path . dirname ( row . file ) , key ) ;
698- var rfile = '/' + path . relative ( basedir , afile ) ;
699+ var rfile = '/' + relativePath ( basedir , afile ) ;
699700 if ( self . _external . indexOf ( rfile ) >= 0 ) {
700701 row . deps [ key ] = rfile ;
701702 }
@@ -738,7 +739,7 @@ Browserify.prototype._debug = function (opts) {
738739 return through . obj ( function ( row , enc , next ) {
739740 if ( opts . debug ) {
740741 row . sourceRoot = 'file://localhost' ;
741- row . sourceFile = path . relative ( basedir , row . file )
742+ row . sourceFile = relativePath ( basedir , row . file )
742743 . replace ( / \\ / g, '/' ) ;
743744 }
744745 this . push ( row ) ;
0 commit comments