Highlights 💡
Import Attributes
Rspack now supports Import Attributes by defaults:
import json from "./foo.json" with { type: "json" };
import("foo.json", { with: { type: "json" } });
PR: #7333
Layers
Rspack now supports module and chunk layers. This feature can be used by frameworks like Rsnext (The Rspack-based Next.js) to implement React Server Components.
- Example: build modern and legacy bundles at the same time:
export default {
entry: {
index: {
import: './src/index.js',
layer: 'modern',
},
'index-legacy': {
import: './src/index.js',
layer: 'legacy',
},
},
module: {
rules: [
{
test: /\.js$/,
issuerLayer: 'modern',
use: [
{
loader: 'builtin:swc-loader',
options: {
env: {
targets: 'Chrome >= 87',
},
},
},
],
},
{
test: /\.js$/,
issuerLayer: 'legacy',
use: [
{
loader: 'builtin:swc-loader',
options: {
env: {
targets: 'ie >= 11',
},
},
},
],
},
],
},
experiments: {
layers: true,
},
};
- Example: Customize rules and resolve options for RSC modules
export default {
module: {
rules: [
// set `layer` for some modules
{
test: /rsc-modules/,
layer: 'rsc',
},
// set resolve options for specified layer
{
issuerLayer: 'rsc',
resolve: {
conditionNames: ['react-server', '...'],
},
},
{
// set loaders for specified layer
oneOf: [
{
issuerLayer: 'rsc',
test: /\.tsx?$/,
use: ['some-rsc-loader'],
},
{
test: /\.tsx?$/,
use: ['some-normal-loader'],
},
],
},
],
},
experiments: {
layers: true,
},
};
PR: #7330
What's Changed
Performance Improvements ⚡
- perf: no need to require entire enhanced-resolve by @chenjiahan in #7343
- perf(allocator): use mimalloc v2 for all by @h-a-n-a in #7361
Exciting New Features 🎉
- feat: experiments layers by @ahabhgk in #7330
- feat(css-extract): avoid reloading all CSS when hot load by @shulaoda in #7314
- feat(modern-module): force concaten single module by @fi3ework in #7317
- feat: better diagnostic report for harmony dependency by @shulaoda in #7337
- feat: support
parser.importMeta
andoutput.importMetaName
by @xc2 in #7231
Bug Fixes 🐞
- fix: lightningcss-loader targets array not work as expected by @chenjiahan in #7331
- fix(rspack_plugin_asset): repect user environment config when inlining svg by @SoonIter in #7347
- fix: rspack errors don't support the correct location by @shulaoda in #7328
- fix: add runtime condition for harmony reexport checked by @ahabhgk in #7353
- fix: remove nonsensical intersection types by @colinaaa in #7360
- fix: builtin:lightningcss-loader shuold keep loader query by @JSerFeng in #7363
Document Updates 📖
- docs(devServer): update webpack-dev-server v5 by @SoonIter in #7319
- docs(blog): correcting the description of decorator configuration in v0.4 by @Mumujianguang in #7320
- docs: add compilation object by @LingyuCoder in #7321
- docs: add
serwist
in community compatibility table by @JoseVSeb in #7345 - docs: include types from common mdx chunks by @LingyuCoder in #7323
- docs: enable prettier for types in website by @Timeless0911 in #7350
- docs: import antd on demand by @Timeless0911 in #7351
- docs: bad symbol in compilation-hooks.mdx by @h-a-n-a in #7352
- docs: improve CssExtractRspackPlugin by @chenjiahan in #7362
- docs: add Logger API by @LingyuCoder in #7365
Other Changes
- chore: add funding page by @hardfist in #7318
- chore(deps): crates update by @SoonIter in #7342
- refactor(typescript): packages/rspack/src/lib from js to ts and esm by @shulaoda in #7289
- chore(infra/biome): switch the biome.jsonc to "off" by @SoonIter in #7357
- refactor: remove module graph accessor by @ahabhgk in #7368
- chore(webpack-test): remove unnecessary snapshots by @shulaoda in #7329
New Contributors
- @Mumujianguang made their first contribution in #7320
- @JoseVSeb made their first contribution in #7345
Full Changelog: v1.0.0-beta.0...v1.0.0-beta.1