Closed 0xBigBoss closed 9 months ago
// ./background.js
import { startApi } from "@sendnodes/pokt-wallet-background"
startApi()
Is that module contains a Top-Level-Await or AsyncWebAssembly module?
startApi
returns a promise. await
-ing the result of startApi seemed to help chrome, but not firefox.
This didn't work on Firefox (v2) but worked on chrome(v3)
import { startApi } from "@sendnodes/pokt-wallet-background"
/**
* Use a dynamic import so webpack-target-webextension compiles correctly
*/
(async () => {
await startApi()
})()
This works on both
/**
* Use a dynamic import so webpack-target-webextension compiles correctly
*/
(async () => {
const { startApi } = await import("@sendnodes/pokt-wallet-background")
await startApi()
})()
Sorry, I can't help much. It looks like @sendnodes/pokt-wallet-background
is not published on npm. If you can provide a minimal available reproduction, I may investigate this.
This is super old now, and the wallet is open source, using the workaround has been working flawlessly though!
For the interested: https://github.com/sendnodes-io/SendWallet
Gonna close. thx for at least hearing me out!
FWIW I was worked a bit on our webpack config and this issue cropped up again. I traced it down to the fact we are using optimization.splitChunks.chunks = 'all'
. https://github.com/sendnodes-io/sendwallet/blob/a90728c9ed746f31c58950b029e35c24b34efc34/apps/webext-legacy/webpack.config.ts#L331
Not sure if that helps or now. The dynamic import still works though.
I'll close this issue for now because there is no reproduction. If you have one, please ping me and I'll try to investigate this issue.
We have a background script that is started like so.
However, this extension fails to add this runtime part in the webpack output. It never fetches all of the modules correctly and so our background script exits without executing the
startApi
logic.The only way to get this plugin to get this part added is to convert our background script is to use dynamic imports. Then, that runtime portion gets added.
I don't know enough about webpack compilation steps to be much more help than that, but maybe this has to do with our webpack setup. This is what our plugin looks like.