Let's assume you have a TypeScript project called "shubidu" and you are using Visual Code as IDE. "shubidu" well be a library, not an app. Also, assume that your TypeScript project has two TypeScript files "core-stuff.ts" and "addon-stuff.ts".
// content of "core-stuff.ts"
export default function sayHello(name: string) {
console.log(`Hello, ${name}`)
}
-
// content of "addon-stuff.ts"
import sayHello from 'shubidu/core'
export default function helloWorld() {
sayHello('World')
}
Both files shall be transpiled to ES5 into two different modules "dist/shubidu-core.js" and "dist/shubidu-addon.js".
Later this "shubidu" library will be used by other projects like follows:
import sayHello from 'shubidu/core'
import helloWorld from 'shubidu/addon'
[...]
When you compile the "shubidu" project, there will be an error in file ""addon-stuff.ts" because module "shubidu/core" is unknown.
To fix this you have to modify file "tsconfig.json" like follows:
// content of tsconfig.json
{
[...]
"compilerOptions": {
[...]
"paths": {
"shubidu/core": "path/to/core-stuff.ts"
}
[...]
}
[...]
}
Compilation is working now. The open problem is that the Visual Code IDE itself still says (in file "addon-stuff.ts") that the module "shubidu/core" is unknown. How can this be fixed???