Avoid source-map import under AMD

Fixes #989
This commit is contained in:
kpdecker
2015-04-07 22:35:14 -05:00
parent e15af4c849
commit 81a4d50955
2 changed files with 16 additions and 4 deletions
+12 -2
View File
@@ -1,9 +1,19 @@
import {isArray} from "../utils"; import {isArray} from "../utils";
var SourceNode;
try { try {
var SourceMap = require('source-map'), if (typeof define !== 'function' || !define.amd) {
SourceNode = SourceMap.SourceNode; // 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) { } catch (err) {
/* NOP */
}
if (!SourceNode) {
/* istanbul ignore next: tested but not covered in istanbul due to dist build */ /* istanbul ignore next: tested but not covered in istanbul due to dist build */
SourceNode = function(line, column, srcFile, chunks) { SourceNode = function(line, column, srcFile, chunks) {
this.src = ''; this.src = '';
+4 -2
View File
@@ -1,7 +1,9 @@
/*global CompilerContext, Handlebars */ /*global CompilerContext, Handlebars */
try { try {
var SourceMap = require('source-map'), if (typeof define !== 'function' || !define.amd) {
SourceMapConsumer = SourceMap.SourceMapConsumer; var SourceMap = require('source-map'),
SourceMapConsumer = SourceMap.SourceMapConsumer;
}
} catch (err) { } catch (err) {
/* NOP for in browser */ /* NOP for in browser */
} }