-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Path mapping module resolution #5728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I suppose this can solve problems I had using angular2 with jspm with Visual Studio. How can try if this works? |
Great, I'll try this out as soon as it is merged :) |
// @file: /a/b/c/generated/form1.content.ts | ||
// export var x = ... | ||
// first './form.content.ts' needs to be converted to non-relative name. | ||
// 1. convert it to absolute name '/a/b/c/src/form1.content.ts' -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
form1.content.ts
is form.content.ts
can you add test with suffix in paths matching like "paths": {
"generated/*/folder1" : ["build/folder1"] as well as the case when there are multiple match but we pick the longest one (so we have a record of what we use to do in case of future change) |
Also what happens in this case: "rootDirs": [
"*",
"generated/*"
], is this allowed? if so could we have some tests as well? (from the spec, it seems so. I can't tell from the comment though) "rootDirs": [
"*",
"generated/*/folder1"
], |
|
Can you enable the |
Sure, I'll add it in the next iteration of this PR |
Here is my folder structure
libs/guid/package.json: {
"name": "guid",
"version": "1.0.0",
"main": "dist/guid.js",
"typings": "dist/guid.d.ts"
} app/app.ts: import guid from 'libs/guid';
console.log(guid()); app/tsconfig.json {
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"noImplicitAny": true,
"removeComments": false,
"sourceMap": true,
"outDir": "dist/",
"target": "es5",
"moduleResolution": "baseUrl",
"baseUrl": "",
"paths": {
"libs/guid": ["../libs/guid/dist/guid.d.ts"]
}
},
"exclude": [
"dist"
]
} Rather than specifying paths as |
Also how do I set path mappings in csproj? |
I'm currently making a few adjustments to this PR based on results of the latest design meeting and I think that your initial scenario should be supported. Regarding specifying path mappings in .csproj - this won't work, |
trace(host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern); | ||
} | ||
|
||
for (const subst of compilerOptions.paths[matchedPattern]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your proposal example, it shows paths can be defined as the follows:
"pattern-1": "substitution" | ["list of substitutions"]
However, when const subst of compilerOptions.paths[matchedPattern]
is ran, if my path's substitution is a string, of will iterate over each character of the string. Does this need to change or perhaps normalize the compiler options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the proposal needs to be adjusted - it should always be the list
@vladima Would really love to see it working in csproj since that is what we are using internally. I was expecting something like this in csproj. <TypeScriptPath>
<Pattern>libs/guid<Pattern>
<Substitution>../libs/guid</Substitution>
<TypeScriptPath> |
{ | ||
// this option can only be specified in tsconfig.json | ||
// use type = object to copy the value as-is | ||
name: "rootDirs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a line note
}, | ||
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, | ||
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic, | ||
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_classic_or_baseUrl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "baseURL" from the message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
👍 |
Path mapping module resolution
which version of typescript and gulp-typescript support this? |
|
initial implementation for this proposal: #5039.