apollo-client-devtools icon indicating copy to clipboard operation
apollo-client-devtools copied to clipboard

Only inject `hook.js` script for Firefox. Use ExecutionWorld.MAIN for Chrome

Open jerelmiller opened this issue 1 year ago • 4 comments

Fixes #1162

This is a revival of https://github.com/apollographql/apollo-client-devtools/pull/1164 with some tweaks. Now that we are running Chrome on Manifest v3, we are able to use hook.js as a content script using ExecutionWorld.MAIN. Unfortunately this is not yet supported in Firefox, so we have to rely on script injection for this to work. The script injection used in #1164 is now added back, but only when building for Firefox.

jerelmiller avatar Feb 21 '24 04:02 jerelmiller

This looks good to me (tested locally in Chrome and Firefox), but I'm slightly concerned: didn't you see the extension break with the current Firefox code, in Firefox?

Could you reproduce that?

phryneas avatar Feb 21 '24 10:02 phryneas

Talked in our 1:1. Posting the answer here for transparency:

I feel a bit more confident now in this change for a couple reasons:

  • We now unconditionally show the devtools where before we relied on a message sent to devtools before the panel was created (https://github.com/apollographql/apollo-client-devtools/pull/1220)
  • Message passing has been reworked for stability (https://github.com/apollographql/apollo-client-devtools/pull/1226)
  • The injection mechanism is now relegated to Firefox only now that Chrome is on manifest v3 (https://github.com/apollographql/apollo-client-devtools/pull/1225)

jerelmiller avatar Feb 21 '24 17:02 jerelmiller

We are going to wait to merge this for a few days after 4.7.0 goes out to ensure we catch any bugs or new issues that arise from that release.

jerelmiller avatar Feb 21 '24 17:02 jerelmiller

Putting in draft for now to avoid accidental merge until we are ready.

jerelmiller avatar Feb 21 '24 17:02 jerelmiller

So far we've seen no reports that the latest update caused any more issues. I'll go ahead and merge this and get a release out tomorrow.

jerelmiller avatar Feb 26 '24 22:02 jerelmiller