Skip to content

Releases: web-infra-dev/rspack

v1.6.7

09 Dec 09:52

Choose a tag to compare

Highlights πŸ’‘

πŸŽ‰ Support for import.meta.filename, import.meta.dirname, and import.meta.resolve

Rspack now supports the import.meta.filename, import.meta.dirname, and import.meta.resolve meta properties in ESM modules.
These properties provide a standardized way to access file and directory paths in ES modules, similar to the CommonJS __filename and __dirname variables:

// Get the absolute path of the current module file
console.log(import.meta.filename);
// e.g., "/path/to/project/src/index.js"

// Get the directory path of the current module
console.log(import.meta.dirname);
// e.g., "/path/to/project/src"

// Resolve a module specifier to an absolute URL
const resolvedPath = import.meta.resolve('./utils.js');

Thanks to @magic-akari for this contribution!

What's Changed

New Features πŸŽ‰

  • feat: update resolver error messages to use colored output by @chenjiahan in #12348
  • feat: Support import.meta.filename/dirname/resolve by @magic-akari in #12317
  • feat: support [relative-resource-path] in moduleFilenameTemplate by @SyMind in #12370

Bug Fixes 🐞

Refactor πŸ”¨

Other Changes

Full Changelog: v1.6.6...v1.6.7

v1.6.6

02 Dec 08:53

Choose a tag to compare

Highlights πŸ’‘

Compact module factories

Rspack now generates a more compact module factory format that trims the wrapper function. Benchmarks show this reduces bundle size by about 1% before gzip.

image

What's Changed

Performance Improvements ⚑

New Features πŸŽ‰

  • feat: support shorthand function for module factory to reduce bundle size by @JSerFeng in #12226
  • feat(loader-runner): Allow limiting worker pool size for parallel loaders by @Pablinho in #12277
  • feat: do not render js output if ref module is only css source type by @JSerFeng in #12329
  • feat: supports async modules for EsmLibraryPlugin by @JSerFeng in #12338

Bug Fixes 🐞

  • fix(plugin): remove duplicated chunks in html scripts by @stormslowly in #12304
  • fix: should generate sri hash for chunks that only have concatenated modules by @LingyuCoder in #12310
  • fix: persistent cache watch context dependencies changes by @jerrykingxyz in #12309
  • fix: should set interop2_used to true if namespace import default-only by @JSerFeng in #12316
  • fix: check unused class names should check all conventions by @JSerFeng in #12336

Refactor πŸ”¨

Document Updates πŸ“–

Other Changes

  • chore: release v1.6.5 by @jerrykingxyz in #12278
  • chore(deps): update dependency @ast-grep/napi to ^0.40.0 by @renovate[bot] in #12290
  • chore(deps): update dependency @microsoft/api-extractor to v7.55.1 by @renovate[bot] in #12291
  • chore(deps): update patch npm dependencies by @renovate[bot] in #12289
  • chore(deps): update dependency @microsoft/api-extractor-model to v7.32.1 by @renovate[bot] in #12292
  • chore: add import_meta_property_in_destructuring parser hook by @LingyuCoder in #12255
  • chore(workflow): update node version to 22 in ci and nvm configuration by @chenjiahan in #12320
  • chore: add Rsdoctor diff action by @yifancong in #12264
  • test: bump rstest to show relevant running tests by @9aoy in #12323
  • ci: add ecosystem CI based on rstack-ecosystem-ci by @fi3ework in #12318
  • ci(ecosystem): do not need to clone ecosystem ci repo to sub folder by @fi3ework in #12339
  • chore(CI): replace the rspack diff demos by @yifancong in #12337

New Contributors

Full Changelog: v1.6.5...v1.6.6

v1.6.5

25 Nov 09:11

Choose a tag to compare

What's Changed

New Features πŸŽ‰

Bug Fixes 🐞

Refactor πŸ”¨

  • refactor: processing more string concatenation in runtime template part 2 by @LingyuCoder in #12235
  • refactor: rename webpack imported vars to rspack format by @chenjiahan in #12245
  • refactor: rename webpack external vars to rspack format by @chenjiahan in #12249
  • refactor: rename webpack default export var to rspack format by @chenjiahan in #12257
  • refactor: rename webpack reexport vars to Rspack format by @chenjiahan in #12263
  • refactor: use chunk id as the placeholder when calculating content-hash by @JSerFeng in #12271
  • refactor: render runtime globals by runtime template by @LingyuCoder in #12272

