Skip to content

Commit 12bde9b

Browse files
committed
docs(loader): remove loader cache documentation
1 parent 5d3570e commit 12bde9b

2 files changed

Lines changed: 0 additions & 112 deletions

File tree

website/docs/en/config/module-rules.mdx

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ type RuleSetLoaderWithOptions = {
754754
ident?: string;
755755
loader: string;
756756
options?: string | Record<string, any>;
757-
cache?: boolean;
758757
parallel?: boolean | { maxWorkers?: number };
759758
};
760759
```
@@ -839,61 +838,6 @@ export default {
839838
};
840839
```
841840

842-
## rules[].use.cache
843-
844-
<ApiMeta stability={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-
export default {
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.
894-
895-
:::
896-
897841
## rules[].use.parallel
898842

899843
<ApiMeta addedVersion="1.3.1" />

website/docs/zh/config/module-rules.mdx

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@ type RuleSetLoaderWithOptions = {
753753
ident?: string;
754754
loader: string;
755755
options?: string | Record<string, any>;
756-
cache?: boolean;
757756
parallel?: boolean | { maxWorkers?: number };
758757
};
759758
```
@@ -837,61 +836,6 @@ export default {
837836
};
838837
```
839838

840-
## rules[].use.cache
841-
842-
<ApiMeta stability={Stability.Experimental} />
843-
844-
- **类型:** `boolean`
845-
- **默认值:** `false`
846-
847-
为单个 loader 启用缓存。该选项仅在启用 `experiments.newCache.loader` 时生效。
848-
849-
以下任一内容变化时,Rspack 会使对应的 loader 缓存失效:
850-
851-
- 传给 loader 的输入内容;
852-
- JSON 序列化后的 loader options;
853-
- loader 实现标识。对于 JavaScript loader,Rspack 会计算解析后入口文件的哈希;对于 native loader,Rspack 使用其声明的缓存版本;
854-
- Rspack 版本。
855-
856-
缓存命中时,Rspack 会直接恢复转换后的内容和 source map,不再执行 loader。
857-
858-
```js title="rspack.config.mjs"
859-
export default {
860-
experiments: {
861-
newCache: {
862-
loader: true,
863-
},
864-
},
865-
module: {
866-
rules: [
867-
{
868-
test: /\.js$/,
869-
use: [
870-
{
871-
loader: './loaders/expensive-loader.js',
872-
options: {
873-
mode: 'transform',
874-
},
875-
cache: true,
876-
},
877-
],
878-
},
879-
],
880-
},
881-
};
882-
```
883-
884-
:::warning
885-
886-
该实验性缓存适用于可观测结果仅包含转换后内容和可选 source map 的纯 loader。
887-
888-
- 通过 loader context 动态添加的依赖不会参与缓存校验,缓存命中时也不会恢复这些依赖。
889-
- JavaScript loader 间接导入的文件及其包元数据不会参与 loader 实现指纹的计算。
890-
- 输入 source map 不参与缓存校验。仅当 loader 输出不依赖输入 source map 时才应启用缓存。
891-
- 涉及 `additionalData`、parse metadata 等暂不支持状态的结果不会被缓存。缓存命中时也不会重放 loader 的副作用。
892-
893-
:::
894-
895839
## rules[].use.parallel
896840

897841
<ApiMeta addedVersion="1.3.1" />

0 commit comments

Comments
 (0)