'test-module' is external module written in Typescript with index.d.ts definition file. it has properties for tsd/tsc in package.json:
"typings": "dist/index.d.ts", "typescript": { "definition": "dist/index.d.ts" }
'test-module' is installed with JSPM in jspm_packages/npm/test-module for dynamic loading using SystemJS
'app' is Typescript application that imports 'test-module' like this:
import {Component} from 'test-module';
The problem is that 'test-module' module HAS TO BE in both locations:
in node_modules for Typescript compiler (otherwise it does not find 'test-module' and errors it during compile import from 'test-module')
in jspm_packages for SystemJS to load it during runtime
So, i need to insert it in package.json 'dependencies' AND 'jspm/dependencies'
Is there a hack to :
A) force JSPM/SystemJS to use ONLY standard node_modules folder? (I know I can use raw SystemJS and map node_modules but it means that I have to map it for every single dependency and dependencies of dependency which is a lot of manual work)
OR
B) force Typescript to search modules using some kind of path mapping (I guess version 1.8 will have this feature)
Any ideas?
This is a answer I don't like but is a work around. In fact I come across your question while searching for a answer to my case, they are similar.
In my case I create a external library too, that library is compiled with typescript and the module is generated to be consumed in external jspm projects.
What works for me is to import the library with the same syntax of javascript es6. Suppose the library is named myLib and have a config.js map of myLib=blabla and you have a file called notify.js (generated from typescript). The import is
At runtime it works, but the problem is that the compiler for the project cannot locate 'myLib/notify'. The definition generated by typescript (file jspm_package/github/myLib/myLib@version/notify.d.ts for the library is something like:
To work around I manually modify the definition wrapping in a declaration of a library:
My tsconfig.json file is configured to look in jspm_packages for definitions
And then the compile stops warning and Atom editor provides intellisense.
There are two problems with this approach:
manually(this is annoying)What I'm searching is a way to auto generate the typescript definition with the module declaration.
I came across this https://www.npmjs.com/package/autodts but I do not fully understand how it works, but it seams that can be use to automatically generate the definition file in this way.
Edit:
I create a gulp task to edit typescript definition files and add automatic add declare module. Here is how:
paths.js