InjectDirectiveParser

InjectDirectiveParser

Parses class methods and functions in order to detect the use of an "inject directive" and replace it with a static property. This class works as a helper for a Babel plugin.

Constructor

new InjectDirectiveParser(file)

Source:
Example
// Input
class MyService {
  constructor(depOne, depTwo) {
    'inject';
    ...
  }
}
// Output
class MyService {
  constructor(depOne, depTwo) {
    'inject';
    ...
  }
}
MyService.inject = ['depOne', 'depTwo']
Parameters:
Name Type Description
file Path

The information of the File Babel is processing.

Methods

parseClassMethod(path)

Source:

This is called from a ParserCallback when the object being processed is a class method.

Parameters:
Name Type Description
path Path

The information of the object being processed.

parseFunction(path)

Source:

This is called from a ParserCallback when the object being processed is a function expression/declaration.

Parameters:
Name Type Description
path Path

The information of the object being processed.

transform()

Source:

This is called from ProgramVisitorFinish, it takes all the parsed elements and processes them in order to apply the transformations.