Document Updates πŸ“–

Other Changes

Full Changelog: v1.6.4...v1.6.5

v1.6.4

18 Nov 11:13
54dd4bb

Choose a tag to compare

What's Changed

New Features πŸŽ‰

  • feat: support arrow function in on_chunks_loaded callback by @chenjiahan in #12193
  • feat(rslib): handle hashbang / react directives natively by @fi3ework in #12168

Bug Fixes 🐞

Refactor πŸ”¨

  • refactor: move code splitting cache into artifact by @hardfist in #12164
  • refactor: split make phase by @hardfist in #12186
  • refactor: split module_graph into ModuleGraphRef and ModuleGraphMut by @hardfist in #12199
  • refactor: processing more string concatenation in runtime template part 1 by @LingyuCoder in #12225

Document Updates πŸ“–

Other Changes

Full Changelog: v1.6.3...v1.6.4

v1.6.3

13 Nov 07:31

Choose a tag to compare

What's Changed

New Features πŸŽ‰

  • feat: export ErrorData from rspack_error crate by @ityuany in #12166

Bug Fixes 🐞

Document Updates πŸ“–

  • docs(split-chunks): update module federation compatibility note by @chenjiahan in #12178

Other Changes

Full Changelog: v1.6.2...v1.6.3

v1.6.2

12 Nov 14:09

Choose a tag to compare

What's Changed

Performance Improvements ⚑

New Features πŸŽ‰

Bug Fixes 🐞

Refactor πŸ”¨

Other Changes

Full Changelog: v1.6.1...v1.6.2

v1.6.1

05 Nov 12:00
874e9fd

Choose a tag to compare

What's Changed

Highlights πŸ’‘

In Rspack 1.6.1, the source map implementation in the rspack-sources crate has been optimized, improving source map generation performance by roughly 30%.

image

Performance Improvements ⚑

Bug Fixes 🐞

Refactor πŸ”¨

  • refactor: import external should not create needless external module by @JSerFeng in #12064

Document Updates πŸ“–

  • docs: add 1.6.0 release blog by @JSerFeng in #12019
  • docs: improve English clarity in documentation by @Copilot in #12060
  • docs: move deprecated experimental options to the bottom by @chenjiahan in #12049
  • docs(quick-start): update non-interactive mode section by @chenjiahan in #12083

Other Changes

Full Changelog: v1.6.0...v1.6.1

v1.6.0

30 Oct 11:05

Choose a tag to compare

πŸŽ‰ See Announcing Rspack 1.6 for more details.

What's Changed

Performance Improvements ⚑

New Features πŸŽ‰

Bug Fixes 🐞

  • fix(loader-runner): add missing break statements in switch cases by @chenjiahan in #11794
  • fix: revert "fix: remove serde feature of lightningcss (#11706)" by @colinaaa in #11796
  • fix: correct stats.color type to include fine-grained options by @chenjiahan in #11797
  • fix: export interop default symbol and ensure import required chunks by @JSerFeng in #11793
  • fix: should re-export real exportInfo when export dynamic js by @JSerFeng in #11776
  • fix: should process runtime chunk after normal chunks of same chunk group by @LingyuCoder in #11778
  • fix: should use external source as name hint by @JSerFeng in #11825
  • fix(swc_plugin_import): fix panic and optimize diagnostic logs by @chenjiahan in #11862
  • fix: distinguish external modules when there are import attributes by @fi3ework in #11845
  • fix: should render default exports for cjs entry and json entry by @JSerFeng in #11860
  • fix: should export from entry chunk for cjs reexport default by @JSerFeng in #11884
  • fix: should not cache dependency instance in DynamicEntryPlugin by @SyMind in #11888
  • fix: updated dependencies sync to persistent cache by @jerrykingxyz in #11910
  • fix: no need to create compiler instance when closing compiler by @chenjiahan in #11923
  • fix: should allow override can_inline_use in flag dependency usage plugin by @ahabhgk in #11934
  • fix: perf regression caused by is_deferred by @ahabhgk in #11944
  • fix(create-rspack): polish README and configurations by @chenjiahan in #11953
  • fix(mf): federation modules plugin hooks leak by @quininer in #11929
  • fix(swcLoader): should correctly generate the default value of env_na… by @Zeahan in #11906
  • fix(types): add createReadStream to OutputFileSystem interface by @chenjiahan in #11963
  • fix: improve type safety for MultiStats options by @chenjiahan in #11964
  • fix: should support entries() for compilation.chunks by @SyMind in #11971
  • fix: esm output chunk module missing load dependent chunks by @stormslowly in #11945
  • fix: inline value for multiple runtime by @ahabhgk in #11983
  • fix: unknown defined properties for exported enum by @ahabhgk in #11992
  • fix: compilation.*_dep.added should not contains updated files by @jerrykingxyz in #11991
  • fix: side effects optimize panic when remove lib file by @jerrykingxyz in #11939
  • fix: should only top-level require wrapped modules for import side-effect specifier by @JSerFeng in #11997
  • fix: use asset resource module as entry by @LingyuCoder in #11993
  • fix: Remove some unnecessary unsafe by @quininer in #12006
  • fix: type definitions for devtool module filename templates by @chenjiahan in #12013
  • fix: incremental wrong provided exports results caused panic when delete module by @ahabhgk in #12009
  • fix: rayon iterator.consume will block in WASM by @jerrykingxyz in #12022
  • fix: calculate side effects of call exprs in seq expr by @LingyuCoder in #12017
  • fix: should remove related correctly in compilation.updateAsset by @LingyuCoder in #12031
  • fix: should resplace resource query in context replacement plugin by @LingyuCoder in #12033
  • fix(wasm): add another SharedArrayBuffer instance check by @CPunisher in #12037

