Skip to content

Commit 7d064b1

Browse files
committed
fixed compacting swallowing blank lines within template literals
this is a workaround until rollup-plugin-cleanup has been fixed: aMarCruz/rollup-plugin-cleanup#7
1 parent 9cd8c4a commit 7d064b1

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

lib/bundle/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function generateConfig({ extensions = [], externals, format, moduleName,
7878
]);
7979
if(compact) {
8080
let cleanup = require("rollup-plugin-cleanup");
81-
plugins = plugins.concat(cleanup());
81+
plugins = plugins.concat(cleanup({ maxEmptyLines: -1 }));
8282
}
8383

8484
let cfg = { format, plugins };
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
let txt = `foo
2+
3+
bar`;
4+
5+
console.log(`[…] ${txt}`); // eslint-disable-line no-console

test/unit/test_bundling.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ console.log(\`[…] $\{util}\`); // eslint-disable-line no-console
303303

304304
it("should optionally compact bundle", () => {
305305
let config = [{
306-
source: "./src/index.js",
306+
source: "./src/multiline.js",
307307
target: "./dist/bundle.js"
308308
}];
309309
let assetManager = new MockAssetManager(FIXTURES_DIR);
@@ -314,9 +314,11 @@ console.log(\`[…] $\{util}\`); // eslint-disable-line no-console
314314
assetManager.assertWrites([{
315315
filepath: path.resolve(FIXTURES_DIR, "./dist/bundle.js"),
316316
content: makeBundle(`
317-
var util = "UTIL";
317+
let txt = \`foo
318+
319+
bar\`;
318320
319-
console.log(\`[…] $\{util}\`);
321+
console.log(\`[…] $\{txt}\`);
320322
`.trim())
321323
}]);
322324

@@ -328,9 +330,9 @@ console.log(\`[…] $\{util}\`);
328330
assetManager.assertWrites([{
329331
filepath: path.resolve(FIXTURES_DIR, "./dist/bundle.js"),
330332
content: makeBundle(`
331-
var util = "UTIL";
333+
var txt = "foo\\n\\nbar";
332334
333-
console.log("[\\u2026] " + util);
335+
console.log("[\\u2026] " + txt);
334336
`.trim())
335337
}]);
336338

@@ -342,9 +344,9 @@ console.log("[\\u2026] " + util);
342344
assetManager.assertWrites([{
343345
filepath: path.resolve(FIXTURES_DIR, "./dist/bundle.js"),
344346
content: makeBundle(`
345-
var util = "UTIL";
347+
var txt = "foo\\n\\nbar";
346348
347-
console.log("[\\u2026] " + util); // eslint-disable-line no-console
349+
console.log("[\\u2026] " + txt); // eslint-disable-line no-console
348350
`.trim())
349351
}]);
350352
});

0 commit comments

Comments
 (0)