Releases: wxt-dev/wxt
v0.17.2
v0.17.1
v0.17.0
🚀 Enhancements
- storage:
⚠️ Improved support for default values on storage items (#477)
🩹 Fixes
- storage:
⚠️ Only run migrations when the extension is updated (#478) - Improve dev mode for content scripts registered at runtime (#474)
📖 Documentation
- storage: Update docs (91fc41c)
⚠️ Breaking Changes
v0.17.0
introduces several breaking changes to wxt/storage
.
First, if you were using defineItem
with versioning and no default value, you will need to add defaultValue: null
to the options and update the first type parameter:
// < 0.17
const item = storage.defineItem<number>("local:count", {
version: ...,
migrations: ...,
})
// >= 0.17
const item = storage.defineItem<number | null>("local:count", {
defaultValue: null,
version: ...,
migrations: ...,
})
The defaultValue
property is now required if passing in the second options argument.
If you exclude the second options argument, it will default to being nullable, as before.
const item: WxtStorageItem<number | null> =
storage.defineItem<number>('local:count');
const value: number | null = await item.getValue();
If you don't use typescript, there aren't any breaking changes, this is just a type change.
For storage items that are not nullable, the watch
callback types has improved and will use the default value instead of null
when the value is missing:
// >=0.17
const item = storage.defineItem<number>('local:count', { defaultValue: 0 });
item.watch((newValue: number | null, oldValue: number | null) => {
// ...
});
// >=0.17
const item = storage.defineItem<number>('local:count', { defaultValue: 0 });
item.watch((newValue: number, oldValue: number) => {
// ...
});
You can also access the default value directly off the item:
console.log(item.defaultValue); // 0
The second breaking change is that migrations for versioned items only run when the extension is updated. Before, they were ran whenever the storage item was created, in any entrypoint (background, popup, content script, etc). Now, in v0.17, storage items will only run migrations when the browser.runtime.onInstalled
event is fired with reason = "update"
in the background. See the updated docs to make sure they run correctly: https://wxt.dev/guide/storage.html#running-migrations. TLDR: you need to import all storage items into the background entrypoint for the onInstalled
hook to fire properly and thus run the migrations.
To keep the old behavior, call the new migrate
function to run migrations as soon as an item is defined:
const item = storage.defineItem(...);
item.migrate();
v0.16.11
v0.16.10
🚀 Enhancements
- Customize when content scripts are registered, in the manifest or at runtime (#471)
🩹 Fixes
v0.16.9
v0.16.8
v0.16.7
🚀 Enhancements
- Generate ESLint globals file for auto-imports (#450)
🔥 Performance
- Upgrade Vite to 5.1 (#452)
📖 Documentation
- Add section about dev mode differences (a0d1643)
- Remove anchor from content script ui examples (87a62a1)
🏡 Chore
- e2e: Use
wxt prepare
instead ofwxt build
when possible to speed up E2E tests (#451)
v0.16.6
🚀 Enhancements
- Add option to customize the analysis artifacts output (#431)
🩹 Fixes
- Use
insertBefore
on mounting content script UI (ba85fdf)
💅 Refactors
- Use
Element.prepend
on mounting UI (295f860)
📖 Documentation
- Fix
createShadowRootUi
unmount calls (946072f)
🏡 Chore
- Enable skipped test since it works now (6b8dfdf)
❤️ Contributors
- Lionelhorn (@Lionelhorn)
- Okou (@ookkoouu)