You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/en/config/module-rules.mdx
-56Lines changed: 0 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -754,7 +754,6 @@ type RuleSetLoaderWithOptions = {
754
754
ident?:string;
755
755
loader:string;
756
756
options?:string|Record<string, any>;
757
-
cache?:boolean;
758
757
parallel?:boolean| { maxWorkers?:number };
759
758
};
760
759
```
@@ -839,61 +838,6 @@ export default {
839
838
};
840
839
```
841
840
842
-
## rules[].use.cache
843
-
844
-
<ApiMetastability={Stability.Experimental} />
845
-
846
-
-**Type:**`boolean`
847
-
-**Default:**`false`
848
-
849
-
Enables caching for an individual loader. This option only takes effect when `experiments.newCache.loader` is enabled.
850
-
851
-
Rspack invalidates a loader cache entry when any of the following changes:
852
-
853
-
- the input content passed to the loader;
854
-
- the loader options after JSON serialization;
855
-
- the loader implementation identity. Rspack hashes the resolved entry file for JavaScript loaders and uses the declared cache version for native loaders;
856
-
- the Rspack version.
857
-
858
-
On a cache hit, Rspack restores the transformed content and source map without executing the loader again.
859
-
860
-
```js title="rspack.config.mjs"
861
-
exportdefault {
862
-
experiments: {
863
-
newCache: {
864
-
loader:true,
865
-
},
866
-
},
867
-
module: {
868
-
rules: [
869
-
{
870
-
test:/\.js$/,
871
-
use: [
872
-
{
873
-
loader:'./loaders/expensive-loader.js',
874
-
options: {
875
-
mode:'transform',
876
-
},
877
-
cache:true,
878
-
},
879
-
],
880
-
},
881
-
],
882
-
},
883
-
};
884
-
```
885
-
886
-
:::warning
887
-
888
-
This experimental cache is intended for pure loaders whose observable result is limited to transformed content and an optional source map.
889
-
890
-
- Dependencies added dynamically through the loader context are not included in cache validation and are not restored on a cache hit.
891
-
- Transitive files imported by a JavaScript loader and its package metadata are not included in the loader implementation fingerprint.
892
-
- Incoming source maps do not participate in cache validation. Only enable caching when the loader output does not depend on its input source map.
893
-
- Results involving unsupported state such as `additionalData` or parse metadata are not cached. Loader side effects are not replayed on a cache hit.
0 commit comments