swc_core/
plugin.rs

1// #[plugin_transform] macro
2#[cfg(any(
3    all(
4        docsrs,
5        any(
6            feature = "__common_plugin_transform",
7            feature = "__css_plugin_transform"
8        )
9    ),
10    feature = "__common_plugin_transform",
11    feature = "__css_plugin_transform",
12))]
13#[cfg_attr(
14    docsrs,
15    doc(cfg(any(
16        feature = "__common_plugin_transform",
17        feature = "__css_plugin_transform"
18    )))
19)]
20pub use swc_plugin_macro::css_plugin_transform;
21#[cfg(any(
22    all(
23        docsrs,
24        any(
25            feature = "__common_plugin_transform",
26            feature = "__css_plugin_transform",
27            feature = "__ecma_plugin_transform"
28        )
29    ),
30    feature = "__common_plugin_transform",
31    feature = "__css_plugin_transform",
32    feature = "__ecma_plugin_transform"
33))]
34#[cfg_attr(
35    docsrs,
36    doc(cfg(any(
37        feature = "__common_plugin_transform",
38        feature = "__css_plugin_transform",
39        feature = "__ecma_plugin_transform"
40    )))
41)]
42pub use swc_plugin_macro::plugin_transform;
43
44/// exported __alloc / __free fn for the guest (plugin)
45/// allows to allocate memory from the host side.
46/// This should not be directly referenced.
47#[cfg(all(feature = "__common_plugin_transform", target_arch = "wasm32"))]
48pub mod memory {
49    pub use swc_plugin::allocation::*;
50}
51
52/// Global HANDLER implementation for the plugin
53/// for error reporting.
54#[cfg(any(
55    all(
56        docsrs,
57        any(
58            feature = "__common_plugin_transform",
59            feature = "__css_plugin_transform",
60            feature = "__ecma_plugin_transform"
61        )
62    ),
63    feature = "__common_plugin_transform",
64    feature = "__css_plugin_transform",
65    feature = "__ecma_plugin_transform"
66))]
67#[cfg_attr(
68    docsrs,
69    doc(cfg(any(
70        feature = "__common_plugin_transform",
71        feature = "__css_plugin_transform",
72        feature = "__ecma_plugin_transform"
73    )))
74)]
75pub mod errors {
76    pub use swc_common::errors::HANDLER;
77}
78
79/// Plugin's environment metadata context.
80#[cfg(any(
81    all(
82        docsrs,
83        any(
84            feature = "__common_plugin_transform",
85            feature = "__css_plugin_transform",
86            feature = "__ecma_plugin_transform"
87        )
88    ),
89    feature = "__common_plugin_transform",
90    feature = "__css_plugin_transform",
91    feature = "__ecma_plugin_transform"
92))]
93#[cfg_attr(
94    docsrs,
95    doc(cfg(any(
96        feature = "__common_plugin_transform",
97        feature = "__css_plugin_transform",
98        feature = "__ecma_plugin_transform"
99    )))
100)]
101pub mod metadata {
102    pub use swc_common::plugin::metadata::TransformPluginMetadataContextKind;
103    pub use swc_plugin_proxy::TransformPluginProgramMetadata;
104}
105
106/// Proxy to the host's data not attached to the AST, like sourcemap / comments.
107/// Or interfaces to setup the plugin's environment from the host.
108#[cfg(any(
109    all(
110        docsrs,
111        any(
112            feature = "__common_plugin_transform",
113            feature = "__plugin_transform_host"
114        )
115    ),
116    feature = "__common_plugin_transform",
117    feature = "__plugin_transform_host"
118))]
119#[cfg_attr(
120    docsrs,
121    doc(cfg(any(
122        feature = "__common_plugin_transform",
123        feature = "__plugin_transform_host"
124    )))
125)]
126pub mod proxies {
127    pub use swc_plugin_proxy::*;
128}