plasmo: [BUG] Development server usually doesn't update the extension or being extremely slow
What happened?
Awesome framework guys š„³! I enjoyed building stuff in it I will try to contribute on some parts. I experienced some problems though and I have to always manually stopping the dev server and running again to see the changes on my components. Iām aware by reading the docs in some situations itās necessary to do so but my changes has been related to the content ui files which should update as my understanding. Iām not sure how to debug this as well since it successfully builds every time but just doesnāt reflect the changes on browser.
I am looking for any suggestions or input how to deal with this problem. I was thinking rm -rf .plasmo build when it gets slower but not sure if thatās a good way of solving slowness.
My development setup might cause this issue, I will download chrome try on that as well. Currently using:
-
Brave
-
Webstorm
-
For the extension, these are my deps:
"dependencies": {
"@hookform/resolvers": "^3.1.1",
"@radix-ui/react-alert-dialog": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"class-variance-authority": "^0.6.1",
"clsx": "^1.2.1",
"lucide-react": "^0.258.0",
"plasmo": "0.77.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.45.1",
"tailwind-merge": "^1.13.2",
"tailwindcss": "3.3.2",
"tailwindcss-animate": "^1.0.6",
"zod": "^3.21.4"
},
"devDependencies": {
"@plasmohq/prettier-plugin-sort-imports": "3.6.4",
"@types/chrome": "0.0.239",
"@types/node": "20.3.2",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
"autoprefixer": "10.4.14",
"postcss": "8.4.24",
"prettier": "2.8.8",
"typescript": "5.1.6"
}
Version
Latest
What OS are you seeing the problem on?
MacOSX
What browsers are you seeing the problem on?
Chrome
Relevant log output
There is no output. Everything seems fine.
(OPTIONAL) Contribution
- I would like to fix this BUG via a PR
Code of Conduct
- I agree to follow this projectās Code of Conduct
- I checked the current issues for duplicate problems.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 3
- Comments: 17 (3 by maintainers)
Iām experiencing this as well. To reliably have changes show up in a content script in Chrome, I have to save a file, add a space to the file, save it again, then the page refreshes a second time and has my updated content. Iām on v0.84.1
Is work still ongoing on this? Massive issue for me - I can only see my changes if I either: A) delete the build folder every change B) āemptyā save package.json with no actual changes to trigger āpackage.json changed, updating manifest overides. You might need to restart the dev serverā. This is annoying to do, because it crashes the extension window every time and I have to open a new tab to keep developing the extension page.
Other things I tried: running with
pnpm run dev, using thelabexperimental mode (made things worse & threw a bunch of other errors).Iām building a 1-page extension with barely any dependencies, pure Plasmo & tailwind, I just started development yesterday and have very few components.
Love Plasmo, this should probably be #1 priority bug to fix.
Edit:
I suspect it could also be something to do with incorrectly named file imports. I was importing a file called
tasks.tsxinto mynewtab/index.tsxfile, but I was importing it asimport Tasks from "./Tasks"with a capital T. This doesnāt throw console errors at build time but when I changed toimport Tasks from "./tasksauto-reload/HMR started working again.Hello folks š Sorry giving late response, I just wanted to experiment and see if the issues will continue after changing the browser. Luckily most of my issues are resolved by changing the browser to chrome from brave which both browsers only used in clean state without any profiles/extensions/history etc. As I know both of them are using the same architecture but under the hood things are different I suppose.
There is weird bug occurring from time to time and just because I forgot āverbose flag most of the time. Itās hard to understand without being able to reproduce it, but I will try my best to remember āverbose. So the bug happens in this way If I am doing bunch of different changes in my source files and save multiple times after certain period, there is a mismatch happening in saved state and extension. If I explain it by giving an example:
Iāve been meaning to raise a similar issue - there are two problems noted here that Iām also having 1) the slowness and 2) the fact that the new code is often not successfully loaded after changes. (@suchcodemuchwow, if it helps, you may not need to restart the server; I find it works to save the file to trigger an additional compilation then reload the extension manually in Chrome.)
(2) has gotten much more frequent as my extension has gotten bigger and recompilation slower. I think it is actually composed of two sub-issues: (2a) is that when the cli reports āExtension repackagedā it does not always have the latest version of the file Iām working on. After it has repackaged once I need to save the file again to catch the latest change. (2b) is that after I have done this the extension is not always reloaded in Chrome so Chrome doesnāt have the latest code.
To give you an idea it currently takes me 40-50secs to start the dev server. The extension is fairly small (
--verbosereports 117 files which includes 4 content scripts). Repackaging is usually around 3-5 secs. However, if there was an error like invalid JSX this goes up to 20-30 secs. Itās hard to compare complexity with my Next.js site but that takes 1-2 secs and has more frontend components and overall files. Would be great to improve the speed, but Iām more bothered by the failure to reload since it means I am compiling twice and constantly manually reloading and refreshing.Would you be able to elaborate on that? Do you mean if we split one CSUI into two weāll see faster compilation?
CLARIFICATION: the Next.js site is 1-2secs for the dev server to start, 20-25secs for static export (
next build). Thatās doing a prod build though.Also one aspect to think about (we should add a best-practice section somewhere in the docs maybe), is that it might be beneficial to reduce the complexity of each CSUI. Unlike web app where the dev server can deliver small piece for the browser to evaluate, extension must include everything in its bundle.
Can you make a bench between plasmoās bundling and NextJSās static export with similar complexity to see if thereās a huge diff? Plasmo is based on Parcel which uses SWC, so itās the same compiler as Next.
The key diff we would find IMO, is that NextJS can leverage more server-side resource to deliver the output so it doesnāt have to bundle everything, whereas for extension, Plasmo has to create a static bundle for the browser to load. So thereās more stuffs being resolved and added into the final bundle compared to a SSR web app.
@suchcodemuchwow can you run dev with
--verboselog together with the generatedmanifest.jsonfile in the dev directory. These would be helpful in pinpointing down where we should look.