And that will require adding the line breaks back in here. When we are splitting the generated code, we can find out what kind of line breaks its using like so:

    var match = REGEX_LINE.exec(aGeneratedCode);
    var lineBreak = match ? match[0] : "";

And then append the line break here like this:

    addMappingWithCode(lastMapping, remainingLines.shift() + lineBreak);

I recognize that your existing approach lets us sidestep all this, but I think that having a really simple regexp is worth this little bit of extra work here.