import * as path from 'path' ; import { URI } from 'vscode-uri' ; import { Language } from './interface' ; export * from './interface' ; export * from './parse' ; export function loadTypeScript ( appRoot ) { const tsPath = path . join ( appRoot , 'extensions' , 'node_modules' , 'typescript' ) ; return require ( tsPath ) ; } export function uriToFsPath ( uri ) { return URI . parse ( uri ) . fsPath ; } export function fsPathToUri ( fsPath ) { return URI . file ( fsPath ) . toString ( ) ; } export function normalizeFileName ( fileName ) { return uriToFsPath ( fsPathToUri ( fileName ) ) ; } export function toVirtualPath ( fileName , index = 0 , lang ? ) { return `${ fileName }.__${ index }.${ lang || 'tsx' }` ; } export function filterEmpty < T > ( value ) { return value !== null && value !== undefined ; } export const languageIdMap = { ts : 'typescript' , js : 'javascript' , tsx : 'typescriptreact' , jsx : 'javascriptreact' , } ;