Skip to content

Releases: web-infra-dev/rspack

v0.5.2

24 Jan 03:32
9e91548
Compare
Choose a tag to compare

What's Changed

Highlights

Support SourceMapDevToolPlugin

Support SourceMapDevToolPlugin. With this enhancement, options such as output.devtoolModuleFilenameTemplate, output.devtoolFallbackModuleFilenameTemplate, and output.devtoolNamespace are now fully supported.

Based on the devtoolModuleFilenameTemplate option, you can follow this example to debug a webpack project in VS Code.

Performance Improvements ⚑

Exciting New Features πŸŽ‰

Bug Fixes 🐞

Other Changes

New Contributors

Full Changelog: v0.5.1...v0.5.2

v0.5.1

16 Jan 04:52
Compare
Choose a tag to compare

What's Changed

Highlights

Rspack Examples

Rspack configuration examples are moved to rspack-examples.

This repository contains all rspack, rsbuild and rspress configuration examples. Contributions are welcome for expanding the examples.

Resolve

  • Deprecated resolve.browserField in favor of resolve.aliasFields.
  • Added resolve.preferAbsolute, resolve.restrictions, resolve.roots and resolve.aliasFields options

Better module resolution hints

img_v3_0275_89cbdb90-0e38-44ba-a14d-7b0587df147g

img_v3_0275_a8db6ea0-d5fc-4f1f-8ae4-84e753104cag

