Build errors when use storage
Describe the bug
- Init project
- Change test_wxt\entrypoints\background.ts
- run build command:
- review background.js
I'm not sure if this can be regarded as a bug. OCD kicking in.
environment: dependencies:
- vue 3.5.30
devDependencies:
- @wxt-dev/module-vue 1.0.3
- typescript 5.9.3
- vue-tsc 3.2.6
- wxt 0.20.20
Reproduction
Steps to reproduce
pnpm installpnpm build
System Info
System:
OS: Windows 11 10.0.26200
CPU: (16) x64 Intel(R) Core(TM) Ultra 7 255H
Memory: 12.64 GB / 31.43 GB
Binaries:
Node: 22.19.0 - D:\Program Files\nodejs\node.EXE
npm: 10.9.3 - D:\Program Files\nodejs\npm.CMD
pnpm: 10.32.0 - C:\Users\27266\AppData\Local\pnpm\pnpm.CMD
Browsers:
Chrome: 145.0.7632.160
Edge: Chromium (133.0.3065.92)`
Used Package Manager
pnpm
Validations
- [x] Read the Contributing Guidelines.
- [x] Read the docs.
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [x] The provided reproduction is a minimal reproducible example of the bug.
So two things to address:
-
The bundled output:
-
This is a multi-line string used as the error message. How it appears in your bundled file is correct and perfectly valid JS.
-
It looks a little weird since everything else is bundled onto one line, but it's more efficient to bundle new lines as real characters instead of the escaped
\n. Here's a demo showing how esbuilt (which WXT uses) bundles your extension code:// test.js console.log('line1'); console.log('This is\nmultiline'); console.log('line3');$ pnpm dlx esbuild test.js --minify "use strict";console.log("line1"),console.log(`This is multi-line`),console.log("line3"); -
As you can see, the string with a
\nis converted to using backticks and a real newline character in the esbuild minified output. This is because\nis two characters and a real newline is one character - since esbuilt is minifying it goes with the real newline to minimize the file size.
-
-
Error thrown at runtime:
-
Your reproduction doesn't work when running
pnpm devbecause of this error:You must add the 'storage' permission to your manifest to use 'wxt/storage' -
This is because you didn't add the storage permission, just like the error message says. The below change fixes your runtime error:
import { defineConfig } from "wxt"; export default defineConfig({ modules: ["@wxt-dev/module-vue"], + manifest: { + permissions: ["storage"], + }, });See the docs: https://wxt.dev/storage.html#storage-permission
-
After you add the storage permission, everything works correctly.
Thank you. I've added the storage permission, but I still get this error message. Sorry, it actually works when it runs. I guess it's just my OCD acting up.