diff --git a/src/printer.js b/src/printer.js index 991c1862b..bc31fab36 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1437,21 +1437,6 @@ function genericPrintNoParens(path, options, print, args) { case "TemplateLiteral": var expressions = path.map(print, "expressions"); - function removeLines(doc) { - // Force this doc into flat mode by statically converting all - // lines into spaces (or soft lines into nothing). Hard lines - // should still output because there's too great of a chance - // of breaking existing assumptions otherwise. - return docUtils.mapDoc(doc, d => { - if (d.type === "line" && !d.hard) { - return d.soft ? "" : " "; - } else if (d.type === "if-break") { - return d.flatContents || ""; - } - return d; - }); - } - parts.push("`"); path.each(function(childPath) { @@ -2291,7 +2276,7 @@ function printFunctionParams(path, print, options, expandArg) { // }) ) => { // }) if (expandArg) { - return group(concat(["(", join(", ", printed), ")"])); + return group(concat(["(", join(", ", printed.map(removeLines)), ")"])); } // Single object destructuring should hug @@ -3579,6 +3564,21 @@ function printArrayItems(path, options, printPath, print) { return concat(printedElements); } +function removeLines(doc) { + // Force this doc into flat mode by statically converting all + // lines into spaces (or soft lines into nothing). Hard lines + // should still output because there's too great of a chance + // of breaking existing assumptions otherwise. + return docUtils.mapDoc(doc, d => { + if (d.type === "line" && !d.hard) { + return d.soft ? "" : " "; + } else if (d.type === "if-break") { + return d.flatContents || ""; + } + return d; + }); +} + function printAstToDoc(ast, options) { function printGenerically(path, args) { return comments.printComments( diff --git a/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap b/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap index 96e5329a0..d56fb1305 100644 --- a/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap +++ b/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap @@ -39,6 +39,37 @@ export default function searchUsers(action$) { `; +exports[`break.js 1`] = ` +export default class AddAssetHtmlPlugin { + apply(compiler: WebpackCompilerType) { + compiler.plugin('compilation', (compilation: WebpackCompilationType) => { + compilation.plugin('html-webpack-plugin-before-html', (callback: Callback) => { + addAllAssetsToCompilation(this.assets, compilation, htmlPluginData, callback); + }); + }); + } +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +export default class AddAssetHtmlPlugin { + apply(compiler: WebpackCompilerType) { + compiler.plugin("compilation", (compilation: WebpackCompilationType) => { + compilation.plugin( + "html-webpack-plugin-before-html", + (callback: Callback) => { + addAllAssetsToCompilation( + this.assets, + compilation, + htmlPluginData, + callback + ); + } + ); + }); + } +} + +`; + exports[`break-parent.js 1`] = ` ({ processors: [ diff --git a/tests/last_argument_expansion/break.js b/tests/last_argument_expansion/break.js new file mode 100644 index 000000000..cc736b0c3 --- /dev/null +++ b/tests/last_argument_expansion/break.js @@ -0,0 +1,9 @@ +export default class AddAssetHtmlPlugin { + apply(compiler: WebpackCompilerType) { + compiler.plugin('compilation', (compilation: WebpackCompilationType) => { + compilation.plugin('html-webpack-plugin-before-html', (callback: Callback) => { + addAllAssetsToCompilation(this.assets, compilation, htmlPluginData, callback); + }); + }); + } +}