-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to manifest v3 #59
Comments
I've made a simple migration on this branch, but it can work on build only. HMR is also been unavailable, see: If anyone is familiar with mv3, PR is welcome. ❤️ |
hi, @tmkx , thanks for your template. When I coding, I replaced The chrome extension compiled successfully and supported HMR. I don't know if it is a good solution, if so, we can simplify the template dev-related script together. |
I think because of this reason, in manifest v3, we can no longer load script from remote server |
@tmkx thx for providing a workaround, at least we can build the extension. |
Reference: https://groups.google.com/a/chromium.org/g/chromium-extensions/c/pYtdXH0f46E |
Using ur branch it builds the extension, after now if an extension remain idle for some ~5mins, it throws error whenever it sendsMessage |
Found that the disconnected port object error is fixed in v. 5.0.4 of webext-bridge |
For people also waiting for the HMR issue to be resolved, a working
|
@xlzy520 |
@lautr sorry. |
Hi all, branch changes: main...refactor/mv3 For anyone who is interested in how did that: In MV3, we can't use dynamic codes (eval, server file, CDN, .etc) anymore, so we need to put files to the file system, just like After putting files to FS, we are facing another problem: file extension. The HTTP server can use |
@tmkx Waiting for the debugger to disconnect... 应该是 vite-mv3-hmr.ts 内 await fs.ensureDir(dirname(targetFile)) |
Sorry 我还没在 Windows 上验证过,你试试 WSL 能不能运行,我回头找个 Win 电脑看下,现在居家 🥲 Sorry, I haven't verified it on Windows, please try WSL, I will find a Win computer to check, WFH now.. |
"scripts": {
"dev": "npm run clear && cross-env NODE_ENV=development run-p dev:*",
"dev:prepare": "esno scripts/prepare.ts",
"dev:web": "vite",
"dev:js": "npm run build:js -- --mode development",
"dev:bg": "npm run build:bg -- --mode development",
"build": "cross-env NODE_ENV=production run-s clear build:web build:prepare build:js build:bg",
"build:prepare": "esno scripts/prepare.ts",
"build:web": "vite build",
"build:js": "vite build --config vite.config.content.ts",
"build:bg": "vite build --config vite.config.bg.ts",
"watch:bg": "nodemon --ignore \"*.d.ts\" --watch \"src/background\" -e ts,js,mjs,json,vue --exec \"pnpm dev:bg\""
} use watch:bg |
我只调试background的时候,这样可以加快速度 |
just tried the new version and now getting this on windows, any ideas?
|
how would I know, it's an You could try this branch with yarn PNP, maybe it would work? |
Hi! |
@tmkx Thanks for the work on manifest v3! I tried the
|
I'm having the exact same problems as you @zmwangx. Did you find a solution for these 2 problems? |
I already posted a patch for the first problem. I didn't look into the second one, I just stuck to Windi even though it has some shortcomings. |
Thank you, man. |
For everyone like me that still has failing dev builds to to file system issues on windows, this helped me install concurrently
entry in
|
Noticed another problem with declare global {
interface Window {
__APP_VERSION__: string;
}
}
window.__APP_VERSION__ = __APP_VERSION__; |
@zmwangx here is my solution for problem 2: const cacheMap = new Map<string, string>()
async function writeToDisk(url: string) {
const result = await server.transformRequest(url.replace(/^\/@id\//, ''))
if (result?.etag && result?.etag === cacheMap.get(url))
return
// Add to cache
cacheMap.set(url, result?.etag || '')
// ....
} |
Hey guys — currently developing a webextension using this template and 85% through stumbled across this thread 🤦♂️ Is there anything we can help with re porting this template to MV3? Is the MV3 branch ok for production? |
I would say it is really close to, I am redoing an extension with it, so far doing great when not taking in consideration those bullshit MV3 changes 😄 |
My extension (mv3) is already on chrome store. Everything other than HMR is working fine! |
vite had published v3, current |
https://github.com/antfu/vitesse-webext/tree/refactor/mv3 has upgraded vite to v3 now. |
@tmkx latest commit has two problems:
I have some other ideas:
|
anyone managed to get a working example with mv3? |
I have exactly the same problem @tmkx |
Hey @antfu, any plans on supporting this thread? It's nearly 2023 and the steps taken may require your attention |
Seems like manifest v3 isn't supported by Firefox 💀
terminal output➜ test-extension-2 git:(test-release) ✗ npm run start:firefox
> [email protected] start:firefox
> web-ext run --source-dir ./extension --target=firefox-desktop
Applying config file: ./package.json
Running web extension from /Users/sahindeniz/projects/test-extension-2/extension
Use --verbose or --devtools to see logging
WebExtError: installTemporaryAddon: Error: Error: Could not install add-on at '/Users/sahindeniz/projects/test-extension-2/extension': Error: Unsupported manifest version: 3
at RemoteFirefox.installTemporaryAddon (file:///Users/sahindeniz/projects/test-extension-2/node_modules/web-ext/lib/firefox/remote.js:90:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async FirefoxDesktopExtensionRunner.startFirefoxInstance (file:///Users/sahindeniz/projects/test-extension-2/node_modules/web-ext/lib/extension-runners/firefox-desktop.js:218:27)
at async FirefoxDesktopExtensionRunner.run (file:///Users/sahindeniz/projects/test-extension-2/node_modules/web-ext/lib/extension-runners/firefox-desktop.js:51:5)
at async Promise.all (index 0)
at async MultiExtensionRunner.run (file:///Users/sahindeniz/projects/test-extension-2/node_modules/web-ext/lib/extension-runners/index.js:68:5)
at async run (file:///Users/sahindeniz/projects/test-extension-2/node_modules/web-ext/lib/cmd/run.js:178:3)
at async Program.execute (file:///Users/sahindeniz/projects/test-extension-2/node_modules/web-ext/lib/program.js:263:7)
at async file:///Users/sahindeniz/projects/test-extension-2/node_modules/web-ext/bin/web-ext.js:13:1 Upstream library |
@seahindeniz compatible with Firefox without making too many changes. |
This comment was marked as off-topic.
This comment was marked as off-topic.
https://bugs.chromium.org/p/chromium/issues/detail?id=1247690#c35
It seems the issue that MV3 CSP doesn't allow localhost scripts for unpacked extensions has been solved in chromium. |
MV3 sunset is under review. I guess we can expect some breaking changes |
Because Vite doesn't support write requested file to disk |
Thanks for this good inititive!
Also, to me it seems the response of
As a minor suggestion, it might be possible to generalize the escaping
At the end, I found crxjs to be working well |
hello all, Chromium has allowed localhost sources in extension CSP, and I tested in the latest Edge version(113), HMR also works, so there's no need for the trick anymore. The https://chromium.googlesource.com/chromium/src/+/b81d6dcb2f2a89075b2bd8619b59bbf00994a01d |
It happens cause https://github.com/crxjs/chrome-extension-tools/blob/main/packages/vite-plugin/src/node/plugin-hmr.ts#L49 |
With google deciding to make manifest v2 extensions (see https://developer.chrome.com/blog/mv2-transition/) wouldn't it be wise to move the repo to the new format ?
I can't find the article but I read somewhere that firefox will do the same
The text was updated successfully, but these errors were encountered: