Skip to content

Commit db16602

Browse files
authored
docs: Add missing breaking change to 0.20 migration (#1636)
1 parent 5c20280 commit db16602

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/guide/resources/upgrading.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,20 @@ See <https://github.com/wxt-dev/wxt/issues/784>
5353

5454
To upgrade, you have two options:
5555

56-
1. **Stop using the polyfill** - No changes necessary, though you may want to do some manual testing to make sure everything continues to work. None of the early testers of this feature reported any runtime issues once they stopped using the polyfill.
57-
- If you're already using `extensionApi: "chrome"`, then you don't need to test anything! You're already using the same `browser` object v0.20 provides by default.
56+
1. **Stop using the polyfill**
57+
- If you're already using `extensionApi: "chrome"`, then you're not using the polyfill and there is nothing to change!
58+
- Otherwise there is only one change: `browser.runtime.onMessage` no longer supports using promises to return a response:
59+
```ts
60+
browser.runtime.onMessage.addListener(async () => { // [!code --]
61+
const res = await someAsyncWork(); // [!code --]
62+
return res; // [!code --]
63+
browser.runtime.onMessage.addListener(async (_message, _sender, sendResponse) => { // [!code ++]
64+
someAsyncWork().then((res) => { // [!code ++]
65+
sendResponse(res); // [!code ++]
66+
}); // [!code ++]
67+
return true; // [!code ++]
68+
});
69+
```
5870
2. **Continue using the polyfill** - If you want to keep using the polyfill, you can! One less thing to worry about during this upgrade.
5971
6072
- Install `webextension-polyfill` and WXT's [new polyfill module](https://www.npmjs.com/package/@wxt-dev/webextension-polyfill):

0 commit comments

Comments
 (0)