sindresorhus / multiline

Multiline strings in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiline strings are gone when using uglifyify

opened this issue · comments

Comments are being stripped out in the final bundle when using uglifyify module.

To reproduce the issue, first install these modules:

# npm install -g watchify
# npm install uglifyify

Then just create a simple file test.js:

var multiline = require("multiline");

var str = multiline(function(){/*@preserve
<!doctype html>
<html>
    <body>
        <h1>❤ unicorns</h1>
    </body>
</html>
*/console.log});

console.log("Starting multiline test:");
console.log(str);
console.log("Finished multiline test:");

First check the bundle.js is alright without uglifying the code:

> watchify test.js -o bundle.js -v
1911 bytes written to bundle.js (0.06 seconds)
> grep unicorns bundle.js
        <h1>❤ unicorns</h1>

BUT when you use -t uglifyify transformation as explained in the documentation:

> watchify test.js -o bundle.js -v -t [uglifyify --comments]
1799 bytes written to bundle.js (0.13 seconds)

You'll see the multiline string isn't in the bundle anymore:
> grep unicorns bundle.js

Am I missing something here or is it a bug?