Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Bundler / minifier not handling end of file comments correctly [884]

$
0
0
I have noticed that the bundler doesn't handle single line comments at the end of a javascript file correctly (or as would be expected), when the script is bundled and minified.

A single line comment at the end of one of the script files, without a line break at the end, affects the content/interpretation of the script of the next file.

Suppose script 1 has:

```
var hello = "Hello";

function SayHelloWorld() {
alert(hello + "World");
}

//=======test comment==========(no line break here)
```

and script two has:

```
function Test()
{
this.a = 1;
}

//===== another comment with no line break at the end=======
```

The resulting script after bundling is:

```
function SayHelloWorld(){alert(hello+"World")}var hello="Hello";this.a=1
```
Notice that constructor function Test() has disappeared and only the contents of that function are placed on the resulting script;

Removing the comment at the end of the file, or adding a line break after it outputs the correct and expected script

```
function SayHelloWorld(){alert(hello+"World")}function Test(){this.a=1}var hello="Hello"
```


about the attatchment: I includes a Bundle.cs (with the bundle definition), the javascript files in the script/testscripts directory, and a modified _layout to include the bundle. This can be copied onto a simple MVC4 internet Application project.

Comments: Same problem here. (With Microsoft ASP.NET Web Optimization Framework 1.0.0) I'm using jquery-migrate package. The jquery-migrate-1.1.1.min.js file have a End-line comment, and this comment broke the minification process.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>