Struct swc::Compiler [−][src]
Fields
cm: Arc<SourceMap>
CodeMap
handler: Arc<Handler>
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
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.
pub fn config_for_file<'a>(
&'a self,
opts: &Options,
name: &FileName
) -> Result<Option<BuiltConfig<impl 'a + Fold>>, Error>
pub fn config_for_file<'a>(
&'a self,
opts: &Options,
name: &FileName
) -> Result<Option<BuiltConfig<impl 'a + Fold>>, Error>
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, external_helpers: bool, op: F) -> Ret where
F: FnOnce() -> Ret,
pub fn process_js_with_custom_pass<P>(
&self,
fm: Arc<SourceFile>,
opts: &Options,
custom_after_pass: P
) -> Result<TransformOutput, Error> where
P: Fold,
pub fn process_js_with_custom_pass<P>(
&self,
fm: Arc<SourceFile>,
opts: &Options,
custom_after_pass: P
) -> Result<TransformOutput, Error> where
P: Fold,
custom_after_pass
is applied after swc transforms are applied.
pub fn process_js_file(
&self,
fm: Arc<SourceFile>,
opts: &Options
) -> Result<TransformOutput, Error>
pub fn minify(
&self,
fm: Arc<SourceFile>,
opts: &JsMinifyOptions
) -> Result<TransformOutput, Error>
You can use custom pass with this method.
There exists a PassBuilder to help building custom passes.