parcel: inline script is empty when minified

Software Version(s)
Parcel 1.7.0
Node v9.11.1
npm/Yarn npm 5.8.0
Operating System Linux archlinux 4.15.15-1-ARCH #1 SMP PREEMPT Sat Mar 31 23:59:25 UTC 2018 x86_64 GNU/Linux

The inline script inside index.html is empty when building with parcel build index.html, however, the inline script are correctly included when building with parcel build --no-minify index.html.

I have included a simplest example:

index.html

<html lang="en">

<head>
    <script src="./app.js"></script>
</head>

<body>
    <script>
        console.log('hello');
        const p = new Point(10, 10);
    </script>
</body>

</html>

app.js

class Point {
    constructor(x = 1, y = 1) {
        this.x = x;
        this.y = y;
    }

    move(x, y) {
        this.x = x;
        this.y = y;
    }
}

window.Point = Point;

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@DeMoorJasper thanks for the explanation. I haven’t filed a bug report to htmlnano. I am too lazy to prepare a use case for their project from scratch. However, I will share this thread with them. I guess this thread should provide enough information for them to address this problem, if they want, of course.

@elgs We provided a fix while htmlnano tries to resolve it (unless u didn’t file a bug report there), there is not much more we can do. Doesn’t seem like it happens that often so including it as standard config, doesn’t seem like the obvious choice.

Not sure where cssnano’s safe option is defined in their docs, but it describes what it does in the readme. They made it the default behaviour recently as I can see, so it might even be possible that they removed it from the docs, as it’s the default now.