Skip to content

Commit 65b7ef6

Browse files
authored
fix: remove last builtin:swc-loader warning for collecting ts info (#11079)
1 parent 91dc2db commit 65b7ef6

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

crates/rspack_loader_swc/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,6 @@ impl SwcLoader {
113113
else {
114114
return;
115115
};
116-
if loader_context.loader_index != 0 {
117-
loader_context.emit_diagnostic(
118-
miette::miette! {
119-
severity = miette::Severity::Warning,
120-
"To ensure the accuracy of the collected TypeScript information, `rspackExperiments.collectTypeScriptInfo` can only be used when `builtin:swc-loader` is employed as the last normal loader. For now `rspackExperiments.collectTypeScriptInfo` is overridden to disabled. If you want to suppress this warning, either turn off `rspackExperiments.collectTypeScriptInfo` in the configuration or place `builtin:swc-loader` as the first element in the `use` array.\nLoaders: {}\nLoader index: {}\nResource: {}",
121-
loader_context.request().to_string(),
122-
loader_context.loader_index,
123-
loader_context.resource(),
124-
}.into(),
125-
);
126-
return;
127-
}
128116
collected_ts_info = Some(collect_typescript_info(program, options));
129117
},
130118
|_| transformer::transform(&self.options_with_additional.rspack_experiments),

website/docs/en/guide/features/builtin-swc-loader.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ import 'antd/es/button/style';
459459
460460
Collects information from TypeScript's AST for consumption by subsequent Rspack processes, providing better TypeScript development experience and smaller output bundle size.
461461
462-
To ensure the accuracy of collected information, this configuration can only be used when `builtin:swc-loader` is the last normal loader.
462+
To ensure the accuracy of the collected information, users must ensure that subsequent Normal Loaders after `builtin:swc-loader` do not modify the Abstract Syntax Tree (AST) corresponding to the collected information. This precaution is necessary to prevent discrepancies between the collected information and the actual code.
463463
464464
Please refer to this [example](https://github.com/rspack-contrib/rstack-examples/tree/main/rspack/collect-typescript-info) for more details.
465465

website/docs/zh/guide/features/builtin-swc-loader.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ import 'antd/es/button/style';
461461
462462
从 TypeScript 的 AST 中收集信息,以供 Rspack 后续过程进行消费,提供对 TypeScript 更好的开发体验和更小的产物体积。
463463
464-
为了保证收集到的信息的准确性,该配置只能在 builtin:swc-loader 作为最后一个 normal loader 时使用
464+
为了保证收集到的信息的准确性,用户需要确保 `builtin:swc-loader` 后续的 Normal Loader 不会去修改这些已经被收集到的相关信息对应的 AST,以免导致收集到的信息和实际的代码不一致的情况
465465
466466
详细示例可参考:[example](https://github.com/rspack-contrib/rstack-examples/tree/main/rspack/collect-typescript-info)
467467

0 commit comments

Comments
 (0)