Skip to content

Commit

Permalink
Fix resolver issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckdumont committed Jul 8, 2017
1 parent 13c9ad9 commit c95ca13
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions lib/DojoAMDResolverPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/
const path = require("path");
const async = require("async");

module.exports = class DojoAMDResolverPlugin {
constructor(dojoRequire) {
Expand All @@ -23,25 +22,17 @@ module.exports = class DojoAMDResolverPlugin {

apply(resolver) {
resolver.plugin('module', (request, callback) => {
if (request.directory) return;
const url = this.dojoRequire.toUrl(request.request, {mid: path.join(request.path, "x").replace(/\\/g, "/")});
if (url && url != request.request) {
let answer;
async.each([url, url+".js"], (tryUrl, cb) =>{
const obj = {
path: tryUrl,
query: request.query,
directory: request.directory
};
const message = "Dojo resolve '" + request + "' in '" + path;
resolver.doResolve(['file'], obj, message, (err, result) => {
if (result) {
answer = result;
}
cb();
});
}, function() {
callback(null, answer);
if (request.directory) return;
const url = this.dojoRequire.toUrl(request.request, {mid: path.join(request.path, "x").replace('\\', '/')});
if (url && url != request.request) {
const obj = {
path: path.normalize(url), // sets path separators to platform specific values
query: request.query,
directory: request.directory
};
const message = `Dojo resolve ${obj.path} from ${request.request} in ${request.path}`;
resolver.doResolve(['raw-file'], obj, message, (err, result) => {
callback(null, result);
});
} else {
return callback();
Expand Down

0 comments on commit c95ca13

Please sign in to comment.