Closed Richard-Walton closed 6 years ago
@goto-bus-stop Any thoughts?
oh crap, thanks. adding a check for s.offset
and then using one of the append or prepend methods instead sounds good to me!
Oops, I committed on the wrong branch, meant to open a PR for that instead. If CI comes back green I'll release. Thanks for the detailed report!
:package: 2.2.2
Thanks @goto-bus-stop - I ended up getting stuck thinking about how to write a test for the change... looks like it wasn't needed! Sorry I didn't get around to opening a PR for you.
Thanks again
no worries! I changed an existing test to also generate source maps, which triggered the error. :)
I've recently upgraded my
brfs
package to 1.50 which includes the latest source map changes implemented in this module.Unfortunately my build is now failing with the following error:
Fatal error: Cannot overwrite a zero-length range – use appendLeft or prependRight instead
After some digging around I tracked down the issue to this line: https://github.com/browserify/static-module/blob/master/index.js#L64
In my case
s.offset
===0
(creating the aforementionedzero-length range
error).I have discovered a workaround for the issue. Originally my code looked like this:
Moving the
require('fs')
to it's own line fixes the problem:I wonder if the removal of the
require('fs')
calls during the browserify build process causes this error?My initial thoughts to fix this issue would involve adding a guard against
s.offset
being0
... I'm happy to open a PR if you think this is a viable solution.