@@ -8,7 +8,7 @@ test('index.js of module dir', function(done) {
8
8
resolve ( 'module-a' , { paths : [ fixtures_dir ] , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
9
9
assert . ifError ( err ) ;
10
10
assert . equal ( path , require . resolve ( './fixtures/node_modules/module-a/index' ) ) ;
11
- assert . strictEqual ( pkg , undefined ) ;
11
+ assert . strictEqual ( pkg . main , 'fixtures' ) ;
12
12
done ( ) ;
13
13
} ) ;
14
14
} ) ;
@@ -70,7 +70,7 @@ test('string alt browser field as main - require subfile', function(done) {
70
70
// one of the keys replaces the main file
71
71
// this would be done if the user needed to replace main and some other module
72
72
test ( 'object browser field as main' , function ( done ) {
73
- resolve ( 'module-d' , { paths : [ fixtures_dir ] , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
73
+ resolve ( 'module-d' , { paths : [ fixtures_dir ] } , function ( err , path , pkg ) {
74
74
assert . ifError ( err ) ;
75
75
assert . equal ( path , require . resolve ( './fixtures/node_modules/module-d/browser' ) ) ;
76
76
assert . equal ( pkg . main , './browser.js' ) ;
@@ -82,7 +82,7 @@ test('object browser field as main', function(done) {
82
82
// one of the keys replaces the main file
83
83
// however the main has no prefix and browser uses ./ prefix for the same file
84
84
test ( 'object browser field as main' , function ( done ) {
85
- resolve ( 'module-k' , { paths : [ fixtures_dir ] , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
85
+ resolve ( 'module-k' , { paths : [ fixtures_dir ] } , function ( err , path , pkg ) {
86
86
assert . ifError ( err ) ;
87
87
assert . equal ( path , require . resolve ( './fixtures/node_modules/module-k/browser' ) ) ;
88
88
assert . equal ( pkg . main , './browser.js' ) ;
@@ -91,7 +91,7 @@ test('object browser field as main', function(done) {
91
91
} ) ;
92
92
93
93
test ( 'deep module reference mapping' , function ( done ) {
94
- resolve ( 'module-l/direct' , { basedir : __dirname + '/fixtures' , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
94
+ resolve ( 'module-l/direct' , { basedir : __dirname + '/fixtures' } , function ( err , path , pkg ) {
95
95
assert . ifError ( err ) ;
96
96
assert . equal ( path , require . resolve ( './fixtures/node_modules/module-l/browser-direct' ) ) ;
97
97
assert . equal ( pkg . main , './browser.js' ) ;
@@ -102,14 +102,14 @@ test('deep module reference mapping', function(done) {
102
102
// package.json has browser field as object
103
103
// test that file resolves even though the file extension is omitted
104
104
test ( 'deep module reference mapping without file extension - .js' , function ( done ) {
105
- resolve ( 'module-n/foo' , { basedir : __dirname + '/fixtures' , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
105
+ resolve ( 'module-n/foo' , { basedir : __dirname + '/fixtures' } , function ( err , path , pkg ) {
106
106
assert . ifError ( err ) ;
107
107
assert . equal ( path , require . resolve ( './fixtures/node_modules/module-n/browser-foo' ) ) ;
108
108
done ( ) ;
109
109
} ) ;
110
110
} ) ;
111
111
test ( 'deep module reference mapping without file extension - .json' , function ( done ) {
112
- resolve ( 'module-n/bar' , { basedir : __dirname + '/fixtures' , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
112
+ resolve ( 'module-n/bar' , { basedir : __dirname + '/fixtures' } , function ( err , path , pkg ) {
113
113
assert . ifError ( err ) ;
114
114
assert . equal ( path , require . resolve ( './fixtures/node_modules/module-n/browser-bar' ) ) ;
115
115
done ( ) ;
@@ -285,7 +285,6 @@ test('alt-browser field', function(done) {
285
285
test ( 'alt-browser deep module reference mapping' , function ( done ) {
286
286
resolve ( 'alt-browser-field/direct' , {
287
287
basedir : __dirname + '/fixtures' ,
288
- package : { main : 'fixtures' } ,
289
288
browser : 'chromeapp'
290
289
} , function ( err , path , pkg ) {
291
290
assert . ifError ( err ) ;
@@ -312,10 +311,9 @@ test('alt-browser fallback to "browser" on deps of deps', function(done) {
312
311
} ) ;
313
312
314
313
test ( 'not fail on accessing path name defined in Object.prototype' , function ( done ) {
315
- resolve ( 'toString' , { paths : [ fixtures_dir ] , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
314
+ resolve ( 'toString' , { paths : [ fixtures_dir ] } , function ( err , path , pkg ) {
316
315
assert . ifError ( err ) ;
317
316
assert . equal ( path , require . resolve ( './fixtures/node_modules/toString/index' ) ) ;
318
- assert . strictEqual ( pkg , undefined ) ;
319
317
done ( ) ;
320
318
} ) ;
321
319
} ) ;
@@ -334,10 +332,9 @@ test('respect symlinks', function (done) {
334
332
// - node_modules
335
333
// - symlink to x
336
334
//
337
- resolve ( 'linked' , { paths : [ fixtures_dir + '/linker/node_modules' ] , package : { main : 'fixtures' } } , function ( err , path , pkg ) {
335
+ resolve ( 'linked' , { paths : [ fixtures_dir + '/linker/node_modules' ] , preserveSymlinks : false } , function ( err , path , pkg ) {
338
336
assert . ifError ( err ) ;
339
337
assert . equal ( path , require . resolve ( './fixtures/linked/index' ) ) ;
340
- assert . strictEqual ( pkg , undefined ) ;
341
338
done ( ) ;
342
339
} ) ;
343
- } ) ;
340
+ } ) ;
0 commit comments