Replies: 4 comments 6 replies
-
| 
         Do it!  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         @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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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 thebuiltinsoptions, and implement these common used features under thebuiltinsoptions, with good performance of course, but as time goes on, we found that thebuiltinsoptions causes some problems.builtinsoptions only exists in Rspack, when you migrate a existing webpack project to Rspack, not all config is compatible, and most of them are underbuiltinsoptions.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 withbuiltinsoptions, 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.XxxRspackPluginnaming 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
builtinsoptions, and othersbuiltinsoptions will be replaced bybuiltin:swc-loader:builtins.define=>rspack.DefinePluginbuiltins.provide=>rspack.ProvidePluginbuiltins.banner=>rspack.BannerPluginbuiltins.minifyOptions=>rspack.SwcJsMinimizerRspackPluginandrspack.SwcCssMinimizerRspackPluginbuiltins.html=>rspack.HtmlRspackPluginbuiltins.progress=>rspack.ProgressPluginbuiltins.copy=>rspack.CopyRspackPluginbuiltins.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-loaderbuiltins.decorator=>builtin:swc-loaderbuiltins.emotion=>builtin:swc-loaderbuiltins.pluginImport=>builtin:swc-loaderbuiltins.relay=>builtin:swc-loaderwe will deprecate
builtinsoptions in 0.3.x and builtin plugins andbuiltin:swc-loaderwill be the recommended way, we will provide a guide for users to migrate smoothly. And deprecate doesn't mean drop support, we will still supportbuiltinsoptions 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