Skip to main content
Version: 1.2

MacroPlugin

MacroPlugin

Macro plugin enables the use of "use macro" directive in the code. Functions with this directive will be transformed at compile time and only the result will be included in the final bundle.

Example

function myMacro() {
"use macro";
return Math.random();
}

// This will be transformed to a constant value at compile time.
const result = myMacro();
Signature
class MacroPlugin extends CompilerPlugin {
public readonly name = 'MacroPlugin';
activate() => Promise<void>;
deactivate() => Promise<void>;
transform(params: PluginTransformParameters) => Promise<MaybeFalsey<TransformedResult>>;
}

name

property

activate

method
() => Promise<void>

deactivate

method
() => Promise<void>

transform

method
(params: PluginTransformParameters) => Promise<MaybeFalsey<TransformedResult>>