Skip to content

Commit

Permalink
Merge branch 'v0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Apr 4, 2014
2 parents 36e1e68 + 2288616 commit fabc62e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/parser.js
Expand Up @@ -252,12 +252,13 @@ parser = {
}
return this.resolveExternal(fromfile, dirname, scope, dep);
},
resolveLocal: function (fromfile, dirpath, scope, tree, dep, orgFn) {
resolveLocal: function (fromfile, dirpath, scope, tree, dep, orgFn, lScope) {
var filename = dep.localFilename || dep.value, extNames = this.extNames
, resolveDirPath, resolvePath, resolveFirstTypePath, resolveExtTypePath
, resolveSpecificPath, init;
// console.log("RL", filename, dirpath, fromfile, tree.length);

if (!lScope) lScope = scope;
if (!orgFn) orgFn = filename;

resolveDirPath = function (path) {
Expand Down Expand Up @@ -375,7 +376,7 @@ parser = {
if (!scope[name]) scope[name] = result;
return result(filename);
}.bind(this), function (error) {
if (isOptional(scope[basename(fromfile)], dep.point, dep.raw.length)) {
if (isOptional(lScope[basename(fromfile)], dep.point, dep.raw.length)) {
return;
}
throw error;
Expand All @@ -384,7 +385,7 @@ parser = {
resolveExternal: function (fromfile, dirname, scope, dep) {
// console.log("RE", dep.value);
var org = dep.value, filename = join(dep.value)
, name, tree, require, main, path, cache, ext;
, lScope = scope, name, tree, require, main, path, cache, ext;
name = filename.split(sep, 1)[0];
return deferred.promisifySync(function () {
// If already processed, return result
Expand Down Expand Up @@ -477,7 +478,7 @@ parser = {
// console.log("RE", name, scope, filename);
dep.localFilename = filename;
return this.resolveLocal(fromfile, this.packages[name], scope, tree,
dep, org);
dep, org, lScope);
}.bind(this));
},
toString: function () {
Expand Down
6 changes: 6 additions & 0 deletions test/__playground/lib/program.js
Expand Up @@ -49,3 +49,9 @@ exports.external = {
other: require('test/lib/other.js'),
noMain: require('no-main/lib/some-module')
};

try {
require('test/marko/optional-module-of-outer-package');
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') throw e;
}

0 comments on commit fabc62e

Please sign in to comment.