developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.06k stars 361 forks source link

microbundle --no-compress removes the first line if it is a comment #869

Closed trafnar closed 2 years ago

trafnar commented 3 years ago

I set up a simple project and needed to maintain comments, so I used the --no-compress flag, which worked, except it seems to remove the first line if it is a comment.

// foo
// bar
console.log("Hello")

becomes this in dist/index.js

//bar
console.log("Hello")

I'm using typescript with this configuration in package.json:

{
  "main": "dist/index.js",
  "scripts": {
    "build": "microbundle --no-compress",
    "dev": "microbundle --no-compress watch"
  },
  "source": "src/index.ts",
  "devDependencies": {
    "microbundle": "^0.13.0"
  }
}
developit commented 3 years ago

hah! what a strange issue. I'm guessing this is a Terser bug.

rschristian commented 3 years ago

Shouldn't be Terser, it isn't used with compression disabled.

https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L574-L575

rschristian commented 2 years ago

This might've been an upstream bug, as I cannot reproduce on latest version (0.14.2). Therefore going to close this out.