diff --git a/lib/less/browser.js b/lib/less/browser.js index b00599ad..a40ce1a1 100644 --- a/lib/less/browser.js +++ b/lib/less/browser.js @@ -286,12 +286,3 @@ function error(e, href) { } } -// -// Used by `@import` directives -// -less.Parser.importer = function (path, paths, callback) { - loadStyleSheet({ href: path, title: path }, function (root) { - callback(root); - }); -}; - diff --git a/lib/less/parser.js b/lib/less/parser.js index 000a09c0..e02daeea 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -927,5 +927,14 @@ less.Parser = function Parser(env) { }; }; -less.Parser.importer = null; +if (typeof(window) !== 'undefined') { + // + // Used by `@import` directives + // + less.Parser.importer = function (path, paths, callback) { + loadStyleSheet({ href: path, title: path }, function (root) { + callback(root); + }); + }; +} diff --git a/lib/less/tree/import.js b/lib/less/tree/import.js index 4df1e3c7..2a910656 100644 --- a/lib/less/tree/import.js +++ b/lib/less/tree/import.js @@ -28,6 +28,9 @@ tree.Import = function (path, imports) { // Only pre-compile .less files if (! this.css) { imports.push(this.path, function (root) { + if (! root) { + throw new(Error)("Error parsing " + that.path); + } that.root = root; }); }