Refactor πŸ”¨

  • refactor: update type definitions to fix Rslint issues by @chenjiahan in #11798
  • refactor: remove experiments.layers by @JSerFeng in #11819
  • refactor: output.charset false by default by @JSerFeng in #11837
  • refactor: make artifact collect affected dependencies by @jerrykingxyz in #11905
  • refactor: clean up default stats plugins by @chenjiahan in #11904
  • refactor: consolidate ModuleError and ModuleWarning classes by @chenjiahan in #11935
  • refactor(watcher): split watcher from rspack_fs by @h-a-n-a in #11948
  • refactor(core): Convert BoxModule from type alias to newtype struct by @kdy1 in http...
Read more

v1.6.0-beta.1

22 Oct 08:44

Choose a tag to compare

What's Changed

Highlights πŸ’‘

EsmLibraryPlugin supports preserveModules

EsmLibraryPlugin now provides experimental support for the preserveModules feature. This allows you to maintain your source code structure as is while bundling all libraries within the node_modules folder. You can try it out using the following configuration example:

Feel free to copy and use it!

import { rspack } from "@rspack/core";
import path from 'node:path'

export default{
  entry: "./index.js",
  output: {
    chunkFormat: false,  // required, EsmLibraryPlugin handles how chunk renders 
    chunkLoading: 'import',  // required, using es module dynamic import syntax to load other chunks
  },
  optimization: {
    runtimeChunk: true,  // recommended if you have async chunks
    concatenateModules: false,  // required, EsmLibraryPlugin handles scope hoisting
  },
  plugins: [
    new rspack.experiments.EsmLibraryPlugin({
      preserveModules: path.resolve(__dirname, './src')
    })
  ],
};

Experimental supports for defer import

Rspack now supports defer import, you can enable it by experiments.deferImport = true. It is worth noting that we currently only support import defer, import.defer() will be implemented in the near future.

export default {
  experiments: {
    deferImport: true
  }
}

Performance Improvements ⚑

New Features πŸŽ‰

Bug Fixes 🐞

  • fix: should export from entry chunk for cjs reexport default by @JSerFeng in #11884
  • fix: should not cache dependency instance in DynamicEntryPlugin by @SyMind in #11888
  • fix: updated dependencies sync to persistent cache by @jerrykingxyz in #11910
  • fix: no need to create compiler instance when closing compiler by @chenjiahan in #11923
  • fix: should allow override can_inline_use in flag dependency usage plugin by @ahabhgk in #11934
  • fix: perf regression caused by is_deferred by @ahabhgk in #11944

Refactor πŸ”¨

Document Updates πŸ“–

Other Changes

New Contributors

Full Changelog: v1.6.0-beta.0...v1.6.0-beta.1

v1.6.0-beta.0

15 Oct 07:46
0a101e2

Choose a tag to compare

πŸ§ͺ Enhanced ESM library output (experimental)

Rspack now provides a new ESM library output that is cleaner, statically analyzable, and supports custom chunk splitting.

This new output format is fully independent of the existing chunk loading logic β€” each chunk can be used in isolation, and all exports are placed at the top level instead of being wrapped inside the __webpack_modules__ closure.

  • Before:
