Skip to content

Releases: web-infra-dev/rspack

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

v0.3.13

15 Nov 13:30
Compare
Choose a tag to compare

Highlight

This version contains a hotfix of #4643

What's Changed

Exciting New Features πŸŽ‰

  • feat: support library for instance unique name by @nyqykk in #4628

Bug Fixes 🐞

Other Changes

New Contributors

Full Changelog: v0.3.12...v0.3.13

v0.3.12

14 Nov 10:34
Compare
Choose a tag to compare

Highlight

Caution

Don't use this version, use 0.3.13 instead, this version contains a serious bug related to #4643

support EntryDescription.library

Bundling this entry as a library, and allows you to configure the library format through this option, enabling the generation of different module formats (CommonJS, global variable, ESModule, etc.). This flexibility ensures that your code can be easily used in various environments. Additionally, this feature serves as a prerequisite for Module Federation.

What's Changed

Performance Improvements ⚑

Exciting New Features πŸŽ‰

Bug Fixes 🐞

Other Changes

New Contributors

Full Changelog: v0.3.11...v0.3.12

v0.3.11

07 Nov 10:39
Compare
Choose a tag to compare

Highlights

Support WarnCaseSensitiveModulesPlugin

support WarnCaseSensitiveModulesPlugin

Fix issue when optional expression has an imported variable

The bug fix in this release ensures that optional chaining works flawlessly. For more details, you could refer to #4502

support asset info source filename

Now compilation.getAsset(chunkFile) can return sourceFilename correctly.

bump swc

Bump swc-core from 0.86.9 to 0.86.33

What's Changed

Performance Improvements ⚑

Exciting New Features πŸŽ‰

Bug Fixes 🐞

Other Changes

New Contributors

Full Changelog: v0.3.10...v0.3.11

v0.3.10

02 Nov 08:10
Compare
Choose a tag to compare

Highlights

monaco-editor-webpack-plugin support

Support monaco-editor-webpack-plugin, you can see example using monaco-editor-webpack-plugin in example-monaco-editor-webpack-plugin
WebWorkerTemplatePlugin and LimitChunkCountPlugin are supported at the same time. Really appreciate for @SyMind 's great work!

Optimized performance for builtin:swc-loader

builtin:swc-loader can now pass AST back to rspack core. Check out performance between legacy transforming and transforming with builtin:swc-loader

Support Compiler.compile()

We have implemented support for Compiler.compile to ensure smooth operation of ο»ΏchildCompiler

Support dynamicImportMode: "eager"

For runtime that does not support dynamically loading JavaScript chunks, module.parser.javascript.dynamicImportMode: "eager" is exactly what you're looking for.

What's Changed

Exciting New Features πŸŽ‰

  • feat: support reuse AST passed from builtin loaders by @h-a-n-a in #4367
  • feat: support passing query to loader by @h-a-n-a in #4418
  • feat: enable deprecation warnings by default by @h-a-n-a in #4247
  • feat: to support the monaco-editor-webpack-plugin by @SyMind in #4384
  • feat: support weak of import.meta.wabpackContext by @bvanjoi in #4466
  • feat: support Compiler.compile by @bvanjoi in #4499
  • feat: support module.parser.javascript.dynamicImportMode: "eager" by @bvanjoi in #4510
  • feat: replace top-level this in esm by @Austaras in #4497

Bug Fixes 🐞

Other Changes

New Contributors

Full Changelog: v0.3.8...v0.3.10