Skip to content

Commit b8cb206

Browse files
removed transformation to luaRequirePath so the module identifier meets
the format specified in the interface
1 parent e3dbf77 commit b8cb206

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/transpilation/resolve.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,10 @@ class ResolutionContext {
100100

101101
private resolveDependencyPathsWithPlugins(requiringFile: ProcessedFile, dependency: string) {
102102
const requiredFromLuaFile = requiringFile.fileName.endsWith(".lua");
103-
const moduleIdentifier = requiredFromLuaFile ? luaRequireToPath(dependency) : dependency;
104-
105103
for (const plugin of this.plugins) {
106104
if (plugin.moduleResolution != null) {
107105
const pluginResolvedPath = plugin.moduleResolution(
108-
moduleIdentifier,
106+
dependency,
109107
requiringFile.fileName,
110108
this.options,
111109
this.emitHost
@@ -121,7 +119,7 @@ class ResolutionContext {
121119
if (resolvedNodeModulesFile) {
122120
if (this.options.tstlVerbose) {
123121
console.log(
124-
`Resolved file path for module ${moduleIdentifier} to path ${pluginResolvedPath} using plugin.`
122+
`Resolved file path for module ${dependency} to path ${pluginResolvedPath} using plugin.`
125123
);
126124
}
127125
return resolvedNodeModulesFile;
@@ -134,7 +132,7 @@ class ResolutionContext {
134132
if (fileFromPath) {
135133
if (this.options.tstlVerbose) {
136134
console.log(
137-
`Resolved file path for module ${moduleIdentifier} to path ${pluginResolvedPath} using plugin.`
135+
`Resolved file path for module ${dependency} to path ${pluginResolvedPath} using plugin.`
138136
);
139137
}
140138
return fileFromPath;

test/transpile/plugins/moduleResolution.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import path = require("path");
12
import type * as tstl from "../../../src";
23

34
const plugin: tstl.Plugin = {
45
moduleResolution(moduleIdentifier) {
6+
const modulePath = moduleIdentifier.replace(/\./g, path.sep);
57
if (moduleIdentifier.includes("foo")) {
6-
return moduleIdentifier.replace("foo", "bar");
8+
return modulePath.replace("foo", "bar");
79
}
810
},
911
};

0 commit comments

Comments
 (0)