Core features
Loader compatibility
style-loader
+ css-loader
is now supported experimentally.
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: "style-loader",
options: {
esModule: false, // only `esModule: false` is supported right now.
},
},
"css-loader",
],
type: "javascript/auto",
},
],
},
};
thread-loader
(requires pitching loader) and eslint-loader
(can be used with enforce: 'pre'
) are also supported.
For more loader-compat examples, please visit example-loader-compat.
Inline loader
// Prefixing with ! will disable all configured normal loaders
require("!postcss-loader!less-loader!./style.less")
// Prefixing with !! will disable all configured loaders (preLoaders, loaders, postLoaders)
require("!!postcss-loader!less-loader!./style.less")
// Prefixing with -! will disable all configured preLoaders and loaders but not postLoaders
require("-!postcss-loader!less-loader!./style.less")
Pitching loader
module.exports = function() {}
module.exports.pitch = function (remainingRequest, previousRequest, data) {
if (someCondition) {
return `require("!!${remainingRequest}")`
}
};
What's Changed
Performance Improvements ⚡
- perf(rspack_core): reduce memory allocation when cloning RuntimeSpec by @Boshen in #2844
- perf: avoid
clone
while matchingimport.meta.webpackHot
by @hyf0 in #2857 - perf: bailout if possible and ignore AstNode of type in
ReactRefreshUsageFinder
by @hyf0 in #2875 - perf: compose loaders on the native side by @h-a-n-a in #2894
Exciting New Features 🎉
- feat: add chunkFormat & chunkLoading & enabledChunkLoadingTypes config by @underfin in #2792
- feat: impl new
loader-runner
for preparing to supportvue-loader
andpitching loader
by @h-a-n-a in #2789 - feat: support complex magical comment
import(/* webpackChunkName: "/dist/d/js_d" */ "./d")
by @suxin2017 in #2812 - feat: support
experiments.outputModule
by @underfin in #2803 - chore: 🤖 optimize code completion of config.target by @IWANABETHATGUY in #2826
- feat: support
npx rspack preview
by @faga295 in #2434 - feat: implement built-in
BannerPlugin
by @9aoy in #2819 - feat(hook): add
optimizeModules
hook by @nieyuyao in #2758 - feat: add ImportScriptsChunkLoadingPlugin by @underfin in #2839
- feat: support loader-runner and pitching by @h-a-n-a in #2808
- feat: support
Rule.enforce
by @h-a-n-a in #2862 - feat: chunk asset hook by @IWANABETHATGUY in #2603
- feat: support passing function to
externals
by @underfin in #2866 - feat: add moduleAssets for stats by @ahabhgk in #2864
- feat: support inline loader by @h-a-n-a in #2867
- feat: 🎸 compiler. getCache by @IWANABETHATGUY in #2892
- feat: require.resolve and require.resolveWeak for string literal by @ahabhgk in #2888
- feat: external module render with node-commonjs & module by @underfin in #2906
- feat(@rspack/core): add typings about
LoaderDefinition
by @Asuka109 in #2908 - feat: enable compression and cache with
noEmitAssets: true
by @hyf0 in #2907
Bug Fixes 🐞
- fix: preset env use unresolved_mark by @underfin in #2807
- fix: 🐛 fix ci a is undefined by @IWANABETHATGUY in #2810
- fix: error snap should be ordered by @IWANABETHATGUY in #2811
- fix: support magic comment
import( /* webpackChunkName: "/user/[id]/page" */ './foo')
containing[id]
by @GiveMe-A-Name in #2835 - fix: use webworker instead of web-worker in AvailableTarget type by @9aoy in #2834
- chore: bump resolver and fix resolve.alias with resource query by @Boshen in #2817
- fix: sourcemap lost when enable builtins.banner by @ahabhgk in #2858
- fix: undefined reasons with stats.toJson by @ahabhgk in #2859
- fix(resolve): return query and fragment when alias target had by @bvanjoi in #2869
- fix: remove
.d.ts
from the defaultresolve.extensions
by @lippzhang in #2861 - fix: react refresh runtime inject for nest function call by @underfin in #2874
- fix: optimize tree shaking swc/helpers by @IWANABETHATGUY in #2871
- fix(resolve): delay the directory check in exportsFieldPlugin by @bvanjoi in #2883
- fix: fix loader arguments by @h-a-n-a in #2898
- fix: HMR scanner should only visit dependencies related to HMR by @h-a-n-a in #2911
Other Changes
- ci: set fail-fast: false for matrix builds by @Boshen in #2796
- chore: 🤖 revert examples basic by @IWANABETHATGUY in #2799
- ci: only cache Rust builds on the main branch by @Boshen in #2798
- refactor: SplitChunksPlugin by @hyf0 in #2782
- chore: fix lock by @h-a-n-a in #2805
- test: webpack compatibility metric by @IWANABETHATGUY in #2745
- ci: fix fail-fast by @Boshen in #2809
- chore: 🤖 check node binding lock file by @IWANABETHATGUY in #2814
- ci: share rust target directory in check-rs by @Boshen in #2818
- chore: remove ./x and Makefile and replace them with npm scripts by @hyf0 in #2825
- chore: bump sugar_path to 0.0.12 by @Boshen in #2830
- ci: 🐛CI ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL by @IWANABETHATGUY in #2833
- chore: scripts should be ESM by default by @hyf0 in #2827
- ci: install pnpm in benchmark CI by @hyf0 in #2836
- test: webpack examples by @IWANABETHATGUY in #2793
- chore: 🤖 add common-check.yaml and fix ci by @IWANABETHATGUY in #2847
- chore: use
zx
to replace xtask by @hyf0 in #2840 - chore: 🤖 update benchmark link by @IWANABETHATGUY in #2848
- refactor:
crates/rspack_plugin_javascript/src/visitors/dependency/util.rs
by @hyf0 in #2865 - refactor(runtime): unwrap the function in ir by @bvanjoi in #2860
- refactor: align
starts_with
with the same semantics by @hyf0 in #2872 - refactor: Make
check_changeset.cjs
ESM and use ZX by @hyf0 in #2878 - chore: should exit if the exitCode is not zero at
check_changeset.js
by @hyf0 in #2880 - chore: fix peerDep of rspack-plugin-html by @hardfist in #2876
- chore: fix
make-threejs10x.js
script by @hyf0 in #2887 - chore: prettier example code by @hardfist in #2889
- chore: 🤖 bump napi retry by @IWANABETHATGUY in #2784
- chore: add more examples by @hardfist in #2896
New Contributors
- @GiveMe-A-Name made their first contribution in #2835
- @lippzhang made their first contribution in #2861
- @Asuka109 made their first contribution in #2908
Full Changelog: v0.1.8...v0.1.9