Skip to content

Commit dee8ebd

Browse files
fhammerschmidtcristianoc
authored andcommitted
Explicitly handle available compiled folder names
1 parent e9946d6 commit dee8ebd

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

server/src/utils.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,18 @@ export let createInterfaceFileUsingValidBscExePath = (
252252
}
253253
};
254254

255+
let getCompiledFolderName = (moduleFormat: string): string => {
256+
switch (moduleFormat) {
257+
case "es6":
258+
return "es6";
259+
case "es6-global":
260+
return "es6_global";
261+
case "commonjs":
262+
default:
263+
return "js";
264+
}
265+
};
266+
255267
export let getCompiledFilePath = (
256268
filePath: string,
257269
projDir: string
@@ -272,13 +284,17 @@ export let getCompiledFilePath = (
272284
let module = c.bsconfigModuleDefault;
273285
let suffix = c.bsconfigSuffixDefault;
274286

275-
if (pkgSpecs && pkgSpecs.module) {
276-
moduleFormatObj = pkgSpecs;
277-
} else if (pkgSpecs && pkgSpecs[0]) {
278-
if (typeof pkgSpecs[0] === "string") {
279-
module = pkgSpecs[0];
280-
} else {
281-
moduleFormatObj = pkgSpecs[0];
287+
if (pkgSpecs) {
288+
if (pkgSpecs.module) {
289+
moduleFormatObj = pkgSpecs;
290+
} else if (typeof pkgSpecs === "string") {
291+
module = pkgSpecs;
292+
} else if (pkgSpecs[0]) {
293+
if (typeof pkgSpecs[0] === "string") {
294+
module = pkgSpecs[0];
295+
} else {
296+
moduleFormatObj = pkgSpecs[0];
297+
}
282298
}
283299
}
284300

@@ -287,7 +303,7 @@ export let getCompiledFilePath = (
287303
}
288304

289305
if (!moduleFormatObj["in-source"]) {
290-
pathFragment = "lib/" + module.replace("-", "_");
306+
pathFragment = "lib/" + getCompiledFolderName(module);
291307
}
292308

293309
if (moduleFormatObj.suffix) {

0 commit comments

Comments
 (0)