import { loader } from 'webpack' ; import * as loaderUtils from 'loader-utils' ; import { NewlineKind } from '@rushstack/node-core-library' ; export interface IBaseLoaderOptions { resxNewlineNormalization : NewlineKind | undefined ; } export interface ILoaderResult { [ stringName ] : string ; } export function loaderFactory < TOptions extends IBaseLoaderOptions > ( innerLoader ) { return function ( this , content ) : string { const options = loaderUtils . getOptions ( this ) as TOptions ; if ( typeof content !== 'string' ) { content = content . toString ( ) ; } const resultObject = innerLoader . call ( this , this . resourcePath , content , options ) ; return JSON . stringify ( resultObject ) ; } ; }