Background script missing === creating one for me

I discovered that if I don't include background.ts, it will create one for me In Chrome's case it will not be an issue, but in Firefox's case, it also makes it a Service Worker, rather than loading as MV2-style background script It's worth noting that I specified the dev target as firefox-mv3
19 Replies
Avi
AviOPβ€’2y ago
@louisgv This is pretty much the only thing preventing me from testing the extension on Firefox and pushing the update πŸ˜‚
lab
labβ€’2y ago
Is it not working at all in ff-mv3 in dev mode?? in ff-mv3, that service worker page is turned into a bg page instead :-?... so it shoulda work doh :d
Avi
AviOPβ€’2y ago
I haven't tried directly loading onto Firefox but rather through https://npm.im/web-ext
npm
web-ext
A command line tool to help build, run, and test web extensions. Latest version: 7.6.2, last published: a month ago. Start using web-ext in your project by running npm i web-ext. There are 26 other projects in the npm registry using web-ext.
Avi
AviOPβ€’2y ago
You're correct, that is, if I have a background.ts But if I don't, it turns out that Plasmo will create a script for me and load it as a background script
lab
labβ€’2y ago
like bgsw? or bgp? which version of plasmo are you using?
Avi
AviOPβ€’2y ago
I'm honestly not sure how it's possible to use a Service Worker within a Chrome extension I do know that to migrate from MV2 to MV3 you basically remove the background.persistent 0.74.1
Avi
AviOPβ€’2y ago
No description
Avi
AviOPβ€’2y ago
Note that it is possible perhaps, I just don't know the method All I know is that you need to enable some sort of a flag in Firefox @louisgv Sorry for the ping, are you looking into it or should I push the update tomorrow?
lab
labβ€’2y ago
give me a sec very weird werid..
Avi
AviOPβ€’2y ago
NGL, I love being a bug hunter πŸ˜‚
lab
labβ€’2y ago
@avi12 in the meantime I'd test with prod version <- that one doesn't have the bgsw runtime injection
Avi
AviOPβ€’2y ago
oki
Avi
AviOPβ€’2y ago
hmmm
No description
Avi
AviOPβ€’2y ago
That moment when Firefox is the only browser in which the extension doesn't run as expected TrollDespair
lab
labβ€’2y ago
https://github.com/PlasmoHQ/plasmo/pull/611 PR is up to fix the bgsw in dev issue
Arcane
Arcaneβ€’2y ago
@avi12 has reached level 28. GG!
Avi
AviOPβ€’2y ago
@louisgv I noticed that if I don't have a background.ts, any Plasmo version above 0.75.2 doesn't allow me to run
plasmo build --target=firefox-mv3
plasmo build --target=firefox-mv3
For example, in 0.76.3
🟑 0 | @plasmohq/parcel-transformer-manifest
🟑 1 | Adding icons
🟑 2 | Adding default_icon
🟑 3 | Adding page
πŸ”΄ ERROR | Cannot read properties of undefined (reading 'service\_worker')
🟑 14 | TypeError: Cannot read properties of undefined (reading 'service_worker')
at qe (C:\repositories\extensions\skillshare-player-control\node_modules\.pnpm\@[email protected]\node_modules\@plasmohq\parcel-transformer-manifest\dist\index.js:1:2895)
🟑 0 | @plasmohq/parcel-transformer-manifest
🟑 1 | Adding icons
🟑 2 | Adding default_icon
🟑 3 | Adding page
πŸ”΄ ERROR | Cannot read properties of undefined (reading 'service\_worker')
🟑 14 | TypeError: Cannot read properties of undefined (reading 'service_worker')
at qe (C:\repositories\extensions\skillshare-player-control\node_modules\.pnpm\@[email protected]\node_modules\@plasmohq\parcel-transformer-manifest\dist\index.js:1:2895)
So not only will it create a background page out of thin air, I assume that Plasmo creates the proper Manifest and then for some reason it attempts to access background.service_worker as if it's a Chromium build
lab
labβ€’2y ago
cc @jeffjacobsenstaqfi Might be related @avi12 should be fixed in latest, I also upgraded svelte to 4.x
lab
labβ€’2y ago
(needed a hack which I implemented on our framework and also a PR upstream: https://github.com/sveltejs/svelte/pull/8874 )
GitHub
chore: adding default for disclose version by louisgv Β· Pull Reques...
Description This PR allows the built-in nodejs resolver (18.x) to lookup internal/disclose-version, otherwise it yields: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './internal/discl...
Want results from more Discord servers?
Add your server