Skip to content

minifier: the comments on the top is not preserved when the first statement is inlined #19750

@sapphi-red

Description

@sapphi-red
//! some license for this library

const foo = 'foobarfoobar'
console.log(foo)

is minified to

console.log("foobarfoobar");

while

//! some license for this library

const foo = 'foobarfoobar'
console.log(foo)
console.log(foo)

is minified to

//! some license for this library
const foo = "foobarfoobar";
console.log(foo), console.log(foo);

Since this library is included, I expect the license comment to be preserved.
esbuild1 and SWC keep these.

Footnotes

  1. the input code is a bit different because of how esbuild inlines values

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions