Merged
Conversation
|
|
||
| page_script_relative_path="pages/$page_basename.js" | ||
| jq ".web_accessible_resources" $MANIFESTPATH | grep "$page_script_relative_path" >/dev/null | ||
| # TODO: manifest is no longer manually created, so will need to check in a different way |
Owner
There was a problem hiding this comment.
TODO is not necessary as the page scripts are automatically added to web_accessible_resources
Owner
killergerbah
left a comment
There was a problem hiding this comment.
I'm 99% done developing a tutorial using your branch - the hotswap was a life saver.
Just want to test a bit more before merging.
Owner
|
@mwojick Thank you so much for this invaluable change. You've saved future developers many many hours of iteration time on this project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://wxt.dev/
Lot of changes, partly due to changes in how things are built, because you can’t build things in the same arbitrary way that was being done before (which was expected), and also partly due to the fact that firefox needs to be built for mv2, since dev mode doesn’t work for firefox mv3. So pretty much everything will have to be tested. Not sure how to go about this efficiently. Maybe we need other people willing to test it. I’ve mostly tested it with youtube and at least that seems to be fine for some common things.
General info about WXT:
defineContentScript, as well as additions toimport.metalikeimport.meta.env.BROWSER, etc. Also the auto import stuff can be disabled if you don’t like it, but it’s similar to what Nuxt does apparently.Caveats and other findings:
Firefox’s mv3 doesn’t support dev mode due to a bug in firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1864284. Seems like firefox’s mv3 in general is pretty broken, and I think a lot of the permission issues people have been getting on firefox are related to firefox’s mv3 (e.g. https://www.reddit.com/r/firefox/comments/1326r7e/webextension_mv3_manifestjson_host_permissions/). So because of that I made mv2 work, which was actually relatively simple. Just had to replace chrome calls with browser (imported from wxt), which accounts for the differences like promises, return values, etc of the different manifest versions. Also now have to set an action var to account for different actions (
const action = browser.action || browser.browserAction;).Not sure if it’s really necessary to keep separate builds for firefox and firefox-android. I think I was able to handle this use case either way, but seems like the only difference is lack of commands and contextMenu permission. Would it matter to leave these in? Also I wonder if you would be able to use the shortcut keys on android if you plug in a keyboard.
Specific thing about the offscreen audio recorder: I changed it to use
mp3WorkerFactorysince I noticed it was creating a duplicate asset in the output, but haven’t been able to verify that it works sinceencodeAsMp3always seems to be false. Haven’t dug into why that is yet though.By default there’s no way to create an arbitrary output structure for unlisted scripts (https://wxt.dev/guide/essentials/entrypoints.html#unlisted-scripts). So all the scripts that were in the pages dir are at the moment just at the top level in the output. Based on what I can see though, it seems like these could just be standalone content scripts with the proper match URLs.
The biggest caveat that I’ll need some input on: by default you also can’t build arbitrary esm with wxt. So the first thing I tried for the module scripts was just building them as unlisted scripts, and it works, but doing this slows the initial build to like 30 sec since they are like content scripts with the way they are built. So I tried building the previous module script entry points for the UIs along side an actual html file, instead of injecting them into a template string like in anki-ui for instance. Problem is that, during dev, wxt needs to inject some localhost scripts into the html pages for vite’s hmr to work, and so manually injecting the html the way it is currently done causes bunch of cors issues with localhost that I don’t think are solvable without letting the iframe create it. So I came up with a few possible solutions:
In spite of the caveats there are some great dev ex improvements. Like developing in the context of UIs like the popup, settings, or sidebar where you have full hmr so you can see the change to the UI instantly. Even in the context of content scripts, you at least don’t have to wait as long nor manually rebuild/reload the extension. Usually just need to do a page reload if anything. Only exception is when changing a config file which requires a full rebuild. The fact that it also handles the differences between mv2 and mv3 and has an auto publish feature is a huge plus.