mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Minor adjustments in new source map code.
Handle empty code properly.
This commit is contained in:
parent
2d702d0247
commit
735150d165
1 changed files with 5 additions and 3 deletions
|
@ -114,6 +114,8 @@ Base.exports.PaperScript = (function() {
|
|||
* @return {String} The compiled PaperScript as JavaScript code.
|
||||
*/
|
||||
function compile(code, url, options) {
|
||||
if (!code)
|
||||
return '';
|
||||
options = options || {};
|
||||
url = url || '';
|
||||
// Use Acorn or Esprima to translate the code into an AST structure
|
||||
|
@ -268,14 +270,14 @@ Base.exports.PaperScript = (function() {
|
|||
sourceMap = {
|
||||
version: 3,
|
||||
file: url,
|
||||
sourceRoot: '',
|
||||
sources: [url],
|
||||
names:[],
|
||||
// Since PaperScript doesn't actually change the offsets between
|
||||
// the lines of the original code, all that is required is a
|
||||
// mappings string that increments by one between each line.
|
||||
// AACA is the instruction to increment the line by one.
|
||||
mappings: mappings.join(';AACA')
|
||||
mappings: mappings.join(';AACA'),
|
||||
sourceRoot: '',
|
||||
sources: [url]
|
||||
};
|
||||
// Include the original code in the sourceMap if there is no linked
|
||||
// source file so the debugger can still display it correctly.
|
||||
|
|
Loading…
Reference in a new issue