Skip to content

Commit 10f884a

Browse files
TheLartiansPerryvw
authored andcommitted
named import prefix (#362)
* prefix import identifiers * refactor TSTL identifier function * update transformation tests
1 parent 40fc3b1 commit 10f884a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/LuaTransformer.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,14 @@ export class LuaTransformer {
203203
return undefined;
204204
}
205205

206-
const importUniqueName = tstl.createIdentifier(path.basename((importPath)));
206+
const tstlIdentifier = (name: string) => "__TSTL_" + name;
207+
const importUniqueName = tstl.createIdentifier(tstlIdentifier(path.basename((importPath))));
207208
const requireStatement = tstl.createVariableDeclarationStatement(
208-
tstl.createIdentifier(path.basename(importPath)), requireCall, undefined, statement);
209+
tstl.createIdentifier(tstlIdentifier(path.basename((importPath)))),
210+
requireCall,
211+
undefined,
212+
statement
213+
);
209214
result.push(requireStatement);
210215

211216
filteredElements.forEach(importSpecifier => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
local test = require("test");
2-
local TestClass = test.TestClass;
1+
local __TSTL_test = require("test");
2+
local TestClass = __TSTL_test.TestClass;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
local test = require("test");
2-
local RenamedClass = test.TestClass;
1+
local __TSTL_test = require("test");
2+
local RenamedClass = __TSTL_test.TestClass;

0 commit comments

Comments
 (0)