How do we hot-patch JS code in production?

In https://gitlab.com/gitlab-com/runbooks/blob/master/howto/patching-production.md, we describe patching production (i.e. GitLab.com) with critical changes from https://dev.gitlab.org/gitlab/post-deployment-patches.

These patches are typically to Ruby code, so we can just patch the code directly on the server, restart, and see the changes.

However, our JS pipeline is more complicated. We compile the assets and generate hashes, and use those hashes in the filenames. This means that we can't just patch the source files and call it a day, as the assets are compiled in the package itself.

I think it should be possible to:

  1. Create a patch against the current version in production.
  2. Build a package from this.
  3. Extract the assets (and any other metadata) we need.
  4. Include those in our MR to https://dev.gitlab.org/gitlab/post-deployment-patches

But this is clearly much, much more complicated than the Ruby case. Thankfully, we haven't needed it yet, but we should probably figure it out before we do need it in an emergency.