Skip to content

Commit a4206b0

Browse files
committed
fix: inherit local paths
1 parent 3ec69dc commit a4206b0

File tree

8 files changed

+33
-0
lines changed

8 files changed

+33
-0
lines changed

lib/resolver.js

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Resolver.prototype.pull = function(type){
240240
*/
241241

242242
Resolver.prototype.resolve = function(dep, fn){
243+
this.locals = this.locals.concat(this.parent.locals);
243244
var paths = this.paths.concat(this.locals);
244245
var dep = dep.replace('/', '-');
245246
var name = this.conf.name;

test/fixtures/locals/app.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
module.exports = require('boot');

test/fixtures/locals/component.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "app",
3+
"main": "app.js",
4+
"paths": ["lib"],
5+
"scripts": ["app.js"],
6+
"local": ["boot"]
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "a",
3+
"main": "index.js",
4+
"scripts": ["index.js"]
5+
}

test/fixtures/locals/lib/a/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
module.exports = 'a';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "boot",
3+
"main": "index.js",
4+
"scripts": ["index.js"],
5+
"local": ["a"]
6+
}
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
module.exports = require('a');

test/resolver.js

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ describe('Resolver', function(){
4141
})
4242
})
4343

44+
45+
describe('locals', function(){
46+
it('should work', function(done){
47+
var resolver = Resolver('test/fixtures/locals');
48+
resolver.end(done);
49+
})
50+
})
51+
4452
describe('collision', function(){
4553
it('should work', function(done){
4654
var collision = Resolver('test/fixtures/collision');

0 commit comments

Comments
 (0)