Struct swc::Compiler [−][src]
Expand description
All methods accept Handler, which is a storage for errors.
The caller should check if the handler contains any errors after calling method.
Fields
cm: Arc<SourceMap>
CodeMap
Implementations
These are low-level apis.
Runs op
in current compiler’s context.
Note: Other methods of Compiler
already uses this internally.
This method parses a javascript / typescript file
pub fn print<T>(
&self,
node: &T,
source_file_name: Option<&str>,
output_path: Option<PathBuf>,
inline_sources_content: bool,
target: JscTarget,
source_map: SourceMapsConfig,
source_map_names: &[JsWord],
orig: Option<&SourceMap>,
minify: bool,
preserve_comments: Option<BoolOrObject<JsMinifyCommentOption>>
) -> Result<TransformOutput, Error> where
T: Node + VisitWith<IdentCollector>,
pub fn print<T>(
&self,
node: &T,
source_file_name: Option<&str>,
output_path: Option<PathBuf>,
inline_sources_content: bool,
target: JscTarget,
source_map: SourceMapsConfig,
source_map_names: &[JsWord],
orig: Option<&SourceMap>,
minify: bool,
preserve_comments: Option<BoolOrObject<JsMinifyCommentOption>>
) -> Result<TransformOutput, Error> where
T: Node + VisitWith<IdentCollector>,
Converts ast node to source string and sourcemap.
This method receives target file path, but does not write file to the path. See: https://github.com/swc-project/swc/issues/1255
High-level apis.
This method returns None if a file should be skipped.
This method handles merging of config.
This method does not parse module.
pub fn run_transform<F, Ret>(
&self,
handler: &Handler,
external_helpers: bool,
op: F
) -> Ret where
F: FnOnce() -> Ret,
pub fn transform(
&self,
handler: &Handler,
program: Program,
external_helpers: bool,
pass: impl Fold
) -> Program
pub fn process_js_with_custom_pass<P1, P2>(
&self,
fm: Arc<SourceFile>,
handler: &Handler,
opts: &Options,
custom_before_pass: P1,
custom_after_pass: P2
) -> Result<TransformOutput, Error> where
P1: Fold,
P2: Fold,
pub fn process_js_with_custom_pass<P1, P2>(
&self,
fm: Arc<SourceFile>,
handler: &Handler,
opts: &Options,
custom_before_pass: P1,
custom_after_pass: P2
) -> Result<TransformOutput, Error> where
P1: Fold,
P2: Fold,
custom_after_pass
is applied after swc transforms are applied.
pub fn process_js_file(
&self,
fm: Arc<SourceFile>,
handler: &Handler,
opts: &Options
) -> Result<TransformOutput, Error>
pub fn minify(
&self,
fm: Arc<SourceFile>,
handler: &Handler,
opts: &JsMinifyOptions
) -> Result<TransformOutput, Error>
pub fn process_js(
&self,
handler: &Handler,
program: Program,
opts: &Options
) -> Result<TransformOutput, Error>
pub fn process_js(
&self,
handler: &Handler,
program: Program,
opts: &Options
) -> Result<TransformOutput, Error>
You can use custom pass with this method.
There exists a PassBuilder to help building custom passes.
Auto Trait Implementations
impl !RefUnwindSafe for Compiler
impl !UnwindSafe for Compiler
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more