diff options
Diffstat (limited to 'lib/handlebars/compiler/code-gen.js')
-rw-r--r-- | lib/handlebars/compiler/code-gen.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/handlebars/compiler/code-gen.js b/lib/handlebars/compiler/code-gen.js index 0fddb7c..e998095 100644 --- a/lib/handlebars/compiler/code-gen.js +++ b/lib/handlebars/compiler/code-gen.js @@ -1,9 +1,19 @@ import {isArray} from "../utils"; +var SourceNode; + try { - var SourceMap = require('source-map'), - SourceNode = SourceMap.SourceNode; + if (typeof define !== 'function' || !define.amd) { + // We don't support this in AMD environments. For these environments, we asusme that + // they are running on the browser and thus have no need for the source-map library. + var SourceMap = require('source-map'); + SourceNode = SourceMap.SourceNode; + } } catch (err) { + /* NOP */ +} + +if (!SourceNode) { /* istanbul ignore next: tested but not covered in istanbul due to dist build */ SourceNode = function(line, column, srcFile, chunks) { this.src = ''; |