Skip to content
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

Support rspack #88

Open
Khauri opened this issue Mar 26, 2024 · 0 comments
Open

Support rspack #88

Khauri opened this issue Mar 26, 2024 · 0 comments

Comments

@Khauri
Copy link

Khauri commented Mar 26, 2024

Description

The marko webpack plugin requires some minor changes in order to support rspack, a webpack compatible bundler written in rust that claims to be very fast.

Specifically, rspack is webpack 5 compatible (mostly), but the explicit webpack 5 check in @marko/webpack leads the plugin down incompatible branches.
Additionally an old and deprecated webpack hooks aren't yet (or may never be) supported in rspack, namely the afterOptimizeAssets hook, which seemingly can simply be changed to afterProcessAssets.
Finally, referencing the webpack module, ie for the enum webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS, may not work as webpack may not necessarily be installed. I'm not entirely sure the best approach to solving this, but both rpsack and webpack define this value as -100.
There didn't appear to be any other necessary changes otherwise, though I did not thoroughly test this

Why

We're evaluating ways to make our builds faster. We cannot change our bundler to vite without significant developer cost, so we're stuck with webpack for now.

Supporting rspack may be beneficial to others in a similar situation

Possible Implementation & Open Questions

I would think introducing a new major version that drops support for webpack 4 entirely might be appropriate here. This would remove the need to check the webpack version. The PROCESS_ASSETS_STAGE_ADDITIONS could potentially be hardcoded.
This would remove the need to import webpack, and thus webpack itself could now be made an optionalDependency instead of a peerDependency so that it doesn't necessarily need to be installed alongside this plugin.

Is this something you're interested in working on?

Sure, I would just need guidance on if dropping support for webpack 4 is practical. Otherwise there may need to be a discussion on how to get around importing webpack

I can also make a repro repository, but this is more of a feature request than a bug report so I didn't think it'd be necessary. Theoretically it should be as simple as creating a new project using a webpack 5 based config, renaming it to rpsack.config.[ts/js], and swapping out webpack with rspack in the package scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant