Conversation
…ts/references, remove module resolution from the checker
…dule kind differs in old and new programs, move setting of resolvedModules cache to the program, added tests
…nsion to the end of the list
Contributor
Author
Contributor
|
Excited 🌹 ! |
Contributor
Author
|
adding @dbaeumer, @derekcicerone, @mhegazy |
src/harness/projectsRunner.ts
Outdated
Contributor
There was a problem hiding this comment.
i would use Harness.IO.fileExists
|
Neat, looks like this could be used for modules which need to be resolved across project boundaries perhaps. |
src/compiler/program.ts
Outdated
Contributor
There was a problem hiding this comment.
function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule {
switch(compilerOptions.module) {
case ModuleKind.CommonJS:
resolveCommonJSModuleName(....);
//...
}
}
Contributor
|
👍 |
basarat
added a commit
to TypeStrong/atom-typescript
that referenced
this pull request
Aug 20, 2015
|
Just wanted to comment that I recently added support for this to ts-loader for resolving modules the same way that webpack does (setting up aliases and such) and it's fantastic. This is a great addition to TypeScript! Good work. |
Contributor
Author
|
Great to hear that! |
This was referenced Aug 31, 2015
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR consolidates all module resolution logic in one place so there is only one entry point for everything that needs to resolve module names. Currently it is function
getDefaultModuleNameResolverfunction that acceptsCompilerOptionsand returns back an instance ofModuleResolvedwhich is the alias forexport type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule;. Default module resolver is used in several places:preProcessFilethat is called from VS to determine dependencies of the filecreateProgram- at this point default module resolver will be requested if host wants to process with default module name resolution rules. NOTE: host can override built-in rules by implementingresolveModuleNames?(moduleNames: string[], containingFile: string): string[];function that accepts a list of imported names in the file and returns a list of resolved file names in the same order.resolveModuleNamesimplementation inLSHostfor 'tsserver'.Now
CompilerHost / LanguageServiceHostcan implementresolveModuleNamesand be completely in control of how module names are resolved. Alternatively they might want to use built-in rules - in this case they should implementgetModuleResolutionHost, return value of this function will be used by default module resolver to ask file system related questions.