Home Reference Source
import {ProjextRollupRuntimeReplacePlugin} from 'projext-plugin-rollup/src/plugins/runtimeReplace/index.js'
public class | source

ProjextRollupRuntimeReplacePlugin

This is a Rollup plugin that works as a wrapper for @rollup/plugin-replace in order to reload all definitions when the bundle changes.

Constructor Summary

Public Constructor
public

constructor(definitionsFn: Function():Object, name: string)

Member Summary

Public Members
public

The name of the plugin's instance.

Method Summary

Public Methods
public

This is called when Rollup starts the building process; if it's not the first build, it will reload the definitions. The reason it doesn't load them on the first build it's because when the plugin is instantiated, the definitions are already loaded for the @rollup/plugin-replace instance creation.

public

transform(code: string, filepath: string): *

This is called by Rollup when is parsing a file, and it just "forwards the call" to @rollup/plugin-replace.

Public Constructors

public constructor(definitionsFn: Function():Object, name: string) source

Params:

NameTypeAttributeDescription
definitionsFn Function():Object

When this function is called, it should return the object with the definitions.

name string
  • optional
  • default: 'projext-rollup-plugin-runtime-replace'

The name of the plugin's instance.

Throw:

Error

If definitionsFn is not a function.

Public Members

public name: string source

The name of the plugin's instance.

Public Methods

public buildStart() source

This is called when Rollup starts the building process; if it's not the first build, it will reload the definitions. The reason it doesn't load them on the first build it's because when the plugin is instantiated, the definitions are already loaded for the @rollup/plugin-replace instance creation.

public transform(code: string, filepath: string): * source

This is called by Rollup when is parsing a file, and it just "forwards the call" to @rollup/plugin-replace.

Params:

NameTypeAttributeDescription
code string

The file contents.

filepath string

The file path.

Return:

*

Whatever @rollup/plugin-replace returns.