swc_ecma_transforms_react/
lib.rs1#![deny(clippy::all)]
2#![allow(clippy::mutable_key_type)]
3#![allow(clippy::arc_with_non_send_sync)]
4#![allow(rustc::untranslatable_diagnostic_trivial)]
5#![cfg_attr(not(feature = "concurrent"), allow(unused))]
6
7use swc_common::{comments::Comments, sync::Lrc, Mark, SourceMap};
8use swc_ecma_ast::Pass;
9
10pub use self::{
11 display_name::display_name,
12 jsx::*,
13 jsx_self::jsx_self,
14 jsx_src::jsx_src,
15 pure_annotations::pure_annotations,
16 refresh::{options::RefreshOptions, refresh},
17};
18
19mod display_name;
20mod jsx;
21mod jsx_self;
22mod jsx_src;
23mod pure_annotations;
24mod refresh;
25
26pub fn react<C>(
40 cm: Lrc<SourceMap>,
41 comments: Option<C>,
42 mut options: Options,
43 top_level_mark: Mark,
44 unresolved_mark: Mark,
45) -> impl Pass
46where
47 C: Comments + Clone,
48{
49 let Options { development, .. } = options;
50 let development = development.unwrap_or(false);
51
52 let refresh_options = options.refresh.take();
53
54 (
55 jsx_src(development, cm.clone()),
56 jsx_self(development),
57 refresh(
58 development,
59 refresh_options.clone(),
60 cm.clone(),
61 comments.clone(),
62 top_level_mark,
63 ),
64 jsx(
65 cm.clone(),
66 comments.clone(),
67 options,
68 top_level_mark,
69 unresolved_mark,
70 ),
71 display_name(),
72 pure_annotations(comments.clone()),
73 )
74}