File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -320,11 +320,13 @@ export abstract class LuaTranspiler {
320320
321321 const imports = node . importClause . namedBindings ;
322322
323+ const reqKeyword = this . getRequireKeyword ( ) ;
324+
323325 if ( ts . isNamedImports ( imports ) ) {
324326 const fileImportTable = path . basename ( importPathWithoutQuotes ) + this . importCount ;
325327 const resolvedImportPath = this . getImportPath ( importPathWithoutQuotes ) ;
326328
327- let result = `local ${ fileImportTable } = ${ this . getRequireKeyword ( ) } (${ resolvedImportPath } )\n` ;
329+ let result = `local ${ fileImportTable } = ${ reqKeyword } (${ resolvedImportPath } )\n` ;
328330 this . importCount ++ ;
329331
330332 imports . elements . forEach ( element => {
@@ -340,7 +342,7 @@ export abstract class LuaTranspiler {
340342 return result ;
341343 } else if ( ts . isNamespaceImport ( imports ) ) {
342344 const resolvedImportPath = this . getImportPath ( importPathWithoutQuotes ) ;
343- return `local ${ this . transpileIdentifier ( imports . name ) } = require (${ resolvedImportPath } )\n` ;
345+ return `local ${ this . transpileIdentifier ( imports . name ) } = ${ reqKeyword } (${ resolvedImportPath } )\n` ;
344346 } else {
345347 throw TSTLErrors . UnsupportedImportType ( imports ) ;
346348 }
Original file line number Diff line number Diff line change @@ -7,10 +7,10 @@ export class LuaTranspilerGLua extends LuaTranspiler {
77 public getImportPath ( relativePath : string ) : string {
88 if ( path . isAbsolute ( relativePath ) ) {
99 // Get Path relative to baseDir (baseDir should be set to /lua/)
10- return `"${ this . getAbsoluteImportPath ( relativePath ) } "` ;
10+ return `"${ this . getAbsoluteImportPath ( relativePath ) } .lua "` ;
1111 } else {
1212 // We can use realtive paths in gmod
13- return `"${ this . pathToLuaRequirePath ( relativePath ) } "` ;
13+ return `"${ relativePath } .lua "` ;
1414 }
1515 }
1616
You can’t perform that action at this time.
0 commit comments