Every so often I find myself in a situation where I’m tracking down a bug and I want to monkey patch some internal Ember function, usually as a temporary or debug fix.
Today I’m in a situation where I need to change this function: https://github.com/emberjs/data/blob/ced0cdfe9c410575adb0034ea06bf4f51fd9e4ab/addon/-private/utils/parse-response-headers.js - There’s a bug that causes it to not work correctly in fastboot.
I’ve been able to fix this with running fastboot + node debugger, but now I want to monkey patch it so I can deploy my application.
In the past, I would fork the Ember Data version tag my app is using and then point my package.json at that fork. However that’s cumbersome and hard to understand.
Earlier I noticed that the
parseResponseHeaders is available in as a module in
require.entries['ember-data/-private'].module.exports.parseResponseHeaders. This got me thinking… is it possible to monkey patch this function without needing an ED fork?