Ensure unique source maps’ sourceURL; closes #4126

This commit is contained in:
Geoffrey Booth
2017-02-20 15:32:11 -08:00
parent 6f0f173795
commit 7de06c3dcb
2 changed files with 9 additions and 0 deletions

View File

@@ -92,11 +92,13 @@
};
source = script.src || script.getAttribute('data-src');
if (source) {
options.filename = source;
return CoffeeScript.load(source, function(param) {
coffees[i] = param;
return execute();
}, options, true);
} else {
options.filename = script.id && script.id !== '' ? script.id : `coffeescript${(i !== 0 ? i : '')}`;
options.sourceFiles = ['embedded'];
return coffees[i] = [script.innerHTML, options];
}

View File

@@ -69,6 +69,7 @@ runScripts = ->
options = literate: script.type is coffeetypes[1]
source = script.src or script.getAttribute('data-src')
if source
options.filename = source
CoffeeScript.load source,
(param) ->
coffees[i] = param
@@ -76,6 +77,12 @@ runScripts = ->
options
true
else
# `options.filename` defines how the filename the source map appears as
# in Developer Tools. If a script tag has an `id`, use that as the
# filename; otherwise use `coffeescript`, or `coffeescript1` etc.
# leaving the first one unnumbered for the common case that theres
# only one CoffeeScript script block to parse.
options.filename = if script.id and script.id isnt '' then script.id else "coffeescript#{if i isnt 0 then i else ''}"
options.sourceFiles = ['embedded']
coffees[i] = [script.innerHTML, options]