exports.modules = { 
  "src/async-module.js": function(exports) {
    __webpack_require__.d(exports, {
      foo: () => foo
    })
    const foo = 42
  }
}
  • After:
// src/async-module.js
const foo = 42

export { foo }

If you'd like to try this now, follow this example:

import { rspack } from "@rspack/core";

export default{
  entry: "./index.js",
  output: {
    chunkFormat: false,  // required, EsmLibraryPlugin handles how chunk renders 
    chunkLoading: 'import',  // required, using es module dynamic import syntax to load other chunks
  },
  optimization: {
    runtimeChunk: true,  // recommended if you have async chunks
    concatenateModules: false,  // required, EsmLibraryPlugin handles scope hoisting
  },
  plugins: [new rspack.experiments.EsmLibraryPlugin()],
};

We'll make this out-of-box in Rslib soon.

See EsmLibraryPlugin for more.

🎯 Layers is now stable

The layer feature is now enabled by default - you no longer need to enable it manually using the experiments.layer option.

Layers is a feature that helps you group certain modules and their dependencies, allowing you to bundle them using different transforms.

For example, you can generate both ES5 and ES2015 outputs in one compilation by assigning different layers to different entries with the following configuration:

export default {
  entry: {
    legacy: {
      import: "./index.js",
      layer: "es5",
    },
    modern: {
      import: "./index.js",
      layer: "es6",
    },
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        oneOf: [
          {
            issuerLayer: "es5",
            use: [
              {
                loader: "builtin:swc-loader",
                options: {
                  jsc: {
                    target: "es5",
                    // ...
                  },
                },
              },
            ],
          },
          {
            issuerLayer: "es6",
            use: [
              {
                loader: "builtin:swc-loader",
                options: {
                  jsc: {
                    target: "es2015",
                    // ...
                  },
                },
              },
            ]
          },
        ],
      },
    ],
  },
};

πŸ“„ Extract existing source maps

Rspack now supports extracting existing source map data from files (from their //# sourceMappingURL comment) via Rule.extractSourceMap. This feature is particularly useful for preserving source maps provided by third-party libraries, ensuring that debugging information remains accurate even when those libraries are bundled or transformed.

It was originally introduced in webpack v5.102.0
as a built-in replacement for the source-map-loader plugin, offering better performance and tighter integration with the build process.

export default {
  // ...
  module: {
    rules: [
      {
        test: /\.m?js$/,
        extractSourceMap: true,
      },
    ],
  },
};

βœ… Lazy barrel enabled by default

Since Rspack v1.5 introduced experimental barrel file optimization, it has been enabled by default in Rsbuild to collect early feedback.

After extensive usage and validation within Rsbuild, we now consider lazyBarrel stable, and it is enabled by default in Rspack as well.

What's Changed

Performance Improvements ⚑

  • perf(browser): minor performance optimization for @rspack/browser by @CPunisher in #11795
  • perf(swc_plugin_import): replace handlebars with custom template engine by @chenjiahan in #11852

New Features πŸŽ‰

Bug Fixes 🐞

  • fix(loader-runner): add missing break statements in switch cases by @chenjiahan in #11794
  • fix: revert "fix: remove serde feature of lightningcss (#11706)" by @colinaaa in #11796
  • fix: correct stats.color type to include fine-grained options by @chenjiahan in #11797
  • fix: export interop default symbol and ensure import required chunks by @JSerFeng in #11793
  • fix: should re-export real exportInfo when export dynamic js by @JSerFeng in #11776
  • fix: should process runtime chunk after normal chunks of same chunk group by @LingyuCoder in #11778
  • fix: should use external source as name hint by @JSerFeng in #11825
  • fix(swc_plugin_import): fix panic and optimize diagnostic logs by @chenjiahan in #11862
  • fix: distinguish external modules when there are import attributes by @fi3ework in #11845
  • fix: should render default exports for cjs entry and json entry by @JSerFeng in #11860

Refactor πŸ”¨

Document Updates πŸ“–

  • docs: improve documentation for stats properties by @chenjiahan in #11792
  • docs: explain how resolve.alias affects package resolution by @SyMind in #11799
  • docs(browser): add usage of useInputFileSystem to "In-Memory File system" section by @CPunisher in #11833
  • docs(browser): Add compatibility with resolve.alias description for BrowserHttpImportEsmPlugin by @CPunisher in #11838

Other Changes

Read more