wxt-dev / wxt

⚡ Next-gen Web Extension Framework
https://wxt.dev
MIT License
4.65k stars 200 forks source link

Config make rebuilding background faster #1130

Open ducan-ne opened 3 weeks ago

ducan-ne commented 3 weeks ago

Hi, currently I'm using wxt for a heavy extension, my bundle is about 40mb in development and 10mb in production

Is there any way to make the build process faster? Right now every time I save, it has to wait ~5-7s (100% cpu) to rebuild the background, but content script/ page work great (I think it's because we're using Vite dev server + hot reload, and small bundle size).

My ideas:

ducan-ne commented 3 weeks ago

53 is an interesting approach, IMHO, I would love to use an older version of Chrome if it solves the problem, it's really a pain point to me 😅

ducan-ne commented 3 weeks ago

another idea: put the background logic to offscreen and gets hot reload in there, I assume it has dom api therefore will support Vite's hot reload:

offscreen: hold the logic, any chrome.xxx.xxx API will call background through an RPC provider (learn from TRPC's idea). Only on dev server, in production we will remove offscreen's permission background: hold the RPC, in production, it will hold the RPC backend for chrome's api calls

I've made a side project a few months ago that does this (for calling browser apis in Raycast extension) https://github.com/ducan-ne/raycast-browser