Replies: 1 comment 1 reply
-
|
we may need some performance stats about the before and after |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Rspack future:
disableTransformByDefaultSummary
This change aims to deprecate two internal features in 0.4.0:
Multiple PRs will be submitted, users of Rspack can opt-in these features by enabling corresponding
experiments.rspackFutureoptions.Motivation
The idea behind this is to provide a better alignment and design concept with webpack.
Disabling default transformation
Webpack is plug-able with its outstanding plugin system and highly resource manipulative
with it's loader infrastructure, giving that the bundler itself a web standard bundler. So,
for the bundler itself, it does not trying to do any internal code transformation related to something
like es2022 -> es5 transformation from the perspective of user code. This means that everything
can be opt-in progressively and keep the main bundler pipeline as clean as possible in spite of
modifying the module format itself for cross-platform reason since different platform requires different
module linking strategy(just like things how every linker is doing).
Here's how webpack bundles JS files:
However, here's how rspack deals with JS files:
It looks the same right? However there's a gap in the internal parsing stage between webpack and rspack.
If developers were to compile the application to elder JavaScript syntax, in webpack, they have to configure a
loader to do so, giving that
option.targetis only an option to control the generated webpack runtime not thecode input by user, however, in rspack, users only need to configure the
option.targetto achieve this.Why that's a difference and at what cost does this feature take? The essential concept of rspack is to make the bundler
itself as fast as possible. However, configuring loaders such as
babel-loadergreatly jeopardizes performance.After a discussion within the team, we discuss to leverage the option
targetto handle the syntax downgradingwith regard of the fact that we don't have anything to replace
babel-loaderat that time. By doing so, we lostthe control of features like
Rule.includeandRule.exclude, etc provided by Webpack. Does that hurt? Definitely!In the world of web application bundling, we would like to treat different files with different resource processing logic.
Often, we regard files in the
node_modulesas downgraded modules. We don't want them being added to a transformingpipeline again as these tasks are CPU intensive and not to say there's some cases we should not do any transformation
at all, for example: core-js transformation and we have to manually
exclude the transformation for these polyfill libraries. These logic all located at the internal parser, making Rspack main
pipeline a real mess. However, we don't have a choice at that time.
This code can be deprecated once
builtin:swc-loaderis landed. We can finally remove these thing at once:Removing internal types
Webpack does not provides internal
Rule.typeslikets,tsx, etc. In order to make webpack team and us on the samepage, we would like to remove all these internal types and try to come up with a new solution for that.
Guide-level explanation
Only transform web standard modules
JavaScript-like files with non-webstandard features will result in a parse error:
TypeScript-like files will convert decorators with as if
experimentalDecoratorsandemitDecoratorMetadataare turned on(as what it is in the old version).Make
options.targetfor runtime onlyoptions.targetis only regarded as an option to control Rspack's runtime downgrading.After this change, this behavior is aligned with webpack.
before:
After:
Additional
Rule.typewill be deprecatedAdditional
Rule.typewill be deprecated in v0.4.0. We are working with the webpack team toadd the same functionality back as soon as possible, hoping to give you an out-of-the-box
support to some widely-used features. But for now, these types will be deprecated.
before:
After:
Beta Was this translation helpful? Give feedback.
All reactions