Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 24461b7

Browse files
Tom van Ommerentomv564
Tom van Ommeren
authored andcommitted
fix: plugin loading for windows
1 parent 9f4efdc commit 24461b7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/project-manager.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,9 +948,10 @@ export class ProjectConfiguration {
948948
* @param initialDir
949949
*/
950950
private resolveModule(moduleName: string, initialDir: string): {} | undefined {
951-
const resolvedPath = path.resolve(initialDir, 'node_modules');
951+
// const resolvedPath = path.resolve(initialDir, 'node_modules');
952+
const resolvedPath = '';
952953
this.logger.info(`Loading ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`);
953-
const result = this.requirePlugin(resolvedPath, moduleName);
954+
const result = this.requirePlugin(initialDir, moduleName);
954955
if (result.error) {
955956
this.logger.info(`Failed to load module: ${JSON.stringify(result.error)}`);
956957
return undefined;
@@ -979,14 +980,16 @@ export class ProjectConfiguration {
979980
* Throws an error if the module can't be resolved.
980981
*/
981982
private resolveJavaScriptModule(moduleName: string, initialDir: string, host: ts.ModuleResolutionHost): string {
982-
const { resolvedModule /* , failedLookupLocations */ } =
983-
ts.nodeModuleNameResolver(moduleName, /* containingFile */ initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, this.fs, undefined);
983+
// const { resolvedModule /* , failedLookupLocations */ } =
984+
const result =
985+
ts.nodeModuleNameResolver(moduleName, /* containingFile */ initialDir.replace('\\', '/') + '/package.json', { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, this.fs, undefined);
984986
// TODO: jsOnly flag missing :(
985-
if (!resolvedModule) {
987+
if (!result.resolvedModule) {
986988
// TODO: add Looked in: ${failedLookupLocations.join(', ')} back into error.
989+
// this.logger.error(result.failedLookupLocations!);
987990
throw new Error(`Could not resolve JS module ${moduleName} starting at ${initialDir}.`);
988991
}
989-
return resolvedModule.resolvedFileName;
992+
return result.resolvedModule.resolvedFileName;
990993
}
991994

992995
/**

0 commit comments

Comments
 (0)