Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
"prettier": "^2.8.4",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.2"
"typescript": "^5.0.4"
}
}
22 changes: 21 additions & 1 deletion src/cli/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,33 @@ export function parseConfigFileWithSystem(
return updateParsedConfigFile(parsedConfigFile);
}

function resolveNpmModuleConfig(
moduleName: string,
configRootDir: string,
host: ts.ModuleResolutionHost
): string | undefined {
const resolved = ts.nodeNextJsonConfigResolver(moduleName, path.join(configRootDir, "tsconfig.json"), host);
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
}

function getExtendedTstlOptions(
configFilePath: string,
configRootDir: string,
cycleCache: Set<string>,
system: ts.System
): TypeScriptToLuaOptions {
const absolutePath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(configRootDir, configFilePath);
const absolutePath = ts.pathIsAbsolute(configFilePath)
? configFilePath
: ts.pathIsRelative(configFilePath)
? path.resolve(configRootDir, configFilePath)
: resolveNpmModuleConfig(configFilePath, configRootDir, system); // if a path is neither relative nor absolute, it is probably a npm module

if (!absolutePath) {
return {};
}

const newConfigRoot = path.dirname(absolutePath);

if (cycleCache.has(absolutePath)) {
Expand Down
9 changes: 9 additions & 0 deletions src/typescript-internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ declare module "typescript" {

function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression;
export function isOuterExpression(node: Node, kinds?: OuterExpressionKinds): node is OuterExpression;

export function nodeNextJsonConfigResolver(
moduleName: string,
containingFile: string,
host: ModuleResolutionHost
): ResolvedModuleWithFailedLookupLocations;

export function pathIsAbsolute(path: string): boolean;
export function pathIsRelative(path: string): boolean;
}