MyGit

v0.3.4

web-infra-dev/rspack

版本发布时间: 2023-09-13 17:29:00

web-infra-dev/rspack最新发布版本:v0.3.13(2023-11-15 21:30:09)

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 🎉

Bug Fixes 🐞

Other Changes

Full Changelog: https://github.com/web-infra-dev/rspack/compare/v0.3.2...v0.3.4

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-09-13发行的版本