ServiceStack/Bundler — Issue #3: Beware UTF-8 BOM
Author: duncansmart
Created: 2012-02-06 13:55:07+00:00
State: open

Something to either make a note in the docs for when creating .bundle files, or to handle in bundle.js, is save the file without a UTF-8 BOM otherwise you get this:

C:\Temp\BundlerTest\bundler>node bundler.js

processing ../Content/app.css.bundle:
compiling ..\Content\ï»¿bootstrap\less\bootstrap.css...
[TypeError: Cannot call method 'replace' of undefined]

I worked around this in https://github.com/duncansmart/less.js-windows/blob/master/lessc.wsf by stripping off the BOM and treating as ASCII:

// Strip off any UTF-8 BOM
var utf8bom = String.fromCharCode(0xEF, 0xBB, 0xBF);
if (text.substr(0, utf8bom.length) == utf8bom) {
text = text.substr(utf8bom.length);
}

But I'm sure there's a better way in node's file I/O for handling BOMs.