Skip to content

Commit 18e75ba

Browse files
committed
Add failing test
1 parent 2e5af2f commit 18e75ba

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
!test/fixtures/node_modules

test/fixtures/node_modules/module-k/browser.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/node_modules/module-k/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/node_modules/module-k/package.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/modules.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ test('object browser field as main', function(done) {
6161
});
6262
});
6363

64+
// package.json has browser field as object
65+
// one of the keys replaces the main file
66+
// however the main has no prefix and browser uses ./ prefix for the same file
67+
test('object browser field as main', function(done) {
68+
resolve('module-k', { paths: [ fixtures_dir ], package: { main: 'fixtures' } }, function(err, path, pkg) {
69+
assert.ifError(err);
70+
assert.equal(path, require.resolve('./fixtures/node_modules/module-k/browser'));
71+
assert.equal(pkg.main, './browser.js');
72+
done();
73+
});
74+
});
75+
6476
// browser field in package.json maps ./foo.js -> ./browser.js
6577
// when we resolve ./foo while in module-e, this mapping should take effect
6678
// the result is that ./foo resolves to ./browser

0 commit comments

Comments
 (0)