Skip to content

Commit 31adcef

Browse files
refactor: better
1 parent e079528 commit 31adcef

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎src/index.js‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -596,24 +596,24 @@ class TerserPlugin {
596596
);
597597
}
598598

599-
let shebang;
599+
if (output.code) {
600+
let shebang;
600601

601-
if (
602-
/** @type {ExtractCommentsObject} */
603-
(this.options.extractComments).banner !== false &&
604-
output.extractedComments &&
605-
output.extractedComments.length > 0 &&
606-
output.code.startsWith("#!")
607-
) {
608-
const firstNewlinePosition = output.code.indexOf("\n");
602+
if (
603+
/** @type {ExtractCommentsObject} */
604+
(this.options.extractComments).banner !== false &&
605+
output.extractedComments &&
606+
output.extractedComments.length > 0 &&
607+
output.code.startsWith("#!")
608+
) {
609+
const firstNewlinePosition = output.code.indexOf("\n");
609610

610-
shebang = output.code.slice(0, Math.max(0, firstNewlinePosition));
611-
output.code = output.code.slice(
612-
Math.max(0, firstNewlinePosition + 1),
613-
);
614-
}
611+
shebang = output.code.slice(0, Math.max(0, firstNewlinePosition));
612+
output.code = output.code.slice(
613+
Math.max(0, firstNewlinePosition + 1),
614+
);
615+
}
615616

616-
if (output.code) {
617617
if (output.map) {
618618
output.source = new SourceMapSource(
619619
output.code,

‎test/__snapshots__/minify-option.test.js.snap‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ error",
1111

1212
exports[`minify option should output errors and warning: warnings 1`] = `
1313
Array [
14-
"Warning: Error: warning",
14+
"Warning: warning",
1515
]
1616
`;
1717

‎test/minify-option.test.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ describe("minify option", () => {
162162

163163
new TerserPlugin({
164164
minify: () => ({
165-
errors: [new Error("error")],
166-
warnings: [new Error("warning")],
165+
errors: ["error"],
166+
warnings: ["warning"],
167167
}),
168168
}).apply(compiler);
169169

0 commit comments

Comments
 (0)