npm @rspack/cli 0.3.4
v0.3.4

latest releases: 1.1.0, 1.1.0-beta.0, 1.0.14...
14 months ago

Highlight

Internal plugins

To further improve Rspack's compatibility with webpack ecosystem, we implemented internal plugins in Rspack.
For example, you can use rspack.XxxPlugin in your configuration.

const rspack = require('@rspack/core');

module.exports = {
  plugins: [
    new rspack.DefinePlugin({ 'process.env.NODE_ENV': "'production'", }),
    // In addition to webpack's existing plugins, some of the plugins implemented
    // in rust in Rspack are also exported by internal plugins
    new rspack.HtmlRspackPlugin({ template: './index.html' }),
  ],
};

Or use compiler.webpack.XxxPlugin in your plugin.

class ReactRefreshRspackPlugin {
  apply(compiler) {
    const reactRefreshPath = require.resolve("../client/reactRefresh.js");
    const reactRefreshEntryPath = require.resolve("../client/reactRefreshEntry.js");
    new compiler.webpack.EntryPlugin(compiler.context, reactRefreshEntryPath, {
      name: undefined
    }).apply(compiler);
    new compiler.webpack.ProvidePlugin({
      $ReactRefreshRuntime$: reactRefreshPath
    }).apply(compiler);
  }
};

See

@rspack/plugin-react-refresh

Thanks to the implementation of internal plugins, we can now easily implement the @rspack/plugin-react-refresh, which was coupled into @rspack/dev-server before.
Now, if you are using a custom dev server instead of @rspack/dev-server or @rspack/cli, you can easily enable react fast refresh by adding the @rspack/plugin-react-refresh plugin.
See

Compatible with html-webpack-plugin

Rspack is now html-webpack-plugin compatible!

const path = require("node:path")
const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {
  plugins: [
    new HtmlWebpackPlugin({
      template: "pug-loader!" + path.join(__dirname, "template.pug")
    })
  ]
}

See

builtin:swc-loader supports builtin transformations

These fields served as the alternative to the current builtin transform options, aiming to support transforming with respect to the certain module.

type RspackExperiments = {
  react?: ReactOptions;
  import?: PluginImportOptions;
  emotion?: EmotionOptions;
  relay?: RelayOptions;
};

For example, integrating emotion transformation in the project:

module.exports = {
  module: {
    rules: [
      {
         test: /\.jsx$/,
         exclude: /node_modules/,
         loader: "builtin:swc-loader",
         options: {
            jsc: {
              parser: {
                syntax: "ecmascript",
                jsx: true,
              }
            },
            rspackExperiments: {
              emotion: true
            }
         }
      }
    ]
  }
}

See

What's Changed

Performance Improvements ⚡

Exciting New Features 🎉

  • feat: flagDependencyUsagePlugin by @IWANABETHATGUY in #4114
  • feat(core): add cache hits info to stats by @LingyuCoder in #4140
  • feat: HarmonyExportImportedSpecifierDependency get mode by @underfin in #4141
  • feat: support builtin:swc-loader experimental transformers by @h-a-n-a in #4133
  • feat: support stats ids by @ahabhgk in #4148
  • feat: support function for BannerPlugin by @ahabhgk in #4151
  • feat: react refresh plugin by @ahabhgk in #4135
  • feat: expose keepFnNames and keepClassNames options of builtin swc minfier by @xinxinhe1810 in #4121
  • feat(config): warn while using experiments.newSplitChunks by @hyf0 in #4169
  • feat(config): only warn while experiments.newSplitChunks being explicitly setted by @hyf0 in #4174
  • feat: compatible with html-webpack-plugin by @ahabhgk in #4175
  • feat: combine three tree shaking related plugin, and add corresponding configuration. by @IWANABETHATGUY in #4147
  • feat: add externalsPresets webAsync target support by @lippzhang in #4184
  • feat: add boolean type for builtins.html[0].inject by @lippzhang in #3771

Bug Fixes 🐞

Other Changes

Full Changelog: v0.3.2...v0.3.4

Don't miss a new cli release

NewReleases is sending notifications on new releases.