esnode/plugin.js
/**
 * Factory create plugin which analyze the source files and replace
 * found aliases according to path mapped in tsconfig.json.
 *
 * @param program Typescript program.
 * @param pluginConfig Plugin config.
 * @return Typescript transformer.
 * @author Oleksandr Dakal <oleksandr-dakal@project-kit.org>
 */
Factory create plugin which analyze the source files and replace
found aliases according to path mapped in tsconfig.json.

@param program Typescript program.
@param pluginConfig Plugin config.
@return Typescript transformer.
@author Oleksandr Dakal 
Factory create plugin which analyze the source files and replace found aliases according to path mapped in tsconfig . json . @param program Typescript program . @param pluginConfig Plugin config . @return Typescript transformer . @author Oleksandr Dakal
function pluginFactory(program, pluginConfig = {}) {
    logger_1.logger.debugEnabled = pluginConfig.debug;
    if (compare(ts.versionMajorMinor, '2.9') < 0) {
        throw new Error('Min requirement ts version is 2.9');
    }
    return {
        before(context) {
            return (sourceFile) => {
                logger_1.logger.debug(chalk_1.default.cyan(`* ${sourceFile.fileName} [ts]`));
                return ts.visitNode(sourceFile, visitor_1.visitorFactory({ program, context, sourceFile, pluginConfig }));
            };
        },
        afterDeclarations(context) {
            return (sourceFile) => {
                logger_1.logger.debug(chalk_1.default.gray(`* ${sourceFile.fileName} [d.ts]`));
                return ts.visitNode(sourceFile, visitor_1.visitorFactory({ program, context, sourceFile, pluginConfig }));
            };
        }
    };
}
function pluginFactory ( program , pluginConfig = { } ) { logger_1 . logger . debugEnabled = pluginConfig . debug ; if ( compare ( ts . versionMajorMinor , '2.9' ) < 0 ) { throw new Error ( 'Min requirement ts version is 2.9' ) ; } return { before ( context ) { return ( sourceFile ) => { logger_1 . logger . debug ( chalk_1 . default . cyan ( ` ${ sourceFile . fileName } ` ) ) ; return ts . visitNode ( sourceFile , visitor_1 . visitorFactory ( { program , context , sourceFile , pluginConfig } ) ) ; } ; } , afterDeclarations ( context ) { return ( sourceFile ) => { logger_1 . logger . debug ( chalk_1 . default . gray ( ` ${ sourceFile . fileName } ` ) ) ; return ts . visitNode ( sourceFile , visitor_1 . visitorFactory ( { program , context , sourceFile , pluginConfig } ) ) ; } ; } } ; }
Factory create plugin which analyze the source files and replace
 found aliases according to path mapped in tsconfig.json.
Factory create plugin which analyze the source files and replace found aliases according to path mapped in tsconfig . json .
// Enable/disable plugin debug logging. // Verify ts compatibility. // Analyze and transform before compilation of sources. // Visit each node try to find aliases and replace with proper path. // Analyze and transform after compilation of declarations. // Visit each node try to find aliases and replace with proper path.