|
20 | 20 | var runScripts; |
21 | 21 | var loadScripts; |
22 | 22 | var headEl; |
| 23 | +var dummyAnchor; |
23 | 24 |
|
24 | 25 | var buffer = require('buffer'); |
25 | 26 | var transform = require('jstransform').transform; |
@@ -124,13 +125,20 @@ var transformCode = function(code, source, options) { |
124 | 125 | if (inlineScriptCount > 1) { |
125 | 126 | source += ' (' + inlineScriptCount + ')'; |
126 | 127 | } |
| 128 | + } else if (dummyAnchor) { |
| 129 | + // Firefox has problems when the sourcemap source is a proper URL with a |
| 130 | + // protocol and hostname, so use the pathname. We could use just the |
| 131 | + // filename, but hopefully using the full path will prevent potential |
| 132 | + // issues where the same filename exists in multiple directories. |
| 133 | + dummyAnchor.href = source; |
| 134 | + source = dummyAnchor.pathname.substr(1); |
127 | 135 | } |
128 | 136 | map.sources = [source]; |
129 | 137 | map.sourcesContent = [code]; |
130 | 138 |
|
131 | 139 | return ( |
132 | 140 | transformed.code + |
133 | | - '//# sourceMappingURL=data:application/json;base64,' + |
| 141 | + '\n//# sourceMappingURL=data:application/json;base64,' + |
134 | 142 | buffer.Buffer(JSON.stringify(map)).toString('base64') |
135 | 143 | ); |
136 | 144 | } else { |
@@ -226,6 +234,7 @@ runScripts = function() { |
226 | 234 |
|
227 | 235 | if (typeof window !== "undefined" && window !== null) { |
228 | 236 | headEl = document.getElementsByTagName('head')[0]; |
| 237 | + dummyAnchor = document.createElement('a'); |
229 | 238 |
|
230 | 239 | if (window.addEventListener) { |
231 | 240 | window.addEventListener('DOMContentLoaded', runScripts, false); |
|
0 commit comments