Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ModuleRaid

Main moduleRaid class

Hierarchy

  • ModuleRaid

Index

Constructors

constructor

  • moduleRaid constructor

    example

    Constructing an instance without any arguments:

    const mR = new ModuleRaid()
    

    Constructing an instance with the optional opts object:

    const mR = new ModuleRaid({ entrypoint: 'webpackChunk_custom_name' })
    

    Parameters

    • Optional opts: boolean | ModuleRaidParameters

      a object containing options to initialize moduleRaid with

      • opts:
        • entrypoint: the Webpack entrypoint present on the global window object
        • debug: whether debug mode is enabled or not

    Returns ModuleRaid

Properties

constructors

constructors: AnyFunction[] = []

Storage for the constructors we extracted from Webpack

Private debug

debug: boolean

Option enabling or disabling debug output

default

false

Private entrypoint

entrypoint: string

The Webpack entrypoint present on the global window object

default

webpackJsonp

Optional get

get: WebpackRequire

Intermediary storage for webpack_require if we were able to extract it

Private moduleID

moduleID: string = ...

A random generated module ID we use for injecting into Webpack

modules

modules: WebpackModuleList = {}

Storage for the modules we extracted from Webpack

Methods

findConstructor

  • Method to search through the constructor array, searching for the fitting content if a string is supplied

    If query is supplied as a function, everything that returns true when passed to the query function will be returned

    example

    With a string as query argument:

    const results = mR.findConstructor('feature')
    // => Array of constructor/module tuples
    

    With a function as query argument:

    const results = mR.findConstructor((constructor) => { constructor.prototype.value !== undefined })
    // => Array of constructor/module tuples
    

    Accessing the resulting data:

    // With array destructuring (ES6)
    const [constructor, module] = results[0]
    
    // ...or...
    
    // regular access
    const constructor = results[0][0]
    const module = results[0][1]
    

    Parameters

    • query: string | ((query: WebpackModule) => boolean)

      query to search the constructor list for

    Returns ConstructorModuleTuple[]

    a list of constructor/module tuples fitting the query

findModule

  • Method to search through the module object, searching for the fitting content if a string is supplied

    If query is supplied as a function, everything that returns true when passed to the query function will be returned

    example

    With a string as query argument:

    const results = mR.findModule('feature')
    // => Array of module results
    

    With a function as query argument:

    const results = mR.findModule((module) => { typeof module === 'function' })
    // => Array of module results
    

    Parameters

    • query: string | ((query: WebpackModule) => boolean)

      query to search the module list for

    Returns WebpackModule[]

    a list of modules fitting the query

Generated using TypeDoc