Replies: 4 comments 6 replies
-
@ahabhgk I see that
|
Beta Was this translation helpful? Give feedback.
-
To be honest I'm quite a fan of builtins. First experience with rspack, builtins let me remove massive amounts of configs and it just worked. If I needed extra customization I could implement as plugin but it was great to have a non webpacky set of quick options. We need to support these as plugins. Just because many destructure these and use them to compose other plugins, and for advanced customization- it may offer more controls. If I need more control I can turn off builtins and use plugin, or loader. But the majority of my quick POC or testing apps or initial interactions of a codebase would likely work fine using builtins. As more refinement is needed, we offer it but there's not an upfront cost to using rspack. Could be easy, but powerful. If not in rspack core. We should provide a similar abstraction with smaller api surface or something with lots of builtins. This could appeal to users who like rollup or esbuild just because it's not as heavy to configure as webpack. Rspack-lite api could provide fast powerful builds but with rollup simplicity. |
Beta Was this translation helpful? Give feedback.
-
Detailed design for swc-loader related features: {
builtins: {
emotion: {},
relay: {}
}
} Will be converted to the internal {
module: {
rules: [{
loader: "builtin:swc-loader",
options: {
rspackExperiments: { emotion: {}, relay: {} }
}
}]
}
} This feature is not stable and subject to change. wasm-plugin will be supported in the future. |
Beta Was this translation helpful? Give feedback.
-
In webpack, lots of common used features can be added by plugins,
HTMLWebpackPlugin
,webpack.DefinePlugin
,webpack.ProvidePlugin
,webpack.ExternalsPlugin
, etc. In early stage of Rspack, we want to implement these common used features without slow down the performance by JS plugins, so we introduced thebuiltins
options, and implement these common used features under thebuiltins
options, with good performance of course, but as time goes on, we found that thebuiltins
options causes some problems.builtins
options only exists in Rspack, when you migrate a existing webpack project to Rspack, not all config is compatible, and most of them are underbuiltins
options.webpack.ProvidePlugin
, webpack-dev-server depend onwebpack.HotModuleReplacementPlugin
, for these plugins, we have to (re)write our own version plugins.EntryPlugin
. Rspack can't do these for now withbuiltins
options, but webpack can do these with plugins.So, to resolve these problems in Rspack, we propose another kind of plugin in addition to the JS plugin: builtin plugin.
Builtin plugins are a set of internal Rspack plugin, written by Rust, and can be used by
rspack.XxxPlugin
.And we use
rspack.XxxRspackPlugin
naming convention for those plugins that commonly used in webpack community, and ported into Rspack rust side for performance reason.Builtin plugins will replace some of the
builtins
options, and othersbuiltins
options will be replaced bybuiltin:swc-loader
:builtins.define
=>rspack.DefinePlugin
builtins.provide
=>rspack.ProvidePlugin
builtins.banner
=>rspack.BannerPlugin
builtins.minifyOptions
=>rspack.SwcJsMinimizerRspackPlugin
andrspack.SwcCssMinimizerRspackPlugin
builtins.html
=>rspack.HtmlRspackPlugin
builtins.progress
=>rspack.ProgressPlugin
builtins.copy
=>rspack.CopyRspackPlugin
builtins.css
=>experiments.css
(builtins css is the peer implementation of experiments css, so this probably will be moved toexperiments.css
)builtins.devFriendlySplitChunks
=>rspack.DevFriendlySplitChunksRspackPlugin
(this is used to speed up bundle-splitting in development mode, but after we refactor the implementation of SplitChunksPlugin in v0.2, the performance problem is solved, so you don't need this anymore and this probably will be removed)builtins.treeShaking
=>rspack.TreeShakingRspackPlugin
(we are refactoring our implementation of tree shaking, and the config will align with webpack:optimization.sideEffects
,optimization.provideExports
,optimization.innerGraph
, andoptimization.usedExports
, so this probably will be removed or be a plugin which alias for these config under the hood, we will decide after we finish the refactor)builtins.noEmitAssets
=>rspack.NoEmitAssetsRspackPlugin
(this is an alternative implement for memory output file system, since we already implement memory output file system, so you don't need this anymore and this probably will be removed)builtins.react
=>builtin:swc-loader
builtins.decorator
=>builtin:swc-loader
builtins.emotion
=>builtin:swc-loader
builtins.pluginImport
=>builtin:swc-loader
builtins.relay
=>builtin:swc-loader
we will deprecate
builtins
options in 0.3.x and builtin plugins andbuiltin:swc-loader
will be the recommended way, we will provide a guide for users to migrate smoothly. And deprecate doesn't mean drop support, we will still supportbuiltins
options for at least 2 minor versions (0.4.x, 0.5.x) and drop support in 0.6.0.Beta Was this translation helpful? Give feedback.
All reactions