Safely concatenate JavaScript
Most JavaScript packages wrap their code in IIFEs, which is good.
Pipeline used to concatenate JS only with a newline. That can break those IIFES
though:
(function() {
// package A
}()) // No semicolon! Most people put one here, but unfortunately not all!
(function() {
// package B
}());
The above is equivalent to:
(function() {
// package A
}())(function() {
// package B
}());
Suddenly we have a function call!
With this commit, JS is concatenated with a newline followed by a semicolon,
which fixes the above issue:
(function() {
// package A
}()) // No semicolon! Most people put one here, but unfortunately not all!
;(function() {
// package B
}());
There is no need to worry about superfluos semicolons, such as:
(function() {
// package A
}());
;;(function() {
// package B
}());
That is still valid JavaScript and the extra semicolons will be removed by the
minifier.
Showing
Please
register
or
sign in
to comment