src/format-webpack-stats-errors-warnings.js
function _formatErrorsWarnings(level, list, projectRoot){
    return list.map(x => {
        let file, line, col, endLine, endCol, message
        try{
            // resolve  the relative path 
            let fullFilePath = data_get(x, 'module.resource')
            file = fullFilePath && projectRoot ? path.relative(projectRoot, fullFilePath) : ''
            // file = file.replace(/[\\//]/g, '/')

            line = data_get(x, 'error.error.loc.line') || 0
            col = data_get(x, 'error.error.loc.column') || 0

            // only need first line of message
            let fullMessage = (x.message + '').trim()
            let crPos = fullMessage.indexOf("\n")
            if (crPos >= 0){
                message = fullMessage.substring(0, crPos)
            } else {
                message = fullMessage
            }

            if (!line){
                let linesColsInfo
                let m
                if (x.name === 'ModuleNotFoundError'
                    && (m = fullMessage.match(MODULE_NOT_FOUND_ERR_MSG_PATTERN))){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1])
                } else if (fullMessage.indexOf('component lists rendered with v-for should have explicit keys') > 0
                    && (m = fullMessage.match(/([a-zA-Z-_]+)\s+(v-for=['"].*?['"])/))){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[2], {after: m[1]})
                } else if (m = fullMessage.match(/export ['"](\S+?)['"] was not found/)){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1], {after: 'import'})
                } else if (m = fullMessage.match(/Error compiling template:((?:.|[\r\n])*)- Component template/m)){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1].trim())
                    message = fullMessage.replace(/\n/g, ' ')
                }

                if (linesColsInfo){
                    line = linesColsInfo.line || 0
                    col = linesColsInfo.col || 0
                    endLine = linesColsInfo.endLine
                    endCol = linesColsInfo.endCol
                }
            }

            let endLinesCols = (endLine || endCol) ? ('~' + (endLine || '') + (endLine ? ',' : '') + (endCol || '0')) : ''

            return `!>${level}: ${file}:${line},${col}${endLinesCols}: ${message || '@see output window'}`            
        } catch (e){
            console.warn(e)
            return ''
        }
    }).join("\n")
}
function _formatErrorsWarnings(level, list, projectRoot){
    return list.map(x => {
        let file, line, col, endLine, endCol, message
        try{
            // resolve  the relative path 
            let fullFilePath = data_get(x, 'module.resource')
            file = fullFilePath && projectRoot ? path.relative(projectRoot, fullFilePath) : ''
            // file = file.replace(/[\\//]/g, '/')

            line = data_get(x, 'error.error.loc.line') || 0
            col = data_get(x, 'error.error.loc.column') || 0

            // only need first line of message
            let fullMessage = (x.message + '').trim()
            let crPos = fullMessage.indexOf("\n")
            if (crPos >= 0){
                message = fullMessage.substring(0, crPos)
            } else {
                message = fullMessage
            }

            if (!line){
                let linesColsInfo
                let m
                if (x.name === 'ModuleNotFoundError'
                    && (m = fullMessage.match(MODULE_NOT_FOUND_ERR_MSG_PATTERN))){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1])
                } else if (fullMessage.indexOf('component lists rendered with v-for should have explicit keys') > 0
                    && (m = fullMessage.match(/([a-zA-Z-_]+)\s+(v-for=['"].*?['"])/))){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[2], {after: m[1]})
                } else if (m = fullMessage.match(/export ['"](\S+?)['"] was not found/)){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1], {after: 'import'})
                } else if (m = fullMessage.match(/Error compiling template:((?:.|[\r\n])*)- Component template/m)){
                    linesColsInfo = _resolveLineColNumInFile(fullFilePath, m[1].trim())
                    message = fullMessage.replace(/\n/g, ' ')
                }

                if (linesColsInfo){
                    line = linesColsInfo.line || 0
                    col = linesColsInfo.col || 0
                    endLine = linesColsInfo.endLine
                    endCol = linesColsInfo.endCol
                }
            }

            let endLinesCols = (endLine || endCol) ? ('~' + (endLine || '') + (endLine ? ',' : '') + (endCol || '0')) : ''

            return `!>${level}: ${file}:${line},${col}${endLinesCols}: ${message || '@see output window'}`            
        } catch (e){
            console.warn(e)
            return ''
        }
    }).join("\n")
}
function _formatErrorsWarnings ( level , list , projectRoot ) { return list . map ( x => { let file , line , col , endLine , endCol , message try { // resolve  the relative path  let fullFilePath = data_get ( x , 'module.resource' ) file = fullFilePath && projectRoot ? path . relative ( projectRoot , fullFilePath ) : '' // file = file.replace(/[\\//]/g, '/') line = data_get ( x , 'error.error.loc.line' ) || 0 col = data_get ( x , 'error.error.loc.column' ) || 0 // only need first line of message let fullMessage = ( x . message + '' ) . trim ( ) let crPos = fullMessage . indexOf ( "\n" ) if ( crPos >= 0 ) { message = fullMessage . substring ( 0 , crPos ) } else { message = fullMessage } if ( ! line ) { let linesColsInfo let m if ( x . name === 'ModuleNotFoundError' && ( m = fullMessage . match ( MODULE_NOT_FOUND_ERR_MSG_PATTERN ) ) ) { linesColsInfo = _resolveLineColNumInFile ( fullFilePath , m [ 1 ] ) } else if ( fullMessage . indexOf ( 'component lists rendered with v-for should have explicit keys' ) > 0 && ( m = fullMessage . match ( / ([a-zA-Z-_]+)\s+(v-for=['"].*?['"]) / ) ) ) { linesColsInfo = _resolveLineColNumInFile ( fullFilePath , m [ 2 ] , { after : m [ 1 ] } ) } else if ( m = fullMessage . match ( / export ['"](\S+?)['"] was not found / ) ) { linesColsInfo = _resolveLineColNumInFile ( fullFilePath , m [ 1 ] , { after : 'import' } ) } else if ( m = fullMessage . match ( / Error compiling template:((?:.|[\r\n])*)- Component template / m ) ) { linesColsInfo = _resolveLineColNumInFile ( fullFilePath , m [ 1 ] . trim ( ) ) message = fullMessage . replace ( / \n / g , ' ' ) } if ( linesColsInfo ) { line = linesColsInfo . line || 0 col = linesColsInfo . col || 0 endLine = linesColsInfo . endLine endCol = linesColsInfo . endCol } } let endLinesCols = ( endLine || endCol ) ? ( '~' + ( endLine || '' ) + ( endLine ? ',' : '' ) + ( endCol || '0' ) ) : '' return ` ${ level } ${ file } ${ line } ${ col } ${ endLinesCols } ${ message || '@see output window' } ` } catch ( e ) { console . warn ( e ) return '' } } ) . join ( "\n" ) }
Format errors or warnings
@param {string} level
@param {Array<Error>} list
@param {String|null} projectRoot
Format errors or warnings