Exciting New Features πŸŽ‰

  • feat(swc_plugin_import): support camelCase and snake_case (#5283)
  • feat: deprecate resolve.browserField and enable resolve.{preferAbsolute,restrictions,roots,aliasFields} (#5223)
  • feat: introduce JavascriptParser (#5280)
  • feat: resolve with hint (#5178)
  • feat: support module build error (#5286)

Bug Fixes 🐞

  • fix: cjs module reexport unused error (#5291)
  • fix: fix cli command alias bug (#5307)
  • fix: module graph incorrect when delete or create file (#5301)
  • fix: should not assume module directories always exist (#5326)
  • fix: unregistered case handler should not panic (#5330)

Performance Improvements ⚑

  • perf: lazily init help message (#5309)

Chores

  • chore(diff): fix diff detail output (#5299)
  • chore: add link to rspack-contrib/rspack-examples in README (#5297)
  • chore: bump oxlint to v0.2.0 (#5327)
  • chore: nightly release alert when failed (#5323)
  • chore: remove examples directory (to github.com/rspack-contrib/rspack-examples) (#5296)
  • chore: remove unused Rust dependencies (#5312)
  • chore: turn off --bail --forceExit --logHeapUsage from webpack test (#5303)
  • chore: upgrade Rust to v1.75.0 (nightly) (#5305)
  • chore: use pnpm v8 default flags (#5304)
  • test: replace error stack in test (#5325)

v0.5.0

10 Jan 02:20
Compare
Choose a tag to compare

Rspack 0.5.0 is out!

Read the announcement blog post: Announcing Rspack 0.5.

Overview

What's Changed

Performance Improvements ⚑

Exciting New Features πŸŽ‰

Bug Fixes 🐞

  • fix(rspack-dev-server): remove webpack dep by @hardfist in #5119
  • fix(mf): should not have extra empty chunk by @ahabhgk in #5128
  • fix: user freindly error msg for output.hashFunction by @bvanjoi in #5129
  • fix: library module renderStartup missing export by @bvanjoi in #4901
  • fix(plugin-runtime): stringify_chunk should escape special chars in chunk names as js's JSON.stringify do by @xc2 in #5117
  • fix: entryOptions should able to merge by @ahabhgk in #5134
  • fix: should not create additional missing modules by @h-a-n-a in #5124
  • fix(treeshaking): calculate add_connection_states right by @JSerFeng in #5140
  • fix: sort errors and warnings in stats based on offsets by @h-a-n-a in #5142
  • fix: harmony export default from should be a parse error by @h-a-n-a in #5144
  • fix: import meta url property by @LingyuCoder in #5145
  • fix: enable more mf v1.5 tests by @ahabhgk in #5148
  • fix: external modules in esm by @LingyuCoder in #5146
  • fix: should store dependencies even if module factorization is failed by @h-a-n-a in #5137
  • fix: empty name and complex member expression in cjs dependency by @LingyuCoder in #5154
  • fix: missing module in block by @ahabhgk in #5171
  • fix(mf1.5): container name in runtime by @ahabhgk in #5175
  • fix(mf1.5): add resolve alias for mf runtime by @ahabhgk in #5239
  • fix: not enable rspack-plugin-react-refresh when mode set to 'product… by @hardfist in #5260

Other Changes

Full Changelog: v0.4.5...v0.5.0

v0.4.5

26 Dec 07:40
38bdd60
Compare
Choose a tag to compare

Highlights

Support compilation.hooks.afterOptimizeModules hook

Called after modules optimization has completed.

compilation.hooks.afterOptimizeModules.tap("plugin_name", function(modules) {
  // do something
})

Support __webpack_is_included__

Test whether or not the given module is bundled by rspack.

if (__webpack_is_included__('./module-a.js')) {
  // do something
}

Support webpackPrefetch and webpackPreload

When doing dynamic import, it is allowed in the magic comments to tell the browser whether the resource will be used in the future.

import(
  /* webpackPrefetch: true */
  /* webpackPreload: true */
  'module'
);

Support error early bail

Fail out on the first error instead of tolerating it.

// rspack.config.js
module.exports = {
  //...
  bail: true,
};

What's Changed

Exciting New Features πŸŽ‰

Bug Fixes 🐞

Other Changes

Full Changelog: v0.4.4...v0.4.5

v0.4.4

21 Dec 05:59
Compare
Choose a tag to compare

Highlights

Allow passing function type to splitChunks.cacheGroups

//...
optimization: {
    splitChunks: {
      chunks: "all",
      minSize: 0,
      cacheGroups: {
        splitLib2: {
          chunks(chunk) {
            console.log(chunk);
            return chunk.name !== "lib1";
          },
          test: /shared\.js/,
          name: "shared",
        },
      },
    },
  },
...

It gives you more flexibility to control code splitting behavior

Allow parse js hashbang syntax

Now rspack can process file like

#!/usr/bin/env node

import { foo } from "./lib";
console.log("index", foo);

A bunch of diagnostics improvement

Rspack
image

Webpack
image

more details you could refer:

What's Changed

Performance Improvements ⚑

Exciting New Features πŸŽ‰

Bug Fixes 🐞

Other Changes

New Contributors

Full Changelog: v0.4.3...v0.4.4

v0.4.3

13 Dec 05:43
Compare
Choose a tag to compare

Highlights

Support optimization.splitChunks.hidePathInfo

Prevents exposing path info when creating names for parts splitted by maxSize.

Support splitChunks.automaticNameDelimiter

By default rspack will generate names using origin and name of the chunk (e.g. vendors~main.js). This option lets you specify the delimiter to use for the generated names. doc

Support splitChunks.cacheGroups.{cacheGroup}.filename

Sets the hint for chunk id. It will be added to chunk's filename. doc

What's Changed

Performance Improvements ⚑

  • refactor: key performance in merge_matched_item_into_module_group_map by @aweary in #4851

Exciting New Features πŸŽ‰

Bug Fixes 🐞

Other Changes

  • chore(runtime-diff): align module decorator runtime modules with webpack by @LingyuCoder in #4891
  • chore(runtime-diff): alignment of hot module replacement runtime module by @LingyuCoder in #4856
  • chore: remove all skipLibCheck by @xiaoxiangmoe in #4910
  • chore: add build:cli:release:{platform} scripts by @aweary in #4859
  • test: prevent .DS_store been add to test cases on macos by @LingyuCoder in #4920
  • refactor: de-hardcoded module factory and move mf out of core by @ahabhgk in #4925
  • chore: deprecate @rspack/plugin-node-polyfill by @hardfist in #4937
  • chore: add debug info under panic with debug build by @h-a-n-a in #4940
  • chore(runtime-diff): alignment of get chunk filename by @LingyuCoder in #4500
  • refactor: error and diagnostics by @h-a-n-a in #4866
  • refactor: miette::Error as Diagnostic and rspack_error::Error by @h-a-n-a in #4892
  • chore: optimize diff test case by @LingyuCoder in #4950
  • refactor: should not always rely on Result by @h-a-n-a in #4880
  • chore(webpack-test): enable resolving/browser-field tests by @Boshen in #4952
  • test(runtime): add test case of using [id] in get chunk filename runtime module by @LingyuCoder in #4972
  • chore(runtime-diff): alignment of startup chunk dependencies runtime module by @LingyuCoder in #4508

New Contributors

Full Changelog: v0.4.2...v0.4.3

v0.4.2

05 Dec 13:35
Compare
Choose a tag to compare

Highlights

experiments.rspackFuture.newTreeshaking

the new tree shaking implementation specifically addressing compatibility issues with webpack architecture and optimizing for reduced output size.
(see below for a detailed explanation)

optimization.mangleExports

allow rspack to control export mangling.
(see below for a detailed explanation)

What's Changed

Exciting New Features πŸŽ‰

  • feat: JsAsset remove version field by @jerrykingxyz in #4836
  • feat: support ecosystem-ci suiteRef trigger by @ahabhgk in #4847
  • feat: do not convert panics to results by @h-a-n-a in #4848
  • feat: implement ChunkGraph.getChunkModulesIterable and ChunkGraph.getChunkEntryModulesIterable by @xc2 in #4855
  • feat(runtime-diff): alignment of wasm async loading runtime module by @LingyuCoder in #4863
  • feat: align webpack - allow false for optimization.splitChunks on options validation by @xc2 in #4883
  • feat: mangle exports by @IWANABETHATGUY in #4805
  • feat: support scriptType by @faga295 in #4814
  • feat: extract data from mf generated code by @ahabhgk in #4799

Bug Fixes 🐞

New Contributors

Full Changelog: v0.4.1...v0.4.2


experiments.rspackFuture.newTreeshaking

This quarter, substantial efforts were dedicated to enhancing tree shaking. While the older tree shaking method remains applicable in most scenarios, it lacks full compatibility with webpack architecture, resulting in divergent behaviors compared to webpack. Additionally, it may produce larger output in certain scenarios when contrasted with webpack. For example, efforts were made to address these issues and optimize tree shaking for improved performance and compatibility.

One of the noteworthy enhancements is the reduction in generated output size. The revamped tree shaking is designed to produce leaner output, particularly when compared to certain scenarios with the previous tree shaking implementation. Here is an example:

source

// index.js
import { a } from './lib.js'
a

// lib.js

export * from './a.js'

// a.js

export const a = 3;
export const b = 3;

package.json

{
  "sideEffects": false
}

rspack.config.js

const rspack = require("@rspack/core");
/** @type {import('@rspack/core').Configuration} */
const config = {
        entry: "./src/index.js",
        plugins: [
        ],
        experiments: {
                rspackFuture: {
                        newTreeshaking: false // `newTreeshaking` disable by default
                }
        },
        optimization: {
                moduleIds:"named", // use nanmed moduleIds and disable `minize` for better demonstration
                minimize: false
        },
};
module.exports = config;

Since the whole module is side effects free, we could directly import a from a.js . This could eliminate lib.js in output.

with old tree shaking

// skip runtime code ...
var __webpack_modules__ = {
"./src/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
  a: function() { return a; }
});
 const a = 3;
 const b = 3;
}),
"./src/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib */"./src/lib.js");

_lib__WEBPACK_IMPORTED_MODULE_0__.a;
}),
"./src/lib.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */var _a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./a */"./src/a.js");
__webpack_require__.es(_a__WEBPACK_IMPORTED_MODULE_0__, __webpack_exports__);

}),

}

with new tree shaking

enable experiments.rspackFuture.newTreeshaking

const rspack = require("@rspack/core");
/** @type {import('@rspack/core').Configuration} */
const config = {
        // ...
        experiments: {
                rspackFuture: {
-                        newTreeshaking: false
+                        newTreeshaking: true 
                }
        },
        // ...
};
module.exports = config;
output 
 var __webpack_modules__ = {
"./src/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
  a: function() { return a; }
});
 const a = 3;
 const b = 3;
}),
"./src/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib */"./src/a.js");

_lib__WEBPACK_IMPORTED_MODULE_0__.a;
}),

}

The new treeshaking implementation is still undergoing stability testing; hence, it remains disabled by default. If you wish to experiment with it, you can enable it by using the following:

const rspack = require("@rspack/core");
/** @type {import('@rspack/core').Configuration} */
const config = {
        // ...
        experiments: {
                rspackFuture: {
                        newTreeshaking: true 
                }
        },
        // ...
};
module.exports = config; 

more details you could refer:
https://www.rspack.dev/config/experiments.html#experimentsrspackfuturenewtreeshaking
and related options:

  1. usedExports
  2. innerGraph
  3. providedExports
  4. sideEffects

optimization.mangleExports

optimization.mangleExports allows to control export mangling.
Reuse the previous example, making slight modifications for a better explanation.

// index.js
- import { aaa } from './lib.js'
+ import { aaa } from './lib.js'
- a
+ aaa

// lib.js

export * from './a.js'

// a.js

- export const aaa = 3;
+ export const aaa = 3;
export const b = 3;

Enable experiments.rspackFuture.newTreeshaking and optimization.mangleExports

Output

The export of module src/a.js was condensed into a single letter, leading to a decrease in the overall output size.

var __webpack_modules__ = {
"./src/a.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
  P: function() { return aaa; }
});
 const aaa = 3;
 const b = 3;
}),
"./src/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */var _lib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib */"./src/a.js");

_lib__WEBPACK_IMPORTED_MODULE_0__.P;
}),

}

Note this feature is not stable yet, and requires experiments.rspackFuture.newTreeshaking to be enabled.

v0.4.1

29 Nov 07:49
e34899c
Compare
Choose a tag to compare

Highlights

  • Support compiler.hooks.shouldEmit hook: Return a boolean telling whether to emit.
  • Support compilation.hooks.childCompiler hook: Executed after created a childCompiler.
  • Support function type splitChunks.cacheGroups.{cacheGroup}.test

What's Changed

Performance Improvements ⚑

Exciting New Features πŸŽ‰

  • feat: support function type for splitChunks.{cacheGroup}.{test, name} by @bvanjoi in #4722
  • feat: support Chunk.groupsIterable and ChunkGroup.getParents by @bvanjoi in #4641
  • feat(plugin-driver): add execute module by @JSerFeng in #4737
  • feat: support Compiler.shouldEmit by @bvanjoi in #4742
  • feat: Module Federation, part 1, ContainerPlugin by @ahabhgk in #4642
  • feat: support compilation.hooks.childCompiler by @bvanjoi in #4773
  • feat: Module Federation, part 2, ContainerReferencePlugin by @ahabhgk in #4735
  • feat: bump swc to support format.inline_script by @bvanjoi in #4786
  • feat: Module Federation, part 3, ProvideSharedPlugin by @ahabhgk in #4778
  • feat: Module Federation, part 4, ConsumeSharedPlugin by @ahabhgk in #4783
  • feat: support String.raw for context module by @faga295 in #4764

Bug Fixes 🐞

Other Changes

New Contributors

Full Changelog: v0.4.0...v0.4.1

v0.4.0

22 Nov 09:47
Compare
Choose a tag to compare

Rspack 0.4.0 is out!

Read the announcement blog post: Announcing Rspack 0.4.

Overview

Migrating from v0.3

Check out our migration guide for in-depth migration details.

What's Changed

Performance Improvements ⚑

Exciting New Features πŸŽ‰

Bug Fixes 🐞

Other Changes

Full Changelog: v0.3.14...v0.4.0

v0.3.14

17 Nov 10:07
Compare
Choose a tag to compare

What's Changed

Bug Fixes 🐞

Other Changes

Full Changelog: v0.3.13...v0.3.14