@@ -87,16 +87,15 @@ class Transpilation {
8787
8888 if ( isBundleEnabled ( this . options ) ) {
8989 const [ bundleDiagnostics , bundleFile ] = getBundleResult ( this . program , this . emitHost , this . files , file =>
90- this . toRequireParameter ( this . toGeneratedFileName ( file . fileName ) )
90+ this . createModuleId ( file . fileName )
9191 ) ;
9292 this . diagnostics . push ( ...bundleDiagnostics ) ;
9393 return [ bundleFile ] ;
9494 } else {
95- return this . files . map ( file => {
96- const pathInOutDir = this . toAbsoluteOutputPath ( this . toGeneratedFileName ( file . fileName ) ) ;
97- const outputPath = normalizeSlashes ( trimExtension ( pathInOutDir ) + ".lua" ) ;
98- return { ...file , outputPath } ;
99- } ) ;
95+ return this . files . map ( file => ( {
96+ ...file ,
97+ outputPath : this . moduleIdToOutputPath ( this . createModuleId ( file . fileName ) ) ,
98+ } ) ) ;
10099 }
101100 }
102101
@@ -130,7 +129,7 @@ class Transpilation {
130129 }
131130 }
132131
133- return this . toRequireParameter ( this . toGeneratedFileName ( resolvedPath ) ) ;
132+ return this . createModuleId ( resolvedPath ) ;
134133 } ;
135134
136135 if ( file . sourceMapNode ) {
@@ -153,18 +152,17 @@ class Transpilation {
153152 useSyncFileSystemCalls : true ,
154153 } ) ;
155154
156- protected toGeneratedFileName ( fileName : string ) {
155+ protected createModuleId ( fileName : string ) {
157156 const result = path . relative ( this . rootDir , trimExtension ( fileName ) ) ;
158157 // TODO: handle files on other drives
159158 assert ( ! path . isAbsolute ( result ) , `Invalid path: ${ result } ` ) ;
160- return result . replace ( / \. \. \/ / g, "_/" ) . replace ( / \. / g, "__" ) ;
159+ return result
160+ . replace ( / \. \. [ / \\ ] / g, "_/" )
161+ . replace ( / \. / g, "__" )
162+ . replace ( / [ / \\ ] / g, "." ) ;
161163 }
162164
163- protected toRequireParameter ( fileName : string ) {
164- return fileName . replace ( / [ / \\ ] / g, "." ) ;
165- }
166-
167- protected toAbsoluteOutputPath ( fileName : string ) {
168- return path . resolve ( this . outDir , `${ fileName } .lua` ) ;
165+ protected moduleIdToOutputPath ( moduleId : string ) {
166+ return normalizeSlashes ( path . resolve ( this . outDir , `${ moduleId . replace ( / \. / g, "/" ) } .lua` ) ) ;
169167 }
170168}
0 commit comments