Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/coffee-script/coffee-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/coffee-script/sourcemap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions src/coffee-script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ exports.compile = compile = withPrettyErrors (code, options) ->
v3SourceMap = map.generate(options, code)

if options.inlineMap
sourceMapDataURI = "//# sourceMappingURL=data:application/json;base64,#{base64encode v3SourceMap}"
encoded = base64encode JSON.stringify v3SourceMap
sourceMapDataURI = "//# sourceMappingURL=data:application/json;base64,#{encoded}"
sourceURL = "//# sourceURL=#{options.filename ? 'coffeescript'}"
js = "#{js}\n#{sourceMapDataURI}\n#{sourceURL}"

if options.sourceMap
answer = {js}
answer.sourceMap = map
answer.v3SourceMap = v3SourceMap
answer
{
js
sourceMap: map
v3SourceMap: JSON.stringify v3SourceMap, null, 2
}
else
js

Expand Down Expand Up @@ -204,7 +206,11 @@ exports._compileFile = (filename, sourceMap = no, inlineMap = no) ->
stripped = if raw.charCodeAt(0) is 0xFEFF then raw.substring 1 else raw

try
answer = compile(stripped, {filename, sourceMap, inlineMap, literate: helpers.isLiterate filename})
answer = compile stripped, {
filename, sourceMap, inlineMap
sourceFiles: [filename]
literate: helpers.isLiterate filename
}
catch err
# As the filename and code of a dynamically loaded file will be different
# from the original file compiled with CoffeeScript.run, add that
Expand Down
4 changes: 2 additions & 2 deletions src/sourcemap.litcoffee
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ Produce the canonical JSON object format for a "v3" source map.
names: []
mappings: buffer

v3.sourcesContent = [code] if options.inline
v3.sourcesContent = [code] if options.inlineMap

JSON.stringify v3, null, 2
v3


Base64 VLQ Encoding
Expand Down