Highlights π‘
Support for persistent cache
Rspack v1.2 introduced an experimental cache configuration that supports persistent caching, which can significantly improve hot startup speed.
When a build hits the cache, it can bring up to 60% performance improvement in real projects.
// rspack.config.js
module.exports = {
cache: true,
experiments: {
cache: {
type: 'persistent',
},
},
};
Note that the persistent cache is still in an early experimental stage and there is a lot of room for performance improvement.
No longer watching node_modules
Rspack v1.2 no longer watching the node_modules
directory by default. This can greatly reduce the number of files to watch and improve performance.
According to our benchmark repo, this change will:
- Reduce memory usage by 120MB.
- Increase dev startup speed by 40%.
- Increase HMR speed by 20~30%.
This change will not affect symlinked resources in monorepo, as symlinked resources are resolved to their real path by default.
Related PR: perf: ignore watching files in node_modules by @chenjiahan in #8645
Upgrade to SWC 9.0
The Rust crate swc_core
has been upgraded to 9.0.2
. Users of the SWC Wasm plugin need to ensure version consistency with the swc_core
being used, otherwise, it may lead to unforeseen issues.
For more details, see SWC Plugin Version Unmatched.
Related PR: feat(core)!: bump swc_core to 9.0.0 by @andersk in #8639
Reduced memory usage
We have optimized the data structure used to store strings during the rspack-sources
computation process. Throughout the computation, all string data points to the string heap memory of the root node, effectively avoiding the generation of new string allocations during the computation.
Related PR: perf: reduce memory consumption of CachedSource by @h-a-n-a in #8666
Reduced bundle size
Rspack v1.2.0 set default SWC minimizer passes
to 2 to reduce bundle size by 1%-7%.
passes
is the the maximum number of times to run compress. In some cases, more than one pass leads to further compressed code. Given Rspack's inherent speed, we've determined that using 2 passes
by default strikes an optimal balance between build performance and bundle size.
Related PR: feat: set default SWC minimizer passes to
2
to reduce bundle size by @chenjiahan in #8853
Parallelize side effects optimization
The implementation of side effects optimization has been refactored to be simpler and more parallelism-friendly. It can take full advantage of parallelism to improve performance. In tested projects, there is typically a 2x-3x performance improvement at this stage.
Related PR: perf: parallelize side effects optimization by @ahabhgk in #8781
Disable WarnCaseSensitiveModulesPlugin by default
The WarnCaseSensitiveModulesPlugin will check the paths of modules and issue warnings for modules that conflict when their paths are all in lowercase. We used to enable it by default, but since it is only a "linter" plugin and it has additional performance overhead especially in development mode. So now we disable it by default, and recommend to use WarnCaseSensitiveModulesPlugin
to add it to your own needs.
// rspack.config.js
module.exports = {
plugins: [new rspack.WarnCaseSensitiveModulesPlugin()],
};
Related PR: feat: export
WarnCaseSensitiveModulesPlugin
and disable it by default by @ahabhgk in #8697
What's Changed
Performance Improvements β‘
- perf: remove tokio-console to reduce binary size by @chenjiahan in #8681
- perf: bump miette v7 to reduce binary size by @chenjiahan in #8694
- perf(incremental): compute affected cgm incrementally by @ahabhgk in #8688
- perf: reduce memory consumption of
CachedSource
by @h-a-n-a in #8666 - perf: faster
substring
ofrspack-sources
by @h-a-n-a in #8731 - perf: side effects when there aren't too many optimizable dependencies by @ahabhgk in #8746
- perf: parallelize side effects optimization by @ahabhgk in #8781
- perf(deps): bump
fast-glob
to v0.4.1 by @shulaoda in #8800 - perf: improve FlagDependencyExportsPlugin for large JSON by depth by @hai-x in #8802
- perf(incremental): better parallel for side effects plugin rebuild by @ahabhgk in #8848
- perf(cli): remove Node.js semver checker by @chenjiahan in #8855
- perf(cli): lazy import rechoir and interpret by @chenjiahan in #8856
Exciting New Features π
- feat: pass compiler_path to rust Compiler by @jerrykingxyz in #8665
- feat: cache storage by @LingyuCoder in #8466
- feat(incremental): named chunk ids by @ahabhgk in #8652
- feat: support additional-pass hook by @SyMind in #8672
- feat: improve cache storage by @LingyuCoder in #8675
- feat: exports info binding API by @SyMind in #8677
- feat: chunkGraph.getModuleId binding API by @SyMind in #8680
- feat: persistent cache by @jerrykingxyz in #8687
- feat: support
size
option for optimization.chunkIds config by @inottn in #8642 - feat: do not cleanup Rust instance by @h-a-n-a in #8702
- feat: export
WarnCaseSensitiveModulesPlugin
and disable it by default by @ahabhgk in #8697 - feat: cache storage move lock file by @LingyuCoder in #8686
- feat: addInclude binding API by @SyMind in #8713
- feat: update experiments.cache signature by @jerrykingxyz in #8729
- feat(mf): bump @module-federation/runtime-tools to 0.8.4 by @chenjiahan in #8728
- feat!: align AssetGeneratorDataUrlFunction with webpack by @inottn in #8614
- feat: support module.generator.outputPath by @inottn in #8554
- feat: add macro to get rspack version by @jerrykingxyz in #8760
- feat: persistent cache expose error to compilation.diagnostic by @jerrykingxyz in #8765
- feat: persistent cache in production mode wait for save to complete by @jerrykingxyz in #8777
- feat: split big chunks based on modules path similarities by @JSerFeng in #8775
- feat: add help message for version check by @h-a-n-a in #8774
- feat: splitChunks.cacheGroups.filename supports function by @JSerFeng in #8779
- feat: bench js api by codspeed by @SyMind in #8808
- feat: support module graph connection js api by @SyMind in #8812
- feat: support
match_when_empty
for rule condition by @CPunisher in #8809 - feat: add context info issuer layer for external function by @ahabhgk in #8832
- feat: add new optimization.avoidEntryIife config by @fi3ework in #8814
- feat(incremental): side effects optimization by @ahabhgk in #8799
- feat: initialize compiler options builder by @h-a-n-a in #8857
- feat(storage): improve storage memory by @LingyuCoder in #8847
Bug Fixes π
- fix: external module move out initial chunk by @SyMind in #8644
- fix: escape css by @JSerFeng in #8698
- fix: the wrong filename was passed when calling the assetEmitted hook by @inottn in #8709
- fix: module concatenation for dynamic export info by @ahabhgk in #8730
- fix: duplicate move lock files by @LingyuCoder in #8732
- fix: fix nightly release compare-before-emit-disable test failed by @jerrykingxyz in #8739
- fix: mf parse range not compat with safari by @ahabhgk in #8749
- fix: incremental rebuild are compatible with empty artifact by @jerrykingxyz in #8758
- fix: correct type for
loaderContext.importModule
by @chenjiahan in #8766 - fix: allow empty persistent cache options by @h-a-n-a in #8813
- fix: use cgm hash to verify rename inline modules cache by @ahabhgk in #8820
- fix: Rspack cssParser will parse failed when url(' ') by @cbbfcd in #8824
- fix(diagnostic): improve diagnostics for swc wasm plugins when mismatch by @SyMind in #8001
- fix!: handle glob patterns ending with /** in CopyRspackPlugin by @inottn in #8803
- fix(exernals): add hash to distinguish conflict id by @fi3ework in #8834
- fix: importModule should receive error correctly by @JSerFeng in #8827
- fix(rspack-test-tools): use
process.cwd()
when outside Rspack by @colinaaa in #8845 - fix(incremental): build chunk graph with runtime chunk true by @ahabhgk in #8866
- fix: persistent cache save ModuleArgumentDependency.id by @jerrykingxyz in #8870
- fix(incremental): activate inactive module not codegen by @ahabhgk in #8871
- fix: should recognize negative preload value by @JSerFeng in #8862
- fix: correct css modules hashing to match Webpack when leading digit #8735 by @daveskybet in #8778
- fix: rspack_version macro support match alpha version by @jerrykingxyz in #8880
Document Updates π
- docs: invite @GiveMe-A-Name @nyqykk to Rspack core team by @chenjiahan in #8684
- docs: clarify support for JavaScriptModulesPlugin as partial by @steverep in #8678
- docs: fix webpack plugins overview docs panic for zh lang by @SyMind in #8689
- docs: fix link for bundle size link in English locale by @31piy in #8692
- docs: improve
resolve.mainFields
by @chenjiahan in #8703 - docs: React Compiler for React 17 and 18 by @chenjiahan in #8708
- docs: persistent cache by @jerrykingxyz in #8725
- docs: rewrite
SwcJsMinimizerRspackPlugin
by @chenjiahan in #8745 - docs: add
loaderContext.importModule()
by @chenjiahan in #8821 - docs: update output.clean type declaration by @cbbfcd in #8826
- docs: add FAQ for SWC plugin version unmatched by @chenjiahan in #8829
- docs: add Google and DeepSeek to who is using by @chenjiahan in #8865
- docs: make LoaderContext documentation more friendly by @chenjiahan in #8869
Other Changes
- chore(deps): update cargo-bins/cargo-binstall action to v1.10.16 by @renovate in #8656
- chore(deps): update dependency prettier to v3.4.2 by @renovate in #8660
- chore(deps): update pnpm to v9.15.0 by @renovate in #8662
- chore(workflow): set Issue types by @chenjiahan in #8663
- chore(deps): update dependency @rspack/dev-server to v1.0.10 by @renovate in #8659
- refactor: chunk graph binding API by @SyMind in #8648
- refactor: simplify file system code by @nilptr in #8654
- chore: update API change by @h-a-n-a in #8700
- chore(deps): bump textwrap 0.16 for deduplication by @chenjiahan in #8699
- refactor: unify the logic of
span_to_location
into traitSourcePosition
by @shulaoda in #8640 - chore: upgrade Rust to 1.83.0 nightly by @andersk in #8712
- chore(renovate): Enable lockFileMaintenance by @andersk in #8715
- chore(deps): update rspress to v1.38.0 by @renovate in #8719
- chore(deps): update dependency mermaid to v11 by @renovate in #8720
- revert: Revert "chore: sanitize file paths" by @h-a-n-a in #8721
- chore(deps): update dependency check-dependency-version-consistency to v5 by @renovate in #8718
- chore(deps): update dependency is-ci to v4 by @renovate in #8723
- chore(ci): only trim-paths on release and enable renovate update Cargo.lock by @h-a-n-a in #8722
- chore(deps): update rust crate rspack_resolver to 0.3.6 by @renovate in #8717
- chore(deps): update rust crate napi to 3.0.0-alpha.23 by @renovate in #8661
- chore(deps): update dependency rimraf to v5 by @renovate in #8727
- chore(deps): remove dependency internal-ip by @renovate in #8733
- chore(deps): remove dependency mkdirp by @renovate in #8734
- chore(deps): update dependency glob to v11 by @renovate in #8738
- chore(deps): update typescript and @microsoft/api-extractor by @renovate in #8737
- chore(deps): stop updating inventory with renovate ci by @h-a-n-a in #8742
- chore(deps): update crates by @renovate in #8657
- ci: linux-musl build failed by @jerrykingxyz in #8743
- ci: build linux debug binary directly for CI purpose to speedup PR check by @xc2 in #7243
- ci: should skip trim paths for doc changes by @chenjiahan in #8750
- chore(deps): update github-actions by @renovate in #8752
- refactor: improve storage error message by @LingyuCoder in #8740
- refactor: merge binding crates into
rspack_binding_values
by @h-a-n-a in #8761 - ci: use ubuntu-22.04 by @h-a-n-a in #8776
- chore: remove all unnecessary workflow by @hardfist in #8783
- chore: remove issue_comment trigger from CI by @chenjiahan in #8784
- ci: remove useless variable in release-pull-request.yml by @jerrykingxyz in #8787
- refactor: remove as much
getRawOptions
as possible by @h-a-n-a in #8773 - chore(deps): update napi by @renovate in #8771
- chore(napi/build): disable dts cache of napi build by @h-a-n-a in #8795
- ci: disable pkg preview by @LingyuCoder in #8794
- ci: disable miri, eco-ci and benchmark check by @LingyuCoder in #8797
- ci: add security pr type by @LingyuCoder in #8796
- ci: add @GiveMe-A-Name to team label by @LingyuCoder in #8810
- build: remove no-dts-cache by @h-a-n-a in #8819
- chore: split canary to separate scope by @hardfist in #8828
- chore(deps): update crates by @renovate in #8840
- chore(deps): update pnpm to v9.15.1 by @renovate in #8841
- chore: remove unnecessary TODOs by @shulaoda in #8850
- chore(deps): update rspress to v1.39.2 by @renovate in #8842
- style: use inlined args for
format!
by @hamirmahal in #8228 - chore: ignore style changes in git blame #8228 by @h-a-n-a in #8852
- test: add cache test cases by @jerrykingxyz in #8854
- chore(deps): bump Rslib to v0.2.2 by @chenjiahan in #8859
- test: split incremental test cases to run in parallel by @LingyuCoder in #8860
- chore(deps): update crates by @renovate in #8858
- test: refresh modified file mtime when run NEXT_START by @jerrykingxyz in #8863
- chore(deps): upgrade miette 7.2.0 to 7.4.0 by @andersk in #8864
- chore(deps): lock file maintenance by @renovate in #8805
- ci: add ecosystem benchmark by @jerrykingxyz in #8868
- chore: update version to match the latest release by @chenjiahan in #8872
- chore(deps): Upgrade @types/node 20.12.7 to 20.17.10 by @andersk in #8867
- chore: add profile choice for release canary by @hardfist in #8874
- chore(deps): update dependency css-loader to v7 by @renovate in #8024
- chore: change input_filesystem to ReadableFileSystem by @hardfist in #8878
- test: easier way to write hmr test cases by @LingyuCoder in #8849
New Contributors
- @steverep made their first contribution in #8678
- @31piy made their first contribution in #8692
- @hamirmahal made their first contribution in #8228
- @daveskybet made their first contribution in #8778
Full Changelog: v1.1.8...v1.2.0-alpha.0