Search code examples
grunt-contrib-concat

grunt concat trying to read the inlined source map as a file name


I use browserify to bundle some files and when the 'debug' option is true it also adds a source map at the end of the file

//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2Vz...

The problem is when I concatenate this file with another one through grunt-contrib-concat, it tries to read the sourceMappingURL as a file name. So I get this error

Warning: Unable to read "E:\xampp\htdocs\frontend\app\newportal\portal\data:application\json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3Vy...

I tried everything I could think of, even reinstalling node/npm, with no luck.

And it used to work with the current setup. It suddenly started not working. Maybe a node module updated or something. But I tried installing the original versions(downgraded) that used to work and still no luck.

Any insight appreciated, thanks.


Solution

  • It appears this is related to the first part of the datauri source map that browserify generates (with debug: true) and the check that is made in the grunt concat task.

    Sometimes it starts with

    data:application/json;base64,
    

    and sometimes it starts with

    data:application/json;charset:utf-8;base64,
    

    there's an extra "charset:utf-8;" in the middle there.

    I don't know how that was generated, it seemed to only happen on my machine, my colleagues had no problem. And I reinstalled node and re-cloned my repo and it still reproduced. I still haven't figured out that part.

    Anyway I submitted a pull request to grunt-contrib-concat, hopefully it will get accepted.