Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2b83f56

Browse files
committedJul 27, 2014
fixed resolving issues cause when aliases were included
1 parent 6c7597f commit 2b83f56

File tree

13 files changed

+75
-13
lines changed

13 files changed

+75
-13
lines changed
 

‎lib/index.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,36 @@ AngularPlugin.prototype = {
119119
// just a prefix.
120120
// prefer the segments to be directories and prefer the full name to be
121121
// used.
122-
var pairs = [];
123-
for( var j = 0; j > (0-split.length); j-- ){
124-
var cropped = split.slice(0, j || undefined);
125-
for( var i = 0; i < cropped.length; i++ ){
126-
pairs.push({ front: cropped.slice(0, i), back: cropped.slice(i) });
122+
var namespaced = [], ns, mod;
123+
for( var j = 0; j < split.length; j++ ){
124+
ns = split.slice(0, -j);
125+
mod = split.slice(-j);
126+
namespaced.push({
127+
namespace: ns,
128+
module: mod.join('.')
129+
});
130+
}
131+
for( var k = 0; k < split.length; k++ ){
132+
ns = split.slice(0, -k);
133+
mod = split.slice(-k);
134+
for( var i = 1; i < mod.length; i++ ){
135+
namespaced.push({
136+
namespace: ns,
137+
module: mod.slice(0, -i).join('.')
138+
});
127139
}
128140
}
129-
pairs.shift();
130-
var requests = pairs.map(function(p){
131-
return {
132-
path: path.join.apply(path, [request.path].concat(p.front)),
133-
request: p.back.join('.'),
141+
namespaced.shift();
142+
143+
return resolver.forEachBail(namespaced, function(nsmod, cb){
144+
callback.log("resolve module " + nsmod.module +
145+
" in namespace " + JSON.stringify(nsmod.namespace));
146+
var req = {
147+
path: request.path,
148+
request: path.join.apply(path, nsmod.namespace.concat(nsmod.module)),
134149
query: request.query
135150
};
136-
});
137-
138-
return resolver.forEachBail(requests, function(req, cb){
151+
callback.log(JSON.stringify(req));
139152
return resolver.doResolve("module", req, cb, true);
140153
}, function(err, resolved){
141154
if( err || !resolved ){
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
angular.module('myLibrary.one', []);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
angular.module('myLibrary.two.something', []);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// deps with dots
2+
angular.module('main', ['myLibrary.one', 'myLibrary.two.something']);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
([
2+
function(module, exports, __webpack_require__) {
3+
__webpack_require__(2);
4+
__webpack_require__(1);
5+
(function(angular) {
6+
(module.exports['main'] = angular.module('main', ['myLibrary.one', 'myLibrary.two.something']));
7+
}.call(exports, __webpack_require__(3)))
8+
},
9+
function(module, exports, __webpack_require__) {
10+
(function(angular) {
11+
(module.exports['myLibrary.one'] = angular.module('myLibrary.one', []));
12+
}.call(exports, __webpack_require__(3)))
13+
},
14+
function(module, exports, __webpack_require__) {
15+
(function(angular) {
16+
(module.exports['myLibrary.two.something'] = angular.module('myLibrary.two.something', []));
17+
}.call(exports, __webpack_require__(3)))
18+
},
19+
function(module, exports, __webpack_require__) {
20+
module.exports = window.angular
21+
}
22+
])
23+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var path = require('path');
2+
var AngularPlugin = require('../../../lib');
3+
4+
module.exports = {
5+
entry: "main",
6+
resolve: {
7+
root: path.resolve(__dirname, 'in'),
8+
alias: {
9+
myLibrary: 'alib/src'
10+
}
11+
},
12+
plugins: [new AngularPlugin()]
13+
};

‎test/scenarios/basic-module-dependency/out/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ function(module, exports, __webpack_require__) {
1616
},
1717
function(module, exports, __webpack_require__) {
1818
// stub
19+
module.exports = window.angular
1920
}
2021
])

‎test/scenarios/basic-module/out/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
},
88
function(module, exports, require) {
99
// angular.js stub
10+
module.exports = window.angular
1011
}
1112
])

‎test/scenarios/dots-for-path-separator/out/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function(module, exports, __webpack_require__) {
1414
},
1515
function(module, exports, __webpack_require__) {
1616
// stub
17+
module.exports = window.angular
1718
}
1819
])
1920

‎test/scenarios/local-module/out/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
}.call(exports, __webpack_require__(1)))
77
},
88
function(module, exports, __webpack_require__) {
9+
module.exports = window.angular
910
}
1011
])

‎test/scenarios/module-dir-and-file/out/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ function(module, exports, __webpack_require__) {
1717
}.call(exports, __webpack_require__(3)))
1818
},
1919
function(module, exports, __webpack_require__) {
20+
module.exports = window.angular
2021
}
2122
])

‎test/scenarios/multi-module-files/out/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ function(module, exports, __webpack_require__) {
1515
}.call(exports, __webpack_require__(2)))
1616
},
1717
function(module, exports, __webpack_require__) {
18+
module.exports = window.angular
1819
}
1920
])

‎test/scenarios/multi-modules/out/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
}.call(exports, __webpack_require__(1)))
1818
},
1919
function(module, exports, __webpack_require__) {
20+
module.exports = window.angular
2021
}
2122
])

0 commit comments

Comments
 (0)
This repository has been archived.