mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -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.
|
* @return {String} The compiled PaperScript as JavaScript code.
|
||||||
*/
|
*/
|
||||||
function compile(code, url, options) {
|
function compile(code, url, options) {
|
||||||
|
if (!code)
|
||||||
|
return '';
|
||||||
options = options || {};
|
options = options || {};
|
||||||
url = url || '';
|
url = url || '';
|
||||||
// Use Acorn or Esprima to translate the code into an AST structure
|
// Use Acorn or Esprima to translate the code into an AST structure
|
||||||
|
@ -268,14 +270,14 @@ Base.exports.PaperScript = (function() {
|
||||||
sourceMap = {
|
sourceMap = {
|
||||||
version: 3,
|
version: 3,
|
||||||
file: url,
|
file: url,
|
||||||
sourceRoot: '',
|
|
||||||
sources: [url],
|
|
||||||
names:[],
|
names:[],
|
||||||
// Since PaperScript doesn't actually change the offsets between
|
// Since PaperScript doesn't actually change the offsets between
|
||||||
// the lines of the original code, all that is required is a
|
// the lines of the original code, all that is required is a
|
||||||
// mappings string that increments by one between each line.
|
// mappings string that increments by one between each line.
|
||||||
// AACA is the instruction to increment the line by one.
|
// 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
|
// Include the original code in the sourceMap if there is no linked
|
||||||
// source file so the debugger can still display it correctly.
|
// source file so the debugger can still display it correctly.
|
||||||
|
|
Loading…
Reference in a new issue