I\'m trying to publish a typescript library on NPM but I can\'t to have a \"good\" path after publishing.
I follow several guide on this point but I\'m not found a solut
This might be a little different than what you were looking for, but I think this is the more standard approach. Instead of trying to import from different directories in your module, just use a single main.ts
file to gather everything up for export. Assuming that you have this main.ts
file in your lib directory that re-exports everything, you can just configure the package.json to point to the generated JS.
Folder structure:
dist
|- main.js
|- main.d.ts
|- all other generates files
lib
|- main.ts
...
package.json:
{
...
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
...
}
In this example, if you have the following in your main.ts:
export const testValue = 5;
You could import it in other code that depends on this library by using import { testValue } from '
Check out the typescript docs for more info about this.