extension.js icon indicating copy to clipboard operation
extension.js copied to clipboard

Experimental: Migrate to Rspack

Open cezaraugusto opened this issue 1 year ago • 9 comments

cezaraugusto avatar Aug 23 '24 16:08 cezaraugusto

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.

cezaraugusto avatar Aug 24 '24 17:08 cezaraugusto

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.

cezaraugusto avatar Aug 27 '24 18:08 cezaraugusto

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% <ø> (ø)

codecov[bot] avatar Aug 27 '24 19:08 codecov[bot]

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.

cezaraugusto avatar Aug 27 '24 19:08 cezaraugusto

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 avatar Aug 28 '24 07:08 OSpoon

@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 avatar Aug 28 '24 11:08 cezaraugusto

@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.

OSpoon avatar Aug 28 '24 16:08 OSpoon

Open in Stackblitz

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

pkg-pr-new[bot] avatar Sep 03 '24 22:09 pkg-pr-new[bot]

Open in Stackblitz

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

pkg-pr-new[bot] avatar Sep 03 '24 22:09 pkg-pr-new[bot]

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 avatar Dec 20 '24 05:12 dandv

@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

cezaraugusto avatar Dec 21 '24 13:12 cezaraugusto

made in #254

cezaraugusto avatar Apr 05 '25 00:04 cezaraugusto