DEV Community

Alex Spinov
Alex Spinov

Posted on

Rspack Has a Free API You're Not Using

Rspack is a Rust-powered webpack replacement that's 5-10x faster. It's webpack-compatible — your webpack config works with minimal changes.

The Free APIs You're Missing

1. Webpack Compatibility — Drop-In Replacement

// rspack.config.js — looks like webpack.config.js!
module.exports = {
  entry: "./src/index.ts",
  output: { filename: "[name].[contenthash].js" },
  module: {
    rules: [
      { test: /\.tsx?$/, use: "builtin:swc-loader" },
      { test: /\.css$/, use: ["style-loader", "css-loader"] },
      { test: /\.(png|svg)$/, type: "asset" },
    ],
  },
  plugins: [new rspack.HtmlRspackPlugin({ template: "./index.html" })],
};
Enter fullscreen mode Exit fullscreen mode

2. Built-In SWC Loader — No babel-loader

{
  test: /\.(js|ts|tsx)$/,
  use: {
    loader: "builtin:swc-loader",
    options: {
      jsc: {
        parser: { syntax: "typescript", tsx: true },
        transform: { react: { runtime: "automatic" } },
      },
    },
  },
}
Enter fullscreen mode Exit fullscreen mode

SWC compilation built into the bundler. No separate transpilation step.

3. Module Federation 2.0 — Micro-Frontends

const { ModuleFederationPlugin } = require("@module-federation/enhanced/rspack");

module.exports = {
  plugins: [
    new ModuleFederationPlugin({
      name: "host_app",
      remotes: {
        remote_app: "remote_app@http://localhost:3001/remoteEntry.js",
      },
      shared: ["react", "react-dom"],
    }),
  ],
};
Enter fullscreen mode Exit fullscreen mode

4. Built-In CSS Extraction — No mini-css-extract-plugin

module.exports = {
  experiments: { css: true },
  module: {
    rules: [
      {
        test: /\.module\.css$/,
        type: "css/module",
      },
    ],
  },
};
Enter fullscreen mode Exit fullscreen mode

Native CSS Modules support. No extra plugins.

5. Profile — Built-In Build Analysis

# Generate build profile
RSPACK_PROFILE=ALL rspack build

# Opens in Chrome DevTools Performance tab
# Shows exactly where time is spent
Enter fullscreen mode Exit fullscreen mode

Benchmarks

Operation webpack Rspack Speedup
Dev cold start 12s 1.2s 10x
HMR 800ms 80ms 10x
Production build 45s 6s 7.5x

Getting Started

npm create rspack@latest
cd my-rspack-app
npm run dev
Enter fullscreen mode Exit fullscreen mode

Need data from any website delivered as clean JSON? I build production web scrapers that handle anti-bot, proxies, and rate limits. 77 scrapers running in production. Email me: Spinov001@gmail.com

Check out my awesome-web-scraping list for the best scraping tools and resources.

Top comments (0)