[RFC] Integrate Rspack builtin:swc-loader #4620
9aoy
started this conversation in
RFC Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
1 . Summary
The current Rspack mode has the following issues when using swc translation:
polyfill.usage
、source.exclude
、source.include
can not be usedtransformLoadsh
,styledComponents
,removePropTypes
cannot be used due to not supporting extended swc capabilities.Based on this background, Rspack supports
builtin:swc-loader
and disable default transformation (to avoid multiple transformations). see: web-infra-dev/rspack#4070This RFC will describe how to migrate to
builtin:swc-loader
in modern.js and support the above features, since Rspack supportsbuiltin:swc-loader
and disable default transformation.2. Detailed design
Migration from default transformation to
builtin:swc-loader
will be divided into three stages:builtin:swc-loader
disableTransformByDefault
config and migrate builtins functionality tobuiltin:swc-loader
polyfill.usage
andsource.exclude
configuration.source.include
configuration, and the files outside the project, such asnode_modules
, will not be translated by default2.1 Migrate builtins functionality to
builtin:swc-loader
Configurations/plugins that need to be migrated and modified include:
source.exclude
This stage will turn on the Rspack
disableTransformByDefault
& does not support switching back to the default translation, but the include rule does not apply and thus it should have no impact on users.2.2 Apply include rule
include: [context.rootPath, {not: /node_modules/}]
configuration. And supports reading the current projectsource.include
configuration.How to determine which third-party packages need to be added to source.includeafter migration?
Modern.js provides security.checkSyntax capabilities, support analyzes whether there is incompatible advanced syntax in the build artifacts under the current browser scope. If any incompatible syntax is found, detailed information will be printed on the terminal and you can add them to
source.include
.Migration plan
We will not take breaking change for users until the Rspack 0.4.0 version is published. We will add a new configuration disableTransformByDefault to support it.
disableTransformByDefault
switch.disableTransformByDefault
is not enabled, it will prompt error/warning, indicating that the TransformByDefault will be deprecated. Please migrate as soon as possible.3. Drawbacks
Not translate the files outside the project(such as node_modules) is a breaking change for users who already use Rspack mode.
When we apply it by default. We should take some measures to avoid problems after users upgrade, including but not limited to progressive upgrades, giving upgrade announcements, etc.
Beta Was this translation helpful? Give feedback.
All reactions