@@ -29,6 +29,7 @@ inherits(Browserify, EventEmitter);
29
29
30
30
var fs = require ( 'fs' ) ;
31
31
var path = require ( 'path' ) ;
32
+ var relativePath = require ( 'cached-path-relative' )
32
33
var paths = {
33
34
empty : path . join ( __dirname , 'lib/_empty.js' )
34
35
} ;
@@ -116,14 +117,14 @@ Browserify.prototype.require = function (file, opts) {
116
117
var basedir = defined ( opts . basedir , self . _options . basedir , process . cwd ( ) ) ;
117
118
var expose = opts . expose ;
118
119
if ( file === expose && / ^ [ \. ] / . test ( expose ) ) {
119
- expose = '/' + path . relative ( basedir , expose ) ;
120
+ expose = '/' + relativePath ( basedir , expose ) ;
120
121
expose = expose . replace ( / \\ / g, '/' ) ;
121
122
}
122
123
if ( expose === undefined && this . _options . exposeAll ) {
123
124
expose = true ;
124
125
}
125
126
if ( expose === true ) {
126
- expose = '/' + path . relative ( basedir , file ) ;
127
+ expose = '/' + relativePath ( basedir , file ) ;
127
128
expose = expose . replace ( / \\ / g, '/' ) ;
128
129
}
129
130
@@ -256,15 +257,15 @@ Browserify.prototype.external = function (file, opts) {
256
257
if ( ! opts ) opts = { } ;
257
258
var basedir = defined ( opts . basedir , process . cwd ( ) ) ;
258
259
this . _external . push ( file ) ;
259
- this . _external . push ( '/' + path . relative ( basedir , file ) ) ;
260
+ this . _external . push ( '/' + relativePath ( basedir , file ) ) ;
260
261
return this ;
261
262
} ;
262
263
263
264
Browserify . prototype . exclude = function ( file , opts ) {
264
265
if ( ! opts ) opts = { } ;
265
266
var basedir = defined ( opts . basedir , process . cwd ( ) ) ;
266
267
this . _exclude . push ( file ) ;
267
- this . _exclude . push ( '/' + path . relative ( basedir , file ) ) ;
268
+ this . _exclude . push ( '/' + relativePath ( basedir , file ) ) ;
268
269
return this ;
269
270
} ;
270
271
@@ -409,10 +410,10 @@ Browserify.prototype._createPipeline = function (opts) {
409
410
if ( self . _external . indexOf ( row . file ) >= 0 ) return next ( ) ;
410
411
411
412
if ( isAbsolutePath ( row . id ) ) {
412
- row . id = '/' + path . relative ( basedir , row . file ) ;
413
+ row . id = '/' + relativePath ( basedir , row . file ) ;
413
414
}
414
415
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 ] ) ;
416
417
} ) ;
417
418
this . push ( row ) ;
418
419
next ( ) ;
@@ -475,7 +476,7 @@ Browserify.prototype._createDeps = function (opts) {
475
476
}
476
477
477
478
if ( file ) {
478
- var ex = '/' + path . relative ( basedir , file ) ;
479
+ var ex = '/' + relativePath ( basedir , file ) ;
479
480
if ( self . _external . indexOf ( ex ) >= 0 ) {
480
481
return cb ( null , ex ) ;
481
482
}
@@ -678,7 +679,7 @@ Browserify.prototype._label = function (opts) {
678
679
var prev = row . id ;
679
680
680
681
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 ) {
682
683
return next ( ) ;
683
684
}
684
685
if ( self . _external . indexOf ( row . file ) >= 0 ) return next ( ) ;
@@ -695,7 +696,7 @@ Browserify.prototype._label = function (opts) {
695
696
}
696
697
697
698
var afile = path . resolve ( path . dirname ( row . file ) , key ) ;
698
- var rfile = '/' + path . relative ( basedir , afile ) ;
699
+ var rfile = '/' + relativePath ( basedir , afile ) ;
699
700
if ( self . _external . indexOf ( rfile ) >= 0 ) {
700
701
row . deps [ key ] = rfile ;
701
702
}
@@ -738,7 +739,7 @@ Browserify.prototype._debug = function (opts) {
738
739
return through . obj ( function ( row , enc , next ) {
739
740
if ( opts . debug ) {
740
741
row . sourceRoot = 'file://localhost' ;
741
- row . sourceFile = path . relative ( basedir , row . file )
742
+ row . sourceFile = relativePath ( basedir , row . file )
742
743
. replace ( / \\ / g, '/' ) ;
743
744
}
744
745
this . push ( row ) ;
0 commit comments