Home Reference Source Repository
import {CompilerBase} from 'electron-compilers/src/compiler-base.js'
public interface | source

CompilerBase

Direct Subclass:

SimpleCompilerBase

This class is the base interface for compilers that are used by electron-compile. If your compiler library only supports a synchronous API, use SimpleCompilerBase instead.

Static Method Summary

Static Public Methods
public static abstract

This method describes the MIME types that your compiler supports as input.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Method Summary

Public Methods
public abstract

compile(sourceCode: string, fileName: string, compilerContext: Object): Promise<Object>

Compiles the file

public

compileSync(sourceCode: *, filePath: *, compilerContext: *)

public abstract

determineDependentFiles(sourceCode: string, fileName: string, compilerContext: Object): Promise<string[]>

Returns the dependent files of this file.

public

determineDependentFilesSync(sourceCode: *, filePath: *, compilerContext: *)

public

Returns a version number representing the version of the underlying compiler library.

public abstract

shouldCompileFile(fileName: string, compilerContext: Object): Promise<bool>

Determines whether a file should be compiled

public

shouldCompileFileSync(fileName: *, compilerContext: *)

Static Public Methods

public static abstract getInputMimeTypes(): string[] source

This method describes the MIME types that your compiler supports as input. Many precompiled file types don't have a specific MIME type, so if it's not recognized by the mime-types package, you need to patch rig-mime-types in electron-compile.

Return:

string[]

An array of MIME types that this compiler can compile.

Public Constructors

public constructor source

Public Members

public compilerOptions: * source

Public Methods

public abstract compile(sourceCode: string, fileName: string, compilerContext: Object): Promise<Object> source

Compiles the file

Params:

NameTypeAttributeDescription
sourceCode string

The contents of filePath

fileName string

The full path of a file to compile.

compilerContext Object

An object that compilers can add extra information to as part of a job - the caller won't do anything with this.

Return:

Promise<Object>

An object representing the compiled result

Return Properties:

NameTypeAttributeDescription
code string

The compiled code

mimeType string

The MIME type of the compiled result, which should exist in the mime-types database.

public compileSync(sourceCode: *, filePath: *, compilerContext: *) source

Params:

NameTypeAttributeDescription
sourceCode *
filePath *
compilerContext *

public abstract determineDependentFiles(sourceCode: string, fileName: string, compilerContext: Object): Promise<string[]> source

Returns the dependent files of this file. This is used for languages such as LESS which allow you to import / reference other related files. In future versions of electron-compile, we will use this information to invalidate all of the parent files if a child file changes.

Params:

NameTypeAttributeDescription
sourceCode string

The contents of filePath

fileName string

The full path of a file to compile.

compilerContext Object

An object that compilers can add extra information to as part of a job - the caller won't do anything with this.

Return:

Promise<string[]>

An array of dependent file paths, or an empty array if there are no dependent files.

public determineDependentFilesSync(sourceCode: *, filePath: *, compilerContext: *) source

Params:

NameTypeAttributeDescription
sourceCode *
filePath *
compilerContext *

public getCompilerVersion(): string source

Returns a version number representing the version of the underlying compiler library. When this number changes, electron-compile knows to throw all away its generated code.

Return:

string

A version number. Note that this string isn't parsed in any way, just compared to the previous one for equality.

public abstract shouldCompileFile(fileName: string, compilerContext: Object): Promise<bool> source

Determines whether a file should be compiled

Params:

NameTypeAttributeDescription
fileName string

The full path of a file to compile.

compilerContext Object

An object that compilers can add extra information to as part of a job - the caller won't do anything with this.

Return:

Promise<bool>

True if you are able to compile this file.

public shouldCompileFileSync(fileName: *, compilerContext: *) source

Params:

NameTypeAttributeDescription
fileName *
compilerContext *