-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
Integrate new typescript module resolution #1476
Comments
+1 for somehow integrating this! I did some testing and I could not make it work by just copying but with the right entries for baseUrl and paths in tsconfig.json it is now possible to for tsc to consume embedded typings from npm packages installed by jspm. (Works with typescript@next). |
Apart from this issue I got it working fine. Here is my tsconfig.json: {
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "tmp",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"removeComments": false,
"sourceMap": true,
"baseUrl": "./jspm_packages",
"paths": {
"angular2/*": [
"npm/angular2@2.0.0-beta.1/*"
]
}
},
"exclude": [
"node_modules",
"jspm_packages"
]
} To enable this in VSCode you can add this snippet to your workspace settings. {
"typescript.tsdk": "node_modules/typescript/lib"
} |
//cc @frankwallis |
I also got it to work with a private git package I have which have embedded typings. Although it is not possible to just cut and paste from config.js but in trivial cases it is close. |
This is not a jspm concern unfortunately, and would be unnecessary coupling. |
I can see how it is not a jspm concern, also I can see how it is not a typescript concern. So the situation becomes a bit unfortunate as the only solution left is to build a third tool that looks up the information in config.js and fills in tsconfig.json. Another solution could be possible if there is some integration point in jspm or tsc we could use. Any suggestions? |
@jonaskello wrapping the typescript build with jspm support through a small third-party project does sound like the correct way forward. |
The way I currently think about it is this:
However, not sure if all those items are true so my logic might be flawed :-). Anyway I guess my question is if we can extend jspm install with thirdparty logic somehow? |
Thanks, that's making a lot of sense. How about a simple CLI tool like
Where it then updates the |
Yes that makes sense. One step further would be if we could automatically execute a script after each "jspm install x". Npm will automatically run some predefined scripts from the scripts section of package.json after a certain command is issued. For example it will run the script "postinstall" if you do a "npm install" without parameters. If jspm could execute a script after each "jspm install x" (with parameters) we could automate the running of jspm-tsc-update. For example in package.json:
However the first step would of course be to actually make the jspm-tsc-update tool :-). |
That sounds like a viable solution and I will be happy to contribute. +1 for a postinstall/postuninstall hook for jspm. |
I think only packages that have embedded typings would have to be added to tsconfig. So maybe the tool could check package.json for a typings key in order to determine if it should be added to tsconfig. Regarding the hook, maybe it is better if we had a hook for when map in config.js changes. I think that would cover both install and uninstall. Something like:
|
Has this script hook been added to jspm? |
I tried to setup TS@next latest with the following config:
but it seems to still use node_modules for module resolution, any thoughts on what to do different? tx Sean |
Just a guess but moduleResolution: node?
|
you got it @lookfirst I just changed it to classic |
the good news is that when I switched to classics I get the errors but so far still am not able to get it to resolve properly. current config is:
|
here is a dump of: tsc --traceResolution
wondering why it's looking for .ts files? and not .js |
@guybedford @jonaskello I've created a very basic package, actually named |
@fabiandev really nice work! We will need this for jspm 2 :) |
@guybedford thanks! Currently it's a very simple approach and it can definitely be improved in terms of code quality and functionality (e.g. passing options). I just needed to get it working for a project of mine. I'll update the package eventually :) |
As this PR is now merged in typescript@next it would be nice to set the baseUrl and path mappings in the tsconfig.json when installing a module. This information is already present in the jspm.config.js and can easily be copied I think.
This way it would be just as easy to use the typings that a module ships with it, as it is now to import the library with jspm.
The text was updated successfully, but these errors were encountered: