summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/code-gen.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-04-07 22:35:14 -0500
committerkpdecker <kpdecker@gmail.com>2015-04-07 22:35:14 -0500
commit81a4d50955b13e7d5e5052d904bb3e8c993ebb88 (patch)
tree0cc6e3fcf64a45c515a4b33ed6a670f02bb3fd2e /lib/handlebars/compiler/code-gen.js
parente15af4c84993ef730e1c07168f7cc97bc027f304 (diff)
downloadhandlebars.js-81a4d50955b13e7d5e5052d904bb3e8c993ebb88.zip
handlebars.js-81a4d50955b13e7d5e5052d904bb3e8c993ebb88.tar.gz
handlebars.js-81a4d50955b13e7d5e5052d904bb3e8c993ebb88.tar.bz2
Avoid source-map import under AMD
Fixes #989
Diffstat (limited to 'lib/handlebars/compiler/code-gen.js')
-rw-r--r--lib/handlebars/compiler/code-gen.js14
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 = '';