extension.js
extension.js copied to clipboard
Experimental: Migrate to Rspack
Updates Aug, 24th
Reloader plugin isn't working, which means manifest.json, service_worker and content_scripts are not reloading. Can't connect to the websocket server and requires a full migration of https://github.com/awesome-webextension/webpack-target-webextension to Rspack. I made a few adjustments to make it compile but it's far from working. Migration is doing well so far during tests and almost everything else works including the multiple CSS/JS integrations.
Updates Aug, 27th
Reloader plugin is working partially. Websocket server work is done. The manifest.json, service_worker and content_scripts files are still not reloading and requires a full migration of https://github.com/awesome-webextension/webpack-target-webextension to Rspack.
The manifest.json file should be working already given it's not part of webpack-target-webextension but it isn't for some reason.
Having the reload step done this PR will be ready to merge. I plan to have it in the final version of 2.0.0.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
| Files | Coverage Δ | |
|---|---|---|
| programs/develop/webpack/lib/messages.ts | 22.43% <ø> (ø) |
|
| programs/develop/webpack/lib/utils.ts | 31.20% <ø> (ø) |
|
| ...on/feature-resolve/steps/transform-source/index.ts | 11.66% <ø> (ø) |
cc @OSpoon are you familiar with Rspack? I need a hand figuring out why Rspack isn't watching the manifest.json file (I'm testing with the content-react template). I'm currently trying to make the new rspack-target-webextension a thing. These are the two items left to make Extension.js fully migrated.
Are you planning to abandon Webpack and fully embrace Rspack? I'm not familiar with Rspack, but I can try to learn about it. This would be helpful for me in the future.
@OSpoon if all works well, yes. Rspack has some advantages like a faster cold start, faster compilation time (for our templates, time is reduced by 2x/3x), overall smaller package sizes, and decent integration with the webpack ecosystem.
The plan for v2 is that users are requesting a way to extend Extension.js via config files and exposing webpack once would make it very hard to migrate later.
@cezaraugusto
How to confirm where the log should be printed when Rspack detects the manifest.json file?
I found that compiler.modifiedFiles does not return the manifest.json file in reload:create-web-socket-server, and it will not return in Webpack as well.
I might not fully understand the exact reason why it doesn't work.
yarn add https://pkg.pr.new/extension-js/extension.js/[email protected]
yarn add https://pkg.pr.new/extension-js/extension.js/[email protected]
yarn add https://pkg.pr.new/extension-js/extension.js/[email protected]
commit: 70aaee7
yarn add https://pkg.pr.new/extension-js/extension.js/[email protected]
yarn add https://pkg.pr.new/extension-js/extension.js/[email protected]
yarn add https://pkg.pr.new/extension-js/extension.js/[email protected]
commit: 70aaee7
I haven't worked with Rspack and don't know how these bundlers work under the hood, but in my experience with Jonghakseo's and especially NekitCorp's boilerplates, Vite was blazing fast.
Rspack is written in Rust though, so it seems very promising.
@dandv yeah, so Extension.js is built on top of webpack and Rspack is faster and supports most of its API. I'll get back to this once we can make the reload plugin work with Rspack
made in #254