Bug report or Feature request?
Bug report.
Version (complete output of terser -V or specific git commit)
terser 4.6.9
According to git bisect, this regressed in 0e40b8d2e96005121801ccb02340e4f990fd66d7.
Complete CLI command or minify() options used
terser input.js --compress --beautify
terser input
(function () {
const HtmlContent = require('./html-content.js')
class BreadcrumbPanel extends HtmlContent {}
module.exports = BreadcrumbPanel
}())
From my tests, it seems to only happen with a combination of factors:
HtmlContent variable is used in a class's extends nodeBreadcrumbPanel) is namedBreadcrumbPanel) _becomes_ anonymous during minification, and/or the class that it is used in is _moved_ during minification (to module.exports = class {})For example, using the HtmlContent value in these patterns do _not_ have this bug:
console.log(HtmlContent)
```js
const BreadcrumbPanel = class extends HtmlContent {}
```js
module.exports = class BreadcrumbPanel extends HtmlContent {}
terser output or error
The initializer is separated from the const declaration by a semicolon, which is invalid:
!function() {
const HtmlContent;
require("./html-content.js");
module.exports = class extends HtmlContent {};
}();
Expected result
!function() {
const HtmlContent = require("./html-content.js");
module.exports = class extends HtmlContent {};
}();
Nasty! I'll have a look right away.
I think I encountered the same issue. This happens since 4.6.8.
Chrome Console says: Uncaught SyntaxError: Missing initializer in const declaration
{const e;Wt(t);return class extends e{
I havent looked up the source as it occurs in a library I use (Polymer)
That does the trick :tada: Thanks for the quick fix @fabiosantoscode!
I'm waiting for the functional tests to ship 4.6.10
Thanks a lot for the quick fix!
Most helpful comment
Nasty! I'll have a look right away.