@@ -19,13 +19,15 @@ export * from './types';
1919
2020export type ComponentMetaChecker = ReturnType < typeof baseCreate > ;
2121
22+ const windowsPathReg = / \\ / g;
23+
2224export function createComponentMetaCheckerByJsonConfig (
2325 root : string ,
2426 json : any ,
2527 checkerOptions : MetaCheckerOptions = { } ,
2628 ts : typeof import ( 'typescript/lib/tsserverlibrary' ) = require ( 'typescript' ) ,
2729) {
28- const rootPath = ( root as path . OsPath ) . replace ( / \\ / g , '/' ) as path . PosixPath ;
30+ const rootPath = ( root as path . OsPath ) . replace ( windowsPathReg , '/' ) as path . PosixPath ;
2931 return createComponentMetaCheckerWorker (
3032 ( ) => vue . createParsedCommandLineByJson ( ts , ts . sys , root , json ) ,
3133 checkerOptions ,
@@ -40,7 +42,7 @@ export function createComponentMetaChecker(
4042 checkerOptions : MetaCheckerOptions = { } ,
4143 ts : typeof import ( 'typescript/lib/tsserverlibrary' ) = require ( 'typescript' ) ,
4244) {
43- const tsconfig = ( tsconfigPath as path . OsPath ) . replace ( / \\ / g , '/' ) as path . PosixPath ;
45+ const tsconfig = ( tsconfigPath as path . OsPath ) . replace ( windowsPathReg , '/' ) as path . PosixPath ;
4446 return createComponentMetaCheckerWorker (
4547 ( ) => vue . createParsedCommandLine ( ts , ts . sys , tsconfigPath ) ,
4648 checkerOptions ,
@@ -63,7 +65,7 @@ function createComponentMetaCheckerWorker(
6365 */
6466
6567 let parsedCommandLine = loadParsedCommandLine ( ) ;
66- let fileNames = ( parsedCommandLine . fileNames as path . OsPath [ ] ) . map < path . PosixPath > ( path => path . replace ( / \\ / g , '/' ) as path . PosixPath ) ;
68+ let fileNames = ( parsedCommandLine . fileNames as path . OsPath [ ] ) . map < path . PosixPath > ( path => path . replace ( windowsPathReg , '/' ) as path . PosixPath ) ;
6769 let projectVersion = 0 ;
6870
6971 const scriptSnapshots = new Map < string , ts . IScriptSnapshot > ( ) ;
@@ -87,18 +89,18 @@ function createComponentMetaCheckerWorker(
8789 return {
8890 ...baseCreate ( _host , vue . resolveVueCompilerOptions ( parsedCommandLine . vueOptions ) , checkerOptions , globalComponentName , ts ) ,
8991 updateFile ( fileName : string , text : string ) {
90- fileName = ( fileName as path . OsPath ) . replace ( / \\ / g , '/' ) as path . PosixPath ;
92+ fileName = ( fileName as path . OsPath ) . replace ( windowsPathReg , '/' ) as path . PosixPath ;
9193 scriptSnapshots . set ( fileName , ts . ScriptSnapshot . fromString ( text ) ) ;
9294 projectVersion ++ ;
9395 } ,
9496 deleteFile ( fileName : string ) {
95- fileName = ( fileName as path . OsPath ) . replace ( / \\ / g , '/' ) as path . PosixPath ;
97+ fileName = ( fileName as path . OsPath ) . replace ( windowsPathReg , '/' ) as path . PosixPath ;
9698 fileNames = fileNames . filter ( f => f !== fileName ) ;
9799 projectVersion ++ ;
98100 } ,
99101 reload ( ) {
100102 parsedCommandLine = loadParsedCommandLine ( ) ;
101- fileNames = ( parsedCommandLine . fileNames as path . OsPath [ ] ) . map < path . PosixPath > ( path => path . replace ( / \\ / g , '/' ) as path . PosixPath ) ;
103+ fileNames = ( parsedCommandLine . fileNames as path . OsPath [ ] ) . map < path . PosixPath > ( path => path . replace ( windowsPathReg , '/' ) as path . PosixPath ) ;
102104 this . clearCache ( ) ;
103105 } ,
104106 clearCache ( ) {
0 commit comments