pub struct Compiler {
    pub cm: Arc<SourceMap>,
    /* private fields */
}
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

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.

custom_after_pass is applied after swc transforms are applied.

program: If you already parsed Program, you can pass it.

Guarantee

swc invokes custom_before_pass after

  • Handling decorators, if configured
  • Applying resolver
  • Stripping typescript nodes

This means, you can use noop_visit_type, noop_fold_type and noop_visit_mut_type in your visitor to reduce the binary size.

You can use custom pass with this method.

There exists a PassBuilder to help building custom passes.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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